move test folder
This commit is contained in:
@ -0,0 +1,343 @@
|
||||
result_format: 4
|
||||
drop database if exists shaoge;
|
||||
drop table if exists t1;
|
||||
create database shaoge;
|
||||
use shaoge;
|
||||
|
||||
create table t1(col_float float, col_char char(100), col_text text);
|
||||
insert into t1 values (1.1, '1.1', '1.1');
|
||||
insert into t1 values (1.9, '1.9', '1.9');
|
||||
insert into t1 values (2.1, '2.1', '2.1');
|
||||
insert into t1 values (2.9, '2.9', '2.9');
|
||||
insert into t1 values (9223372036854775807, '9223372036854775807', '9223372036854775807');
|
||||
insert into t1 values (9223372036854775807.5, '9223372036854775807.5', '9223372036854775807.5');
|
||||
insert into t1 values (9223372036854775806.5, '9223372036854775806.5', '9223372036854775806.5');
|
||||
insert into t1 values (null, '1234567890123456789012345678901234567890.5', '1234567890123456789012345678901234567890.5');
|
||||
|
||||
insert into t1 values (-1.1, '-1.1', '-1.1');
|
||||
insert into t1 values (-1.9, '-1.9', '-1.9');
|
||||
insert into t1 values (-2.1, '-2.1', '-2.1');
|
||||
insert into t1 values (-2.9, '-2.9', '-2.9');
|
||||
insert into t1 values (-9223372036854775807, '-9223372036854775808', '-9223372036854775808');
|
||||
insert into t1 values (-9223372036854775807.5, '-9223372036854775807.5', '-9223372036854775807.5');
|
||||
insert into t1 values (-9223372036854775806.5, '-9223372036854775806.5', '-9223372036854775806.5');
|
||||
insert into t1 values (null, '-1234567890123456789012345678901234567890.5', '-1234567890123456789012345678901234567890.5');
|
||||
|
||||
create table tbl_check_zerofill(col_zf int(3) zerofill, col_no_zf int(3));
|
||||
insert into tbl_check_zerofill values(1, 1);
|
||||
|
||||
// sql engine 3.0 test
|
||||
// string->int/uint will trunc
|
||||
// otherwise will round
|
||||
select col_float, cast(col_float as signed) from t1;
|
||||
+-------------+---------------------------+
|
||||
| col_float | cast(col_float as signed) |
|
||||
+-------------+---------------------------+
|
||||
| 1.1 | 1 |
|
||||
| 1.9 | 2 |
|
||||
| 2.1 | 2 |
|
||||
| 2.9 | 3 |
|
||||
| 9.22337e18 | -9223372036854775808 |
|
||||
| 9.22337e18 | -9223372036854775808 |
|
||||
| 9.22337e18 | -9223372036854775808 |
|
||||
| NULL | NULL |
|
||||
| -1.1 | -1 |
|
||||
| -1.9 | -2 |
|
||||
| -2.1 | -2 |
|
||||
| -2.9 | -3 |
|
||||
| -9.22337e18 | -9223372036854775808 |
|
||||
| -9.22337e18 | -9223372036854775808 |
|
||||
| -9.22337e18 | -9223372036854775808 |
|
||||
| NULL | NULL |
|
||||
+-------------+---------------------------+
|
||||
select col_char, cast(col_char as signed) from t1;
|
||||
+---------------------------------------------+--------------------------+
|
||||
| col_char | cast(col_char as signed) |
|
||||
+---------------------------------------------+--------------------------+
|
||||
| 1.1 | 1 |
|
||||
| 1.9 | 1 |
|
||||
| 2.1 | 2 |
|
||||
| 2.9 | 2 |
|
||||
| 9223372036854775807 | 9223372036854775807 |
|
||||
| 9223372036854775807.5 | 9223372036854775807 |
|
||||
| 9223372036854775806.5 | 9223372036854775806 |
|
||||
| 1234567890123456789012345678901234567890.5 | 9223372036854775807 |
|
||||
| -1.1 | -1 |
|
||||
| -1.9 | -1 |
|
||||
| -2.1 | -2 |
|
||||
| -2.9 | -2 |
|
||||
| -9223372036854775808 | -9223372036854775808 |
|
||||
| -9223372036854775807.5 | -9223372036854775807 |
|
||||
| -9223372036854775806.5 | -9223372036854775806 |
|
||||
| -1234567890123456789012345678901234567890.5 | -9223372036854775808 |
|
||||
+---------------------------------------------+--------------------------+
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '2.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '2.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '9223372036854775807.5'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '9223372036854775806.5'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-1.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-1.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-2.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-2.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-9223372036854775807.5'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-9223372036854775806.5'
|
||||
select col_text, cast(col_text as signed) from t1;
|
||||
+---------------------------------------------+--------------------------+
|
||||
| col_text | cast(col_text as signed) |
|
||||
+---------------------------------------------+--------------------------+
|
||||
| 1.1 | 1 |
|
||||
| 1.9 | 1 |
|
||||
| 2.1 | 2 |
|
||||
| 2.9 | 2 |
|
||||
| 9223372036854775807 | 9223372036854775807 |
|
||||
| 9223372036854775807.5 | 9223372036854775807 |
|
||||
| 9223372036854775806.5 | 9223372036854775806 |
|
||||
| 1234567890123456789012345678901234567890.5 | 9223372036854775807 |
|
||||
| -1.1 | -1 |
|
||||
| -1.9 | -1 |
|
||||
| -2.1 | -2 |
|
||||
| -2.9 | -2 |
|
||||
| -9223372036854775808 | -9223372036854775808 |
|
||||
| -9223372036854775807.5 | -9223372036854775807 |
|
||||
| -9223372036854775806.5 | -9223372036854775806 |
|
||||
| -1234567890123456789012345678901234567890.5 | -9223372036854775808 |
|
||||
+---------------------------------------------+--------------------------+
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '2.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '2.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '9223372036854775807.5'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '9223372036854775806.5'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-1.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-1.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-2.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-2.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-9223372036854775807.5'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-9223372036854775806.5'
|
||||
|
||||
select col_float, cast(col_float as unsigned) from t1;
|
||||
+-------------+-----------------------------+
|
||||
| col_float | cast(col_float as unsigned) |
|
||||
+-------------+-----------------------------+
|
||||
| 1.1 | 1 |
|
||||
| 1.9 | 2 |
|
||||
| 2.1 | 2 |
|
||||
| 2.9 | 3 |
|
||||
| 9.22337e18 | 9223372036854775808 |
|
||||
| 9.22337e18 | 9223372036854775808 |
|
||||
| 9.22337e18 | 9223372036854775808 |
|
||||
| NULL | NULL |
|
||||
| -1.1 | 18446744073709551615 |
|
||||
| -1.9 | 18446744073709551614 |
|
||||
| -2.1 | 18446744073709551614 |
|
||||
| -2.9 | 18446744073709551613 |
|
||||
| -9.22337e18 | 9223372036854775808 |
|
||||
| -9.22337e18 | 9223372036854775808 |
|
||||
| -9.22337e18 | 9223372036854775808 |
|
||||
| NULL | NULL |
|
||||
+-------------+-----------------------------+
|
||||
select col_char, cast(col_char as unsigned) from t1;
|
||||
+---------------------------------------------+----------------------------+
|
||||
| col_char | cast(col_char as unsigned) |
|
||||
+---------------------------------------------+----------------------------+
|
||||
| 1.1 | 1 |
|
||||
| 1.9 | 1 |
|
||||
| 2.1 | 2 |
|
||||
| 2.9 | 2 |
|
||||
| 9223372036854775807 | 9223372036854775807 |
|
||||
| 9223372036854775807.5 | 9223372036854775807 |
|
||||
| 9223372036854775806.5 | 9223372036854775806 |
|
||||
| 1234567890123456789012345678901234567890.5 | 18446744073709551615 |
|
||||
| -1.1 | 18446744073709551615 |
|
||||
| -1.9 | 18446744073709551615 |
|
||||
| -2.1 | 18446744073709551614 |
|
||||
| -2.9 | 18446744073709551614 |
|
||||
| -9223372036854775808 | 9223372036854775808 |
|
||||
| -9223372036854775807.5 | 9223372036854775809 |
|
||||
| -9223372036854775806.5 | 9223372036854775810 |
|
||||
| -1234567890123456789012345678901234567890.5 | 18446744073709551615 |
|
||||
+---------------------------------------------+----------------------------+
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '2.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '2.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '9223372036854775807.5'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '9223372036854775806.5'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1234567890123456789012345678901234567890.5'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-1.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-1.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-2.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-2.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-9223372036854775807.5'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-9223372036854775806.5'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-1234567890123456789012345678901234567890.5'
|
||||
select col_text, cast(col_text as unsigned) from t1;
|
||||
+---------------------------------------------+----------------------------+
|
||||
| col_text | cast(col_text as unsigned) |
|
||||
+---------------------------------------------+----------------------------+
|
||||
| 1.1 | 1 |
|
||||
| 1.9 | 1 |
|
||||
| 2.1 | 2 |
|
||||
| 2.9 | 2 |
|
||||
| 9223372036854775807 | 9223372036854775807 |
|
||||
| 9223372036854775807.5 | 9223372036854775807 |
|
||||
| 9223372036854775806.5 | 9223372036854775806 |
|
||||
| 1234567890123456789012345678901234567890.5 | 18446744073709551615 |
|
||||
| -1.1 | 18446744073709551615 |
|
||||
| -1.9 | 18446744073709551615 |
|
||||
| -2.1 | 18446744073709551614 |
|
||||
| -2.9 | 18446744073709551614 |
|
||||
| -9223372036854775808 | 9223372036854775808 |
|
||||
| -9223372036854775807.5 | 9223372036854775809 |
|
||||
| -9223372036854775806.5 | 9223372036854775810 |
|
||||
| -1234567890123456789012345678901234567890.5 | 18446744073709551615 |
|
||||
+---------------------------------------------+----------------------------+
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '2.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '2.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '9223372036854775807.5'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '9223372036854775806.5'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1234567890123456789012345678901234567890.5'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-1.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-1.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-2.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-2.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-9223372036854775807.5'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-9223372036854775806.5'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-1234567890123456789012345678901234567890.5'
|
||||
|
||||
// 测试zerofill
|
||||
// 应该有warning: Truncated incorrect CHAR(1) value: '001'
|
||||
select cast(col_zf as char(1)) from tbl_check_zerofill;
|
||||
+-------------------------+
|
||||
| cast(col_zf as char(1)) |
|
||||
+-------------------------+
|
||||
| 0 |
|
||||
+-------------------------+
|
||||
select cast(col_zf as char(2)) from tbl_check_zerofill;
|
||||
+-------------------------+
|
||||
| cast(col_zf as char(2)) |
|
||||
+-------------------------+
|
||||
| 00 |
|
||||
+-------------------------+
|
||||
select cast(col_zf as char(3)) from tbl_check_zerofill;
|
||||
+-------------------------+
|
||||
| cast(col_zf as char(3)) |
|
||||
+-------------------------+
|
||||
| 001 |
|
||||
+-------------------------+
|
||||
select cast(col_zf as char(4)) from tbl_check_zerofill;
|
||||
+-------------------------+
|
||||
| cast(col_zf as char(4)) |
|
||||
+-------------------------+
|
||||
| 001 |
|
||||
+-------------------------+
|
||||
select cast(col_no_zf as char(1)) from tbl_check_zerofill;
|
||||
+----------------------------+
|
||||
| cast(col_no_zf as char(1)) |
|
||||
+----------------------------+
|
||||
| 1 |
|
||||
+----------------------------+
|
||||
select cast(col_no_zf as char(1)) from tbl_check_zerofill;
|
||||
+----------------------------+
|
||||
| cast(col_no_zf as char(1)) |
|
||||
+----------------------------+
|
||||
| 1 |
|
||||
+----------------------------+
|
||||
select cast(col_no_zf as char(2)) from tbl_check_zerofill;
|
||||
+----------------------------+
|
||||
| cast(col_no_zf as char(2)) |
|
||||
+----------------------------+
|
||||
| 1 |
|
||||
+----------------------------+
|
||||
select cast(col_no_zf as char(3)) from tbl_check_zerofill;
|
||||
+----------------------------+
|
||||
| cast(col_no_zf as char(3)) |
|
||||
+----------------------------+
|
||||
| 1 |
|
||||
+----------------------------+
|
||||
select cast(col_no_zf as char(4)) from tbl_check_zerofill;
|
||||
+----------------------------+
|
||||
| cast(col_no_zf as char(4)) |
|
||||
+----------------------------+
|
||||
| 1 |
|
||||
+----------------------------+
|
||||
|
||||
drop table t1;
|
||||
create table t1(c1 varchar(3));
|
||||
insert into t1 values('abc');
|
||||
select cast(c1 as char(10)), concat(c1, '123') from t1;
|
||||
+----------------------+-------------------+
|
||||
| cast(c1 as char(10)) | concat(c1, '123') |
|
||||
+----------------------+-------------------+
|
||||
| abc | abc123 |
|
||||
+----------------------+-------------------+
|
||||
select cast(c1 as char(1)), concat(c1, '123') from t1;
|
||||
+---------------------+-------------------+
|
||||
| cast(c1 as char(1)) | concat(c1, '123') |
|
||||
+---------------------+-------------------+
|
||||
| a | abc123 |
|
||||
+---------------------+-------------------+
|
||||
select concat(cast(c1 as char(10)), '123') from t1;
|
||||
+-------------------------------------+
|
||||
| concat(cast(c1 as char(10)), '123') |
|
||||
+-------------------------------------+
|
||||
| abc123 |
|
||||
+-------------------------------------+
|
||||
select concat(cast(c1 as char(1)), '123') from t1;
|
||||
+------------------------------------+
|
||||
| concat(cast(c1 as char(1)), '123') |
|
||||
+------------------------------------+
|
||||
| a123 |
|
||||
+------------------------------------+
|
||||
|
||||
drop table t1;
|
||||
create table t1(c1 decimal(10, 3));
|
||||
insert into t1 values(1.123);
|
||||
select cast(c1 as decimal(10,1)), concat(c1, 'abc') from t1;
|
||||
+---------------------------+-------------------+
|
||||
| cast(c1 as decimal(10,1)) | concat(c1, 'abc') |
|
||||
+---------------------------+-------------------+
|
||||
| 1.1 | 1.123abc |
|
||||
+---------------------------+-------------------+
|
||||
select c1, cast(c1 as binary(10)), hex(cast(c1 as binary(10))) from t1;
|
||||
+-------+------------------------+-----------------------------+
|
||||
| c1 | cast(c1 as binary(10)) | hex(cast(c1 as binary(10))) |
|
||||
+-------+------------------------+-----------------------------+
|
||||
| 1.123 | 1.123 | 312E3132330000000000 |
|
||||
+-------+------------------------+-----------------------------+
|
||||
|
||||
drop table t1;
|
||||
create table t1(c1 time(6));
|
||||
insert into t1 values('11:11:11.123456');
|
||||
select cast(c1 as time), concat(c1, 'abc') from t1;
|
||||
+------------------+--------------------+
|
||||
| cast(c1 as time) | concat(c1, 'abc') |
|
||||
+------------------+--------------------+
|
||||
| 11:11:11 | 11:11:11.123456abc |
|
||||
+------------------+--------------------+
|
||||
|
||||
drop table t1;
|
||||
create table t1(c1 bigint unsigned);
|
||||
insert into t1 values(18446744073709551615);
|
||||
select cast(c1 as signed) from t1;
|
||||
+--------------------+
|
||||
| cast(c1 as signed) |
|
||||
+--------------------+
|
||||
| -1 |
|
||||
+--------------------+
|
||||
select c1, cast(c1 as binary(30)), hex(cast(c1 as binary(30))) from t1;
|
||||
+----------------------+--------------------------------+--------------------------------------------------------------+
|
||||
| c1 | cast(c1 as binary(30)) | hex(cast(c1 as binary(30))) |
|
||||
+----------------------+--------------------------------+--------------------------------------------------------------+
|
||||
| 18446744073709551615 | 18446744073709551615 | 313834343637343430373337303935353136313500000000000000000000 |
|
||||
+----------------------+--------------------------------+--------------------------------------------------------------+
|
||||
|
||||
drop table t1;
|
||||
@ -0,0 +1,859 @@
|
||||
result_format: 4
|
||||
|
||||
alter system flush plan cache global;
|
||||
|
||||
|
||||
drop table if exists t;
|
||||
create table t (t1 tinyint,
|
||||
t2 smallint,
|
||||
t3 mediumint,
|
||||
t4 integer,
|
||||
t5 bigint,
|
||||
t6 tinyint unsigned,
|
||||
t7 smallint unsigned,
|
||||
t8 mediumint unsigned,
|
||||
t9 integer unsigned,
|
||||
t10 bigint unsigned,
|
||||
t11 float,
|
||||
t12 float unsigned,
|
||||
t13 double,
|
||||
t14 double unsigned,
|
||||
t15 number,
|
||||
t16 number unsigned,
|
||||
t17 datetime,
|
||||
t18 timestamp,
|
||||
t19 date,
|
||||
t20 time,
|
||||
t21 year,
|
||||
t22 varchar(255),
|
||||
t23 char(255),
|
||||
t24 tinytext,
|
||||
t25 mediumtext,
|
||||
t26 longtext,
|
||||
t27 bit,
|
||||
t28 enum('a', 'b', 'c'),
|
||||
t29 set('a', 'b', 'c'));
|
||||
|
||||
insert into t values (1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -0.2, 0.3, 0.4, 0.5, -0.6, 0.7,
|
||||
'1993-03-20', '1993-03-20', '1993-03-20', '10:10:10', '1993', '0.8', '0.9', '1.0', '1.1',
|
||||
'1.2', 1, 'b', 'b');
|
||||
insert into t(t1) values (null);
|
||||
|
||||
|
||||
alter system flush plan cache global;
|
||||
|
||||
set ob_enable_plan_cache=false;
|
||||
|
||||
select abs(1.0);
|
||||
+----------+
|
||||
| abs(1.0) |
|
||||
+----------+
|
||||
| 1.0 |
|
||||
+----------+
|
||||
explain select abs(1.0);
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([?]), filter(nil)
|
||||
values({?})
|
||||
|
||||
select abs(1);
|
||||
+--------+
|
||||
| abs(1) |
|
||||
+--------+
|
||||
| 1 |
|
||||
+--------+
|
||||
explain select abs(1);
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([?]), filter(nil)
|
||||
values({?})
|
||||
|
||||
select abs(1+2+3-4-1-2+5-5);
|
||||
+----------------------+
|
||||
| abs(1+2+3-4-1-2+5-5) |
|
||||
+----------------------+
|
||||
| 1 |
|
||||
+----------------------+
|
||||
explain select abs(1+2+3-4-1-2+5-5);
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([?]), filter(nil)
|
||||
values({?})
|
||||
|
||||
select abs(abs(1+2+3-4-1-2+5-5)-abs(-3));
|
||||
+-----------------------------------+
|
||||
| abs(abs(1+2+3-4-1-2+5-5)-abs(-3)) |
|
||||
+-----------------------------------+
|
||||
| 2 |
|
||||
+-----------------------------------+
|
||||
explain select abs(abs(1+2+3-4-1-2+5-5)-abs(-3));
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([?]), filter(nil)
|
||||
values({?})
|
||||
|
||||
select abs(true and false);
|
||||
+---------------------+
|
||||
| abs(true and false) |
|
||||
+---------------------+
|
||||
| 0 |
|
||||
+---------------------+
|
||||
explain select abs(true and false);
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([?]), filter(nil)
|
||||
values({?})
|
||||
|
||||
select abs(10/0);
|
||||
+-----------+
|
||||
| abs(10/0) |
|
||||
+-----------+
|
||||
| NULL |
|
||||
+-----------+
|
||||
SELECT ABS(-9223372036854775808);
|
||||
ERROR 22003: value is out of range
|
||||
explain SELECT ABS(-9223372036854775808);
|
||||
ERROR 22003: value is out of range
|
||||
select abs(-9999999999999999999999);
|
||||
+------------------------------+
|
||||
| abs(-9999999999999999999999) |
|
||||
+------------------------------+
|
||||
| 9999999999999999999999 |
|
||||
+------------------------------+
|
||||
explain select abs(-9999999999999999999999);
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([?]), filter(nil)
|
||||
values({?})
|
||||
|
||||
select abs(9999999999999999999999);
|
||||
+-----------------------------+
|
||||
| abs(9999999999999999999999) |
|
||||
+-----------------------------+
|
||||
| 9999999999999999999999 |
|
||||
+-----------------------------+
|
||||
explain select abs(9999999999999999999999);
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([?]), filter(nil)
|
||||
values({?})
|
||||
|
||||
select abs(repeat('1',100));
|
||||
+----------------------+
|
||||
| abs(repeat('1',100)) |
|
||||
+----------------------+
|
||||
| 1.111111111111111e99 |
|
||||
+----------------------+
|
||||
explain select abs(repeat('1',100));
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([?]), filter(nil)
|
||||
values({?})
|
||||
|
||||
select abs(repeat('1',46));
|
||||
+-----------------------+
|
||||
| abs(repeat('1',46)) |
|
||||
+-----------------------+
|
||||
| 1.1111111111111112e45 |
|
||||
+-----------------------+
|
||||
explain select abs(repeat('1',46));
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([?]), filter(nil)
|
||||
values({?})
|
||||
|
||||
select abs(0-repeat('1',46));
|
||||
+-----------------------+
|
||||
| abs(0-repeat('1',46)) |
|
||||
+-----------------------+
|
||||
| 1.1111111111111112e45 |
|
||||
+-----------------------+
|
||||
explain select abs(0-repeat('1',46));
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([?]), filter(nil)
|
||||
values({?})
|
||||
|
||||
|
||||
|
||||
select abs(t1) from t;
|
||||
+---------+
|
||||
| abs(t1) |
|
||||
+---------+
|
||||
| 1 |
|
||||
| NULL |
|
||||
+---------+
|
||||
explain select abs(t1) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t1, BIGINT(-1, 0)))]), filter(nil),
|
||||
access([t.t1]), partitions(p0)
|
||||
|
||||
select abs(t2) from t;
|
||||
+---------+
|
||||
| abs(t2) |
|
||||
+---------+
|
||||
| 1 |
|
||||
| NULL |
|
||||
+---------+
|
||||
explain select abs(t2) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t2, BIGINT(-1, 0)))]), filter(nil),
|
||||
access([t.t2]), partitions(p0)
|
||||
|
||||
select abs(t3) from t;
|
||||
+---------+
|
||||
| abs(t3) |
|
||||
+---------+
|
||||
| 1 |
|
||||
| NULL |
|
||||
+---------+
|
||||
explain select abs(t3) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t3, BIGINT(-1, 0)))]), filter(nil),
|
||||
access([t.t3]), partitions(p0)
|
||||
|
||||
select abs(t4) from t;
|
||||
+---------+
|
||||
| abs(t4) |
|
||||
+---------+
|
||||
| 1 |
|
||||
| NULL |
|
||||
+---------+
|
||||
explain select abs(t4) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t4, BIGINT(-1, 0)))]), filter(nil),
|
||||
access([t.t4]), partitions(p0)
|
||||
|
||||
select abs(t5) from t;
|
||||
+---------+
|
||||
| abs(t5) |
|
||||
+---------+
|
||||
| 1 |
|
||||
| NULL |
|
||||
+---------+
|
||||
explain select abs(t5) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(t.t5)]), filter(nil),
|
||||
access([t.t5]), partitions(p0)
|
||||
|
||||
select abs(t6) from t;
|
||||
+---------+
|
||||
| abs(t6) |
|
||||
+---------+
|
||||
| 1 |
|
||||
| NULL |
|
||||
+---------+
|
||||
explain select abs(t6) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t6, BIGINT UNSIGNED(-1, 0)))]), filter(nil),
|
||||
access([t.t6]), partitions(p0)
|
||||
|
||||
select abs(t7) from t;
|
||||
+---------+
|
||||
| abs(t7) |
|
||||
+---------+
|
||||
| 1 |
|
||||
| NULL |
|
||||
+---------+
|
||||
explain select abs(t7) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t7, BIGINT UNSIGNED(-1, 0)))]), filter(nil),
|
||||
access([t.t7]), partitions(p0)
|
||||
|
||||
select abs(t8) from t;
|
||||
+---------+
|
||||
| abs(t8) |
|
||||
+---------+
|
||||
| 1 |
|
||||
| NULL |
|
||||
+---------+
|
||||
explain select abs(t8) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t8, BIGINT UNSIGNED(-1, 0)))]), filter(nil),
|
||||
access([t.t8]), partitions(p0)
|
||||
|
||||
select abs(t9) from t;
|
||||
+---------+
|
||||
| abs(t9) |
|
||||
+---------+
|
||||
| 1 |
|
||||
| NULL |
|
||||
+---------+
|
||||
explain select abs(t9) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t9, BIGINT UNSIGNED(-1, 0)))]), filter(nil),
|
||||
access([t.t9]), partitions(p0)
|
||||
|
||||
select abs(t10) from t;
|
||||
+----------+
|
||||
| abs(t10) |
|
||||
+----------+
|
||||
| 1 |
|
||||
| NULL |
|
||||
+----------+
|
||||
explain select abs(t10) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(t.t10)]), filter(nil),
|
||||
access([t.t10]), partitions(p0)
|
||||
|
||||
select abs(t11) from t;
|
||||
+---------------------+
|
||||
| abs(t11) |
|
||||
+---------------------+
|
||||
| 0.20000000298023224 |
|
||||
| NULL |
|
||||
+---------------------+
|
||||
explain select abs(t11) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t11, DOUBLE(-1, -1)))]), filter(nil),
|
||||
access([t.t11]), partitions(p0)
|
||||
|
||||
select abs(t12) from t;
|
||||
+---------------------+
|
||||
| abs(t12) |
|
||||
+---------------------+
|
||||
| 0.30000001192092896 |
|
||||
| NULL |
|
||||
+---------------------+
|
||||
explain select abs(t12) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t12, DOUBLE UNSIGNED(-1, -1)))]), filter(nil),
|
||||
access([t.t12]), partitions(p0)
|
||||
|
||||
select abs(t13) from t;
|
||||
+----------+
|
||||
| abs(t13) |
|
||||
+----------+
|
||||
| 0.4 |
|
||||
| NULL |
|
||||
+----------+
|
||||
explain select abs(t13) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(t.t13)]), filter(nil),
|
||||
access([t.t13]), partitions(p0)
|
||||
|
||||
select abs(t14) from t;
|
||||
+----------+
|
||||
| abs(t14) |
|
||||
+----------+
|
||||
| 0.5 |
|
||||
| NULL |
|
||||
+----------+
|
||||
explain select abs(t14) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(t.t14)]), filter(nil),
|
||||
access([t.t14]), partitions(p0)
|
||||
|
||||
select abs(t15) from t;
|
||||
+----------+
|
||||
| abs(t15) |
|
||||
+----------+
|
||||
| 1 |
|
||||
| NULL |
|
||||
+----------+
|
||||
explain select abs(t15) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(t.t15)]), filter(nil),
|
||||
access([t.t15]), partitions(p0)
|
||||
|
||||
select abs(t16) from t;
|
||||
+----------+
|
||||
| abs(t16) |
|
||||
+----------+
|
||||
| 1 |
|
||||
| NULL |
|
||||
+----------+
|
||||
explain select abs(t16) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(t.t16)]), filter(nil),
|
||||
access([t.t16]), partitions(p0)
|
||||
|
||||
select abs(t17) from t;
|
||||
+----------------+
|
||||
| abs(t17) |
|
||||
+----------------+
|
||||
| 19930320000000 |
|
||||
| NULL |
|
||||
+----------------+
|
||||
explain select abs(t17) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t17, DOUBLE(-1, -1)))]), filter(nil),
|
||||
access([t.t17]), partitions(p0)
|
||||
|
||||
select abs(t18) from t;
|
||||
+----------------+
|
||||
| abs(t18) |
|
||||
+----------------+
|
||||
| 19930320000000 |
|
||||
| NULL |
|
||||
+----------------+
|
||||
explain select abs(t18) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t18, DOUBLE(-1, -1)))]), filter(nil),
|
||||
access([t.t18]), partitions(p0)
|
||||
|
||||
select abs(t19) from t;
|
||||
+----------+
|
||||
| abs(t19) |
|
||||
+----------+
|
||||
| 19930320 |
|
||||
| NULL |
|
||||
+----------+
|
||||
explain select abs(t19) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t19, DOUBLE(-1, -1)))]), filter(nil),
|
||||
access([t.t19]), partitions(p0)
|
||||
|
||||
select abs(t20) from t;
|
||||
+----------+
|
||||
| abs(t20) |
|
||||
+----------+
|
||||
| 101010 |
|
||||
| NULL |
|
||||
+----------+
|
||||
explain select abs(t20) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t20, DOUBLE(-1, -1)))]), filter(nil),
|
||||
access([t.t20]), partitions(p0)
|
||||
|
||||
select abs(t21) from t;
|
||||
+----------+
|
||||
| abs(t21) |
|
||||
+----------+
|
||||
| 1993 |
|
||||
| NULL |
|
||||
+----------+
|
||||
explain select abs(t21) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t21, BIGINT UNSIGNED(-1, 0)))]), filter(nil),
|
||||
access([t.t21]), partitions(p0)
|
||||
|
||||
select abs(t22) from t;
|
||||
+----------+
|
||||
| abs(t22) |
|
||||
+----------+
|
||||
| 0.8 |
|
||||
| NULL |
|
||||
+----------+
|
||||
explain select abs(t22) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t22, DOUBLE(-1, -1)))]), filter(nil),
|
||||
access([t.t22]), partitions(p0)
|
||||
|
||||
select abs(t23) from t;
|
||||
+----------+
|
||||
| abs(t23) |
|
||||
+----------+
|
||||
| 0.9 |
|
||||
| NULL |
|
||||
+----------+
|
||||
explain select abs(t23) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t23, DOUBLE(-1, -1)))]), filter(nil),
|
||||
access([t.t23]), partitions(p0)
|
||||
|
||||
select abs(t24) from t;
|
||||
+----------+
|
||||
| abs(t24) |
|
||||
+----------+
|
||||
| 1 |
|
||||
| NULL |
|
||||
+----------+
|
||||
explain select abs(t24) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t24, DOUBLE(-1, -1)))]), filter(nil),
|
||||
access([t.t24]), partitions(p0)
|
||||
|
||||
select abs(t25) from t;
|
||||
+----------+
|
||||
| abs(t25) |
|
||||
+----------+
|
||||
| 1.1 |
|
||||
| NULL |
|
||||
+----------+
|
||||
explain select abs(t25) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t25, DOUBLE(-1, -1)))]), filter(nil),
|
||||
access([t.t25]), partitions(p0)
|
||||
|
||||
select abs(t26) from t;
|
||||
+----------+
|
||||
| abs(t26) |
|
||||
+----------+
|
||||
| 1.2 |
|
||||
| NULL |
|
||||
+----------+
|
||||
explain select abs(t26) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t26, DOUBLE(-1, -1)))]), filter(nil),
|
||||
access([t.t26]), partitions(p0)
|
||||
|
||||
select abs(t27) from t;
|
||||
+----------+
|
||||
| abs(t27) |
|
||||
+----------+
|
||||
| 1 |
|
||||
| NULL |
|
||||
+----------+
|
||||
explain select abs(t27) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t27, BIGINT UNSIGNED(-1, 0)))]), filter(nil),
|
||||
access([t.t27]), partitions(p0)
|
||||
|
||||
select abs(t28) from t;
|
||||
+----------+
|
||||
| abs(t28) |
|
||||
+----------+
|
||||
| 2 |
|
||||
| NULL |
|
||||
+----------+
|
||||
explain select abs(t28) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t28, DOUBLE(-1, -1)))]), filter(nil),
|
||||
access([t.t28]), partitions(p0)
|
||||
|
||||
select abs(t29) from t;
|
||||
+----------+
|
||||
| abs(t29) |
|
||||
+----------+
|
||||
| 2 |
|
||||
| NULL |
|
||||
+----------+
|
||||
explain select abs(t29) from t;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([abs(cast(t.t29, DOUBLE(-1, -1)))]), filter(nil),
|
||||
access([t.t29]), partitions(p0)
|
||||
|
||||
|
||||
drop table if exists t1;
|
||||
create table t1(c1 decimal unsigned, c2 smallint unsigned);
|
||||
insert into t1 values(1, 1);
|
||||
select mod(round(abs(c1)), c2) from t1;
|
||||
+-------------------------+
|
||||
| mod(round(abs(c1)), c2) |
|
||||
+-------------------------+
|
||||
| 0 |
|
||||
+-------------------------+
|
||||
drop table t1;
|
||||
|
||||
// abs(hex_string)
|
||||
select abs(X'31');
|
||||
+------------+
|
||||
| abs(X'31') |
|
||||
+------------+
|
||||
| 49 |
|
||||
+------------+
|
||||
select abs(binary'-100');
|
||||
+-------------------+
|
||||
| abs(binary'-100') |
|
||||
+-------------------+
|
||||
| 100 |
|
||||
+-------------------+
|
||||
select abs(_utf8'-100');
|
||||
+------------------+
|
||||
| abs(_utf8'-100') |
|
||||
+------------------+
|
||||
| 100 |
|
||||
+------------------+
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,342 @@
|
||||
result_format: 4
|
||||
explain_protocol: 0
|
||||
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 int, c2 int unsigned,
|
||||
c3 tinyint, c4 tinyint unsigned,
|
||||
c5 smallint, c6 smallint unsigned,
|
||||
c7 mediumint, c8 mediumint unsigned,
|
||||
c9 integer, c10 integer unsigned,
|
||||
c11 bigint, c12 bigint unsigned,
|
||||
c13 float, c14 float unsigned,
|
||||
c15 double, c16 double unsigned,
|
||||
c17 decimal, c18 decimal unsigned,
|
||||
c19 datetime, c20 timestamp,
|
||||
c21 varchar(30), c22 char(30));
|
||||
insert into t1 values(1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
3.5, 4.5,
|
||||
5.5, 6.5,
|
||||
7.5, 8.5,
|
||||
'2019-12-01 12:00:00', '2019-12-03 06:00:00',
|
||||
'9.5', '10.5');
|
||||
|
||||
select @var1, @var2;
|
||||
+-------+-------+
|
||||
| @var1 | @var2 |
|
||||
+-------+-------+
|
||||
| NULL | NULL |
|
||||
+-------+-------+
|
||||
|
||||
select @var2_1 := @var1_1 := c1 from t1;
|
||||
+--------------------------+
|
||||
| @var2_1 := @var1_1 := c1 |
|
||||
+--------------------------+
|
||||
| 1 |
|
||||
+--------------------------+
|
||||
select @var1_1, @var2_1;
|
||||
+---------+---------+
|
||||
| @var1_1 | @var2_1 |
|
||||
+---------+---------+
|
||||
| 1 | 1 |
|
||||
+---------+---------+
|
||||
select @var2_2 := @var1_2 := c2 from t1;
|
||||
+--------------------------+
|
||||
| @var2_2 := @var1_2 := c2 |
|
||||
+--------------------------+
|
||||
| 2 |
|
||||
+--------------------------+
|
||||
select @var1_2, @var2_2;
|
||||
+---------+---------+
|
||||
| @var1_2 | @var2_2 |
|
||||
+---------+---------+
|
||||
| 2 | 2 |
|
||||
+---------+---------+
|
||||
select @var2_3 := @var1_3 := c3 from t1;
|
||||
+--------------------------+
|
||||
| @var2_3 := @var1_3 := c3 |
|
||||
+--------------------------+
|
||||
| 1 |
|
||||
+--------------------------+
|
||||
select @var1_3, @var2_3;
|
||||
+---------+---------+
|
||||
| @var1_3 | @var2_3 |
|
||||
+---------+---------+
|
||||
| 1 | 1 |
|
||||
+---------+---------+
|
||||
select @var2_4 := @var1_4 := c4 from t1;
|
||||
+--------------------------+
|
||||
| @var2_4 := @var1_4 := c4 |
|
||||
+--------------------------+
|
||||
| 2 |
|
||||
+--------------------------+
|
||||
select @var1_4, @var2_4;
|
||||
+---------+---------+
|
||||
| @var1_4 | @var2_4 |
|
||||
+---------+---------+
|
||||
| 2 | 2 |
|
||||
+---------+---------+
|
||||
select @var2_5 := @var1_5 := c5 from t1;
|
||||
+--------------------------+
|
||||
| @var2_5 := @var1_5 := c5 |
|
||||
+--------------------------+
|
||||
| 1 |
|
||||
+--------------------------+
|
||||
select @var1_5, @var2_5;
|
||||
+---------+---------+
|
||||
| @var1_5 | @var2_5 |
|
||||
+---------+---------+
|
||||
| 1 | 1 |
|
||||
+---------+---------+
|
||||
select @var2_6 := @var1_6 := c6 from t1;
|
||||
+--------------------------+
|
||||
| @var2_6 := @var1_6 := c6 |
|
||||
+--------------------------+
|
||||
| 2 |
|
||||
+--------------------------+
|
||||
select @var1_6, @var2_6;
|
||||
+---------+---------+
|
||||
| @var1_6 | @var2_6 |
|
||||
+---------+---------+
|
||||
| 2 | 2 |
|
||||
+---------+---------+
|
||||
select @var2_7 := @var1_7 := c7 from t1;
|
||||
+--------------------------+
|
||||
| @var2_7 := @var1_7 := c7 |
|
||||
+--------------------------+
|
||||
| 1 |
|
||||
+--------------------------+
|
||||
select @var1_7, @var2_7;
|
||||
+---------+---------+
|
||||
| @var1_7 | @var2_7 |
|
||||
+---------+---------+
|
||||
| 1 | 1 |
|
||||
+---------+---------+
|
||||
select @var2_8 := @var1_8 := c8 from t1;
|
||||
+--------------------------+
|
||||
| @var2_8 := @var1_8 := c8 |
|
||||
+--------------------------+
|
||||
| 2 |
|
||||
+--------------------------+
|
||||
select @var1_8, @var2_8;
|
||||
+---------+---------+
|
||||
| @var1_8 | @var2_8 |
|
||||
+---------+---------+
|
||||
| 2 | 2 |
|
||||
+---------+---------+
|
||||
select @var2_9 := @var1_9 := c9 from t1;
|
||||
+--------------------------+
|
||||
| @var2_9 := @var1_9 := c9 |
|
||||
+--------------------------+
|
||||
| 1 |
|
||||
+--------------------------+
|
||||
select @var1_9, @var2_9;
|
||||
+---------+---------+
|
||||
| @var1_9 | @var2_9 |
|
||||
+---------+---------+
|
||||
| 1 | 1 |
|
||||
+---------+---------+
|
||||
select @var2_10 := @var1_10 := c10 from t1;
|
||||
+-----------------------------+
|
||||
| @var2_10 := @var1_10 := c10 |
|
||||
+-----------------------------+
|
||||
| 2 |
|
||||
+-----------------------------+
|
||||
select @var1_10, @var2_10;
|
||||
+----------+----------+
|
||||
| @var1_10 | @var2_10 |
|
||||
+----------+----------+
|
||||
| 2 | 2 |
|
||||
+----------+----------+
|
||||
select @var2_11 := @var1_11 := c11 from t1;
|
||||
+-----------------------------+
|
||||
| @var2_11 := @var1_11 := c11 |
|
||||
+-----------------------------+
|
||||
| 1 |
|
||||
+-----------------------------+
|
||||
select @var1_11, @var2_11;
|
||||
+----------+----------+
|
||||
| @var1_11 | @var2_11 |
|
||||
+----------+----------+
|
||||
| 1 | 1 |
|
||||
+----------+----------+
|
||||
select @var2_12 := @var1_12 := c12 from t1;
|
||||
+-----------------------------+
|
||||
| @var2_12 := @var1_12 := c12 |
|
||||
+-----------------------------+
|
||||
| 2 |
|
||||
+-----------------------------+
|
||||
select @var1_12, @var2_12;
|
||||
+----------+----------+
|
||||
| @var1_12 | @var2_12 |
|
||||
+----------+----------+
|
||||
| 2 | 2 |
|
||||
+----------+----------+
|
||||
select @var2_13 := @var1_13 := c13 from t1;
|
||||
+-----------------------------+
|
||||
| @var2_13 := @var1_13 := c13 |
|
||||
+-----------------------------+
|
||||
| 3.5 |
|
||||
+-----------------------------+
|
||||
select @var1_13, @var2_13;
|
||||
+----------+----------+
|
||||
| @var1_13 | @var2_13 |
|
||||
+----------+----------+
|
||||
| 3.5 | 3.5 |
|
||||
+----------+----------+
|
||||
select @var2_14 := @var1_14 := c14 from t1;
|
||||
+-----------------------------+
|
||||
| @var2_14 := @var1_14 := c14 |
|
||||
+-----------------------------+
|
||||
| 4.5 |
|
||||
+-----------------------------+
|
||||
select @var1_14, @var2_14;
|
||||
+----------+----------+
|
||||
| @var1_14 | @var2_14 |
|
||||
+----------+----------+
|
||||
| 4.5 | 4.5 |
|
||||
+----------+----------+
|
||||
select @var2_15 := @var1_15 := c15 from t1;
|
||||
+-----------------------------+
|
||||
| @var2_15 := @var1_15 := c15 |
|
||||
+-----------------------------+
|
||||
| 5.5 |
|
||||
+-----------------------------+
|
||||
select @var1_15, @var2_15;
|
||||
+----------+----------+
|
||||
| @var1_15 | @var2_15 |
|
||||
+----------+----------+
|
||||
| 5.5 | 5.5 |
|
||||
+----------+----------+
|
||||
select @var2_16 := @var1_16 := c16 from t1;
|
||||
+-----------------------------+
|
||||
| @var2_16 := @var1_16 := c16 |
|
||||
+-----------------------------+
|
||||
| 6.5 |
|
||||
+-----------------------------+
|
||||
select @var1_16, @var2_16;
|
||||
+----------+----------+
|
||||
| @var1_16 | @var2_16 |
|
||||
+----------+----------+
|
||||
| 6.5 | 6.5 |
|
||||
+----------+----------+
|
||||
select @var2_17 := @var1_17 := c17 from t1;
|
||||
+-----------------------------+
|
||||
| @var2_17 := @var1_17 := c17 |
|
||||
+-----------------------------+
|
||||
| 8 |
|
||||
+-----------------------------+
|
||||
select @var1_17, @var2_17;
|
||||
+----------+----------+
|
||||
| @var1_17 | @var2_17 |
|
||||
+----------+----------+
|
||||
| 8 | 8 |
|
||||
+----------+----------+
|
||||
select @var2_18 := @var1_18 := c18 from t1;
|
||||
+-----------------------------+
|
||||
| @var2_18 := @var1_18 := c18 |
|
||||
+-----------------------------+
|
||||
| 9 |
|
||||
+-----------------------------+
|
||||
select @var1_18, @var2_18;
|
||||
+----------+----------+
|
||||
| @var1_18 | @var2_18 |
|
||||
+----------+----------+
|
||||
| 9 | 9 |
|
||||
+----------+----------+
|
||||
select @var2_19 := @var1_19 := c19 from t1;
|
||||
+-----------------------------+
|
||||
| @var2_19 := @var1_19 := c19 |
|
||||
+-----------------------------+
|
||||
| 2019-12-01 12:00:00 |
|
||||
+-----------------------------+
|
||||
select @var1_19, @var2_19;
|
||||
+---------------------+---------------------+
|
||||
| @var1_19 | @var2_19 |
|
||||
+---------------------+---------------------+
|
||||
| 2019-12-01 12:00:00 | 2019-12-01 12:00:00 |
|
||||
+---------------------+---------------------+
|
||||
select @var2_20 := @var1_20 := c20 from t1;
|
||||
+-----------------------------+
|
||||
| @var2_20 := @var1_20 := c20 |
|
||||
+-----------------------------+
|
||||
| 2019-12-03 06:00:00 |
|
||||
+-----------------------------+
|
||||
select @var1_20, @var2_20;
|
||||
+---------------------+---------------------+
|
||||
| @var1_20 | @var2_20 |
|
||||
+---------------------+---------------------+
|
||||
| 2019-12-03 06:00:00 | 2019-12-03 06:00:00 |
|
||||
+---------------------+---------------------+
|
||||
select @var2_21 := @var1_21 := c21 from t1;
|
||||
+-----------------------------+
|
||||
| @var2_21 := @var1_21 := c21 |
|
||||
+-----------------------------+
|
||||
| 9.5 |
|
||||
+-----------------------------+
|
||||
select @var1_21, @var2_21;
|
||||
+----------+----------+
|
||||
| @var1_21 | @var2_21 |
|
||||
+----------+----------+
|
||||
| 9.5 | 9.5 |
|
||||
+----------+----------+
|
||||
select @var2_22 := @var1_22 := c22 from t1;
|
||||
+-----------------------------+
|
||||
| @var2_22 := @var1_22 := c22 |
|
||||
+-----------------------------+
|
||||
| 10.5 |
|
||||
+-----------------------------+
|
||||
select @var1_22, @var2_22;
|
||||
+----------+----------+
|
||||
| @var1_22 | @var2_22 |
|
||||
+----------+----------+
|
||||
| 10.5 | 10.5 |
|
||||
+----------+----------+
|
||||
|
||||
set @a = 1;
|
||||
select @a := @someval;
|
||||
+----------------+
|
||||
| @a := @someval |
|
||||
+----------------+
|
||||
| NULL |
|
||||
+----------------+
|
||||
select @a;
|
||||
+------+
|
||||
| @a |
|
||||
+------+
|
||||
| NULL |
|
||||
+------+
|
||||
drop view if exists vv;
|
||||
create view vv as select @a;
|
||||
desc vv;
|
||||
+-------+--------------------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+-------+--------------------+------+-----+---------+-------+
|
||||
| @a | varbinary(1048576) | NO | | | |
|
||||
+-------+--------------------+------+-----+---------+-------+
|
||||
|
||||
select @a := null;
|
||||
+------------+
|
||||
| @a := null |
|
||||
+------------+
|
||||
| NULL |
|
||||
+------------+
|
||||
select @a;
|
||||
+------+
|
||||
| @a |
|
||||
+------+
|
||||
| NULL |
|
||||
+------+
|
||||
drop view if exists vv;
|
||||
create view vv as select @a;
|
||||
desc vv;
|
||||
+-------+--------------------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+-------+--------------------+------+-----+---------+-------+
|
||||
| @a | varbinary(1048576) | NO | | | |
|
||||
+-------+--------------------+------+-----+---------+-------+
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,93 @@
|
||||
result_format: 4
|
||||
alter system flush plan cache global;
|
||||
|
||||
set ob_enable_plan_cache = 0;
|
||||
select char_length(1234);
|
||||
+-------------------+
|
||||
| char_length(1234) |
|
||||
+-------------------+
|
||||
| 4 |
|
||||
+-------------------+
|
||||
select char_length(1);
|
||||
+----------------+
|
||||
| char_length(1) |
|
||||
+----------------+
|
||||
| 1 |
|
||||
+----------------+
|
||||
select char_length(null);
|
||||
+-------------------+
|
||||
| char_length(null) |
|
||||
+-------------------+
|
||||
| NULL |
|
||||
+-------------------+
|
||||
select char_length('');
|
||||
+-----------------+
|
||||
| char_length('') |
|
||||
+-----------------+
|
||||
| 0 |
|
||||
+-----------------+
|
||||
select char_length('a');
|
||||
+------------------+
|
||||
| char_length('a') |
|
||||
+------------------+
|
||||
| 1 |
|
||||
+------------------+
|
||||
select char_length(' a ');
|
||||
+--------------------+
|
||||
| char_length(' a ') |
|
||||
+--------------------+
|
||||
| 3 |
|
||||
+--------------------+
|
||||
select char_length(' a b');
|
||||
+---------------------+
|
||||
| char_length(' a b') |
|
||||
+---------------------+
|
||||
| 4 |
|
||||
+---------------------+
|
||||
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 int, c2 char(10), c3 varchar(10), c4 timestamp, c5 decimal);
|
||||
insert into t1 values(1, 'a ', 'a ', '2010-01-01 11:11:11', 10.1);
|
||||
select char_length(c1) from t1;
|
||||
+-----------------+
|
||||
| char_length(c1) |
|
||||
+-----------------+
|
||||
| 1 |
|
||||
+-----------------+
|
||||
select char_length(c2) from t1;
|
||||
+-----------------+
|
||||
| char_length(c2) |
|
||||
+-----------------+
|
||||
| 1 |
|
||||
+-----------------+
|
||||
select char_length(c3) from t1;
|
||||
+-----------------+
|
||||
| char_length(c3) |
|
||||
+-----------------+
|
||||
| 2 |
|
||||
+-----------------+
|
||||
select char_length(c4) from t1;
|
||||
+-----------------+
|
||||
| char_length(c4) |
|
||||
+-----------------+
|
||||
| 19 |
|
||||
+-----------------+
|
||||
select char_length(c5) from t1;
|
||||
+-----------------+
|
||||
| char_length(c5) |
|
||||
+-----------------+
|
||||
| 2 |
|
||||
+-----------------+
|
||||
|
||||
|
||||
drop table if exists t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1), (2);
|
||||
select CHAR_LENGTH(
|
||||
case when 62 <= (
|
||||
select a from t1
|
||||
) then '1' else '22' end);
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
|
||||
drop table t1;
|
||||
|
||||
@ -0,0 +1,215 @@
|
||||
result_format: 4
|
||||
explain_protocol: 0
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 int, c2 int unsigned,
|
||||
c3 tinyint, c4 tinyint unsigned,
|
||||
c5 smallint, c6 smallint unsigned,
|
||||
c7 mediumint, c8 mediumint unsigned,
|
||||
c9 integer, c10 integer unsigned,
|
||||
c11 bigint, c12 bigint unsigned,
|
||||
c13 float, c14 float unsigned,
|
||||
c15 double, c16 double unsigned,
|
||||
c17 decimal, c18 decimal unsigned,
|
||||
c19 datetime, c20 timestamp,
|
||||
c21 varchar(30), c22 char(30),
|
||||
c23 varchar(30) charset utf8);
|
||||
insert into t1 values(1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
3.5, 4.5,
|
||||
5.5, 6.5,
|
||||
7.5, 8.5,
|
||||
'2019-12-01 12:00:00', '2019-12-03 06:00:00',
|
||||
'9.5', '10.5', 'utf8 col');
|
||||
insert into t1 values(-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-3.5, 4.5,
|
||||
-5.5, 6.5,
|
||||
-7.5, 8.5,
|
||||
'2019-12-01 12:00:00', '2019-12-03 06:00:00',
|
||||
'-9.5', '10.5', 'utf8 col');
|
||||
|
||||
select c1, charset(c1), collation(c1), coercibility(c1) from t1;
|
||||
+------+-------------+---------------+------------------+
|
||||
| c1 | charset(c1) | collation(c1) | coercibility(c1) |
|
||||
+------+-------------+---------------+------------------+
|
||||
| 1 | binary | binary | 5 |
|
||||
| -1 | binary | binary | 5 |
|
||||
+------+-------------+---------------+------------------+
|
||||
select c2, charset(c2), collation(c2), coercibility(c2) from t1;
|
||||
+------+-------------+---------------+------------------+
|
||||
| c2 | charset(c2) | collation(c2) | coercibility(c2) |
|
||||
+------+-------------+---------------+------------------+
|
||||
| 2 | binary | binary | 5 |
|
||||
| 2 | binary | binary | 5 |
|
||||
+------+-------------+---------------+------------------+
|
||||
select c3, charset(c3), collation(c3), coercibility(c3) from t1;
|
||||
+------+-------------+---------------+------------------+
|
||||
| c3 | charset(c3) | collation(c3) | coercibility(c3) |
|
||||
+------+-------------+---------------+------------------+
|
||||
| 1 | binary | binary | 5 |
|
||||
| -1 | binary | binary | 5 |
|
||||
+------+-------------+---------------+------------------+
|
||||
select c4, charset(c4), collation(c4), coercibility(c4) from t1;
|
||||
+------+-------------+---------------+------------------+
|
||||
| c4 | charset(c4) | collation(c4) | coercibility(c4) |
|
||||
+------+-------------+---------------+------------------+
|
||||
| 2 | binary | binary | 5 |
|
||||
| 2 | binary | binary | 5 |
|
||||
+------+-------------+---------------+------------------+
|
||||
select c5, charset(c5), collation(c5), coercibility(c5) from t1;
|
||||
+------+-------------+---------------+------------------+
|
||||
| c5 | charset(c5) | collation(c5) | coercibility(c5) |
|
||||
+------+-------------+---------------+------------------+
|
||||
| 1 | binary | binary | 5 |
|
||||
| -1 | binary | binary | 5 |
|
||||
+------+-------------+---------------+------------------+
|
||||
select c6, charset(c6), collation(c6), coercibility(c6) from t1;
|
||||
+------+-------------+---------------+------------------+
|
||||
| c6 | charset(c6) | collation(c6) | coercibility(c6) |
|
||||
+------+-------------+---------------+------------------+
|
||||
| 2 | binary | binary | 5 |
|
||||
| 2 | binary | binary | 5 |
|
||||
+------+-------------+---------------+------------------+
|
||||
select c7, charset(c7), collation(c7), coercibility(c7) from t1;
|
||||
+------+-------------+---------------+------------------+
|
||||
| c7 | charset(c7) | collation(c7) | coercibility(c7) |
|
||||
+------+-------------+---------------+------------------+
|
||||
| 1 | binary | binary | 5 |
|
||||
| -1 | binary | binary | 5 |
|
||||
+------+-------------+---------------+------------------+
|
||||
select c8, charset(c8), collation(c8), coercibility(c8) from t1;
|
||||
+------+-------------+---------------+------------------+
|
||||
| c8 | charset(c8) | collation(c8) | coercibility(c8) |
|
||||
+------+-------------+---------------+------------------+
|
||||
| 2 | binary | binary | 5 |
|
||||
| 2 | binary | binary | 5 |
|
||||
+------+-------------+---------------+------------------+
|
||||
select c9, charset(c9), collation(c9), coercibility(c9) from t1;
|
||||
+------+-------------+---------------+------------------+
|
||||
| c9 | charset(c9) | collation(c9) | coercibility(c9) |
|
||||
+------+-------------+---------------+------------------+
|
||||
| 1 | binary | binary | 5 |
|
||||
| -1 | binary | binary | 5 |
|
||||
+------+-------------+---------------+------------------+
|
||||
select c10, charset(c10), collation(c10), coercibility(c10) from t1;
|
||||
+------+--------------+----------------+-------------------+
|
||||
| c10 | charset(c10) | collation(c10) | coercibility(c10) |
|
||||
+------+--------------+----------------+-------------------+
|
||||
| 2 | binary | binary | 5 |
|
||||
| 2 | binary | binary | 5 |
|
||||
+------+--------------+----------------+-------------------+
|
||||
select c11, charset(c11), collation(c11), coercibility(c11) from t1;
|
||||
+------+--------------+----------------+-------------------+
|
||||
| c11 | charset(c11) | collation(c11) | coercibility(c11) |
|
||||
+------+--------------+----------------+-------------------+
|
||||
| 1 | binary | binary | 5 |
|
||||
| -1 | binary | binary | 5 |
|
||||
+------+--------------+----------------+-------------------+
|
||||
select c12, charset(c12), collation(c12), coercibility(c12) from t1;
|
||||
+------+--------------+----------------+-------------------+
|
||||
| c12 | charset(c12) | collation(c12) | coercibility(c12) |
|
||||
+------+--------------+----------------+-------------------+
|
||||
| 2 | binary | binary | 5 |
|
||||
| 2 | binary | binary | 5 |
|
||||
+------+--------------+----------------+-------------------+
|
||||
select c13, charset(c13), collation(c13), coercibility(c13) from t1;
|
||||
+------+--------------+----------------+-------------------+
|
||||
| c13 | charset(c13) | collation(c13) | coercibility(c13) |
|
||||
+------+--------------+----------------+-------------------+
|
||||
| 3.5 | binary | binary | 5 |
|
||||
| -3.5 | binary | binary | 5 |
|
||||
+------+--------------+----------------+-------------------+
|
||||
select c14, charset(c14), collation(c14), coercibility(c14) from t1;
|
||||
+------+--------------+----------------+-------------------+
|
||||
| c14 | charset(c14) | collation(c14) | coercibility(c14) |
|
||||
+------+--------------+----------------+-------------------+
|
||||
| 4.5 | binary | binary | 5 |
|
||||
| 4.5 | binary | binary | 5 |
|
||||
+------+--------------+----------------+-------------------+
|
||||
select c15, charset(c15), collation(c15), coercibility(c15) from t1;
|
||||
+------+--------------+----------------+-------------------+
|
||||
| c15 | charset(c15) | collation(c15) | coercibility(c15) |
|
||||
+------+--------------+----------------+-------------------+
|
||||
| 5.5 | binary | binary | 5 |
|
||||
| -5.5 | binary | binary | 5 |
|
||||
+------+--------------+----------------+-------------------+
|
||||
select c16, charset(c16), collation(c16), coercibility(c16) from t1;
|
||||
+------+--------------+----------------+-------------------+
|
||||
| c16 | charset(c16) | collation(c16) | coercibility(c16) |
|
||||
+------+--------------+----------------+-------------------+
|
||||
| 6.5 | binary | binary | 5 |
|
||||
| 6.5 | binary | binary | 5 |
|
||||
+------+--------------+----------------+-------------------+
|
||||
select c17, charset(c17), collation(c17), coercibility(c17) from t1;
|
||||
+------+--------------+----------------+-------------------+
|
||||
| c17 | charset(c17) | collation(c17) | coercibility(c17) |
|
||||
+------+--------------+----------------+-------------------+
|
||||
| 8 | binary | binary | 5 |
|
||||
| -8 | binary | binary | 5 |
|
||||
+------+--------------+----------------+-------------------+
|
||||
select c18, charset(c18), collation(c18), coercibility(c18) from t1;
|
||||
+------+--------------+----------------+-------------------+
|
||||
| c18 | charset(c18) | collation(c18) | coercibility(c18) |
|
||||
+------+--------------+----------------+-------------------+
|
||||
| 9 | binary | binary | 5 |
|
||||
| 9 | binary | binary | 5 |
|
||||
+------+--------------+----------------+-------------------+
|
||||
select c19, charset(c19), collation(c19), coercibility(c19) from t1;
|
||||
+---------------------+--------------+----------------+-------------------+
|
||||
| c19 | charset(c19) | collation(c19) | coercibility(c19) |
|
||||
+---------------------+--------------+----------------+-------------------+
|
||||
| 2019-12-01 12:00:00 | binary | binary | 5 |
|
||||
| 2019-12-01 12:00:00 | binary | binary | 5 |
|
||||
+---------------------+--------------+----------------+-------------------+
|
||||
select c20, charset(c20), collation(c20), coercibility(c20) from t1;
|
||||
+---------------------+--------------+----------------+-------------------+
|
||||
| c20 | charset(c20) | collation(c20) | coercibility(c20) |
|
||||
+---------------------+--------------+----------------+-------------------+
|
||||
| 2019-12-03 06:00:00 | binary | binary | 5 |
|
||||
| 2019-12-03 06:00:00 | binary | binary | 5 |
|
||||
+---------------------+--------------+----------------+-------------------+
|
||||
select c21, charset(c21), collation(c21), coercibility(c21) from t1;
|
||||
+------+--------------+--------------------+-------------------+
|
||||
| c21 | charset(c21) | collation(c21) | coercibility(c21) |
|
||||
+------+--------------+--------------------+-------------------+
|
||||
| 9.5 | utf8mb4 | utf8mb4_general_ci | 2 |
|
||||
| -9.5 | utf8mb4 | utf8mb4_general_ci | 2 |
|
||||
+------+--------------+--------------------+-------------------+
|
||||
select c22, charset(c22), collation(c22), coercibility(c22) from t1;
|
||||
+------+--------------+--------------------+-------------------+
|
||||
| c22 | charset(c22) | collation(c22) | coercibility(c22) |
|
||||
+------+--------------+--------------------+-------------------+
|
||||
| 10.5 | utf8mb4 | utf8mb4_general_ci | 2 |
|
||||
| 10.5 | utf8mb4 | utf8mb4_general_ci | 2 |
|
||||
+------+--------------+--------------------+-------------------+
|
||||
|
||||
// test set_collation expr
|
||||
// set_collation表达式检查charset与collate不匹配,报错
|
||||
// 下面的是等号表达式在类型推导时,进行aggregate collation发现collation不一致报错
|
||||
select _utf8mb4'a' collate utf8mb4_general_ci = _utf8mb4'A' collate utf8mb4_bin;
|
||||
ERROR HY000: Illegal mix of collations
|
||||
select _utf8mb4'a' collate utf8mb4_general_ci = _utf8mb4'A' collate utf8mb4_general_ci;
|
||||
+---------------------------------------------------------------------------------+
|
||||
| _utf8mb4'a' collate utf8mb4_general_ci = _utf8mb4'A' collate utf8mb4_general_ci |
|
||||
+---------------------------------------------------------------------------------+
|
||||
| 1 |
|
||||
+---------------------------------------------------------------------------------+
|
||||
select _utf8mb4'a' collate utf8mb4_bin = _utf8mb4'A' collate utf8mb4_bin;
|
||||
+-------------------------------------------------------------------+
|
||||
| _utf8mb4'a' collate utf8mb4_bin = _utf8mb4'A' collate utf8mb4_bin |
|
||||
+-------------------------------------------------------------------+
|
||||
| 0 |
|
||||
+-------------------------------------------------------------------+
|
||||
|
||||
drop table t1;
|
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,47 @@
|
||||
result_format: 4
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select conv('a',16,2) from dual;
|
||||
+----------------+
|
||||
| conv('a',16,2) |
|
||||
+----------------+
|
||||
| 1010 |
|
||||
+----------------+
|
||||
select conv('6E',18,8) from dual;
|
||||
+-----------------+
|
||||
| conv('6E',18,8) |
|
||||
+-----------------+
|
||||
| 172 |
|
||||
+-----------------+
|
||||
select conv(-17,10,-18) from dual;
|
||||
+------------------+
|
||||
| conv(-17,10,-18) |
|
||||
+------------------+
|
||||
| -H |
|
||||
+------------------+
|
||||
select conv(10+'10'+'10'+X'0a',10,10) from dual;
|
||||
+--------------------------------+
|
||||
| conv(10+'10'+'10'+X'0a',10,10) |
|
||||
+--------------------------------+
|
||||
| 40 |
|
||||
+--------------------------------+
|
||||
select conv(null, 16, 2) from dual;
|
||||
+-------------------+
|
||||
| conv(null, 16, 2) |
|
||||
+-------------------+
|
||||
| NULL |
|
||||
+-------------------+
|
||||
select conv('6E',null,8) from dual;
|
||||
+-------------------+
|
||||
| conv('6E',null,8) |
|
||||
+-------------------+
|
||||
| NULL |
|
||||
+-------------------+
|
||||
select conv('6E',18, null) from dual;
|
||||
+---------------------+
|
||||
| conv('6E',18, null) |
|
||||
+---------------------+
|
||||
| NULL |
|
||||
+---------------------+
|
||||
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
result_format: 4
|
||||
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 varchar(2000));
|
||||
insert into t1 values("2019-10-11");
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
select date(c1) from t1;
|
||||
+------------+
|
||||
| date(c1) |
|
||||
+------------+
|
||||
| 2019-10-11 |
|
||||
+------------+
|
||||
select date("2019-10-10") from dual;
|
||||
+--------------------+
|
||||
| date("2019-10-10") |
|
||||
+--------------------+
|
||||
| 2019-10-10 |
|
||||
+--------------------+
|
||||
select date(null) from dual;
|
||||
+------------+
|
||||
| date(null) |
|
||||
+------------+
|
||||
| NULL |
|
||||
+------------+
|
||||
|
||||
|
||||
@ -0,0 +1,55 @@
|
||||
result_format: 4
|
||||
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 varchar(30), c2 date, c3 date);
|
||||
insert into t1 values("2019-10-11", "2019-01-10", "2018-01-01");
|
||||
insert into t1 values(null, "2019-01-10", null);
|
||||
insert into t1 values("2019-10-11", "0000-00-00", "2019-10-19");
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
select datediff(c1, c2), datediff(c2, c3) from t1;
|
||||
+------------------+------------------+
|
||||
| datediff(c1, c2) | datediff(c2, c3) |
|
||||
+------------------+------------------+
|
||||
| 274 | 374 |
|
||||
| NULL | NULL |
|
||||
| NULL | NULL |
|
||||
+------------------+------------------+
|
||||
select datediff(20080701, "2008-08-01");
|
||||
+----------------------------------+
|
||||
| datediff(20080701, "2008-08-01") |
|
||||
+----------------------------------+
|
||||
| -31 |
|
||||
+----------------------------------+
|
||||
select datediff("20080701", "2012-05-25");
|
||||
+------------------------------------+
|
||||
| datediff("20080701", "2012-05-25") |
|
||||
+------------------------------------+
|
||||
| -1424 |
|
||||
+------------------------------------+
|
||||
select datediff("2012-05-25","20080701");
|
||||
+-----------------------------------+
|
||||
| datediff("2012-05-25","20080701") |
|
||||
+-----------------------------------+
|
||||
| 1424 |
|
||||
+-----------------------------------+
|
||||
select datediff(null,null);
|
||||
+---------------------+
|
||||
| datediff(null,null) |
|
||||
+---------------------+
|
||||
| NULL |
|
||||
+---------------------+
|
||||
select datediff(null,"2012-05-25");
|
||||
+-----------------------------+
|
||||
| datediff(null,"2012-05-25") |
|
||||
+-----------------------------+
|
||||
| NULL |
|
||||
+-----------------------------+
|
||||
select datediff("2012-05-25","0000-00-00");
|
||||
+-------------------------------------+
|
||||
| datediff("2012-05-25","0000-00-00") |
|
||||
+-------------------------------------+
|
||||
| NULL |
|
||||
+-------------------------------------+
|
||||
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
result_format: 4
|
||||
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select des_hex_str("11053FFF80EAB6BADEE6F501");
|
||||
+-----------------------------------------+
|
||||
| des_hex_str("11053FFF80EAB6BADEE6F501") |
|
||||
+-----------------------------------------+
|
||||
| 2004-04-04 04:04:04.000000 |
|
||||
+-----------------------------------------+
|
||||
select des_hex_str("0C053FFFB8BD94DC9E8A8E8B40");
|
||||
+-------------------------------------------+
|
||||
| des_hex_str("0C053FFFB8BD94DC9E8A8E8B40") |
|
||||
+-------------------------------------------+
|
||||
| 5.555 |
|
||||
+-------------------------------------------+
|
||||
select des_hex_str("0C053FFFB8BD94DC9E8A8E8B40");
|
||||
+-------------------------------------------+
|
||||
| des_hex_str("0C053FFFB8BD94DC9E8A8E8B40") |
|
||||
+-------------------------------------------+
|
||||
| 5.555 |
|
||||
+-------------------------------------------+
|
||||
select des_hex_str("04053FFF05");
|
||||
+---------------------------+
|
||||
| des_hex_str("04053FFF05") |
|
||||
+---------------------------+
|
||||
| 5 |
|
||||
+---------------------------+
|
||||
select des_hex_str("0C053FFFADE4F6FCFED4F1F83F");
|
||||
+-------------------------------------------+
|
||||
| des_hex_str("0C053FFFADE4F6FCFED4F1F83F") |
|
||||
+-------------------------------------------+
|
||||
| 1.111 |
|
||||
+-------------------------------------------+
|
||||
select des_hex_str("0B053FFF8080C08504");
|
||||
+-----------------------------------+
|
||||
| des_hex_str("0B053FFF8080C08504") |
|
||||
+-----------------------------------+
|
||||
| 5.5 |
|
||||
+-----------------------------------+
|
||||
select des_hex_str(NULL);
|
||||
ERROR HY000: Invalid argument
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
result_format: 4
|
||||
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select dump(NULL);
|
||||
+------------+
|
||||
| dump(NULL) |
|
||||
+------------+
|
||||
| NULL |
|
||||
+------------+
|
||||
select dump(0.2);
|
||||
+---------------------------------------------------+
|
||||
| dump(0.2) |
|
||||
+---------------------------------------------------+
|
||||
| "sign=1 exp=63 se=0xbf len=1 digits=[200000000,]" |
|
||||
+---------------------------------------------------+
|
||||
select dump(2);
|
||||
ERROR 0A000: Not supported feature or function
|
||||
select dump('abcdef');
|
||||
ERROR 0A000: Not supported feature or function
|
||||
select dump('abcdef');
|
||||
ERROR 0A000: Not supported feature or function
|
||||
select dump(date'2020-01-01');
|
||||
ERROR 0A000: Not supported feature or function
|
||||
select dump(timestamp'2020-01-01');
|
||||
ERROR 0A000: Not supported feature or function
|
||||
|
||||
@ -0,0 +1,194 @@
|
||||
result_format: 4
|
||||
explain_protocol: 0
|
||||
|
||||
alter system set enable_async_syslog = false;
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
set @@ob_log_level='debug';
|
||||
|
||||
drop view if exists v1;
|
||||
create view v1 as select connection_id() from dual limit 10;
|
||||
desc v1;
|
||||
+-----------------+------------------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+-----------------+------------------+------+-----+---------+-------+
|
||||
| connection_id() | int(10) unsigned | NO | | | |
|
||||
+-----------------+------------------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select utc_timestamp() from dual limit 10;
|
||||
desc v1;
|
||||
+-----------------+----------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+-----------------+----------+------+-----+---------+-------+
|
||||
| utc_timestamp() | datetime | NO | | | |
|
||||
+-----------------+----------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select utc_timestamp(3) from dual limit 10;
|
||||
desc v1;
|
||||
+------------------+-------------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+------------------+-------------+------+-----+---------+-------+
|
||||
| utc_timestamp(3) | datetime(3) | NO | | | |
|
||||
+------------------+-------------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select current_timestamp() from dual limit 10;
|
||||
desc v1;
|
||||
+---------------------+----------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+---------------------+----------+------+-----+---------+-------+
|
||||
| current_timestamp() | datetime | NO | | | |
|
||||
+---------------------+----------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select current_timestamp(3) from dual limit 10;
|
||||
desc v1;
|
||||
+----------------------+----------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+----------------------+----------+------+-----+---------+-------+
|
||||
| current_timestamp(3) | datetime | NO | | | |
|
||||
+----------------------+----------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select sysdate() from dual limit 10;
|
||||
desc v1;
|
||||
+-----------+----------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+-----------+----------+------+-----+---------+-------+
|
||||
| sysdate() | datetime | NO | | | |
|
||||
+-----------+----------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select sysdate(3) from dual limit 10;
|
||||
desc v1;
|
||||
+------------+----------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+------------+----------+------+-----+---------+-------+
|
||||
| sysdate(3) | datetime | NO | | | |
|
||||
+------------+----------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select cur_date() from dual limit 10;
|
||||
desc v1;
|
||||
+------------+------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+------------+------+------+-----+---------+-------+
|
||||
| cur_date() | date | NO | | | |
|
||||
+------------+------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select curtime() from dual limit 10;
|
||||
desc v1;
|
||||
+-----------+------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+-----------+------+------+-----+---------+-------+
|
||||
| curtime() | time | NO | | | |
|
||||
+-----------+------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select current_user() from dual limit 10;
|
||||
desc v1;
|
||||
+----------------+--------------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+----------------+--------------+------+-----+---------+-------+
|
||||
| current_user() | varchar(193) | NO | | | |
|
||||
+----------------+--------------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select database() from dual limit 10;
|
||||
desc v1;
|
||||
+------------+--------------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+------------+--------------+------+-----+---------+-------+
|
||||
| database() | varchar(128) | NO | | | |
|
||||
+------------+--------------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select effective_tenant_id() from dual limit 10;
|
||||
desc v1;
|
||||
+-----------------------+---------------------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+-----------------------+---------------------+------+-----+---------+-------+
|
||||
| effective_tenant_id() | bigint(20) unsigned | NO | | | |
|
||||
+-----------------------+---------------------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select effective_tenant() from dual limit 10;
|
||||
desc v1;
|
||||
+--------------------+-------------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+--------------------+-------------+------+-----+---------+-------+
|
||||
| effective_tenant() | varchar(64) | NO | | | |
|
||||
+--------------------+-------------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select found_rows() from dual limit 10;
|
||||
desc v1;
|
||||
+--------------+------------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+--------------+------------+------+-----+---------+-------+
|
||||
| found_rows() | bigint(20) | NO | | | |
|
||||
+--------------+------------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select host_ip() from dual limit 10;
|
||||
desc v1;
|
||||
+-----------+-------------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+-----------+-------------+------+-----+---------+-------+
|
||||
| host_ip() | varchar(46) | NO | | | |
|
||||
+-----------+-------------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select last_execution_id() from dual limit 10;
|
||||
desc v1;
|
||||
+---------------------+--------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+---------------------+--------+------+-----+---------+-------+
|
||||
| last_execution_id() | bigint | NO | | | |
|
||||
+---------------------+--------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select last_trace_id() from dual limit 10;
|
||||
desc v1;
|
||||
+-----------------+--------------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+-----------------+--------------+------+-----+---------+-------+
|
||||
| last_trace_id() | varchar(128) | NO | | | |
|
||||
+-----------------+--------------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select mysql_port() from dual limit 10;
|
||||
desc v1;
|
||||
+--------------+------------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+--------------+------------+------+-----+---------+-------+
|
||||
| mysql_port() | bigint(20) | NO | | | |
|
||||
+--------------+------------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select rpc_port() from dual limit 10;
|
||||
desc v1;
|
||||
+------------+---------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+------------+---------+------+-----+---------+-------+
|
||||
| rpc_port() | int(11) | NO | | | |
|
||||
+------------+---------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select row_count() from dual limit 10;
|
||||
desc v1;
|
||||
+-------------+------------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+-------------+------------+------+-----+---------+-------+
|
||||
| row_count() | bigint(20) | NO | | | |
|
||||
+-------------+------------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select uuid() from dual limit 10;
|
||||
desc v1;
|
||||
+--------+-------------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+--------+-------------+------+-----+---------+-------+
|
||||
| uuid() | varchar(36) | NO | | | |
|
||||
+--------+-------------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select user() from dual limit 10;
|
||||
desc v1;
|
||||
+--------+--------------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+--------+--------------+------+-----+---------+-------+
|
||||
| user() | varchar(193) | NO | | | |
|
||||
+--------+--------------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
create view v1 as select version() from dual limit 10;
|
||||
desc v1;
|
||||
+-----------+-------------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+-----------+-------------+------+-----+---------+-------+
|
||||
| version() | varchar(18) | NO | | | |
|
||||
+-----------+-------------+------+-----+---------+-------+
|
||||
drop view v1;
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
result_format: 4
|
||||
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select field(1, 3, 2, 1, NULL);
|
||||
+-------------------------+
|
||||
| field(1, 3, 2, 1, NULL) |
|
||||
+-------------------------+
|
||||
| 3 |
|
||||
+-------------------------+
|
||||
select field(1, 3, 2, 1, NULL, 1);
|
||||
+----------------------------+
|
||||
| field(1, 3, 2, 1, NULL, 1) |
|
||||
+----------------------------+
|
||||
| 3 |
|
||||
+----------------------------+
|
||||
select field(NULL, 3, 2, 1, NULL);
|
||||
+----------------------------+
|
||||
| field(NULL, 3, 2, 1, NULL) |
|
||||
+----------------------------+
|
||||
| 0 |
|
||||
+----------------------------+
|
||||
select field(2, 3, NULL, 2, 1, NULL);
|
||||
+-------------------------------+
|
||||
| field(2, 3, NULL, 2, 1, NULL) |
|
||||
+-------------------------------+
|
||||
| 3 |
|
||||
+-------------------------------+
|
||||
select field(1, 3, 2, "1", NULL);
|
||||
+---------------------------+
|
||||
| field(1, 3, 2, "1", NULL) |
|
||||
+---------------------------+
|
||||
| 3 |
|
||||
+---------------------------+
|
||||
select field(1, 3, 2.2, "1", NULL);
|
||||
+-----------------------------+
|
||||
| field(1, 3, 2.2, "1", NULL) |
|
||||
+-----------------------------+
|
||||
| 3 |
|
||||
+-----------------------------+
|
||||
select field("abc", 3.2, "def", 'abc');
|
||||
+---------------------------------+
|
||||
| field("abc", 3.2, "def", 'abc') |
|
||||
+---------------------------------+
|
||||
| 2 |
|
||||
+---------------------------------+
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'abc'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'def'
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
result_format: 4
|
||||
explain_protocol: 0
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
// res type is string
|
||||
select @@ob_log_level;
|
||||
+----------------+
|
||||
| @@ob_log_level |
|
||||
+----------------+
|
||||
| disabled |
|
||||
+----------------+
|
||||
set @@ob_log_level='debug';
|
||||
select @@ob_log_level;
|
||||
+----------------+
|
||||
| @@ob_log_level |
|
||||
+----------------+
|
||||
| debug |
|
||||
+----------------+
|
||||
set @@ob_log_level='info';
|
||||
|
||||
// res type is bool
|
||||
set @@ob_enable_plan_cache = 1;
|
||||
select @@ob_enable_plan_cache = 0;
|
||||
+----------------------------+
|
||||
| @@ob_enable_plan_cache = 0 |
|
||||
+----------------------------+
|
||||
| 0 |
|
||||
+----------------------------+
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
select @@ob_enable_plan_cache = 0;
|
||||
+----------------------------+
|
||||
| @@ob_enable_plan_cache = 0 |
|
||||
+----------------------------+
|
||||
| 1 |
|
||||
+----------------------------+
|
||||
|
||||
// res type is int
|
||||
select @@ob_plan_cache_percentage;
|
||||
+----------------------------+
|
||||
| @@ob_plan_cache_percentage |
|
||||
+----------------------------+
|
||||
| 5 |
|
||||
+----------------------------+
|
||||
|
||||
// test null
|
||||
set character_set_results=NULL;
|
||||
select @@character_set_results;
|
||||
+-------------------------+
|
||||
| @@character_set_results |
|
||||
+-------------------------+
|
||||
| NULL |
|
||||
+-------------------------+
|
||||
|
||||
@ -0,0 +1,57 @@
|
||||
result_format: 4
|
||||
alter system flush plan cache global;
|
||||
set ob_enable_plan_cache = 0;
|
||||
|
||||
set @var1 = NULL;
|
||||
select @var1 from dual;
|
||||
+-------+
|
||||
| @var1 |
|
||||
+-------+
|
||||
| NULL |
|
||||
+-------+
|
||||
|
||||
set @var1 = 1;
|
||||
select @var1 from dual;
|
||||
+-------+
|
||||
| @var1 |
|
||||
+-------+
|
||||
| 1 |
|
||||
+-------+
|
||||
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 int);
|
||||
insert into t1 values(@var1);
|
||||
select * from t1;
|
||||
+------+
|
||||
| c1 |
|
||||
+------+
|
||||
| 1 |
|
||||
+------+
|
||||
|
||||
set @a=0,@b=0;
|
||||
select @a:=10, @b:=1, @a > @b, @a < @b;
|
||||
+--------+-------+---------+---------+
|
||||
| @a:=10 | @b:=1 | @a > @b | @a < @b |
|
||||
+--------+-------+---------+---------+
|
||||
| 10 | 1 | 1 | 0 |
|
||||
+--------+-------+---------+---------+
|
||||
select @a:="10", @b:="1", @a > @b, @a < @b;
|
||||
+----------+---------+---------+---------+
|
||||
| @a:="10" | @b:="1" | @a > @b | @a < @b |
|
||||
+----------+---------+---------+---------+
|
||||
| 10 | 1 | 1 | 0 |
|
||||
+----------+---------+---------+---------+
|
||||
select @a:=10, @b:=2, @a > @b, @a < @b;
|
||||
+--------+-------+---------+---------+
|
||||
| @a:=10 | @b:=2 | @a > @b | @a < @b |
|
||||
+--------+-------+---------+---------+
|
||||
| 10 | 2 | 0 | 1 |
|
||||
+--------+-------+---------+---------+
|
||||
select @a:="10", @b:="2", @a > @b, @a < @b;
|
||||
+----------+---------+---------+---------+
|
||||
| @a:="10" | @b:="2" | @a > @b | @a < @b |
|
||||
+----------+---------+---------+---------+
|
||||
| 10 | 2 | 1 | 0 |
|
||||
+----------+---------+---------+---------+
|
||||
|
||||
|
||||
@ -0,0 +1,552 @@
|
||||
result_format: 4
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 int, c2 int unsigned,
|
||||
c3 tinyint, c4 tinyint unsigned,
|
||||
c5 smallint, c6 smallint unsigned,
|
||||
c7 mediumint, c8 mediumint unsigned,
|
||||
c9 integer, c10 integer unsigned,
|
||||
c11 bigint, c12 bigint unsigned,
|
||||
c13 float, c14 float unsigned,
|
||||
c15 double, c16 double unsigned,
|
||||
c17 decimal, c18 decimal unsigned,
|
||||
c19 date, c20 date not null,
|
||||
c21 datetime, c22 datetime not null,
|
||||
c23 timestamp, c24 timestamp not null,
|
||||
c25 varchar(30), c26 char(30));
|
||||
|
||||
select * from t1;
|
||||
+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+-----+------+-----+------+-----+------+------+
|
||||
| c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 | c9 | c10 | c11 | c12 | c13 | c14 | c15 | c16 | c17 | c18 | c19 | c20 | c21 | c22 | c23 | c24 | c25 | c26 |
|
||||
+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+-----+------+-----+------+-----+------+------+
|
||||
+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+-----+------+-----+------+-----+------+------+
|
||||
|
||||
insert into t1 values(NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, '0000-00-00',
|
||||
NULL, '0000-00-00 00:00:00',
|
||||
NULL, '0000-00-00 00:00:00',
|
||||
NULL, NULL);
|
||||
|
||||
insert into t1 values(0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0.0, 0.0,
|
||||
0.0, 0.0,
|
||||
0.0, 0.0,
|
||||
'0000-00-00', '0000-00-00',
|
||||
'0000-00-00 00:00:00', '0000-00-00 00:00:00',
|
||||
'0000-00-00 00:00:00', '0000-00-00 00:00:00',
|
||||
'0', '0.0');
|
||||
|
||||
insert into t1 values(1, 1,
|
||||
1, 1,
|
||||
1, 1,
|
||||
1, 1,
|
||||
1, 1,
|
||||
1, 1,
|
||||
-0.1, 0.1,
|
||||
-0.1, 0.1,
|
||||
-0.1, 0.1,
|
||||
'0001-01-01', '0001-01-01',
|
||||
'0001-01-01 00:00:00', '0001-01-01 00:00:00',
|
||||
'0001-01-01 00:00:00', '0001-01-01 00:00:00',
|
||||
'1', '1.0');
|
||||
|
||||
insert into t1 values(11, 11,
|
||||
11, 11,
|
||||
11, 11,
|
||||
11, 11,
|
||||
11, 11,
|
||||
11, 11,
|
||||
11.0, 11.0,
|
||||
11.0, 11.0,
|
||||
11.0, 11.0,
|
||||
'2019-12-01 12:00:00', '2019-12-01 12:00:00',
|
||||
'2019-12-01 12:00:00', '2019-12-01 12:00:00',
|
||||
'2019-12-01 12:00:00', '2019-12-01 12:00:00',
|
||||
'11', '11.0');
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
|
||||
select c1, c1 is true, c1 is false, c1 is null, c1 is unknown from t1;
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| c1 | c1 is true | c1 is false | c1 is null | c1 is unknown |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 1 | 1 | 0 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
select c1, c1 is not true, c1 is not false, c1 is not null, c1 is not unknown from t1;
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| c1 | c1 is not true | c1 is not false | c1 is not null | c1 is not unknown |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
select c2, c2 is true, c2 is false, c2 is null, c2 is unknown from t1;
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| c2 | c2 is true | c2 is false | c2 is null | c2 is unknown |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 1 | 1 | 0 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
select c2, c2 is not true, c2 is not false, c2 is not null, c2 is not unknown from t1;
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| c2 | c2 is not true | c2 is not false | c2 is not null | c2 is not unknown |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
select c3, c3 is true, c3 is false, c3 is null, c3 is unknown from t1;
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| c3 | c3 is true | c3 is false | c3 is null | c3 is unknown |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 1 | 1 | 0 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
select c3, c3 is not true, c3 is not false, c3 is not null, c3 is not unknown from t1;
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| c3 | c3 is not true | c3 is not false | c3 is not null | c3 is not unknown |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
select c4, c4 is true, c4 is false, c4 is null, c4 is unknown from t1;
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| c4 | c4 is true | c4 is false | c4 is null | c4 is unknown |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 1 | 1 | 0 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
select c4, c4 is not true, c4 is not false, c4 is not null, c4 is not unknown from t1;
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| c4 | c4 is not true | c4 is not false | c4 is not null | c4 is not unknown |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
select c5, c5 is true, c5 is false, c5 is null, c5 is unknown from t1;
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| c5 | c5 is true | c5 is false | c5 is null | c5 is unknown |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 1 | 1 | 0 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
select c5, c5 is not true, c5 is not false, c5 is not null, c5 is not unknown from t1;
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| c5 | c5 is not true | c5 is not false | c5 is not null | c5 is not unknown |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
select c6, c6 is true, c6 is false, c6 is null, c6 is unknown from t1;
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| c6 | c6 is true | c6 is false | c6 is null | c6 is unknown |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 1 | 1 | 0 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
select c6, c6 is not true, c6 is not false, c6 is not null, c6 is not unknown from t1;
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| c6 | c6 is not true | c6 is not false | c6 is not null | c6 is not unknown |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
select c7, c7 is true, c7 is false, c7 is null, c7 is unknown from t1;
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| c7 | c7 is true | c7 is false | c7 is null | c7 is unknown |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 1 | 1 | 0 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
select c7, c7 is not true, c7 is not false, c7 is not null, c7 is not unknown from t1;
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| c7 | c7 is not true | c7 is not false | c7 is not null | c7 is not unknown |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
select c8, c8 is true, c8 is false, c8 is null, c8 is unknown from t1;
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| c8 | c8 is true | c8 is false | c8 is null | c8 is unknown |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 1 | 1 | 0 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
select c8, c8 is not true, c8 is not false, c8 is not null, c8 is not unknown from t1;
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| c8 | c8 is not true | c8 is not false | c8 is not null | c8 is not unknown |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
select c9, c9 is true, c9 is false, c9 is null, c9 is unknown from t1;
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| c9 | c9 is true | c9 is false | c9 is null | c9 is unknown |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 1 | 1 | 0 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+------------+-------------+------------+---------------+
|
||||
select c9, c9 is not true, c9 is not false, c9 is not null, c9 is not unknown from t1;
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| c9 | c9 is not true | c9 is not false | c9 is not null | c9 is not unknown |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+----------------+-----------------+----------------+-------------------+
|
||||
select c10, c10 is true, c10 is false, c10 is null, c10 is unknown from t1;
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| c10 | c10 is true | c10 is false | c10 is null | c10 is unknown |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 1 | 1 | 0 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
select c10, c10 is not true, c10 is not false, c10 is not null, c10 is not unknown from t1;
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| c10 | c10 is not true | c10 is not false | c10 is not null | c10 is not unknown |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
select c11, c11 is true, c11 is false, c11 is null, c11 is unknown from t1;
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| c11 | c11 is true | c11 is false | c11 is null | c11 is unknown |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 1 | 1 | 0 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
select c11, c11 is not true, c11 is not false, c11 is not null, c11 is not unknown from t1;
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| c11 | c11 is not true | c11 is not false | c11 is not null | c11 is not unknown |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
select c12, c12 is true, c12 is false, c12 is null, c12 is unknown from t1;
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| c12 | c12 is true | c12 is false | c12 is null | c12 is unknown |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 1 | 1 | 0 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
select c12, c12 is not true, c12 is not false, c12 is not null, c12 is not unknown from t1;
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| c12 | c12 is not true | c12 is not false | c12 is not null | c12 is not unknown |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
select c13, c13 is true, c13 is false, c13 is null, c13 is unknown from t1;
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| c13 | c13 is true | c13 is false | c13 is null | c13 is unknown |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| -0.1 | 1 | 0 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
select c13, c13 is not true, c13 is not false, c13 is not null, c13 is not unknown from t1;
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| c13 | c13 is not true | c13 is not false | c13 is not null | c13 is not unknown |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| -0.1 | 0 | 1 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
select c14, c14 is true, c14 is false, c14 is null, c14 is unknown from t1;
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| c14 | c14 is true | c14 is false | c14 is null | c14 is unknown |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 0.1 | 1 | 0 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
select c14, c14 is not true, c14 is not false, c14 is not null, c14 is not unknown from t1;
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| c14 | c14 is not true | c14 is not false | c14 is not null | c14 is not unknown |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 0.1 | 0 | 1 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
select c15, c15 is true, c15 is false, c15 is null, c15 is unknown from t1;
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| c15 | c15 is true | c15 is false | c15 is null | c15 is unknown |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| -0.1 | 1 | 0 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
select c15, c15 is not true, c15 is not false, c15 is not null, c15 is not unknown from t1;
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| c15 | c15 is not true | c15 is not false | c15 is not null | c15 is not unknown |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| -0.1 | 0 | 1 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
select c16, c16 is true, c16 is false, c16 is null, c16 is unknown from t1;
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| c16 | c16 is true | c16 is false | c16 is null | c16 is unknown |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 0.1 | 1 | 0 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
select c16, c16 is not true, c16 is not false, c16 is not null, c16 is not unknown from t1;
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| c16 | c16 is not true | c16 is not false | c16 is not null | c16 is not unknown |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 0.1 | 0 | 1 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
select c17, c17 is true, c17 is false, c17 is null, c17 is unknown from t1;
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| c17 | c17 is true | c17 is false | c17 is null | c17 is unknown |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
select c17, c17 is not true, c17 is not false, c17 is not null, c17 is not unknown from t1;
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| c17 | c17 is not true | c17 is not false | c17 is not null | c17 is not unknown |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
select c18, c18 is true, c18 is false, c18 is null, c18 is unknown from t1;
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| c18 | c18 is true | c18 is false | c18 is null | c18 is unknown |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
select c18, c18 is not true, c18 is not false, c18 is not null, c18 is not unknown from t1;
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| c18 | c18 is not true | c18 is not false | c18 is not null | c18 is not unknown |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
select c19, c19 is true, c19 is false, c19 is null, c19 is unknown from t1;
|
||||
+------------+-------------+--------------+-------------+----------------+
|
||||
| c19 | c19 is true | c19 is false | c19 is null | c19 is unknown |
|
||||
+------------+-------------+--------------+-------------+----------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0000-00-00 | 0 | 1 | 0 | 0 |
|
||||
| 0001-01-01 | 1 | 0 | 0 | 0 |
|
||||
| 2019-12-01 | 1 | 0 | 0 | 0 |
|
||||
+------------+-------------+--------------+-------------+----------------+
|
||||
select c19, c19 is not true, c19 is not false, c19 is not null, c19 is not unknown from t1;
|
||||
+------------+-----------------+------------------+-----------------+--------------------+
|
||||
| c19 | c19 is not true | c19 is not false | c19 is not null | c19 is not unknown |
|
||||
+------------+-----------------+------------------+-----------------+--------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0000-00-00 | 1 | 0 | 1 | 1 |
|
||||
| 0001-01-01 | 0 | 1 | 1 | 1 |
|
||||
| 2019-12-01 | 0 | 1 | 1 | 1 |
|
||||
+------------+-----------------+------------------+-----------------+--------------------+
|
||||
select c20, c20 is true, c20 is false, c20 is null, c20 is unknown from t1;
|
||||
+------------+-------------+--------------+-------------+----------------+
|
||||
| c20 | c20 is true | c20 is false | c20 is null | c20 is unknown |
|
||||
+------------+-------------+--------------+-------------+----------------+
|
||||
| 0000-00-00 | 0 | 1 | 0 | 0 |
|
||||
| 0000-00-00 | 0 | 1 | 0 | 0 |
|
||||
| 0001-01-01 | 1 | 0 | 0 | 0 |
|
||||
| 2019-12-01 | 1 | 0 | 0 | 0 |
|
||||
+------------+-------------+--------------+-------------+----------------+
|
||||
select c20, c20 is not true, c20 is not false, c20 is not null, c20 is not unknown from t1;
|
||||
+------------+-----------------+------------------+-----------------+--------------------+
|
||||
| c20 | c20 is not true | c20 is not false | c20 is not null | c20 is not unknown |
|
||||
+------------+-----------------+------------------+-----------------+--------------------+
|
||||
| 0000-00-00 | 1 | 0 | 1 | 1 |
|
||||
| 0000-00-00 | 1 | 0 | 1 | 1 |
|
||||
| 0001-01-01 | 0 | 1 | 1 | 1 |
|
||||
| 2019-12-01 | 0 | 1 | 1 | 1 |
|
||||
+------------+-----------------+------------------+-----------------+--------------------+
|
||||
select c21, c21 is true, c21 is false, c21 is null, c21 is unknown from t1;
|
||||
+---------------------+-------------+--------------+-------------+----------------+
|
||||
| c21 | c21 is true | c21 is false | c21 is null | c21 is unknown |
|
||||
+---------------------+-------------+--------------+-------------+----------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0000-00-00 00:00:00 | 0 | 1 | 0 | 0 |
|
||||
| 0001-01-01 00:00:00 | 1 | 0 | 0 | 0 |
|
||||
| 2019-12-01 12:00:00 | 1 | 0 | 0 | 0 |
|
||||
+---------------------+-------------+--------------+-------------+----------------+
|
||||
select c21, c21 is not true, c21 is not false, c21 is not null, c21 is not unknown from t1;
|
||||
+---------------------+-----------------+------------------+-----------------+--------------------+
|
||||
| c21 | c21 is not true | c21 is not false | c21 is not null | c21 is not unknown |
|
||||
+---------------------+-----------------+------------------+-----------------+--------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0000-00-00 00:00:00 | 1 | 0 | 1 | 1 |
|
||||
| 0001-01-01 00:00:00 | 0 | 1 | 1 | 1 |
|
||||
| 2019-12-01 12:00:00 | 0 | 1 | 1 | 1 |
|
||||
+---------------------+-----------------+------------------+-----------------+--------------------+
|
||||
select c22, c22 is true, c22 is false, c22 is null, c22 is unknown from t1;
|
||||
+---------------------+-------------+--------------+-------------+----------------+
|
||||
| c22 | c22 is true | c22 is false | c22 is null | c22 is unknown |
|
||||
+---------------------+-------------+--------------+-------------+----------------+
|
||||
| 0000-00-00 00:00:00 | 0 | 1 | 0 | 0 |
|
||||
| 0000-00-00 00:00:00 | 0 | 1 | 0 | 0 |
|
||||
| 0001-01-01 00:00:00 | 1 | 0 | 0 | 0 |
|
||||
| 2019-12-01 12:00:00 | 1 | 0 | 0 | 0 |
|
||||
+---------------------+-------------+--------------+-------------+----------------+
|
||||
select c22, c22 is not true, c22 is not false, c22 is not null, c22 is not unknown from t1;
|
||||
+---------------------+-----------------+------------------+-----------------+--------------------+
|
||||
| c22 | c22 is not true | c22 is not false | c22 is not null | c22 is not unknown |
|
||||
+---------------------+-----------------+------------------+-----------------+--------------------+
|
||||
| 0000-00-00 00:00:00 | 1 | 0 | 1 | 1 |
|
||||
| 0000-00-00 00:00:00 | 1 | 0 | 1 | 1 |
|
||||
| 0001-01-01 00:00:00 | 0 | 1 | 1 | 1 |
|
||||
| 2019-12-01 12:00:00 | 0 | 1 | 1 | 1 |
|
||||
+---------------------+-----------------+------------------+-----------------+--------------------+
|
||||
select c23, c23 is true, c23 is false, c23 is null, c23 is unknown from t1;
|
||||
+---------------------+-------------+--------------+-------------+----------------+
|
||||
| c23 | c23 is true | c23 is false | c23 is null | c23 is unknown |
|
||||
+---------------------+-------------+--------------+-------------+----------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0000-00-00 00:00:00 | 0 | 1 | 0 | 0 |
|
||||
| 0001-01-01 00:00:00 | 1 | 0 | 0 | 0 |
|
||||
| 2019-12-01 12:00:00 | 1 | 0 | 0 | 0 |
|
||||
+---------------------+-------------+--------------+-------------+----------------+
|
||||
select c23, c23 is not true, c23 is not false, c23 is not null, c23 is not unknown from t1;
|
||||
+---------------------+-----------------+------------------+-----------------+--------------------+
|
||||
| c23 | c23 is not true | c23 is not false | c23 is not null | c23 is not unknown |
|
||||
+---------------------+-----------------+------------------+-----------------+--------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0000-00-00 00:00:00 | 1 | 0 | 1 | 1 |
|
||||
| 0001-01-01 00:00:00 | 0 | 1 | 1 | 1 |
|
||||
| 2019-12-01 12:00:00 | 0 | 1 | 1 | 1 |
|
||||
+---------------------+-----------------+------------------+-----------------+--------------------+
|
||||
select c24, c24 is true, c24 is false, c24 is null, c24 is unknown from t1;
|
||||
+---------------------+-------------+--------------+-------------+----------------+
|
||||
| c24 | c24 is true | c24 is false | c24 is null | c24 is unknown |
|
||||
+---------------------+-------------+--------------+-------------+----------------+
|
||||
| 0000-00-00 00:00:00 | 0 | 1 | 0 | 0 |
|
||||
| 0000-00-00 00:00:00 | 0 | 1 | 0 | 0 |
|
||||
| 0001-01-01 00:00:00 | 1 | 0 | 0 | 0 |
|
||||
| 2019-12-01 12:00:00 | 1 | 0 | 0 | 0 |
|
||||
+---------------------+-------------+--------------+-------------+----------------+
|
||||
select c24, c24 is not true, c24 is not false, c24 is not null, c24 is not unknown from t1;
|
||||
+---------------------+-----------------+------------------+-----------------+--------------------+
|
||||
| c24 | c24 is not true | c24 is not false | c24 is not null | c24 is not unknown |
|
||||
+---------------------+-----------------+------------------+-----------------+--------------------+
|
||||
| 0000-00-00 00:00:00 | 1 | 0 | 1 | 1 |
|
||||
| 0000-00-00 00:00:00 | 1 | 0 | 1 | 1 |
|
||||
| 0001-01-01 00:00:00 | 0 | 1 | 1 | 1 |
|
||||
| 2019-12-01 12:00:00 | 0 | 1 | 1 | 1 |
|
||||
+---------------------+-----------------+------------------+-----------------+--------------------+
|
||||
select c25, c25 is true, c25 is false, c25 is null, c25 is unknown from t1;
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| c25 | c25 is true | c25 is false | c25 is null | c25 is unknown |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0 | 0 | 1 | 0 | 0 |
|
||||
| 1 | 1 | 0 | 0 | 0 |
|
||||
| 11 | 1 | 0 | 0 | 0 |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
select c25, c25 is not true, c25 is not false, c25 is not null, c25 is not unknown from t1;
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| c25 | c25 is not true | c25 is not false | c25 is not null | c25 is not unknown |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0 | 1 | 0 | 1 | 1 |
|
||||
| 1 | 0 | 1 | 1 | 1 |
|
||||
| 11 | 0 | 1 | 1 | 1 |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
select c26, c26 is true, c26 is false, c26 is null, c26 is unknown from t1;
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| c26 | c26 is true | c26 is false | c26 is null | c26 is unknown |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
| NULL | 0 | 0 | 1 | 1 |
|
||||
| 0.0 | 0 | 1 | 0 | 0 |
|
||||
| 1.0 | 1 | 0 | 0 | 0 |
|
||||
| 11.0 | 1 | 0 | 0 | 0 |
|
||||
+------+-------------+--------------+-------------+----------------+
|
||||
select c26, c26 is not true, c26 is not false, c26 is not null, c26 is not unknown from t1;
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| c26 | c26 is not true | c26 is not false | c26 is not null | c26 is not unknown |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
| NULL | 1 | 1 | 0 | 0 |
|
||||
| 0.0 | 1 | 0 | 1 | 1 |
|
||||
| 1.0 | 0 | 1 | 1 | 1 |
|
||||
| 11.0 | 0 | 1 | 1 | 1 |
|
||||
+------+-----------------+------------------+-----------------+--------------------+
|
||||
drop table t1;
|
||||
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
result_format: 4
|
||||
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select is_serving_tenant(host_ip(), rpc_port(), effective_tenant_id());
|
||||
+-----------------------------------------------------------------+
|
||||
| is_serving_tenant(host_ip(), rpc_port(), effective_tenant_id()) |
|
||||
+-----------------------------------------------------------------+
|
||||
| 1 |
|
||||
+-----------------------------------------------------------------+
|
||||
select is_serving_tenant(host_ip(), rpc_port(), 1);
|
||||
+---------------------------------------------+
|
||||
| is_serving_tenant(host_ip(), rpc_port(), 1) |
|
||||
+---------------------------------------------+
|
||||
| 1 |
|
||||
+---------------------------------------------+
|
||||
select is_serving_tenant(host_ip(), rpc_port(), 888);
|
||||
+-----------------------------------------------+
|
||||
| is_serving_tenant(host_ip(), rpc_port(), 888) |
|
||||
+-----------------------------------------------+
|
||||
| 0 |
|
||||
+-----------------------------------------------+
|
||||
select is_serving_tenant('abc', rpc_port(), effective_tenant_id());
|
||||
+-------------------------------------------------------------+
|
||||
| is_serving_tenant('abc', rpc_port(), effective_tenant_id()) |
|
||||
+-------------------------------------------------------------+
|
||||
| 0 |
|
||||
+-------------------------------------------------------------+
|
||||
select is_serving_tenant('abc', rpc_port(), 1);
|
||||
+-----------------------------------------+
|
||||
| is_serving_tenant('abc', rpc_port(), 1) |
|
||||
+-----------------------------------------+
|
||||
| 1 |
|
||||
+-----------------------------------------+
|
||||
select is_serving_tenant('abc', rpc_port(), 888);
|
||||
+-------------------------------------------+
|
||||
| is_serving_tenant('abc', rpc_port(), 888) |
|
||||
+-------------------------------------------+
|
||||
| 0 |
|
||||
+-------------------------------------------+
|
||||
|
||||
@ -0,0 +1,195 @@
|
||||
result_format: 4
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 int, c2 int unsigned,
|
||||
c3 tinyint, c4 tinyint unsigned,
|
||||
c5 bigint, c6 bigint unsigned,
|
||||
c7 float, c8 float unsigned,
|
||||
c9 double, c10 double unsigned,
|
||||
c11 decimal, c12 decimal unsigned,
|
||||
c13 date, c14 datetime, c15 timestamp,
|
||||
c16 varchar(30), c17 char(30));
|
||||
select * from t1;
|
||||
+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
|
||||
| c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 | c9 | c10 | c11 | c12 | c13 | c14 | c15 | c16 | c17 |
|
||||
+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
|
||||
+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
|
||||
insert into t1 values(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
|
||||
insert into t1 values(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0000-00-00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '', '');
|
||||
insert into t1 values(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, '0013-01-01', '0014-01-01', '0015-01-01', '16', '17');
|
||||
insert into t1 values(-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, '0013-01-01', '0014-01-01 00:00:00', '0015-01-01 00:00:00', '-16', '-17');
|
||||
insert into t1 values(1234567, 7654321, -33, 44, 555555555, 666666666, 777.777, 8888.888, 99999.999999, 10000.00000, 1111, 121212121, '0013-01-01', '0014-01-01 00:00:11', '0015-01-01 00:00:11', 'sadfsadfdsafasasdf', 'asdffdsafadsfdsafsad');
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select c1, length(c1) from t1;
|
||||
+---------+------------+
|
||||
| c1 | length(c1) |
|
||||
+---------+------------+
|
||||
| NULL | NULL |
|
||||
| 0 | 1 |
|
||||
| 1 | 1 |
|
||||
| -1 | 2 |
|
||||
| 1234567 | 7 |
|
||||
+---------+------------+
|
||||
select c2, length(c2) from t1;
|
||||
+---------+------------+
|
||||
| c2 | length(c2) |
|
||||
+---------+------------+
|
||||
| NULL | NULL |
|
||||
| 0 | 1 |
|
||||
| 2 | 1 |
|
||||
| 2 | 1 |
|
||||
| 7654321 | 7 |
|
||||
+---------+------------+
|
||||
select c3, length(c3) from t1;
|
||||
+------+------------+
|
||||
| c3 | length(c3) |
|
||||
+------+------------+
|
||||
| NULL | NULL |
|
||||
| 0 | 1 |
|
||||
| 3 | 1 |
|
||||
| -3 | 2 |
|
||||
| -33 | 3 |
|
||||
+------+------------+
|
||||
select c4, length(c4) from t1;
|
||||
+------+------------+
|
||||
| c4 | length(c4) |
|
||||
+------+------------+
|
||||
| NULL | NULL |
|
||||
| 0 | 1 |
|
||||
| 4 | 1 |
|
||||
| 4 | 1 |
|
||||
| 44 | 2 |
|
||||
+------+------------+
|
||||
select c5, length(c5) from t1;
|
||||
+-----------+------------+
|
||||
| c5 | length(c5) |
|
||||
+-----------+------------+
|
||||
| NULL | NULL |
|
||||
| 0 | 1 |
|
||||
| 5 | 1 |
|
||||
| -5 | 2 |
|
||||
| 555555555 | 9 |
|
||||
+-----------+------------+
|
||||
select c6, length(c6) from t1;
|
||||
+-----------+------------+
|
||||
| c6 | length(c6) |
|
||||
+-----------+------------+
|
||||
| NULL | NULL |
|
||||
| 0 | 1 |
|
||||
| 6 | 1 |
|
||||
| 6 | 1 |
|
||||
| 666666666 | 9 |
|
||||
+-----------+------------+
|
||||
select c7, length(c7) from t1;
|
||||
+---------+------------+
|
||||
| c7 | length(c7) |
|
||||
+---------+------------+
|
||||
| NULL | NULL |
|
||||
| 0 | 1 |
|
||||
| 7 | 1 |
|
||||
| -7 | 2 |
|
||||
| 777.777 | 7 |
|
||||
+---------+------------+
|
||||
select c8, length(c8) from t1;
|
||||
+---------+------------+
|
||||
| c8 | length(c8) |
|
||||
+---------+------------+
|
||||
| NULL | NULL |
|
||||
| 0 | 1 |
|
||||
| 8 | 1 |
|
||||
| 8 | 1 |
|
||||
| 8888.89 | 7 |
|
||||
+---------+------------+
|
||||
select c9, length(c9) from t1;
|
||||
+--------------+------------+
|
||||
| c9 | length(c9) |
|
||||
+--------------+------------+
|
||||
| NULL | NULL |
|
||||
| 0 | 1 |
|
||||
| 9 | 1 |
|
||||
| -9 | 2 |
|
||||
| 99999.999999 | 12 |
|
||||
+--------------+------------+
|
||||
select c10, length(c10) from t1;
|
||||
+-------+-------------+
|
||||
| c10 | length(c10) |
|
||||
+-------+-------------+
|
||||
| NULL | NULL |
|
||||
| 0 | 1 |
|
||||
| 10 | 2 |
|
||||
| 10 | 2 |
|
||||
| 10000 | 5 |
|
||||
+-------+-------------+
|
||||
select c11, length(c11) from t1;
|
||||
+------+-------------+
|
||||
| c11 | length(c11) |
|
||||
+------+-------------+
|
||||
| NULL | NULL |
|
||||
| 0 | 1 |
|
||||
| 11 | 2 |
|
||||
| -11 | 3 |
|
||||
| 1111 | 4 |
|
||||
+------+-------------+
|
||||
select c12, length(c12) from t1;
|
||||
+-----------+-------------+
|
||||
| c12 | length(c12) |
|
||||
+-----------+-------------+
|
||||
| NULL | NULL |
|
||||
| 0 | 1 |
|
||||
| 12 | 2 |
|
||||
| 12 | 2 |
|
||||
| 121212121 | 9 |
|
||||
+-----------+-------------+
|
||||
select c13, length(c13) from t1;
|
||||
+------------+-------------+
|
||||
| c13 | length(c13) |
|
||||
+------------+-------------+
|
||||
| NULL | NULL |
|
||||
| 0000-00-00 | 10 |
|
||||
| 0013-01-01 | 10 |
|
||||
| 0013-01-01 | 10 |
|
||||
| 0013-01-01 | 10 |
|
||||
+------------+-------------+
|
||||
select c14, length(c14) from t1;
|
||||
+---------------------+-------------+
|
||||
| c14 | length(c14) |
|
||||
+---------------------+-------------+
|
||||
| NULL | NULL |
|
||||
| 0000-00-00 00:00:00 | 19 |
|
||||
| 0014-01-01 00:00:00 | 19 |
|
||||
| 0014-01-01 00:00:00 | 19 |
|
||||
| 0014-01-01 00:00:11 | 19 |
|
||||
+---------------------+-------------+
|
||||
select c15, length(c15) from t1;
|
||||
+---------------------+-------------+
|
||||
| c15 | length(c15) |
|
||||
+---------------------+-------------+
|
||||
| NULL | NULL |
|
||||
| 0000-00-00 00:00:00 | 19 |
|
||||
| 0015-01-01 00:00:00 | 19 |
|
||||
| 0015-01-01 00:00:00 | 19 |
|
||||
| 0015-01-01 00:00:11 | 19 |
|
||||
+---------------------+-------------+
|
||||
select c16, length(c16) from t1;
|
||||
+--------------------+-------------+
|
||||
| c16 | length(c16) |
|
||||
+--------------------+-------------+
|
||||
| NULL | NULL |
|
||||
| | 0 |
|
||||
| 16 | 2 |
|
||||
| -16 | 3 |
|
||||
| sadfsadfdsafasasdf | 18 |
|
||||
+--------------------+-------------+
|
||||
select c17, length(c17) from t1;
|
||||
+----------------------+-------------+
|
||||
| c17 | length(c17) |
|
||||
+----------------------+-------------+
|
||||
| NULL | NULL |
|
||||
| | 0 |
|
||||
| 17 | 2 |
|
||||
| -17 | 3 |
|
||||
| asdffdsafadsfdsafsad | 20 |
|
||||
+----------------------+-------------+
|
||||
|
||||
drop table t1;
|
||||
@ -0,0 +1,37 @@
|
||||
result_format: 4
|
||||
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select lnnvl(1) from dual;
|
||||
+----------+
|
||||
| lnnvl(1) |
|
||||
+----------+
|
||||
| 0 |
|
||||
+----------+
|
||||
select lnnvl(-1) from dual;
|
||||
+-----------+
|
||||
| lnnvl(-1) |
|
||||
+-----------+
|
||||
| 0 |
|
||||
+-----------+
|
||||
select lnnvl(0) from dual;
|
||||
+----------+
|
||||
| lnnvl(0) |
|
||||
+----------+
|
||||
| 1 |
|
||||
+----------+
|
||||
select lnnvl(NULL) from dual;
|
||||
+-------------+
|
||||
| lnnvl(NULL) |
|
||||
+-------------+
|
||||
| 1 |
|
||||
+-------------+
|
||||
select lnnvl('abc') from dual;
|
||||
+--------------+
|
||||
| lnnvl('abc') |
|
||||
+--------------+
|
||||
| 1 |
|
||||
+--------------+
|
||||
|
||||
@ -0,0 +1,110 @@
|
||||
result_format: 4
|
||||
explain_protocol: 0
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
// locate(substr, oristr), instr(oristr, substr)
|
||||
select locate(null, 'a'), locate('a', null), locate('a', 'a', null);
|
||||
+-------------------+-------------------+------------------------+
|
||||
| locate(null, 'a') | locate('a', null) | locate('a', 'a', null) |
|
||||
+-------------------+-------------------+------------------------+
|
||||
| NULL | NULL | 0 |
|
||||
+-------------------+-------------------+------------------------+
|
||||
select locate('abc', 'a'), instr('abc', 'a');
|
||||
+--------------------+-------------------+
|
||||
| locate('abc', 'a') | instr('abc', 'a') |
|
||||
+--------------------+-------------------+
|
||||
| 0 | 1 |
|
||||
+--------------------+-------------------+
|
||||
select locate('a', 'aaaa', 1), locate('a', 'aaaa', 0), locate('a', 'aaaa', -1);
|
||||
+------------------------+------------------------+-------------------------+
|
||||
| locate('a', 'aaaa', 1) | locate('a', 'aaaa', 0) | locate('a', 'aaaa', -1) |
|
||||
+------------------------+------------------------+-------------------------+
|
||||
| 1 | 0 | 0 |
|
||||
+------------------------+------------------------+-------------------------+
|
||||
select locate('a', 'aaaa', '1.9'), locate('a', 'aaaa', '0.9'), locate('a', 'aaaa', '-1.9');
|
||||
+----------------------------+----------------------------+-----------------------------+
|
||||
| locate('a', 'aaaa', '1.9') | locate('a', 'aaaa', '0.9') | locate('a', 'aaaa', '-1.9') |
|
||||
+----------------------------+----------------------------+-----------------------------+
|
||||
| 1 | 0 | 0 |
|
||||
+----------------------------+----------------------------+-----------------------------+
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '0.9'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-1.9'
|
||||
select locate('a', 'aaaa', '1.1'), locate('a', 'aaaa', '0.1'), locate('a', 'aaaa', '-1.1');
|
||||
+----------------------------+----------------------------+-----------------------------+
|
||||
| locate('a', 'aaaa', '1.1') | locate('a', 'aaaa', '0.1') | locate('a', 'aaaa', '-1.1') |
|
||||
+----------------------------+----------------------------+-----------------------------+
|
||||
| 1 | 0 | 0 |
|
||||
+----------------------------+----------------------------+-----------------------------+
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '0.1'
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-1.1'
|
||||
select locate('中', 'a中测试', 1);
|
||||
+--------------------------------+
|
||||
| locate('中', 'a中测试', 1) |
|
||||
+--------------------------------+
|
||||
| 2 |
|
||||
+--------------------------------+
|
||||
select locate('a', 'abcdabcd', '2.a');
|
||||
+--------------------------------+
|
||||
| locate('a', 'abcdabcd', '2.a') |
|
||||
+--------------------------------+
|
||||
| 5 |
|
||||
+--------------------------------+
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '2.a'
|
||||
select locate('a', 'abcdabcd', 'a');
|
||||
+------------------------------+
|
||||
| locate('a', 'abcdabcd', 'a') |
|
||||
+------------------------------+
|
||||
| 0 |
|
||||
+------------------------------+
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: 'a'
|
||||
select locate('a', 'abcdabcd', '-2.a');
|
||||
+---------------------------------+
|
||||
| locate('a', 'abcdabcd', '-2.a') |
|
||||
+---------------------------------+
|
||||
| 0 |
|
||||
+---------------------------------+
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '-2.a'
|
||||
select locate('a', 'a', 10000);
|
||||
+-------------------------+
|
||||
| locate('a', 'a', 10000) |
|
||||
+-------------------------+
|
||||
| 0 |
|
||||
+-------------------------+
|
||||
select locate('a', 'a', 1000000000000000000000000000000000000000000000000000000000000000);
|
||||
+------------------------------------------------------------------------------------+
|
||||
| locate('a', 'a', 1000000000000000000000000000000000000000000000000000000000000000) |
|
||||
+------------------------------------------------------------------------------------+
|
||||
| 0 |
|
||||
+------------------------------------------------------------------------------------+
|
||||
|
||||
select instr('abc', 'a'), instr('aaaa','a'), instr('a中测试', '中'), instr(null, 'a'), instr('a', null);
|
||||
+-------------------+-------------------+----------------------------+------------------+------------------+
|
||||
| instr('abc', 'a') | instr('aaaa','a') | instr('a中测试', '中') | instr(null, 'a') | instr('a', null) |
|
||||
+-------------------+-------------------+----------------------------+------------------+------------------+
|
||||
| 1 | 1 | 2 | NULL | NULL |
|
||||
+-------------------+-------------------+----------------------------+------------------+------------------+
|
||||
|
||||
select reverse(''), reverse(null), reverse('你好abc中文'), reverse(12345.123), reverse(null);
|
||||
+-------------+---------------+----------------------------+--------------------+---------------+
|
||||
| reverse('') | reverse(null) | reverse('你好abc中文') | reverse(12345.123) | reverse(null) |
|
||||
+-------------+---------------+----------------------------+--------------------+---------------+
|
||||
| | NULL | 文中cba好你 | 321.54321 | NULL |
|
||||
+-------------+---------------+----------------------------+--------------------+---------------+
|
||||
|
||||
drop table if exists t1;
|
||||
create table t1(c1 bigint unsigned);
|
||||
insert into t1 values(locate('a','b',9223372036854775808));
|
||||
select * from t1;
|
||||
+------+
|
||||
| c1 |
|
||||
+------+
|
||||
| 0 |
|
||||
+------+
|
||||
drop table t1;
|
||||
|
||||
@ -0,0 +1,195 @@
|
||||
result_format: 4
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 int, c2 int unsigned,
|
||||
c3 tinyint, c4 tinyint unsigned,
|
||||
c5 bigint, c6 bigint unsigned,
|
||||
c7 float, c8 float unsigned,
|
||||
c9 double, c10 double unsigned,
|
||||
c11 decimal, c12 decimal unsigned,
|
||||
c13 date, c14 datetime, c15 timestamp,
|
||||
c16 varchar(60), c17 char(60));
|
||||
select * from t1;
|
||||
+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
|
||||
| c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 | c9 | c10 | c11 | c12 | c13 | c14 | c15 | c16 | c17 |
|
||||
+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
|
||||
+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
|
||||
insert into t1 values(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
|
||||
insert into t1 values(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0000-00-00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '', '');
|
||||
insert into t1 values(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, '0013-01-01', '0014-01-01', '0015-01-01', '16abcDeFG00', '16abcDeFG00');
|
||||
insert into t1 values(-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, '0013-01-01', '0014-01-01 00:00:00', '0015-01-01 00:00:00', '=[]-+,/;<>?.*~!@#$%^&*()', '=[]-+,/;<>?.*~!@#$%^&*()');
|
||||
insert into t1 values(1234567, 7654321, -33, 44, 555555555, 666666666, 777.777, 8888.888, 99999.999999, 10000.00000, 1111, 121212121, '0013-01-01', '0014-01-01 00:00:11', '0015-01-01 00:00:11', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select c1, lower(c1), upper(c1) from t1;
|
||||
+---------+-----------+-----------+
|
||||
| c1 | lower(c1) | upper(c1) |
|
||||
+---------+-----------+-----------+
|
||||
| NULL | NULL | NULL |
|
||||
| 0 | 0 | 0 |
|
||||
| 1 | 1 | 1 |
|
||||
| -1 | -1 | -1 |
|
||||
| 1234567 | 1234567 | 1234567 |
|
||||
+---------+-----------+-----------+
|
||||
select c2, lower(c2), upper(c2) from t1;
|
||||
+---------+-----------+-----------+
|
||||
| c2 | lower(c2) | upper(c2) |
|
||||
+---------+-----------+-----------+
|
||||
| NULL | NULL | NULL |
|
||||
| 0 | 0 | 0 |
|
||||
| 2 | 2 | 2 |
|
||||
| 2 | 2 | 2 |
|
||||
| 7654321 | 7654321 | 7654321 |
|
||||
+---------+-----------+-----------+
|
||||
select c3, lower(c3), upper(c3) from t1;
|
||||
+------+-----------+-----------+
|
||||
| c3 | lower(c3) | upper(c3) |
|
||||
+------+-----------+-----------+
|
||||
| NULL | NULL | NULL |
|
||||
| 0 | 0 | 0 |
|
||||
| 3 | 3 | 3 |
|
||||
| -3 | -3 | -3 |
|
||||
| -33 | -33 | -33 |
|
||||
+------+-----------+-----------+
|
||||
select c4, lower(c4), upper(c4) from t1;
|
||||
+------+-----------+-----------+
|
||||
| c4 | lower(c4) | upper(c4) |
|
||||
+------+-----------+-----------+
|
||||
| NULL | NULL | NULL |
|
||||
| 0 | 0 | 0 |
|
||||
| 4 | 4 | 4 |
|
||||
| 4 | 4 | 4 |
|
||||
| 44 | 44 | 44 |
|
||||
+------+-----------+-----------+
|
||||
select c5, lower(c5), upper(c5) from t1;
|
||||
+-----------+-----------+-----------+
|
||||
| c5 | lower(c5) | upper(c5) |
|
||||
+-----------+-----------+-----------+
|
||||
| NULL | NULL | NULL |
|
||||
| 0 | 0 | 0 |
|
||||
| 5 | 5 | 5 |
|
||||
| -5 | -5 | -5 |
|
||||
| 555555555 | 555555555 | 555555555 |
|
||||
+-----------+-----------+-----------+
|
||||
select c6, lower(c6), upper(c6) from t1;
|
||||
+-----------+-----------+-----------+
|
||||
| c6 | lower(c6) | upper(c6) |
|
||||
+-----------+-----------+-----------+
|
||||
| NULL | NULL | NULL |
|
||||
| 0 | 0 | 0 |
|
||||
| 6 | 6 | 6 |
|
||||
| 6 | 6 | 6 |
|
||||
| 666666666 | 666666666 | 666666666 |
|
||||
+-----------+-----------+-----------+
|
||||
select c7, lower(c7), upper(c7) from t1;
|
||||
+---------+-----------+-----------+
|
||||
| c7 | lower(c7) | upper(c7) |
|
||||
+---------+-----------+-----------+
|
||||
| NULL | NULL | NULL |
|
||||
| 0 | 0 | 0 |
|
||||
| 7 | 7 | 7 |
|
||||
| -7 | -7 | -7 |
|
||||
| 777.777 | 777.777 | 777.777 |
|
||||
+---------+-----------+-----------+
|
||||
select c8, lower(c8), upper(c8) from t1;
|
||||
+---------+-----------+-----------+
|
||||
| c8 | lower(c8) | upper(c8) |
|
||||
+---------+-----------+-----------+
|
||||
| NULL | NULL | NULL |
|
||||
| 0 | 0 | 0 |
|
||||
| 8 | 8 | 8 |
|
||||
| 8 | 8 | 8 |
|
||||
| 8888.89 | 8888.89 | 8888.89 |
|
||||
+---------+-----------+-----------+
|
||||
select c9, lower(c9), upper(c9) from t1;
|
||||
+--------------+--------------+--------------+
|
||||
| c9 | lower(c9) | upper(c9) |
|
||||
+--------------+--------------+--------------+
|
||||
| NULL | NULL | NULL |
|
||||
| 0 | 0 | 0 |
|
||||
| 9 | 9 | 9 |
|
||||
| -9 | -9 | -9 |
|
||||
| 99999.999999 | 99999.999999 | 99999.999999 |
|
||||
+--------------+--------------+--------------+
|
||||
select c10, lower(c10), upper(c10) from t1;
|
||||
+-------+------------+------------+
|
||||
| c10 | lower(c10) | upper(c10) |
|
||||
+-------+------------+------------+
|
||||
| NULL | NULL | NULL |
|
||||
| 0 | 0 | 0 |
|
||||
| 10 | 10 | 10 |
|
||||
| 10 | 10 | 10 |
|
||||
| 10000 | 10000 | 10000 |
|
||||
+-------+------------+------------+
|
||||
select c11, lower(c11), upper(c11) from t1;
|
||||
+------+------------+------------+
|
||||
| c11 | lower(c11) | upper(c11) |
|
||||
+------+------------+------------+
|
||||
| NULL | NULL | NULL |
|
||||
| 0 | 0 | 0 |
|
||||
| 11 | 11 | 11 |
|
||||
| -11 | -11 | -11 |
|
||||
| 1111 | 1111 | 1111 |
|
||||
+------+------------+------------+
|
||||
select c12, lower(c12), upper(c12) from t1;
|
||||
+-----------+------------+------------+
|
||||
| c12 | lower(c12) | upper(c12) |
|
||||
+-----------+------------+------------+
|
||||
| NULL | NULL | NULL |
|
||||
| 0 | 0 | 0 |
|
||||
| 12 | 12 | 12 |
|
||||
| 12 | 12 | 12 |
|
||||
| 121212121 | 121212121 | 121212121 |
|
||||
+-----------+------------+------------+
|
||||
select c13, lower(c13), upper(c13) from t1;
|
||||
+------------+------------+------------+
|
||||
| c13 | lower(c13) | upper(c13) |
|
||||
+------------+------------+------------+
|
||||
| NULL | NULL | NULL |
|
||||
| 0000-00-00 | 0000-00-00 | 0000-00-00 |
|
||||
| 0013-01-01 | 0013-01-01 | 0013-01-01 |
|
||||
| 0013-01-01 | 0013-01-01 | 0013-01-01 |
|
||||
| 0013-01-01 | 0013-01-01 | 0013-01-01 |
|
||||
+------------+------------+------------+
|
||||
select c14, lower(c14), upper(c14) from t1;
|
||||
+---------------------+---------------------+---------------------+
|
||||
| c14 | lower(c14) | upper(c14) |
|
||||
+---------------------+---------------------+---------------------+
|
||||
| NULL | NULL | NULL |
|
||||
| 0000-00-00 00:00:00 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 |
|
||||
| 0014-01-01 00:00:00 | 0014-01-01 00:00:00 | 0014-01-01 00:00:00 |
|
||||
| 0014-01-01 00:00:00 | 0014-01-01 00:00:00 | 0014-01-01 00:00:00 |
|
||||
| 0014-01-01 00:00:11 | 0014-01-01 00:00:11 | 0014-01-01 00:00:11 |
|
||||
+---------------------+---------------------+---------------------+
|
||||
select c15, lower(c15), upper(c15) from t1;
|
||||
+---------------------+---------------------+---------------------+
|
||||
| c15 | lower(c15) | upper(c15) |
|
||||
+---------------------+---------------------+---------------------+
|
||||
| NULL | NULL | NULL |
|
||||
| 0000-00-00 00:00:00 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 |
|
||||
| 0015-01-01 00:00:00 | 0015-01-01 00:00:00 | 0015-01-01 00:00:00 |
|
||||
| 0015-01-01 00:00:00 | 0015-01-01 00:00:00 | 0015-01-01 00:00:00 |
|
||||
| 0015-01-01 00:00:11 | 0015-01-01 00:00:11 | 0015-01-01 00:00:11 |
|
||||
+---------------------+---------------------+---------------------+
|
||||
select c16, lower(c16), upper(c16) from t1;
|
||||
+------------------------------------------------------+------------------------------------------------------+------------------------------------------------------+
|
||||
| c16 | lower(c16) | upper(c16) |
|
||||
+------------------------------------------------------+------------------------------------------------------+------------------------------------------------------+
|
||||
| NULL | NULL | NULL |
|
||||
| | | |
|
||||
| 16abcDeFG00 | 16abcdefg00 | 16ABCDEFG00 |
|
||||
| =[]-+,/;<>?.*~!@#$%^&*() | =[]-+,/;<>?.*~!@#$%^&*() | =[]-+,/;<>?.*~!@#$%^&*() |
|
||||
| abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ | abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz | ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ |
|
||||
+------------------------------------------------------+------------------------------------------------------+------------------------------------------------------+
|
||||
select c17, lower(c17), upper(c17) from t1;
|
||||
+------------------------------------------------------+------------------------------------------------------+------------------------------------------------------+
|
||||
| c17 | lower(c17) | upper(c17) |
|
||||
+------------------------------------------------------+------------------------------------------------------+------------------------------------------------------+
|
||||
| NULL | NULL | NULL |
|
||||
| | | |
|
||||
| 16abcDeFG00 | 16abcdefg00 | 16ABCDEFG00 |
|
||||
| =[]-+,/;<>?.*~!@#$%^&*() | =[]-+,/;<>?.*~!@#$%^&*() | =[]-+,/;<>?.*~!@#$%^&*() |
|
||||
| abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ | abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz | ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ |
|
||||
+------------------------------------------------------+------------------------------------------------------+------------------------------------------------------+
|
||||
|
||||
drop table t1;
|
||||
@ -0,0 +1,146 @@
|
||||
result_format: 4
|
||||
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 int, c2 int);
|
||||
drop table if exists t2;
|
||||
create table t2 (c1 int auto_increment primary key, c2 int);
|
||||
drop table if exists t3;
|
||||
create table t3 (c1 int unsigned auto_increment primary key, c2 int);
|
||||
drop table if exists t4;
|
||||
create table t4 (c1 float auto_increment primary key, c2 int);
|
||||
drop table if exists t5;
|
||||
create table t5 (c1 double auto_increment primary key, c2 int);
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
insert into t1 (c1, c2) values (1, 1);
|
||||
insert into t1 (c1, c2) values (1, 1);
|
||||
select * from t1;
|
||||
+------+------+
|
||||
| c1 | c2 |
|
||||
+------+------+
|
||||
| 1 | 1 |
|
||||
| 1 | 1 |
|
||||
+------+------+
|
||||
|
||||
explain insert into t2 (c1, c2) values ('0', '1');
|
||||
Query Plan
|
||||
====================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
------------------------------------
|
||||
|0 |INSERT | |1 |1 |
|
||||
|1 | EXPRESSION| |1 |1 |
|
||||
====================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([column_conv(INT,PS:(11,0),NOT NULL,nextval(16, column_conv(INT,PS:(11,0),NOT NULL,__values.c1)))], [column_conv(INT,PS:(11,0),NULL,__values.c2)]), filter(nil),
|
||||
columns([{t2: ({t2: (t2.c1, t2.c2)})}]), partitions(p0)
|
||||
1 - output([__values.c1], [__values.c2]), filter(nil)
|
||||
values({'0', '1'})
|
||||
|
||||
|
||||
insert into t2 (c1, c2) values (NULL, '1');
|
||||
insert into t2 (c1, c2) values (0, '2');
|
||||
insert into t2 (c2) values ('3');
|
||||
insert into t2 (c1, c2) values (-5, '4');
|
||||
insert into t2 (c1, c2) values (10, '5');
|
||||
insert into t2 (c1, c2) values (0, '6');
|
||||
insert into t2 (c1, c2) values ('0', '7');
|
||||
insert into t2 (c1, c2) values ('-10', '8');
|
||||
insert into t2 (c1, c2) values (-12.1, '9');
|
||||
insert into t2 (c1, c2) values (-13.9, '10');
|
||||
insert into t2 (c1, c2) values ('abc', '11');
|
||||
ERROR HY000: Incorrect integer value
|
||||
insert into t2 (c1, c2) values (0.0, '12');
|
||||
select * from t2;
|
||||
+---------+------+
|
||||
| c1 | c2 |
|
||||
+---------+------+
|
||||
| -14 | 10 |
|
||||
| -12 | 9 |
|
||||
| -10 | 8 |
|
||||
| -5 | 4 |
|
||||
| 1 | 1 |
|
||||
| 2 | 2 |
|
||||
| 3 | 3 |
|
||||
| 10 | 5 |
|
||||
| 1000011 | 6 |
|
||||
| 1000012 | 7 |
|
||||
| 1000013 | 12 |
|
||||
+---------+------+
|
||||
|
||||
insert into t3 (c1, c2) values (NULL, '1');
|
||||
insert into t3 (c1, c2) values (-1, '2');
|
||||
ERROR 22003: Out of range value for column
|
||||
insert into t3 (c1, c2) values (0, '3');
|
||||
insert into t3 (c1, c2) values (10, '4');
|
||||
insert into t3 (c1, c2) values (0, '5');
|
||||
select * from t3;
|
||||
+---------+------+
|
||||
| c1 | c2 |
|
||||
+---------+------+
|
||||
| 1 | 1 |
|
||||
| 2 | 3 |
|
||||
| 10 | 4 |
|
||||
| 1000011 | 5 |
|
||||
+---------+------+
|
||||
|
||||
insert into t4 (c1, c2) values (NULL, '1');
|
||||
insert into t4 (c1, c2) values (0, '2');
|
||||
insert into t4 (c1, c2) values ('0', '3');
|
||||
insert into t4 (c1, c2) values (0.0, '4');
|
||||
insert into t4 (c1, c2) values (-10.12, '5');
|
||||
insert into t4 (c1, c2) values (0, '6');
|
||||
insert into t4 (c1, c2) values (10.5, '7');
|
||||
insert into t4 (c1, c2) values (0, '8');
|
||||
select * from t4;
|
||||
+--------+------+
|
||||
| c1 | c2 |
|
||||
+--------+------+
|
||||
| -10.12 | 5 |
|
||||
| 1 | 1 |
|
||||
| 2 | 2 |
|
||||
| 3 | 3 |
|
||||
| 4 | 4 |
|
||||
| 5 | 6 |
|
||||
| 10.5 | 7 |
|
||||
| 167784 | 8 |
|
||||
+--------+------+
|
||||
|
||||
insert into t5 (c1, c2) values (NULL, '1');
|
||||
insert into t5 (c1, c2) values (0, '2');
|
||||
insert into t5 (c1, c2) values ('0', '3');
|
||||
insert into t5 (c1, c2) values (0.0, '4');
|
||||
insert into t5 (c1, c2) values (-10.12, '5');
|
||||
insert into t5 (c1, c2) values (0, '6');
|
||||
insert into t5 (c1, c2) values (10.5, '7');
|
||||
insert into t5 (c1, c2) values (0, '8');
|
||||
select * from t5;
|
||||
+---------+------+
|
||||
| c1 | c2 |
|
||||
+---------+------+
|
||||
| -10.12 | 5 |
|
||||
| 1 | 1 |
|
||||
| 2 | 2 |
|
||||
| 3 | 3 |
|
||||
| 4 | 4 |
|
||||
| 5 | 6 |
|
||||
| 10.5 | 7 |
|
||||
| 1000012 | 8 |
|
||||
+---------+------+
|
||||
|
||||
set sql_mode = '';
|
||||
insert into t3 (c1, c2) values ("abc", '6');
|
||||
select * from t3;
|
||||
+---------+------+
|
||||
| c1 | c2 |
|
||||
+---------+------+
|
||||
| 1 | 1 |
|
||||
| 2 | 3 |
|
||||
| 10 | 4 |
|
||||
| 1000011 | 5 |
|
||||
| 1000012 | 6 |
|
||||
+---------+------+
|
||||
|
||||
@ -0,0 +1,277 @@
|
||||
result_format: 4
|
||||
|
||||
alter system flush plan cache global;
|
||||
|
||||
|
||||
drop table if exists t;
|
||||
create table t (t1 tinyint,
|
||||
t2 smallint,
|
||||
t3 mediumint,
|
||||
t4 integer,
|
||||
t5 bigint,
|
||||
t6 tinyint unsigned,
|
||||
t7 smallint unsigned,
|
||||
t8 mediumint unsigned,
|
||||
t9 integer unsigned,
|
||||
t10 bigint unsigned,
|
||||
t11 float,
|
||||
t12 float unsigned,
|
||||
t13 double,
|
||||
t14 double unsigned,
|
||||
t15 number,
|
||||
t16 number unsigned,
|
||||
t17 datetime,
|
||||
t18 timestamp,
|
||||
t19 date,
|
||||
t20 time,
|
||||
t21 year,
|
||||
t22 varchar(255),
|
||||
t23 char(255),
|
||||
t24 tinytext,
|
||||
t25 mediumtext,
|
||||
t26 longtext,
|
||||
t27 bit,
|
||||
t28 enum('a', 'b', 'c'),
|
||||
t29 set('a', 'b', 'c'));
|
||||
|
||||
insert into t values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7,
|
||||
'1993-03-20', '1993-03-20', '1993-03-20', '10:10:10', '1993', '0.8', '0.9', '1.0', '1.1',
|
||||
'1.2', 1, 'b', 'b');
|
||||
insert into t(t1) values (null);
|
||||
|
||||
|
||||
alter system flush plan cache global;
|
||||
|
||||
|
||||
set ob_enable_plan_cache = false;
|
||||
select not 1 from dual;
|
||||
+-------+
|
||||
| not 1 |
|
||||
+-------+
|
||||
| 0 |
|
||||
+-------+
|
||||
select not 1.0 from dual;
|
||||
+---------+
|
||||
| not 1.0 |
|
||||
+---------+
|
||||
| 0 |
|
||||
+---------+
|
||||
select not null from dual;
|
||||
+----------+
|
||||
| not null |
|
||||
+----------+
|
||||
| NULL |
|
||||
+----------+
|
||||
select not 'hello' from dual;
|
||||
+-------------+
|
||||
| not 'hello' |
|
||||
+-------------+
|
||||
| 1 |
|
||||
+-------------+
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'hello'
|
||||
|
||||
select not t1 from t;
|
||||
+--------+
|
||||
| not t1 |
|
||||
+--------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+--------+
|
||||
select not t2 from t;
|
||||
+--------+
|
||||
| not t2 |
|
||||
+--------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+--------+
|
||||
select not t3 from t;
|
||||
+--------+
|
||||
| not t3 |
|
||||
+--------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+--------+
|
||||
select not t4 from t;
|
||||
+--------+
|
||||
| not t4 |
|
||||
+--------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+--------+
|
||||
select not t5 from t;
|
||||
+--------+
|
||||
| not t5 |
|
||||
+--------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+--------+
|
||||
select not t6 from t;
|
||||
+--------+
|
||||
| not t6 |
|
||||
+--------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+--------+
|
||||
select not t7 from t;
|
||||
+--------+
|
||||
| not t7 |
|
||||
+--------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+--------+
|
||||
select not t8 from t;
|
||||
+--------+
|
||||
| not t8 |
|
||||
+--------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+--------+
|
||||
select not t9 from t;
|
||||
+--------+
|
||||
| not t9 |
|
||||
+--------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+--------+
|
||||
select not t10 from t;
|
||||
+---------+
|
||||
| not t10 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t11 from t;
|
||||
+---------+
|
||||
| not t11 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t12 from t;
|
||||
+---------+
|
||||
| not t12 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t13 from t;
|
||||
+---------+
|
||||
| not t13 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t14 from t;
|
||||
+---------+
|
||||
| not t14 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t15 from t;
|
||||
+---------+
|
||||
| not t15 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t16 from t;
|
||||
+---------+
|
||||
| not t16 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t17 from t;
|
||||
+---------+
|
||||
| not t17 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t18 from t;
|
||||
+---------+
|
||||
| not t18 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t19 from t;
|
||||
+---------+
|
||||
| not t19 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t20 from t;
|
||||
+---------+
|
||||
| not t20 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t21 from t;
|
||||
+---------+
|
||||
| not t21 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t22 from t;
|
||||
+---------+
|
||||
| not t22 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t23 from t;
|
||||
+---------+
|
||||
| not t23 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t24 from t;
|
||||
+---------+
|
||||
| not t24 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t25 from t;
|
||||
+---------+
|
||||
| not t25 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t26 from t;
|
||||
+---------+
|
||||
| not t26 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t27 from t;
|
||||
+---------+
|
||||
| not t27 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t28 from t;
|
||||
+---------+
|
||||
| not t28 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
select not t29 from t;
|
||||
+---------+
|
||||
| not t29 |
|
||||
+---------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
+---------+
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
19935
tools/deploy/mysql_test/test_suite/static_engine/r/mysql/expr_nvl.result
Normal file
19935
tools/deploy/mysql_test/test_suite/static_engine/r/mysql/expr_nvl.result
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,39 @@
|
||||
result_format: 4
|
||||
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 int, c2 bigint, c3 decimal);
|
||||
insert into t1 (c1, c2, c3) values (1, NULL, 1);
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select c1, partition_hash(c1) from t1;
|
||||
+------+--------------------+
|
||||
| c1 | partition_hash(c1) |
|
||||
+------+--------------------+
|
||||
| 1 | 1 |
|
||||
+------+--------------------+
|
||||
select c2, partition_hash(c2) from t1;
|
||||
+------+--------------------+
|
||||
| c2 | partition_hash(c2) |
|
||||
+------+--------------------+
|
||||
| NULL | 0 |
|
||||
+------+--------------------+
|
||||
select c3, partition_hash(c3) from t1;
|
||||
ERROR HY000: The PARTITION function returns the wrong type
|
||||
select partition_hash(c1, c2) from t1;
|
||||
ERROR HY000: Internal error
|
||||
|
||||
select partition_hash(10) from t1;
|
||||
+--------------------+
|
||||
| partition_hash(10) |
|
||||
+--------------------+
|
||||
| 10 |
|
||||
+--------------------+
|
||||
select partition_hash(-10) from t1;
|
||||
+---------------------+
|
||||
| partition_hash(-10) |
|
||||
+---------------------+
|
||||
| 10 |
|
||||
+---------------------+
|
||||
|
||||
@ -0,0 +1,145 @@
|
||||
result_format: 4
|
||||
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 int, c2 bigint, c3 decimal, c4 char(20), c5 varchar(20), c6 date, c7 datetime, c8 timestamp);
|
||||
insert into t1 (c1, c2, c3, c4, c5, c6, c7, c8) values (1, NULL, 1, "abc ", "abc ", '2020-01-01', '2020-01-01 01:01:01', '2020-01-01 01:01:01');
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select c1, partition_key(c1) from t1;
|
||||
+------+--------------------+
|
||||
| c1 | partition_key(c1) |
|
||||
+------+--------------------+
|
||||
| 1 | 294837134935570197 |
|
||||
+------+--------------------+
|
||||
select c2, partition_key(c2) from t1;
|
||||
+------+---------------------+
|
||||
| c2 | partition_key(c2) |
|
||||
+------+---------------------+
|
||||
| NULL | 6960269033020761575 |
|
||||
+------+---------------------+
|
||||
select c3, partition_key(c3) from t1;
|
||||
+------+---------------------+
|
||||
| c3 | partition_key(c3) |
|
||||
+------+---------------------+
|
||||
| 1 | 4095890315155992887 |
|
||||
+------+---------------------+
|
||||
select c4, partition_key(c4) from t1;
|
||||
+------+---------------------+
|
||||
| c4 | partition_key(c4) |
|
||||
+------+---------------------+
|
||||
| abc | 1801346201538688951 |
|
||||
+------+---------------------+
|
||||
select c5, partition_key(c5) from t1;
|
||||
+-----------+---------------------+
|
||||
| c5 | partition_key(c5) |
|
||||
+-----------+---------------------+
|
||||
| abc | 1801346201538688951 |
|
||||
+-----------+---------------------+
|
||||
select c6, partition_key(c6) from t1;
|
||||
+------------+---------------------+
|
||||
| c6 | partition_key(c6) |
|
||||
+------------+---------------------+
|
||||
| 2020-01-01 | 3780289746228831367 |
|
||||
+------------+---------------------+
|
||||
select c7, partition_key(c7) from t1;
|
||||
+---------------------+---------------------+
|
||||
| c7 | partition_key(c7) |
|
||||
+---------------------+---------------------+
|
||||
| 2020-01-01 01:01:01 | 6488855144877179734 |
|
||||
+---------------------+---------------------+
|
||||
select c8, partition_key(c8) from t1;
|
||||
+---------------------+---------------------+
|
||||
| c8 | partition_key(c8) |
|
||||
+---------------------+---------------------+
|
||||
| 2020-01-01 01:01:01 | 6375794890780556234 |
|
||||
+---------------------+---------------------+
|
||||
|
||||
select partition_key(c1, c2) from t1;
|
||||
+-----------------------+
|
||||
| partition_key(c1, c2) |
|
||||
+-----------------------+
|
||||
| 319562542098195289 |
|
||||
+-----------------------+
|
||||
select partition_key(c1, c2, c3) from t1;
|
||||
+---------------------------+
|
||||
| partition_key(c1, c2, c3) |
|
||||
+---------------------------+
|
||||
| 3093204954362125526 |
|
||||
+---------------------------+
|
||||
select partition_key(c1, c3) from t1;
|
||||
+-----------------------+
|
||||
| partition_key(c1, c3) |
|
||||
+-----------------------+
|
||||
| 9006715823204485749 |
|
||||
+-----------------------+
|
||||
|
||||
select c1, partition_key_v2(c1) from t1;
|
||||
+------+----------------------+
|
||||
| c1 | partition_key_v2(c1) |
|
||||
+------+----------------------+
|
||||
| 1 | 8089716718896805586 |
|
||||
+------+----------------------+
|
||||
select c2, partition_key_v2(c2) from t1;
|
||||
+------+----------------------+
|
||||
| c2 | partition_key_v2(c2) |
|
||||
+------+----------------------+
|
||||
| NULL | 6960269033020761575 |
|
||||
+------+----------------------+
|
||||
select c3, partition_key_v2(c3) from t1;
|
||||
+------+----------------------+
|
||||
| c3 | partition_key_v2(c3) |
|
||||
+------+----------------------+
|
||||
| 1 | 5958971315933813165 |
|
||||
+------+----------------------+
|
||||
select c4, partition_key_v2(c4) from t1;
|
||||
+------+----------------------+
|
||||
| c4 | partition_key_v2(c4) |
|
||||
+------+----------------------+
|
||||
| abc | 258901174748407223 |
|
||||
+------+----------------------+
|
||||
select c5, partition_key_v2(c5) from t1;
|
||||
+-----------+----------------------+
|
||||
| c5 | partition_key_v2(c5) |
|
||||
+-----------+----------------------+
|
||||
| abc | 258901174748407223 |
|
||||
+-----------+----------------------+
|
||||
select c6, partition_key_v2(c6) from t1;
|
||||
+------------+----------------------+
|
||||
| c6 | partition_key_v2(c6) |
|
||||
+------------+----------------------+
|
||||
| 2020-01-01 | 5558489265225801925 |
|
||||
+------------+----------------------+
|
||||
select c7, partition_key_v2(c7) from t1;
|
||||
+---------------------+----------------------+
|
||||
| c7 | partition_key_v2(c7) |
|
||||
+---------------------+----------------------+
|
||||
| 2020-01-01 01:01:01 | 3406840642020255355 |
|
||||
+---------------------+----------------------+
|
||||
select c8, partition_key_v2(c8) from t1;
|
||||
+---------------------+----------------------+
|
||||
| c8 | partition_key_v2(c8) |
|
||||
+---------------------+----------------------+
|
||||
| 2020-01-01 01:01:01 | 8121525409574338685 |
|
||||
+---------------------+----------------------+
|
||||
|
||||
select partition_key_v2(c1, c2) from t1;
|
||||
+--------------------------+
|
||||
| partition_key_v2(c1, c2) |
|
||||
+--------------------------+
|
||||
| 3042015303219230768 |
|
||||
+--------------------------+
|
||||
select partition_key_v2(c1, c2, c3) from t1;
|
||||
+------------------------------+
|
||||
| partition_key_v2(c1, c2, c3) |
|
||||
+------------------------------+
|
||||
| 2899520937750054785 |
|
||||
+------------------------------+
|
||||
select partition_key_v2(c1, c3) from t1;
|
||||
+--------------------------+
|
||||
| partition_key_v2(c1, c3) |
|
||||
+--------------------------+
|
||||
| 4685265492491719863 |
|
||||
+--------------------------+
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
result_format: 4
|
||||
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 varchar(50), c2 varchar(50));
|
||||
insert into t1 (c1, c2) values ('abc1', '^abc[0-9]?$');
|
||||
insert into t1 (c1, c2) values ('abc1', '^abd');
|
||||
|
||||
drop table if exists t2;
|
||||
create table t2 (a varchar(50));
|
||||
insert into t2 values ("abc1");
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select 'abcdef' regexp '^abc.*';
|
||||
+--------------------------+
|
||||
| 'abcdef' regexp '^abc.*' |
|
||||
+--------------------------+
|
||||
| 1 |
|
||||
+--------------------------+
|
||||
select 'abcdef' regexp '^abd.*';
|
||||
+--------------------------+
|
||||
| 'abcdef' regexp '^abd.*' |
|
||||
+--------------------------+
|
||||
| 0 |
|
||||
+--------------------------+
|
||||
|
||||
select '' regexp '^$';
|
||||
+----------------+
|
||||
| '' regexp '^$' |
|
||||
+----------------+
|
||||
| 1 |
|
||||
+----------------+
|
||||
select 'a' regexp '';
|
||||
ERROR 42000: Got error 'empty (sub)expression' from regexp
|
||||
select NULL regexp 'a';
|
||||
+-----------------+
|
||||
| NULL regexp 'a' |
|
||||
+-----------------+
|
||||
| NULL |
|
||||
+-----------------+
|
||||
select 'a' regexp NULL;
|
||||
+-----------------+
|
||||
| 'a' regexp NULL |
|
||||
+-----------------+
|
||||
| NULL |
|
||||
+-----------------+
|
||||
|
||||
select c2, c2 regexp 'abc' from t1;
|
||||
+-------------+-----------------+
|
||||
| c2 | c2 regexp 'abc' |
|
||||
+-------------+-----------------+
|
||||
| ^abc[0-9]?$ | 1 |
|
||||
| ^abd | 0 |
|
||||
+-------------+-----------------+
|
||||
select c2, (select a regexp c2 from t2) from t1;
|
||||
+-------------+------------------------------+
|
||||
| c2 | (select a regexp c2 from t2) |
|
||||
+-------------+------------------------------+
|
||||
| ^abc[0-9]?$ | 1 |
|
||||
| ^abd | 0 |
|
||||
+-------------+------------------------------+
|
||||
select c1, c2, c1 regexp c2 from t1;
|
||||
+------+-------------+--------------+
|
||||
| c1 | c2 | c1 regexp c2 |
|
||||
+------+-------------+--------------+
|
||||
| abc1 | ^abc[0-9]?$ | 1 |
|
||||
| abc1 | ^abd | 0 |
|
||||
+------+-------------+--------------+
|
||||
|
||||
@ -0,0 +1,285 @@
|
||||
result_format: 4
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select regexp_like('abc', 'a.*') from dual;
|
||||
+---------------------------+
|
||||
| regexp_like('abc', 'a.*') |
|
||||
+---------------------------+
|
||||
| 1 |
|
||||
+---------------------------+
|
||||
select regexp_like('abc', 'a.* ') from dual;
|
||||
+----------------------------+
|
||||
| regexp_like('abc', 'a.* ') |
|
||||
+----------------------------+
|
||||
| 0 |
|
||||
+----------------------------+
|
||||
select regexp_like('abc', 'a.* ', NULL) from dual;
|
||||
+----------------------------------+
|
||||
| regexp_like('abc', 'a.* ', NULL) |
|
||||
+----------------------------------+
|
||||
| NULL |
|
||||
+----------------------------------+
|
||||
select regexp_like('abc', 'a.* ', 'x') from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_like('abc', NULL) from dual;
|
||||
+--------------------------+
|
||||
| regexp_like('abc', NULL) |
|
||||
+--------------------------+
|
||||
| NULL |
|
||||
+--------------------------+
|
||||
select regexp_like(NULL, 'a.*') from dual;
|
||||
+--------------------------+
|
||||
| regexp_like(NULL, 'a.*') |
|
||||
+--------------------------+
|
||||
| NULL |
|
||||
+--------------------------+
|
||||
|
||||
select regexp_like(123, 123) from dual;
|
||||
+-----------------------+
|
||||
| regexp_like(123, 123) |
|
||||
+-----------------------+
|
||||
| 1 |
|
||||
+-----------------------+
|
||||
select regexp_like('我是好人', '.是.*') from dual;
|
||||
+---------------------------------------+
|
||||
| regexp_like('我是好人', '.是.*') |
|
||||
+---------------------------------------+
|
||||
| 1 |
|
||||
+---------------------------------------+
|
||||
|
||||
select regexp_instr('abcadef', 'a.') from dual;
|
||||
+-------------------------------+
|
||||
| regexp_instr('abcadef', 'a.') |
|
||||
+-------------------------------+
|
||||
| 1 |
|
||||
+-------------------------------+
|
||||
select regexp_instr('abcadef', 'a.', 1, 2) from dual;
|
||||
+-------------------------------------+
|
||||
| regexp_instr('abcadef', 'a.', 1, 2) |
|
||||
+-------------------------------------+
|
||||
| 4 |
|
||||
+-------------------------------------+
|
||||
select regexp_instr('abcadef', 'a.', 1, 2, 0) from dual;
|
||||
+----------------------------------------+
|
||||
| regexp_instr('abcadef', 'a.', 1, 2, 0) |
|
||||
+----------------------------------------+
|
||||
| 4 |
|
||||
+----------------------------------------+
|
||||
select regexp_instr('abcadef', 'a.', 1, 2, 1) from dual;
|
||||
+----------------------------------------+
|
||||
| regexp_instr('abcadef', 'a.', 1, 2, 1) |
|
||||
+----------------------------------------+
|
||||
| 6 |
|
||||
+----------------------------------------+
|
||||
select regexp_instr('abcadef', 'a.', 0, 2, 1) from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_instr('abcadef', 'a.', 1, 0, 1) from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_instr('abcadef', 'a.', 1, 2, -1) from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_instr('abcadef', 'a.', 100, 2) from dual;
|
||||
+---------------------------------------+
|
||||
| regexp_instr('abcadef', 'a.', 100, 2) |
|
||||
+---------------------------------------+
|
||||
| 0 |
|
||||
+---------------------------------------+
|
||||
select regexp_instr('abcadef', 'a.', 1, 200) from dual;
|
||||
+---------------------------------------+
|
||||
| regexp_instr('abcadef', 'a.', 1, 200) |
|
||||
+---------------------------------------+
|
||||
| 0 |
|
||||
+---------------------------------------+
|
||||
select regexp_instr('abcadef', 'a. ', 1, 2, 1, 'x') from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_instr('', 'a. ', 1, 2, 1, 'x') from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_instr('abcadef', '', 1, 2, 1, 'x') from dual;
|
||||
ERROR 42000: Got error 'empty (sub)expression' from regexp
|
||||
select regexp_instr('abcadef', 'a. ', NULL, 2, 1, 'x') from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_instr('abcadef', 'a. ', 1, NULL, 1, 'x') from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_instr('abcadef', 'a. ', 1, 2, NULL, 'x') from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_instr('abcadef', 'a. ', 1, 2, 1, NULL) from dual;
|
||||
+-----------------------------------------------+
|
||||
| regexp_instr('abcadef', 'a. ', 1, 2, 1, NULL) |
|
||||
+-----------------------------------------------+
|
||||
| NULL |
|
||||
+-----------------------------------------------+
|
||||
|
||||
select regexp_instr(12341834, 1.3, '1', '2', 1) from dual;
|
||||
+------------------------------------------+
|
||||
| regexp_instr(12341834, 1.3, '1', '2', 1) |
|
||||
+------------------------------------------+
|
||||
| 8 |
|
||||
+------------------------------------------+
|
||||
select regexp_instr('我是好人', '是.') from dual;
|
||||
+--------------------------------------+
|
||||
| regexp_instr('我是好人', '是.') |
|
||||
+--------------------------------------+
|
||||
| 2 |
|
||||
+--------------------------------------+
|
||||
|
||||
select regexp_substr('abcadef', 'a.', 1) from dual;
|
||||
+-----------------------------------+
|
||||
| regexp_substr('abcadef', 'a.', 1) |
|
||||
+-----------------------------------+
|
||||
| ab |
|
||||
+-----------------------------------+
|
||||
select regexp_substr('abcadef', 'a.', 1, 2) from dual;
|
||||
+--------------------------------------+
|
||||
| regexp_substr('abcadef', 'a.', 1, 2) |
|
||||
+--------------------------------------+
|
||||
| ad |
|
||||
+--------------------------------------+
|
||||
select regexp_substr('abcadef', 'a.', 0, 2) from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_substr('abcadef', 'a.', 1, 0) from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_substr('abcadef', 'a.', 10, 2) from dual;
|
||||
+---------------------------------------+
|
||||
| regexp_substr('abcadef', 'a.', 10, 2) |
|
||||
+---------------------------------------+
|
||||
| NULL |
|
||||
+---------------------------------------+
|
||||
select regexp_substr('abcadef', 'a.', 1, 10) from dual;
|
||||
+---------------------------------------+
|
||||
| regexp_substr('abcadef', 'a.', 1, 10) |
|
||||
+---------------------------------------+
|
||||
| NULL |
|
||||
+---------------------------------------+
|
||||
select regexp_substr('abcadef', 'a. ', 1, 2, 'x') from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_substr('', 'a. ', 1, 2, 'x') from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_substr('abcadef', '', 1, 2, 'x') from dual;
|
||||
ERROR 42000: Got error 'empty (sub)expression' from regexp
|
||||
select regexp_substr('abcadef', 'a. ', NULL, 2, 'x') from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_substr('abcadef', 'a. ', 1, NULL, 'x') from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_substr('abcadef', 'a. ', 1, 2, NULL) from dual;
|
||||
+---------------------------------------------+
|
||||
| regexp_substr('abcadef', 'a. ', 1, 2, NULL) |
|
||||
+---------------------------------------------+
|
||||
| NULL |
|
||||
+---------------------------------------------+
|
||||
|
||||
select regexp_substr(12341834, 1.3, '1.9', '2') from dual;
|
||||
+------------------------------------------+
|
||||
| regexp_substr(12341834, 1.3, '1.9', '2') |
|
||||
+------------------------------------------+
|
||||
| 183 |
|
||||
+------------------------------------------+
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: '1.9'
|
||||
select regexp_replace('我是好人', '是.') from dual;
|
||||
+----------------------------------------+
|
||||
| regexp_replace('我是好人', '是.') |
|
||||
+----------------------------------------+
|
||||
| 我人 |
|
||||
+----------------------------------------+
|
||||
|
||||
select regexp_replace('abcadef', 'a.') from dual;
|
||||
+---------------------------------+
|
||||
| regexp_replace('abcadef', 'a.') |
|
||||
+---------------------------------+
|
||||
| cef |
|
||||
+---------------------------------+
|
||||
select regexp_replace('abcadef', 'a.*') from dual;
|
||||
+----------------------------------+
|
||||
| regexp_replace('abcadef', 'a.*') |
|
||||
+----------------------------------+
|
||||
| |
|
||||
+----------------------------------+
|
||||
select regexp_replace('abcadef', 'a.', 'X') from dual;
|
||||
+--------------------------------------+
|
||||
| regexp_replace('abcadef', 'a.', 'X') |
|
||||
+--------------------------------------+
|
||||
| XcXef |
|
||||
+--------------------------------------+
|
||||
select regexp_replace('abcadef', 'a.', 'X', 1) from dual;
|
||||
+-----------------------------------------+
|
||||
| regexp_replace('abcadef', 'a.', 'X', 1) |
|
||||
+-----------------------------------------+
|
||||
| XcXef |
|
||||
+-----------------------------------------+
|
||||
select regexp_replace('abcadef', 'a.', 'X', 1, 2) from dual;
|
||||
+--------------------------------------------+
|
||||
| regexp_replace('abcadef', 'a.', 'X', 1, 2) |
|
||||
+--------------------------------------------+
|
||||
| abcXef |
|
||||
+--------------------------------------------+
|
||||
select regexp_replace('abcadef', 'a.', 'X', 2, 1) from dual;
|
||||
+--------------------------------------------+
|
||||
| regexp_replace('abcadef', 'a.', 'X', 2, 1) |
|
||||
+--------------------------------------------+
|
||||
| abcXef |
|
||||
+--------------------------------------------+
|
||||
select regexp_replace('abcadef', 'a.', 'X', 2, 2) from dual;
|
||||
+--------------------------------------------+
|
||||
| regexp_replace('abcadef', 'a.', 'X', 2, 2) |
|
||||
+--------------------------------------------+
|
||||
| abcadef |
|
||||
+--------------------------------------------+
|
||||
select regexp_replace('abcadef', 'a.', 'X', 1, 0) from dual;
|
||||
+--------------------------------------------+
|
||||
| regexp_replace('abcadef', 'a.', 'X', 1, 0) |
|
||||
+--------------------------------------------+
|
||||
| XcXef |
|
||||
+--------------------------------------------+
|
||||
select regexp_replace('abcadef', 'a.', 'X', 1, -1) from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_replace('abcadef', 'a.', 'X', 10, 2) from dual;
|
||||
+---------------------------------------------+
|
||||
| regexp_replace('abcadef', 'a.', 'X', 10, 2) |
|
||||
+---------------------------------------------+
|
||||
| abcadef |
|
||||
+---------------------------------------------+
|
||||
select regexp_replace('abcadef', 'a.', 'X', 1, 100) from dual;
|
||||
+----------------------------------------------+
|
||||
| regexp_replace('abcadef', 'a.', 'X', 1, 100) |
|
||||
+----------------------------------------------+
|
||||
| abcadef |
|
||||
+----------------------------------------------+
|
||||
select regexp_replace('abcadef', 'a. ', 'X', 1, 2) from dual;
|
||||
+---------------------------------------------+
|
||||
| regexp_replace('abcadef', 'a. ', 'X', 1, 2) |
|
||||
+---------------------------------------------+
|
||||
| abcadef |
|
||||
+---------------------------------------------+
|
||||
select regexp_replace('abcadef', 'a. ', 'X', 1, 2, 'x') from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_replace('', 'a. ', 'X', 1, 2, 'x') from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_replace('abcadef', '', 'X', 1, 2, 'x') from dual;
|
||||
ERROR 42000: Got error 'empty (sub)expression' from regexp
|
||||
select regexp_replace('abcadef', 'a. ', NULL, 1, 2, 'x') from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_replace('abcadef', 'a. ', 'X', NULL, 2, 'x') from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_replace('abcadef', 'a. ', 'X', 1, NULL, 'x') from dual;
|
||||
ERROR HY000: Invalid argument
|
||||
select regexp_replace('abcadef', 'a. ', 'X', 1, 2, NULL) from dual;
|
||||
+---------------------------------------------------+
|
||||
| regexp_replace('abcadef', 'a. ', 'X', 1, 2, NULL) |
|
||||
+---------------------------------------------------+
|
||||
| NULL |
|
||||
+---------------------------------------------------+
|
||||
|
||||
select regexp_replace(12341834, 1.3, 99, '1', '2') from dual;
|
||||
+---------------------------------------------+
|
||||
| regexp_replace(12341834, 1.3, 99, '1', '2') |
|
||||
+---------------------------------------------+
|
||||
| 1234994 |
|
||||
+---------------------------------------------+
|
||||
select regexp_replace('我是好人', '是.', '.....') from dual;
|
||||
+-------------------------------------------------+
|
||||
| regexp_replace('我是好人', '是.', '.....') |
|
||||
+-------------------------------------------------+
|
||||
| 我.....人 |
|
||||
+-------------------------------------------------+
|
||||
|
||||
@ -0,0 +1,88 @@
|
||||
result_format: 4
|
||||
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select repeat("abc", -1);
|
||||
+-------------------+
|
||||
| repeat("abc", -1) |
|
||||
+-------------------+
|
||||
| |
|
||||
+-------------------+
|
||||
select repeat("abc", 0);
|
||||
+------------------+
|
||||
| repeat("abc", 0) |
|
||||
+------------------+
|
||||
| |
|
||||
+------------------+
|
||||
select repeat("abc", 1);
|
||||
+------------------+
|
||||
| repeat("abc", 1) |
|
||||
+------------------+
|
||||
| abc |
|
||||
+------------------+
|
||||
select repeat("abc", 2);
|
||||
+------------------+
|
||||
| repeat("abc", 2) |
|
||||
+------------------+
|
||||
| abcabc |
|
||||
+------------------+
|
||||
select repeat("abc", 3);
|
||||
+------------------+
|
||||
| repeat("abc", 3) |
|
||||
+------------------+
|
||||
| abcabcabc |
|
||||
+------------------+
|
||||
|
||||
select repeat("abc", "2.1");
|
||||
+----------------------+
|
||||
| repeat("abc", "2.1") |
|
||||
+----------------------+
|
||||
| abcabc |
|
||||
+----------------------+
|
||||
select repeat("abc", "2.9");
|
||||
+----------------------+
|
||||
| repeat("abc", "2.9") |
|
||||
+----------------------+
|
||||
| abcabc |
|
||||
+----------------------+
|
||||
|
||||
select repeat("", 2);
|
||||
+---------------+
|
||||
| repeat("", 2) |
|
||||
+---------------+
|
||||
| |
|
||||
+---------------+
|
||||
select repeat(NULL, 2);
|
||||
+-----------------+
|
||||
| repeat(NULL, 2) |
|
||||
+-----------------+
|
||||
| NULL |
|
||||
+-----------------+
|
||||
select repeat("abc", NULL);
|
||||
+---------------------+
|
||||
| repeat("abc", NULL) |
|
||||
+---------------------+
|
||||
| NULL |
|
||||
+---------------------+
|
||||
select repeat(1.414, 1);
|
||||
+------------------+
|
||||
| repeat(1.414, 1) |
|
||||
+------------------+
|
||||
| 1.414 |
|
||||
+------------------+
|
||||
select repeat(1.414, 2);
|
||||
+------------------+
|
||||
| repeat(1.414, 2) |
|
||||
+------------------+
|
||||
| 1.4141.414 |
|
||||
+------------------+
|
||||
|
||||
select repeat("abc", 200000000);
|
||||
+--------------------------+
|
||||
| repeat("abc", 200000000) |
|
||||
+--------------------------+
|
||||
| NULL |
|
||||
+--------------------------+
|
||||
|
||||
@ -0,0 +1,58 @@
|
||||
result_format: 4
|
||||
|
||||
drop table if exists t1;
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select replace('abcdbf', 'b', 'cc');
|
||||
+------------------------------+
|
||||
| replace('abcdbf', 'b', 'cc') |
|
||||
+------------------------------+
|
||||
| acccdccf |
|
||||
+------------------------------+
|
||||
select replace('abcdbf', 'b');
|
||||
ERROR 42000: Incorrect parameter count in the call to native function 'replace'
|
||||
select replace('abcdbf', 'b', '');
|
||||
+----------------------------+
|
||||
| replace('abcdbf', 'b', '') |
|
||||
+----------------------------+
|
||||
| acdf |
|
||||
+----------------------------+
|
||||
select replace('abcdbf', '', 'cc');
|
||||
+-----------------------------+
|
||||
| replace('abcdbf', '', 'cc') |
|
||||
+-----------------------------+
|
||||
| abcdbf |
|
||||
+-----------------------------+
|
||||
select replace('', 'b', 'cc');
|
||||
+------------------------+
|
||||
| replace('', 'b', 'cc') |
|
||||
+------------------------+
|
||||
| |
|
||||
+------------------------+
|
||||
select replace(NULL, 'b', 'cc');
|
||||
+--------------------------+
|
||||
| replace(NULL, 'b', 'cc') |
|
||||
+--------------------------+
|
||||
| NULL |
|
||||
+--------------------------+
|
||||
select replace('abcdbf', NULL, 'cc');
|
||||
+-------------------------------+
|
||||
| replace('abcdbf', NULL, 'cc') |
|
||||
+-------------------------------+
|
||||
| NULL |
|
||||
+-------------------------------+
|
||||
select replace('abcdbf', 'b', NULL);
|
||||
+------------------------------+
|
||||
| replace('abcdbf', 'b', NULL) |
|
||||
+------------------------------+
|
||||
| NULL |
|
||||
+------------------------------+
|
||||
select replace('abc', 'abc', '');
|
||||
+---------------------------+
|
||||
| replace('abc', 'abc', '') |
|
||||
+---------------------------+
|
||||
| |
|
||||
+---------------------------+
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
11073
tools/deploy/mysql_test/test_suite/static_engine/r/mysql/expr_str.result
Normal file
11073
tools/deploy/mysql_test/test_suite/static_engine/r/mysql/expr_str.result
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,177 @@
|
||||
result_format: 4
|
||||
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select substr('abcdef', 0) from dual;
|
||||
+---------------------+
|
||||
| substr('abcdef', 0) |
|
||||
+---------------------+
|
||||
| |
|
||||
+---------------------+
|
||||
select substr('abcdef', -1) from dual;
|
||||
+----------------------+
|
||||
| substr('abcdef', -1) |
|
||||
+----------------------+
|
||||
| f |
|
||||
+----------------------+
|
||||
select substr('abcdef', 1) from dual;
|
||||
+---------------------+
|
||||
| substr('abcdef', 1) |
|
||||
+---------------------+
|
||||
| abcdef |
|
||||
+---------------------+
|
||||
select substr('abcdef', 2) from dual;
|
||||
+---------------------+
|
||||
| substr('abcdef', 2) |
|
||||
+---------------------+
|
||||
| bcdef |
|
||||
+---------------------+
|
||||
select substr('abcdef', 10) from dual;
|
||||
+----------------------+
|
||||
| substr('abcdef', 10) |
|
||||
+----------------------+
|
||||
| |
|
||||
+----------------------+
|
||||
select substr('', 1) from dual;
|
||||
+---------------+
|
||||
| substr('', 1) |
|
||||
+---------------+
|
||||
| |
|
||||
+---------------+
|
||||
select substr('abcdef', 10) from dual;
|
||||
+----------------------+
|
||||
| substr('abcdef', 10) |
|
||||
+----------------------+
|
||||
| |
|
||||
+----------------------+
|
||||
select substr('abcdef', 2, 1) from dual;
|
||||
+------------------------+
|
||||
| substr('abcdef', 2, 1) |
|
||||
+------------------------+
|
||||
| b |
|
||||
+------------------------+
|
||||
select substr('abcdef', 2, 2) from dual;
|
||||
+------------------------+
|
||||
| substr('abcdef', 2, 2) |
|
||||
+------------------------+
|
||||
| bc |
|
||||
+------------------------+
|
||||
select substr('abcdef', 2, 0) from dual;
|
||||
+------------------------+
|
||||
| substr('abcdef', 2, 0) |
|
||||
+------------------------+
|
||||
| |
|
||||
+------------------------+
|
||||
select substr('abcdef', 2, -1) from dual;
|
||||
+-------------------------+
|
||||
| substr('abcdef', 2, -1) |
|
||||
+-------------------------+
|
||||
| |
|
||||
+-------------------------+
|
||||
select substr('abcdef', 2, 100) from dual;
|
||||
+--------------------------+
|
||||
| substr('abcdef', 2, 100) |
|
||||
+--------------------------+
|
||||
| bcdef |
|
||||
+--------------------------+
|
||||
select substr('', 2, 100) from dual;
|
||||
+--------------------+
|
||||
| substr('', 2, 100) |
|
||||
+--------------------+
|
||||
| |
|
||||
+--------------------+
|
||||
|
||||
select substr(NULL, 2, 1) from dual;
|
||||
+--------------------+
|
||||
| substr(NULL, 2, 1) |
|
||||
+--------------------+
|
||||
| NULL |
|
||||
+--------------------+
|
||||
select substr('abcdef', NULL, 1) from dual;
|
||||
+---------------------------+
|
||||
| substr('abcdef', NULL, 1) |
|
||||
+---------------------------+
|
||||
| NULL |
|
||||
+---------------------------+
|
||||
select substr('abcdef', 2, NULL) from dual;
|
||||
+---------------------------+
|
||||
| substr('abcdef', 2, NULL) |
|
||||
+---------------------------+
|
||||
| NULL |
|
||||
+---------------------------+
|
||||
|
||||
select substr(3.14159, 2, 3) from dual;
|
||||
+-----------------------+
|
||||
| substr(3.14159, 2, 3) |
|
||||
+-----------------------+
|
||||
| .14 |
|
||||
+-----------------------+
|
||||
explain select substr(3.14159, '2', '3') from dual;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([?]), filter(nil)
|
||||
values({?})
|
||||
|
||||
select substr(3.14159, '2', '2.1') from dual;
|
||||
+-----------------------------+
|
||||
| substr(3.14159, '2', '2.1') |
|
||||
+-----------------------------+
|
||||
| .1 |
|
||||
+-----------------------------+
|
||||
select substr(3.14159, '2', '2.9') from dual;
|
||||
+-----------------------------+
|
||||
| substr(3.14159, '2', '2.9') |
|
||||
+-----------------------------+
|
||||
| .1 |
|
||||
+-----------------------------+
|
||||
select substr(3.14159, '2', '2.9') from dual;
|
||||
+-----------------------------+
|
||||
| substr(3.14159, '2', '2.9') |
|
||||
+-----------------------------+
|
||||
| .1 |
|
||||
+-----------------------------+
|
||||
select substr(3.14159, '2.1', '2.9') from dual;
|
||||
+-------------------------------+
|
||||
| substr(3.14159, '2.1', '2.9') |
|
||||
+-------------------------------+
|
||||
| .1 |
|
||||
+-------------------------------+
|
||||
select substr(3.14159, '2.9', '2.9') from dual;
|
||||
+-------------------------------+
|
||||
| substr(3.14159, '2.9', '2.9') |
|
||||
+-------------------------------+
|
||||
| .1 |
|
||||
+-------------------------------+
|
||||
select substr(3.14159, 2.1, '2.9') from dual;
|
||||
+-----------------------------+
|
||||
| substr(3.14159, 2.1, '2.9') |
|
||||
+-----------------------------+
|
||||
| .1 |
|
||||
+-----------------------------+
|
||||
select substr(3.14159, 2.9, '2.9') from dual;
|
||||
+-----------------------------+
|
||||
| substr(3.14159, 2.9, '2.9') |
|
||||
+-----------------------------+
|
||||
| 14 |
|
||||
+-----------------------------+
|
||||
select substr(3.14159, 2.9, 2.9) from dual;
|
||||
+---------------------------+
|
||||
| substr(3.14159, 2.9, 2.9) |
|
||||
+---------------------------+
|
||||
| 141 |
|
||||
+---------------------------+
|
||||
select substr(3.14159, 2.1, 2.1) from dual;
|
||||
+---------------------------+
|
||||
| substr(3.14159, 2.1, 2.1) |
|
||||
+---------------------------+
|
||||
| .1 |
|
||||
+---------------------------+
|
||||
@ -0,0 +1,135 @@
|
||||
result_format: 4
|
||||
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 bigint, c2 bigint unsigned, c3 decimal(40,2), c4 varchar(40));
|
||||
insert into t1 (c1, c2, c3, c4) values (-1, 0, 1, "2.1");
|
||||
insert into t1 (c1, c2, c3, c4) values (-2, 0, 2.1, "2.9");
|
||||
insert into t1 (c1, c2, c3, c4) values (-2, 0, 2.9, "2.9");
|
||||
insert into t1 (c1, c2, c3, c4) values (-10, 0, 10, "10");
|
||||
insert into t1 (c1, c2, c3, c4) values (4294967296, 4294967296, 4294967296, "4294967296");
|
||||
insert into t1 (c1, c2, c3, c4) values (4294967297, 4294967297, 4294967295, "4294967295");
|
||||
insert into t1 (c1, c2, c3, c4) values (-4294967296, 4294967296, -4294967296, "-4294967296");
|
||||
insert into t1 (c1, c2, c3, c4) values (-4294967297, 4294967297, -4294967295, "-4294967295");
|
||||
insert into t1 (c1, c2, c3, c4) values (9223372036854775806, 9223372036854775808, 9223372036854775808, "9223372036854775808");
|
||||
insert into t1 (c1, c2, c3, c4) values (9223372036854775807, 9223372036854775807, 9223372036854775807, "9223372036854775807");
|
||||
insert into t1 (c1, c2, c3, c4) values (9223372036854775806, 9223372036854775809, 9223372036854775809, "9223372036854775809");
|
||||
insert into t1 (c1, c2, c3, c4) values (-9223372036854775807, 9223372036854775807, -9223372036854775807, "-9223372036854775807");
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select substring_index("a,b,c,d", ",", -1);
|
||||
+-------------------------------------+
|
||||
| substring_index("a,b,c,d", ",", -1) |
|
||||
+-------------------------------------+
|
||||
| d |
|
||||
+-------------------------------------+
|
||||
select substring_index("a,b,c,d", ",", 0);
|
||||
+------------------------------------+
|
||||
| substring_index("a,b,c,d", ",", 0) |
|
||||
+------------------------------------+
|
||||
| |
|
||||
+------------------------------------+
|
||||
select substring_index("a,b,c,d", ",", 1);
|
||||
+------------------------------------+
|
||||
| substring_index("a,b,c,d", ",", 1) |
|
||||
+------------------------------------+
|
||||
| a |
|
||||
+------------------------------------+
|
||||
select substring_index("a,b,c,d", ",", 2);
|
||||
+------------------------------------+
|
||||
| substring_index("a,b,c,d", ",", 2) |
|
||||
+------------------------------------+
|
||||
| a,b |
|
||||
+------------------------------------+
|
||||
select substring_index("", ",", 2);
|
||||
+-----------------------------+
|
||||
| substring_index("", ",", 2) |
|
||||
+-----------------------------+
|
||||
| |
|
||||
+-----------------------------+
|
||||
select substring_index("a,b,c,d", "", 2);
|
||||
+-----------------------------------+
|
||||
| substring_index("a,b,c,d", "", 2) |
|
||||
+-----------------------------------+
|
||||
| |
|
||||
+-----------------------------------+
|
||||
select substring_index(NULL, ",", 2);
|
||||
+-------------------------------+
|
||||
| substring_index(NULL, ",", 2) |
|
||||
+-------------------------------+
|
||||
| NULL |
|
||||
+-------------------------------+
|
||||
select substring_index("a,b,c,d", NULL, 2);
|
||||
+-------------------------------------+
|
||||
| substring_index("a,b,c,d", NULL, 2) |
|
||||
+-------------------------------------+
|
||||
| NULL |
|
||||
+-------------------------------------+
|
||||
select substring_index("a,b,c,d", ",", NULL);
|
||||
+---------------------------------------+
|
||||
| substring_index("a,b,c,d", ",", NULL) |
|
||||
+---------------------------------------+
|
||||
| NULL |
|
||||
+---------------------------------------+
|
||||
select substring_index(1.414, 1, 2);
|
||||
+------------------------------+
|
||||
| substring_index(1.414, 1, 2) |
|
||||
+------------------------------+
|
||||
| 1.4 |
|
||||
+------------------------------+
|
||||
|
||||
select c1, substring_index("a,b,c,d", ",", c1), c2, substring_index("a,b,c,d", ",", c2), c3, substring_index("a,b,c,d", ",", c3), c4, substring_index("a,b,c,d", ",", c4) from t1;
|
||||
+----------------------+-------------------------------------+---------------------+-------------------------------------+-------------------------+-------------------------------------+----------------------+-------------------------------------+
|
||||
| c1 | substring_index("a,b,c,d", ",", c1) | c2 | substring_index("a,b,c,d", ",", c2) | c3 | substring_index("a,b,c,d", ",", c3) | c4 | substring_index("a,b,c,d", ",", c4) |
|
||||
+----------------------+-------------------------------------+---------------------+-------------------------------------+-------------------------+-------------------------------------+----------------------+-------------------------------------+
|
||||
| -1 | d | 0 | | 1.00 | a | 2.1 | a,b |
|
||||
| -2 | c,d | 0 | | 2.10 | a,b | 2.9 | a,b |
|
||||
| -2 | c,d | 0 | | 2.90 | a,b,c | 2.9 | a,b |
|
||||
| -10 | a,b,c,d | 0 | | 10.00 | a,b,c,d | 10 | a,b,c,d |
|
||||
| 4294967296 | | 4294967296 | | 4294967296.00 | | 4294967296 | |
|
||||
| 4294967297 | a | 4294967297 | a | 4294967295.00 | d | 4294967295 | d |
|
||||
| -4294967296 | | 4294967296 | | -4294967296.00 | | -4294967296 | |
|
||||
| -4294967297 | d | 4294967297 | a | -4294967295.00 | a | -4294967295 | a |
|
||||
| 9223372036854775806 | c,d | 9223372036854775808 | | 9223372036854775808.00 | d | 9223372036854775808 | d |
|
||||
| 9223372036854775807 | d | 9223372036854775807 | d | 9223372036854775807.00 | d | 9223372036854775807 | d |
|
||||
| 9223372036854775806 | c,d | 9223372036854775809 | a | 9223372036854775809.00 | d | 9223372036854775809 | d |
|
||||
| -9223372036854775807 | a | 9223372036854775807 | d | -9223372036854775807.00 | a | -9223372036854775807 | a |
|
||||
+----------------------+-------------------------------------+---------------------+-------------------------------------+-------------------------+-------------------------------------+----------------------+-------------------------------------+
|
||||
|
||||
drop table if exists t2, t3;
|
||||
create table t2(c1 varchar(20));
|
||||
create table t3(c1 varchar(20));
|
||||
insert into t2 values(null), (''), ('1');
|
||||
insert into t3 values(''), (null), ('1');
|
||||
|
||||
//the result of next 2 sqls should be same
|
||||
select c1, substring_index(c1, 'vpprm', -47) from t2 order by c1;
|
||||
+------+-----------------------------------+
|
||||
| c1 | substring_index(c1, 'vpprm', -47) |
|
||||
+------+-----------------------------------+
|
||||
| NULL | NULL |
|
||||
| | |
|
||||
| 1 | 1 |
|
||||
+------+-----------------------------------+
|
||||
select c1, substring_index(c1, 'vpprm', -47) from t3 order by c1;
|
||||
+------+-----------------------------------+
|
||||
| c1 | substring_index(c1, 'vpprm', -47) |
|
||||
+------+-----------------------------------+
|
||||
| NULL | NULL |
|
||||
| | |
|
||||
| 1 | 1 |
|
||||
+------+-----------------------------------+
|
||||
|
||||
drop table t1, t2,t3;
|
||||
drop table if exists t1;
|
||||
create table t1(c1 char(10));
|
||||
insert into t1 values(null), ('');
|
||||
select substring_index(c1, 'a', 1) from t1;
|
||||
+-----------------------------+
|
||||
| substring_index(c1, 'a', 1) |
|
||||
+-----------------------------+
|
||||
| NULL |
|
||||
| |
|
||||
+-----------------------------+
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
result_format: 4
|
||||
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select sys_privilege_check('table_acc', effective_tenant_id(), 'oceanbase', '__all_user');
|
||||
+------------------------------------------------------------------------------------+
|
||||
| sys_privilege_check('table_acc', effective_tenant_id(), 'oceanbase', '__all_user') |
|
||||
+------------------------------------------------------------------------------------+
|
||||
| 0 |
|
||||
+------------------------------------------------------------------------------------+
|
||||
select sys_privilege_check('db_acc', effective_tenant_id(), 'oceanbase_', '__all_user_');
|
||||
+-----------------------------------------------------------------------------------+
|
||||
| sys_privilege_check('db_acc', effective_tenant_id(), 'oceanbase_', '__all_user_') |
|
||||
+-----------------------------------------------------------------------------------+
|
||||
| 0 |
|
||||
+-----------------------------------------------------------------------------------+
|
||||
|
||||
drop database if exists espcndb;
|
||||
create database espcndb;
|
||||
|
||||
create user espcnouser;
|
||||
grant all on test.* to espcnouser;
|
||||
|
||||
|
||||
select sys_privilege_check('db_acc', effective_tenant_id(), 'test', 't');
|
||||
+-------------------------------------------------------------------+
|
||||
| sys_privilege_check('db_acc', effective_tenant_id(), 'test', 't') |
|
||||
+-------------------------------------------------------------------+
|
||||
| 0 |
|
||||
+-------------------------------------------------------------------+
|
||||
select sys_privilege_check('db_acc', effective_tenant_id(), 'espcndb', 't');
|
||||
+----------------------------------------------------------------------+
|
||||
| sys_privilege_check('db_acc', effective_tenant_id(), 'espcndb', 't') |
|
||||
+----------------------------------------------------------------------+
|
||||
| -1 |
|
||||
+----------------------------------------------------------------------+
|
||||
|
||||
drop user espcnouser;
|
||||
drop database espcnouser;
|
||||
ERROR HY000: Can't drop database 'espcnouser'; database doesn't exist
|
||||
|
||||
@ -0,0 +1,175 @@
|
||||
alter system flush plan cache global;
|
||||
drop table if exists t1;
|
||||
create table t1(c1 datetime, c2 timestamp, c3 date, c4 time);
|
||||
insert into t1 values('1234-12-12 01:23:45', '2020-01-01 01:23:45', '1234-12-12', '01:23:45');
|
||||
insert into t1 values('2000-2-29 01:23:45.678', '2000-2-29 01:23:45.678', '2000-2-29', '01:23:45.678');
|
||||
insert into t1 values('2001-12-31 12:00:00', '2001-12-31 12:00:00', '2001-12-31', '12:00:00');
|
||||
insert into t1 values(null, null, null, null);
|
||||
select a.c1, b.c1, timediff(a.c1, b.c1) from t1 a, t1 b;
|
||||
c1 c1 timediff(a.c1, b.c1)
|
||||
1234-12-12 01:23:45 1234-12-12 01:23:45 00:00:00
|
||||
1234-12-12 01:23:45 2000-02-29 01:23:46 -838:59:59
|
||||
1234-12-12 01:23:45 2001-12-31 12:00:00 -838:59:59
|
||||
1234-12-12 01:23:45 NULL NULL
|
||||
2000-02-29 01:23:46 1234-12-12 01:23:45 838:59:59
|
||||
2000-02-29 01:23:46 2000-02-29 01:23:46 00:00:00
|
||||
2000-02-29 01:23:46 2001-12-31 12:00:00 -838:59:59
|
||||
2000-02-29 01:23:46 NULL NULL
|
||||
2001-12-31 12:00:00 1234-12-12 01:23:45 838:59:59
|
||||
2001-12-31 12:00:00 2000-02-29 01:23:46 838:59:59
|
||||
2001-12-31 12:00:00 2001-12-31 12:00:00 00:00:00
|
||||
2001-12-31 12:00:00 NULL NULL
|
||||
NULL 1234-12-12 01:23:45 NULL
|
||||
NULL 2000-02-29 01:23:46 NULL
|
||||
NULL 2001-12-31 12:00:00 NULL
|
||||
NULL NULL NULL
|
||||
select a.c2, b.c2, timediff(a.c2, b.c2) from t1 a, t1 b;
|
||||
c2 c2 timediff(a.c2, b.c2)
|
||||
2020-01-01 01:23:45 2020-01-01 01:23:45 00:00:00
|
||||
2020-01-01 01:23:45 2000-02-29 01:23:46 838:59:59
|
||||
2020-01-01 01:23:45 2001-12-31 12:00:00 838:59:59
|
||||
2020-01-01 01:23:45 NULL NULL
|
||||
2000-02-29 01:23:46 2020-01-01 01:23:45 -838:59:59
|
||||
2000-02-29 01:23:46 2000-02-29 01:23:46 00:00:00
|
||||
2000-02-29 01:23:46 2001-12-31 12:00:00 -838:59:59
|
||||
2000-02-29 01:23:46 NULL NULL
|
||||
2001-12-31 12:00:00 2020-01-01 01:23:45 -838:59:59
|
||||
2001-12-31 12:00:00 2000-02-29 01:23:46 838:59:59
|
||||
2001-12-31 12:00:00 2001-12-31 12:00:00 00:00:00
|
||||
2001-12-31 12:00:00 NULL NULL
|
||||
NULL 2020-01-01 01:23:45 NULL
|
||||
NULL 2000-02-29 01:23:46 NULL
|
||||
NULL 2001-12-31 12:00:00 NULL
|
||||
NULL NULL NULL
|
||||
select a.c3, b.c3, timediff(a.c3, b.c3) from t1 a, t1 b;
|
||||
c3 c3 timediff(a.c3, b.c3)
|
||||
1234-12-12 1234-12-12 00:00:00
|
||||
1234-12-12 2000-02-29 -838:59:59
|
||||
1234-12-12 2001-12-31 -838:59:59
|
||||
1234-12-12 NULL NULL
|
||||
2000-02-29 1234-12-12 838:59:59
|
||||
2000-02-29 2000-02-29 00:00:00
|
||||
2000-02-29 2001-12-31 -838:59:59
|
||||
2000-02-29 NULL NULL
|
||||
2001-12-31 1234-12-12 838:59:59
|
||||
2001-12-31 2000-02-29 838:59:59
|
||||
2001-12-31 2001-12-31 00:00:00
|
||||
2001-12-31 NULL NULL
|
||||
NULL 1234-12-12 NULL
|
||||
NULL 2000-02-29 NULL
|
||||
NULL 2001-12-31 NULL
|
||||
NULL NULL NULL
|
||||
select a.c4, b.c4, timediff(a.c4, b.c4) from t1 a, t1 b;
|
||||
c4 c4 timediff(a.c4, b.c4)
|
||||
01:23:45 01:23:45 00:00:00
|
||||
01:23:45 01:23:46 -00:00:01
|
||||
01:23:45 12:00:00 -10:36:15
|
||||
01:23:45 NULL NULL
|
||||
01:23:46 01:23:45 00:00:01
|
||||
01:23:46 01:23:46 00:00:00
|
||||
01:23:46 12:00:00 -10:36:14
|
||||
01:23:46 NULL NULL
|
||||
12:00:00 01:23:45 10:36:15
|
||||
12:00:00 01:23:46 10:36:14
|
||||
12:00:00 12:00:00 00:00:00
|
||||
12:00:00 NULL NULL
|
||||
NULL 01:23:45 NULL
|
||||
NULL 01:23:46 NULL
|
||||
NULL 12:00:00 NULL
|
||||
NULL NULL NULL
|
||||
select timediff(c1, c1) from t1;
|
||||
timediff(c1, c1)
|
||||
00:00:00
|
||||
00:00:00
|
||||
00:00:00
|
||||
NULL
|
||||
select timediff(c1, c2) from t1;
|
||||
timediff(c1, c2)
|
||||
-838:59:59
|
||||
00:00:00
|
||||
00:00:00
|
||||
NULL
|
||||
select timediff(c1, c3) from t1;
|
||||
timediff(c1, c3)
|
||||
01:23:45
|
||||
01:23:46
|
||||
12:00:00
|
||||
NULL
|
||||
select timediff(c1, c4) from t1;
|
||||
timediff(c1, c4)
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
select timediff(c2, c1) from t1;
|
||||
timediff(c2, c1)
|
||||
838:59:59
|
||||
00:00:00
|
||||
00:00:00
|
||||
NULL
|
||||
select timediff(c2, c2) from t1;
|
||||
timediff(c2, c2)
|
||||
00:00:00
|
||||
00:00:00
|
||||
00:00:00
|
||||
NULL
|
||||
select timediff(c2, c3) from t1;
|
||||
timediff(c2, c3)
|
||||
838:59:59
|
||||
01:23:46
|
||||
12:00:00
|
||||
NULL
|
||||
select timediff(c2, c4) from t1;
|
||||
timediff(c2, c4)
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
select timediff(c3, c1) from t1;
|
||||
timediff(c3, c1)
|
||||
-01:23:45
|
||||
-01:23:46
|
||||
-12:00:00
|
||||
NULL
|
||||
select timediff(c3, c2) from t1;
|
||||
timediff(c3, c2)
|
||||
-838:59:59
|
||||
-01:23:46
|
||||
-12:00:00
|
||||
NULL
|
||||
select timediff(c3, c3) from t1;
|
||||
timediff(c3, c3)
|
||||
00:00:00
|
||||
00:00:00
|
||||
00:00:00
|
||||
NULL
|
||||
select timediff(c3, c4) from t1;
|
||||
timediff(c3, c4)
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
select timediff(c4, c1) from t1;
|
||||
timediff(c4, c1)
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
select timediff(c4, c2) from t1;
|
||||
timediff(c4, c2)
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
select timediff(c4, c3) from t1;
|
||||
timediff(c4, c3)
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
select timediff(c4, c4) from t1;
|
||||
timediff(c4, c4)
|
||||
00:00:00
|
||||
00:00:00
|
||||
00:00:00
|
||||
NULL
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,140 @@
|
||||
result_format: 4
|
||||
|
||||
drop table if exists t1;
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select trim(' abc ') x from dual;
|
||||
+------+
|
||||
| x |
|
||||
+------+
|
||||
| abc |
|
||||
+------+
|
||||
select trim(leading from ' abc ') x from dual;
|
||||
+-------------+
|
||||
| x |
|
||||
+-------------+
|
||||
| abc |
|
||||
+-------------+
|
||||
select trim(trailing from ' abc ') x from dual;
|
||||
+---------------+
|
||||
| x |
|
||||
+---------------+
|
||||
| abc |
|
||||
+---------------+
|
||||
select trim(both from ' abc ') x from dual;
|
||||
+------+
|
||||
| x |
|
||||
+------+
|
||||
| abc |
|
||||
+------+
|
||||
select trim(both '' from ' abc ') x from dual;
|
||||
+-----------------------+
|
||||
| x |
|
||||
+-----------------------+
|
||||
| abc |
|
||||
+-----------------------+
|
||||
select trim(both ' ' from ' abc ') x from dual;
|
||||
+------+
|
||||
| x |
|
||||
+------+
|
||||
| abc |
|
||||
+------+
|
||||
select trim(both 'abc' from 'abcabdefabcabc') x from dual;
|
||||
+-------+
|
||||
| x |
|
||||
+-------+
|
||||
| abdef |
|
||||
+-------+
|
||||
select trim(both ' ' from ' abc ') x from dual;
|
||||
+------+
|
||||
| x |
|
||||
+------+
|
||||
| abc |
|
||||
+------+
|
||||
select trim(both NULL from ' abc ') x from dual;
|
||||
+------+
|
||||
| x |
|
||||
+------+
|
||||
| NULL |
|
||||
+------+
|
||||
select trim(both ' ' from NULL) x from dual;
|
||||
+------+
|
||||
| x |
|
||||
+------+
|
||||
| NULL |
|
||||
+------+
|
||||
select trim(both 1 from 112311) x from dual;
|
||||
+------+
|
||||
| x |
|
||||
+------+
|
||||
| 23 |
|
||||
+------+
|
||||
|
||||
select ltrim(' abc ') x from dual;
|
||||
+------------------+
|
||||
| x |
|
||||
+------------------+
|
||||
| abc |
|
||||
+------------------+
|
||||
select ltrim(' ') x from dual;
|
||||
+------+
|
||||
| x |
|
||||
+------+
|
||||
| |
|
||||
+------+
|
||||
select ltrim(NULL) x from dual;
|
||||
+------+
|
||||
| x |
|
||||
+------+
|
||||
| NULL |
|
||||
+------+
|
||||
select rtrim(' abc ') x from dual;
|
||||
+---------------+
|
||||
| x |
|
||||
+---------------+
|
||||
| abc |
|
||||
+---------------+
|
||||
select rtrim(' ') x from dual;
|
||||
+------+
|
||||
| x |
|
||||
+------+
|
||||
| |
|
||||
+------+
|
||||
select rtrim(NULL) x from dual;
|
||||
+------+
|
||||
| x |
|
||||
+------+
|
||||
| NULL |
|
||||
+------+
|
||||
|
||||
drop table if exists t1;
|
||||
drop view if exists v1;
|
||||
create view v1 as select nullif(trim(repeat('abc', 1+1)), 'a');
|
||||
desc v1;
|
||||
+---------------------------------------+----------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+---------------------------------------+----------+------+-----+---------+-------+
|
||||
| nullif(trim(repeat('abc', 1+1)), 'a') | longtext | NO | | | |
|
||||
+---------------------------------------+----------+------+-----+---------+-------+
|
||||
select * from v1;
|
||||
+---------------------------------------+
|
||||
| nullif(trim(repeat('abc', 1+1)), 'a') |
|
||||
+---------------------------------------+
|
||||
| abcabc |
|
||||
+---------------------------------------+
|
||||
|
||||
create table t1(c1 longtext, c2 varchar(100));
|
||||
insert into t1 values('abababa', 'a');
|
||||
// c1 and c2 will cast to longtext
|
||||
select trim(leading c2 from c1) from t1;
|
||||
+--------------------------+
|
||||
| trim(leading c2 from c1) |
|
||||
+--------------------------+
|
||||
| bababa |
|
||||
+--------------------------+
|
||||
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,56 @@
|
||||
result_format: 4
|
||||
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 varchar(2000));
|
||||
insert into t1 values(hex("ABC")), (hex("123"));
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
select unhex(c1) from t1;
|
||||
+-----------+
|
||||
| unhex(c1) |
|
||||
+-----------+
|
||||
| ABC |
|
||||
| 123 |
|
||||
+-----------+
|
||||
select unhex("4142") from dual;
|
||||
+---------------+
|
||||
| unhex("4142") |
|
||||
+---------------+
|
||||
| AB |
|
||||
+---------------+
|
||||
|
||||
drop table if exists t2;
|
||||
|
||||
CREATE TABLE t2 (a VARBINARY(2000));
|
||||
set sql_mode = STRICT_TRANS_TABLES;
|
||||
insert into t2 VALUES (UNHEX('54455354'));
|
||||
insert into t2 VALUES (UNHEX('TEST'));
|
||||
ERROR HY000: invalid hex number
|
||||
select a from t2 where a = UNHEX('TEST');
|
||||
+------+
|
||||
| a |
|
||||
+------+
|
||||
+------+
|
||||
select a from t2 where a = UNHEX('54455354');
|
||||
+------+
|
||||
| a |
|
||||
+------+
|
||||
| TEST |
|
||||
+------+
|
||||
set sql_mode = "";
|
||||
insert into t2 VALUES (UNHEX('54455354'));
|
||||
insert into t2 VALUES (UNHEX('TEST'));
|
||||
select a from t2 where a = UNHEX('TEST');
|
||||
+------+
|
||||
| a |
|
||||
+------+
|
||||
+------+
|
||||
select a from t2 where a = UNHEX('54455354');
|
||||
+------+
|
||||
| a |
|
||||
+------+
|
||||
| TEST |
|
||||
| TEST |
|
||||
+------+
|
||||
|
||||
|
||||
@ -0,0 +1,99 @@
|
||||
result_format: 4
|
||||
alter system flush plan cache global;
|
||||
set ob_enable_plan_cache = 0;
|
||||
|
||||
select unix_timestamp(NULL);
|
||||
+----------------------+
|
||||
| unix_timestamp(NULL) |
|
||||
+----------------------+
|
||||
| NULL |
|
||||
+----------------------+
|
||||
select unix_timestamp('');
|
||||
+--------------------+
|
||||
| unix_timestamp('') |
|
||||
+--------------------+
|
||||
| 0.000000 |
|
||||
+--------------------+
|
||||
select unix_timestamp('2010-01-01 10:50:50.123');
|
||||
+-------------------------------------------+
|
||||
| unix_timestamp('2010-01-01 10:50:50.123') |
|
||||
+-------------------------------------------+
|
||||
| 1262314250.123 |
|
||||
+-------------------------------------------+
|
||||
select unix_timestamp(123);
|
||||
+---------------------+
|
||||
| unix_timestamp(123) |
|
||||
+---------------------+
|
||||
| 948556800 |
|
||||
+---------------------+
|
||||
drop table if exists t1;
|
||||
create table t1 (col_datetime_4_not_null datetime(4) not null);
|
||||
insert into t1 values
|
||||
('0000-00-00 00:00:00.0000'),('2006-05-12 07:06:44.0441'),('2007-11-08 00:00:00.0000'), ('2007-07-23 00:00:00.0000'),('2006-01-10 22:19:14.0158'),('2006-09-13 18:54:05.0013'), ('2002-03-26 00:00:00.0000'),('2002-10-22 10:53:06.0151'),('0000-00-00 00:00:00.0000'),('2001-06-04 00:00:00.0000'),('0000-00-00 00:00:00.0000'),('2000-12-11 10:47:58.0505'), ('2009-04-21 20:01:40.0570'),('2007-03-12 10:48:41.0031'),('0000-00-00 00:00:00.0000'), ('2009-06-22 00:00:00.0000'),('2008-01-21 15:28:44.0592'),('2003-10-05 00:43:55.0577'), ('2002-11-04 00:46:30.0630'),('2006-01-19 11:38:03.0378'),('0000-00-00 00:00:00.0000'), ('2001-02-04 00:00:00.0000'),('2004-10-22 21:59:04.0394'),('2006-03-20 18:54:13.0139'), ('2004-06-09 03:17:31.0403'),('0000-00-00 00:00:00.0000'),('2003-06-01 17:59:12.0365'), ('0000-00-00 00:00:00.0000'),('2009-06-15 08:58:58.0329'),('0000-00-00 00:00:00.0000'), ('2004-03-26 00:00:00.0000'),('2009-04-27 00:00:00.0000'),('2000-09-07 00:00:00.0000'), ('2006-11-04 00:51:03.0501'),('2005-02-20 00:30:47.0647'),('0000-00-00 00:00:00.0000'), ('2004-12-07 00:00:00.0000'),('0000-00-00 00:00:00.0000'),('0000-00-00 00:00:00.0000'), ('2002-08-17 00:27:20.0536'),('2006-10-12 12:12:28.0337'),('0000-00-00 00:00:00.0000'), ('0000-00-00 00:00:00.0000'),('2009-09-09 14:16:05.0354'),('2000-02-25 00:00:00.0000'), ('2003-12-16 05:38:37.0626'),('2000-10-05 03:46:43.0067'),('0000-00-00 00:00:00.0000'), ('2000-10-08 06:45:51.0547'),('0000-00-00 00:00:00.0000'),('2000-04-06 01:46:21.0620'), ('2001-08-10 23:15:40.0304'),('2001-06-24 10:14:00.0497'),('0000-00-00 00:00:00.0000'), ('0000-00-00 00:00:00.0000'),('2004-10-22 00:00:00.0000'),('0000-00-00 00:00:00.0000'), ('0000-00-00 00:00:00.0000'),('2005-08-23 06:34:23.0058'),('2005-03-28 18:34:18.0138'),('2004-05-18 00:00:00.0000');
|
||||
select col_datetime_4_not_null, unix_timestamp(col_datetime_4_not_null) from t1 order by 1;
|
||||
+--------------------------+-----------------------------------------+
|
||||
| col_datetime_4_not_null | unix_timestamp(col_datetime_4_not_null) |
|
||||
+--------------------------+-----------------------------------------+
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 0000-00-00 00:00:00.0000 | 0.0000 |
|
||||
| 2000-02-25 00:00:00.0000 | 951408000.0000 |
|
||||
| 2000-04-06 01:46:21.0620 | 954956781.0620 |
|
||||
| 2000-09-07 00:00:00.0000 | 968256000.0000 |
|
||||
| 2000-10-05 03:46:43.0067 | 970688803.0067 |
|
||||
| 2000-10-08 06:45:51.0547 | 970958751.0547 |
|
||||
| 2000-12-11 10:47:58.0505 | 976502878.0505 |
|
||||
| 2001-02-04 00:00:00.0000 | 981216000.0000 |
|
||||
| 2001-06-04 00:00:00.0000 | 991584000.0000 |
|
||||
| 2001-06-24 10:14:00.0497 | 993348840.0497 |
|
||||
| 2001-08-10 23:15:40.0304 | 997456540.0304 |
|
||||
| 2002-03-26 00:00:00.0000 | 1017072000.0000 |
|
||||
| 2002-08-17 00:27:20.0536 | 1029515240.0536 |
|
||||
| 2002-10-22 10:53:06.0151 | 1035255186.0151 |
|
||||
| 2002-11-04 00:46:30.0630 | 1036341990.0630 |
|
||||
| 2003-06-01 17:59:12.0365 | 1054461552.0365 |
|
||||
| 2003-10-05 00:43:55.0577 | 1065285835.0577 |
|
||||
| 2003-12-16 05:38:37.0626 | 1071524317.0626 |
|
||||
| 2004-03-26 00:00:00.0000 | 1080230400.0000 |
|
||||
| 2004-05-18 00:00:00.0000 | 1084809600.0000 |
|
||||
| 2004-06-09 03:17:31.0403 | 1086722251.0403 |
|
||||
| 2004-10-22 00:00:00.0000 | 1098374400.0000 |
|
||||
| 2004-10-22 21:59:04.0394 | 1098453544.0394 |
|
||||
| 2004-12-07 00:00:00.0000 | 1102348800.0000 |
|
||||
| 2005-02-20 00:30:47.0647 | 1108830647.0647 |
|
||||
| 2005-03-28 18:34:18.0138 | 1112006058.0138 |
|
||||
| 2005-08-23 06:34:23.0058 | 1124750063.0058 |
|
||||
| 2006-01-10 22:19:14.0158 | 1136902754.0158 |
|
||||
| 2006-01-19 11:38:03.0378 | 1137641883.0378 |
|
||||
| 2006-03-20 18:54:13.0139 | 1142852053.0139 |
|
||||
| 2006-05-12 07:06:44.0441 | 1147388804.0441 |
|
||||
| 2006-09-13 18:54:05.0013 | 1158144845.0013 |
|
||||
| 2006-10-12 12:12:28.0337 | 1160626348.0337 |
|
||||
| 2006-11-04 00:51:03.0501 | 1162572663.0501 |
|
||||
| 2007-03-12 10:48:41.0031 | 1173667721.0031 |
|
||||
| 2007-07-23 00:00:00.0000 | 1185120000.0000 |
|
||||
| 2007-11-08 00:00:00.0000 | 1194451200.0000 |
|
||||
| 2008-01-21 15:28:44.0592 | 1200900524.0592 |
|
||||
| 2009-04-21 20:01:40.0570 | 1240315300.0570 |
|
||||
| 2009-04-27 00:00:00.0000 | 1240761600.0000 |
|
||||
| 2009-06-15 08:58:58.0329 | 1245027538.0329 |
|
||||
| 2009-06-22 00:00:00.0000 | 1245600000.0000 |
|
||||
| 2009-09-09 14:16:05.0354 | 1252476965.0354 |
|
||||
+--------------------------+-----------------------------------------+
|
||||
|
||||
16924
tools/deploy/mysql_test/test_suite/static_engine/r/mysql/expr_xor.result
Normal file
16924
tools/deploy/mysql_test/test_suite/static_engine/r/mysql/expr_xor.result
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,301 @@
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
drop table t111_var;
|
||||
create table t1(c1 int,c2 int,c3 int);
|
||||
create table t2(c1 int,c2 int,c3 int);
|
||||
insert into t1 values(1,2,3);
|
||||
insert into t1 values(1,2,3);
|
||||
insert into t1 values(0,2,3);
|
||||
insert into t1 values(2,2,3);
|
||||
insert into t1 values(3,2,3);
|
||||
insert into t2 values(2,2,3);
|
||||
insert into t2 values(2,0,3);
|
||||
insert into t2 values(0,2,3);
|
||||
insert into t2 values(1,2,3);
|
||||
insert into t2 values(null,2,3);
|
||||
insert into t2 values(1,2,3);
|
||||
insert into t2 values(0,2,1);
|
||||
insert into t2 values(2,2,3);
|
||||
commit;
|
||||
create table t111_var(c0 bigint,c1 varchar(4000), c2 varchar(4000), c3 varchar(4000), c4 varchar(4000), c5 varchar(4000),c6 varchar(4000), c7 longtext);
|
||||
insert into t111_var values(1,repeat('ab',2000),repeat('ab',2000),repeat('ab',2000),repeat('ab',2000),repeat('ab',2000),repeat('ab',2000),repeat('abcdefghij',4000));
|
||||
insert into t111_var select c0+1,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
insert into t111_var select c0+10,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
insert into t111_var select c0+100,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
insert into t111_var select c0+1000,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
insert into t111_var select c0+10000,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
insert into t111_var select c0+100000,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
insert into t111_var select c0+1000000,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
insert into t111_var select c0+10000000,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
insert into t111_var select c0+100000000,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
insert into t111_var values(null,null,null,null,null,null,null,null);
|
||||
insert into t111_var select * from t111_var;
|
||||
commit;
|
||||
result_format: 4
|
||||
explain_protocol: 1
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
EXPLAIN BASIC select /*+ USE_HASH_AGGREGATION */distinct c1,c2 from t2;
|
||||
Query Plan
|
||||
=======================
|
||||
|ID|OPERATOR |NAME|
|
||||
-----------------------
|
||||
|0 |HASH DISTINCT| |
|
||||
|1 | TABLE SCAN |t2 |
|
||||
=======================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t2.c1], [t2.c2]), filter(nil),
|
||||
distinct([t2.c1], [t2.c2])
|
||||
1 - output([t2.c1], [t2.c2]), filter(nil),
|
||||
access([t2.c1], [t2.c2]), partitions(p0)
|
||||
|
||||
select /*+ USE_HASH_AGGREGATION */distinct c1,c2 from t2;
|
||||
+------+------+
|
||||
| c1 | c2 |
|
||||
+------+------+
|
||||
| 2 | 2 |
|
||||
| 2 | 0 |
|
||||
| 0 | 2 |
|
||||
| 1 | 2 |
|
||||
| NULL | 2 |
|
||||
+------+------+
|
||||
EXPLAIN BASIC select /*+ USE_HASH_AGGREGATION */distinct c2,c1 from t2;
|
||||
Query Plan
|
||||
=======================
|
||||
|ID|OPERATOR |NAME|
|
||||
-----------------------
|
||||
|0 |HASH DISTINCT| |
|
||||
|1 | TABLE SCAN |t2 |
|
||||
=======================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t2.c2], [t2.c1]), filter(nil),
|
||||
distinct([t2.c2], [t2.c1])
|
||||
1 - output([t2.c2], [t2.c1]), filter(nil),
|
||||
access([t2.c2], [t2.c1]), partitions(p0)
|
||||
|
||||
select /*+ USE_HASH_AGGREGATION */distinct c2,c1 from t2;
|
||||
+------+------+
|
||||
| c2 | c1 |
|
||||
+------+------+
|
||||
| 2 | 2 |
|
||||
| 0 | 2 |
|
||||
| 2 | 0 |
|
||||
| 2 | 1 |
|
||||
| 2 | NULL |
|
||||
+------+------+
|
||||
EXPLAIN BASIC select /*+ USE_HASH_AGGREGATION */distinct c2,c1,c1+c2 from t2;
|
||||
Query Plan
|
||||
=======================
|
||||
|ID|OPERATOR |NAME|
|
||||
-----------------------
|
||||
|0 |HASH DISTINCT| |
|
||||
|1 | TABLE SCAN |t2 |
|
||||
=======================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t2.c2], [t2.c1], [t2.c1 + t2.c2]), filter(nil),
|
||||
distinct([t2.c2], [t2.c1], [t2.c1 + t2.c2])
|
||||
1 - output([t2.c2], [t2.c1], [t2.c1 + t2.c2]), filter(nil),
|
||||
access([t2.c2], [t2.c1]), partitions(p0)
|
||||
|
||||
select /*+ USE_HASH_AGGREGATION */distinct c2,c1,c1+c2 from t2;
|
||||
+------+------+-------+
|
||||
| c2 | c1 | c1+c2 |
|
||||
+------+------+-------+
|
||||
| 2 | 2 | 4 |
|
||||
| 0 | 2 | 2 |
|
||||
| 2 | 0 | 2 |
|
||||
| 2 | 1 | 3 |
|
||||
| 2 | NULL | NULL |
|
||||
+------+------+-------+
|
||||
EXPLAIN BASIC select /*+ USE_HASH_AGGREGATION */distinct c1+c2,abs(c1) from t2;
|
||||
Query Plan
|
||||
=======================
|
||||
|ID|OPERATOR |NAME|
|
||||
-----------------------
|
||||
|0 |HASH DISTINCT| |
|
||||
|1 | TABLE SCAN |t2 |
|
||||
=======================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t2.c1 + t2.c2], [abs(cast(t2.c1, BIGINT(-1, 0)))]), filter(nil),
|
||||
distinct([t2.c1 + t2.c2], [abs(cast(t2.c1, BIGINT(-1, 0)))])
|
||||
1 - output([t2.c1 + t2.c2], [abs(cast(t2.c1, BIGINT(-1, 0)))]), filter(nil),
|
||||
access([t2.c1], [t2.c2]), partitions(p0)
|
||||
|
||||
select /*+ USE_HASH_AGGREGATION */distinct c1+c2,abs(c1) from t2;
|
||||
+-------+---------+
|
||||
| c1+c2 | abs(c1) |
|
||||
+-------+---------+
|
||||
| 4 | 2 |
|
||||
| 2 | 2 |
|
||||
| 2 | 0 |
|
||||
| 3 | 1 |
|
||||
| NULL | NULL |
|
||||
+-------+---------+
|
||||
EXPLAIN BASIC select /*+ USE_HASH_AGGREGATION */distinct c1+c2 from t2;
|
||||
Query Plan
|
||||
=======================
|
||||
|ID|OPERATOR |NAME|
|
||||
-----------------------
|
||||
|0 |HASH DISTINCT| |
|
||||
|1 | TABLE SCAN |t2 |
|
||||
=======================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t2.c1 + t2.c2]), filter(nil),
|
||||
distinct([t2.c1 + t2.c2])
|
||||
1 - output([t2.c1 + t2.c2]), filter(nil),
|
||||
access([t2.c1], [t2.c2]), partitions(p0)
|
||||
|
||||
select /*+ USE_HASH_AGGREGATION */distinct c1+c2 from t2;
|
||||
+-------+
|
||||
| c1+c2 |
|
||||
+-------+
|
||||
| 4 |
|
||||
| 2 |
|
||||
| 3 |
|
||||
| NULL |
|
||||
+-------+
|
||||
EXPLAIN BASIC select /*+ USE_HASH_AGGREGATION */distinct c2,c1,c3 from t2;
|
||||
Query Plan
|
||||
=======================
|
||||
|ID|OPERATOR |NAME|
|
||||
-----------------------
|
||||
|0 |HASH DISTINCT| |
|
||||
|1 | TABLE SCAN |t2 |
|
||||
=======================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t2.c2], [t2.c1], [t2.c3]), filter(nil),
|
||||
distinct([t2.c2], [t2.c1], [t2.c3])
|
||||
1 - output([t2.c2], [t2.c1], [t2.c3]), filter(nil),
|
||||
access([t2.c2], [t2.c1], [t2.c3]), partitions(p0)
|
||||
|
||||
select /*+ USE_HASH_AGGREGATION */distinct c2,c1,c3 from t2;
|
||||
+------+------+------+
|
||||
| c2 | c1 | c3 |
|
||||
+------+------+------+
|
||||
| 2 | 2 | 3 |
|
||||
| 0 | 2 | 3 |
|
||||
| 2 | 0 | 3 |
|
||||
| 2 | 1 | 3 |
|
||||
| 2 | NULL | 3 |
|
||||
| 2 | 0 | 1 |
|
||||
+------+------+------+
|
||||
EXPLAIN BASIC select /*+ USE_HASH_AGGREGATION */distinct 1,2,3,5,'ab' from t2;
|
||||
Query Plan
|
||||
====================
|
||||
|ID|OPERATOR |NAME|
|
||||
--------------------
|
||||
|0 |TABLE SCAN|t2 |
|
||||
====================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([1], [2], [3], [5], ['ab']), filter(nil),
|
||||
access([t2.__pk_increment]), partitions(p0),
|
||||
limit(1), offset(nil)
|
||||
|
||||
select /*+ USE_HASH_AGGREGATION */distinct 1,2,3,5,'ab' from t2;
|
||||
+---+---+---+---+----+
|
||||
| 1 | 2 | 3 | 5 | ab |
|
||||
+---+---+---+---+----+
|
||||
| 1 | 2 | 3 | 5 | ab |
|
||||
+---+---+---+---+----+
|
||||
EXPLAIN BASIC select /*+ USE_HASH_AGGREGATION */distinct 1,c2,2,3,c1,5,'ab' from t2;
|
||||
Query Plan
|
||||
=======================
|
||||
|ID|OPERATOR |NAME|
|
||||
-----------------------
|
||||
|0 |HASH DISTINCT| |
|
||||
|1 | TABLE SCAN |t2 |
|
||||
=======================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([1], [t2.c2], [2], [3], [t2.c1], [5], ['ab']), filter(nil),
|
||||
distinct([t2.c2], [t2.c1])
|
||||
1 - output([t2.c2], [t2.c1]), filter(nil),
|
||||
access([t2.c2], [t2.c1]), partitions(p0)
|
||||
|
||||
select /*+ USE_HASH_AGGREGATION */distinct 1,c2,2,3,c1,5,'ab' from t2;
|
||||
+---+------+---+---+------+---+----+
|
||||
| 1 | c2 | 2 | 3 | c1 | 5 | ab |
|
||||
+---+------+---+---+------+---+----+
|
||||
| 1 | 2 | 2 | 3 | 2 | 5 | ab |
|
||||
| 1 | 0 | 2 | 3 | 2 | 5 | ab |
|
||||
| 1 | 2 | 2 | 3 | 0 | 5 | ab |
|
||||
| 1 | 2 | 2 | 3 | 1 | 5 | ab |
|
||||
| 1 | 2 | 2 | 3 | NULL | 5 | ab |
|
||||
+---+------+---+---+------+---+----+
|
||||
EXPLAIN BASIC select /*+ USE_HASH_AGGREGATION */distinct 1,c2,2,3,c1,5,'ab' from t2 where c2=0;
|
||||
Query Plan
|
||||
=======================
|
||||
|ID|OPERATOR |NAME|
|
||||
-----------------------
|
||||
|0 |HASH DISTINCT| |
|
||||
|1 | TABLE SCAN |t2 |
|
||||
=======================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([1], [t2.c2], [2], [3], [t2.c1], [5], ['ab']), filter(nil),
|
||||
distinct([t2.c1])
|
||||
1 - output([t2.c2], [t2.c1]), filter([t2.c2 = 0]),
|
||||
access([t2.c2], [t2.c1]), partitions(p0)
|
||||
|
||||
select /*+ USE_HASH_AGGREGATION */distinct 1,c2,2,3,c1,5,'ab' from t2 where c2=0;
|
||||
+---+------+---+---+------+---+----+
|
||||
| 1 | c2 | 2 | 3 | c1 | 5 | ab |
|
||||
+---+------+---+---+------+---+----+
|
||||
| 1 | 0 | 2 | 3 | 2 | 5 | ab |
|
||||
+---+------+---+---+------+---+----+
|
||||
|
||||
## dump
|
||||
set ob_query_timeout=30000000;
|
||||
EXPLAIN BASIC select /*+ use_merge(a b) */SQL_CALC_FOUND_ROWS sum(c0),sum(length(c1)),count(c2),count(c3),count(c4),count(c5),count(c6),count(c7)
|
||||
from (select /*+ USE_HASH_AGGREGATION */ distinct * from t111_var) order by c1 limit 1;
|
||||
Query Plan
|
||||
==============================
|
||||
|ID|OPERATOR |NAME |
|
||||
------------------------------
|
||||
|0 |LIMIT | |
|
||||
|1 | SCALAR GROUP BY| |
|
||||
|2 | SUBPLAN SCAN | |
|
||||
|3 | HASH DISTINCT| |
|
||||
|4 | TABLE SCAN |t111_var|
|
||||
==============================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([T_FUN_SUM(.c0)], [T_FUN_SUM(length(.c1))], [T_FUN_COUNT(.c2)], [T_FUN_COUNT(.c3)], [T_FUN_COUNT(.c4)], [T_FUN_COUNT(.c5)], [T_FUN_COUNT(.c6)], [T_FUN_COUNT(.c7)]), filter(nil), limit(1), offset(nil)
|
||||
1 - output([T_FUN_SUM(.c0)], [T_FUN_SUM(length(.c1))], [T_FUN_COUNT(.c2)], [T_FUN_COUNT(.c3)], [T_FUN_COUNT(.c4)], [T_FUN_COUNT(.c5)], [T_FUN_COUNT(.c6)], [T_FUN_COUNT(.c7)]), filter(nil),
|
||||
group(nil), agg_func([T_FUN_SUM(.c0)], [T_FUN_SUM(length(.c1))], [T_FUN_COUNT(.c2)], [T_FUN_COUNT(.c3)], [T_FUN_COUNT(.c4)], [T_FUN_COUNT(.c5)], [T_FUN_COUNT(.c6)], [T_FUN_COUNT(.c7)])
|
||||
2 - output([.c0], [.c2], [.c3], [.c4], [.c5], [.c6], [.c7], [length(.c1)]), filter(nil),
|
||||
access([.c0], [.c1], [.c2], [.c3], [.c4], [.c5], [.c6], [.c7])
|
||||
3 - output([t111_var.c0], [t111_var.c1], [t111_var.c2], [t111_var.c3], [t111_var.c4], [t111_var.c5], [t111_var.c6], [t111_var.c7]), filter(nil),
|
||||
distinct([t111_var.c0], [t111_var.c1], [t111_var.c2], [t111_var.c3], [t111_var.c4], [t111_var.c5], [t111_var.c6], [t111_var.c7])
|
||||
4 - output([t111_var.c0], [t111_var.c1], [t111_var.c2], [t111_var.c3], [t111_var.c4], [t111_var.c5], [t111_var.c6], [t111_var.c7]), filter(nil),
|
||||
access([t111_var.c0], [t111_var.c1], [t111_var.c2], [t111_var.c3], [t111_var.c4], [t111_var.c5], [t111_var.c6], [t111_var.c7]), partitions(p0)
|
||||
|
||||
select /*+ use_merge(a b) */SQL_CALC_FOUND_ROWS sum(c0),sum(length(c1)),count(c2),count(c3),count(c4),count(c5),count(c6),count(c7)
|
||||
from (select /*+ USE_HASH_AGGREGATION */ distinct * from t111_var) order by c1 limit 1;
|
||||
+-------------+-----------------+-----------+-----------+-----------+-----------+-----------+-----------+
|
||||
| sum(c0) | sum(length(c1)) | count(c2) | count(c3) | count(c4) | count(c5) | count(c6) | count(c7) |
|
||||
+-------------+-----------------+-----------+-----------+-----------+-----------+-----------+-----------+
|
||||
| 28444444928 | 2048000 | 512 | 512 | 512 | 512 | 512 | 512 |
|
||||
+-------------+-----------------+-----------+-----------+-----------+-----------+-----------+-----------+
|
||||
|
||||
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
drop table t111_var;
|
||||
@ -0,0 +1,430 @@
|
||||
drop tenant dump_tenant force;
|
||||
drop resource pool new_pool1;
|
||||
drop resource unit new_box1;
|
||||
set global parallel_max_servers=10;
|
||||
set global parallel_servers_target=10;
|
||||
alter system set _sort_area_size='2M';
|
||||
alter system set _hash_area_size='4M';
|
||||
drop table t11_set;
|
||||
drop table t22_set;
|
||||
drop table t111_var;
|
||||
drop table t333_var;
|
||||
create table t11_set(c1 int,c2 int);
|
||||
create table t22_set(c1 int,c2 int);
|
||||
insert into t11_set values(null,null);
|
||||
insert into t11_set values(1,1);
|
||||
insert into t11_set values(5,5);
|
||||
insert into t11_set values(1,1);
|
||||
insert into t11_set values(5,5);
|
||||
insert into t11_set values(12,12);
|
||||
insert into t11_set values(12,12);
|
||||
insert into t11_set values(22,22);
|
||||
insert into t11_set values(26,26);
|
||||
insert into t11_set values(22,22);
|
||||
insert into t11_set values(26,26);
|
||||
insert into t22_set select * from t11_set;
|
||||
create table t111_var(c0 bigint primary key,c1 varchar(4000), c2 varchar(4000), c3 varchar(4000), c4 varchar(4000), c5 varchar(4000),c6 varchar(4000), c7 longtext);
|
||||
insert into t111_var values(1,repeat('ab',1000),repeat('ab',1000),repeat('ab',1000),repeat('ab',1000),repeat('ab',1000),repeat('ab',1000),repeat('a',4000));
|
||||
insert into t111_var select c0+1,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
insert into t111_var select c0+10,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
insert into t111_var select c0+100,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
insert into t111_var select c0+1000,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
insert into t111_var select c0+10000,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
insert into t111_var select c0+100000,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
insert into t111_var select c0+1000000,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
insert into t111_var select c0+10000000,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
insert into t111_var select c0+100000000,c1,c2,c3,c4,c5,c6,c7 from t111_var;
|
||||
commit;
|
||||
create table t333_var(c0 bigint ,c1 varchar(4000), c2 varchar(4000), c3 varchar(4000), c4 varchar(4000), c5 varchar(4000),c6 varchar(4000), c7 longtext);
|
||||
insert into t333_var values(1,repeat('ab',1000),repeat('ab',1000),repeat('ab',1000),repeat('ab',1000),repeat('ab',1000),repeat('ab',1000),repeat('a',4000));
|
||||
insert into t333_var select c0+1,c1,c2,c3,c4,c5,c6,c7 from t333_var;
|
||||
insert into t333_var select c0+10,c1,c2,c3,c4,c5,c6,c7 from t333_var;
|
||||
insert into t333_var select c0+100,c1,c2,c3,c4,c5,c6,c7 from t333_var;
|
||||
insert into t333_var select c0+1000,c1,c2,c3,c4,c5,c6,c7 from t333_var;
|
||||
insert into t333_var select c0+10000,c1,c2,c3,c4,c5,c6,c7 from t333_var;
|
||||
insert into t333_var select c0+100000,c1,c2,c3,c4,c5,c6,c7 from t333_var;
|
||||
insert into t333_var select c0+1000000,c1,c2,c3,c4,c5,c6,c7 from t333_var;
|
||||
insert into t333_var select c0+10000000,c1,c2,c3,c4,c5,c6,c7 from t333_var;
|
||||
insert into t333_var select c0+100000000,c1,c2,c3,c4,c5,c6,c7 from t333_var;
|
||||
insert into t333_var values(null,null,null,null,null,null,null,null);
|
||||
commit;
|
||||
result_format: 4
|
||||
explain_protocol: 1
|
||||
EXPLAIN BASIC select c1,c2 from t11_set union select c1,c2 from t22_set where c1 > 5 and c1 != 12;
|
||||
Query Plan
|
||||
================================
|
||||
|ID|OPERATOR |NAME |
|
||||
--------------------------------
|
||||
|0 |HASH UNION DISTINCT| |
|
||||
|1 | TABLE SCAN |t11_set|
|
||||
|2 | TABLE SCAN |t22_set|
|
||||
================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([UNION([1])], [UNION([2])]), filter(nil)
|
||||
1 - output([t11_set.c1], [t11_set.c2]), filter(nil),
|
||||
access([t11_set.c1], [t11_set.c2]), partitions(p0)
|
||||
2 - output([t22_set.c1], [t22_set.c2]), filter([t22_set.c1 > 5], [t22_set.c1 != 12]),
|
||||
access([t22_set.c1], [t22_set.c2]), partitions(p0)
|
||||
|
||||
select c1,c2 from t11_set union select c1,c2 from t22_set where c1 > 5 and c1 != 12;
|
||||
+------+------+
|
||||
| c1 | c2 |
|
||||
+------+------+
|
||||
| NULL | NULL |
|
||||
| 1 | 1 |
|
||||
| 5 | 5 |
|
||||
| 12 | 12 |
|
||||
| 22 | 22 |
|
||||
| 26 | 26 |
|
||||
+------+------+
|
||||
EXPLAIN BASIC select c1,c2 from t11_set intersect select c1,c2 from t22_set where c1 > 5 and c1 != 12;
|
||||
Query Plan
|
||||
=====================================
|
||||
|ID|OPERATOR |NAME |
|
||||
-------------------------------------
|
||||
|0 |MERGE INTERSECT DISTINCT| |
|
||||
|1 | SORT | |
|
||||
|2 | TABLE SCAN |t11_set|
|
||||
|3 | SORT | |
|
||||
|4 | TABLE SCAN |t22_set|
|
||||
=====================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([INTERSECT([1])], [INTERSECT([2])]), filter(nil)
|
||||
1 - output([t11_set.c1], [t11_set.c2]), filter(nil), sort_keys([t11_set.c1, ASC], [t11_set.c2, ASC])
|
||||
2 - output([t11_set.c1], [t11_set.c2]), filter([t11_set.c1 > 5], [t11_set.c1 != 12]),
|
||||
access([t11_set.c1], [t11_set.c2]), partitions(p0)
|
||||
3 - output([t22_set.c1], [t22_set.c2]), filter(nil), sort_keys([t22_set.c1, ASC], [t22_set.c2, ASC])
|
||||
4 - output([t22_set.c1], [t22_set.c2]), filter([t22_set.c1 > 5], [t22_set.c1 != 12]),
|
||||
access([t22_set.c1], [t22_set.c2]), partitions(p0)
|
||||
|
||||
select c1,c2 from t11_set intersect select c1,c2 from t22_set where c1 > 5 and c1 != 12;
|
||||
+------+------+
|
||||
| c1 | c2 |
|
||||
+------+------+
|
||||
| 22 | 22 |
|
||||
| 26 | 26 |
|
||||
+------+------+
|
||||
EXPLAIN BASIC select c1,c2 from t11_set minus select c1,c2 from t22_set where c1 > 5 and c1 != 12;
|
||||
Query Plan
|
||||
=================================
|
||||
|ID|OPERATOR |NAME |
|
||||
---------------------------------
|
||||
|0 |HASH EXCEPT DISTINCT| |
|
||||
|1 | TABLE SCAN |t11_set|
|
||||
|2 | TABLE SCAN |t22_set|
|
||||
=================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([EXCEPT([1])], [EXCEPT([2])]), filter(nil)
|
||||
1 - output([t11_set.c1], [t11_set.c2]), filter(nil),
|
||||
access([t11_set.c1], [t11_set.c2]), partitions(p0)
|
||||
2 - output([t22_set.c1], [t22_set.c2]), filter([t22_set.c1 > 5], [t22_set.c1 != 12]),
|
||||
access([t22_set.c1], [t22_set.c2]), partitions(p0)
|
||||
|
||||
select c1,c2 from t11_set minus select c1,c2 from t22_set where c1 > 5 and c1 != 12;
|
||||
+------+------+
|
||||
| c1 | c2 |
|
||||
+------+------+
|
||||
| NULL | NULL |
|
||||
| 1 | 1 |
|
||||
| 5 | 5 |
|
||||
| 12 | 12 |
|
||||
+------+------+
|
||||
|
||||
EXPLAIN BASIC select c1,c2 from t11_set where c1 > 5 and c1 != 12 union select c1,c2 from t22_set;
|
||||
Query Plan
|
||||
================================
|
||||
|ID|OPERATOR |NAME |
|
||||
--------------------------------
|
||||
|0 |HASH UNION DISTINCT| |
|
||||
|1 | TABLE SCAN |t11_set|
|
||||
|2 | TABLE SCAN |t22_set|
|
||||
================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([UNION([1])], [UNION([2])]), filter(nil)
|
||||
1 - output([t11_set.c1], [t11_set.c2]), filter([t11_set.c1 > 5], [t11_set.c1 != 12]),
|
||||
access([t11_set.c1], [t11_set.c2]), partitions(p0)
|
||||
2 - output([t22_set.c1], [t22_set.c2]), filter(nil),
|
||||
access([t22_set.c1], [t22_set.c2]), partitions(p0)
|
||||
|
||||
select c1,c2 from t11_set where c1 > 5 and c1 != 12 union select c1,c2 from t22_set;
|
||||
+------+------+
|
||||
| c1 | c2 |
|
||||
+------+------+
|
||||
| 22 | 22 |
|
||||
| 26 | 26 |
|
||||
| NULL | NULL |
|
||||
| 1 | 1 |
|
||||
| 5 | 5 |
|
||||
| 12 | 12 |
|
||||
+------+------+
|
||||
EXPLAIN BASIC select c1,c2 from t11_set where c1 > 5 and c1 != 12 intersect select c1,c2 from t22_set;
|
||||
Query Plan
|
||||
=====================================
|
||||
|ID|OPERATOR |NAME |
|
||||
-------------------------------------
|
||||
|0 |MERGE INTERSECT DISTINCT| |
|
||||
|1 | SORT | |
|
||||
|2 | TABLE SCAN |t11_set|
|
||||
|3 | SORT | |
|
||||
|4 | TABLE SCAN |t22_set|
|
||||
=====================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([INTERSECT([1])], [INTERSECT([2])]), filter(nil)
|
||||
1 - output([t11_set.c1], [t11_set.c2]), filter(nil), sort_keys([t11_set.c1, ASC], [t11_set.c2, ASC])
|
||||
2 - output([t11_set.c1], [t11_set.c2]), filter([t11_set.c1 > 5], [t11_set.c1 != 12]),
|
||||
access([t11_set.c1], [t11_set.c2]), partitions(p0)
|
||||
3 - output([t22_set.c1], [t22_set.c2]), filter(nil), sort_keys([t22_set.c1, ASC], [t22_set.c2, ASC])
|
||||
4 - output([t22_set.c1], [t22_set.c2]), filter([t22_set.c1 > 5], [t22_set.c1 != 12]),
|
||||
access([t22_set.c1], [t22_set.c2]), partitions(p0)
|
||||
|
||||
select c1,c2 from t11_set where c1 > 5 and c1 != 12 intersect select c1,c2 from t22_set;
|
||||
+------+------+
|
||||
| c1 | c2 |
|
||||
+------+------+
|
||||
| 22 | 22 |
|
||||
| 26 | 26 |
|
||||
+------+------+
|
||||
EXPLAIN BASIC select c1,c2 from t11_set where c1 > 5 and c1 != 12 minus select c1,c2 from t22_set;
|
||||
Query Plan
|
||||
==================================
|
||||
|ID|OPERATOR |NAME |
|
||||
----------------------------------
|
||||
|0 |MERGE EXCEPT DISTINCT| |
|
||||
|1 | SORT | |
|
||||
|2 | TABLE SCAN |t11_set|
|
||||
|3 | SORT | |
|
||||
|4 | TABLE SCAN |t22_set|
|
||||
==================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([EXCEPT([1])], [EXCEPT([2])]), filter(nil)
|
||||
1 - output([t11_set.c1], [t11_set.c2]), filter(nil), sort_keys([t11_set.c1, ASC], [t11_set.c2, ASC])
|
||||
2 - output([t11_set.c1], [t11_set.c2]), filter([t11_set.c1 > 5], [t11_set.c1 != 12]),
|
||||
access([t11_set.c1], [t11_set.c2]), partitions(p0)
|
||||
3 - output([t22_set.c1], [t22_set.c2]), filter(nil), sort_keys([t22_set.c1, ASC], [t22_set.c2, ASC])
|
||||
4 - output([t22_set.c1], [t22_set.c2]), filter([t22_set.c1 > 5], [t22_set.c1 != 12]),
|
||||
access([t22_set.c1], [t22_set.c2]), partitions(p0)
|
||||
|
||||
select c1,c2 from t11_set where c1 > 5 and c1 != 12 minus select c1,c2 from t22_set;
|
||||
+------+------+
|
||||
| c1 | c2 |
|
||||
+------+------+
|
||||
+------+------+
|
||||
|
||||
EXPLAIN BASIC select c1,c2 from t11_set union select c1,c2 from t22_set where c1 <22;
|
||||
Query Plan
|
||||
================================
|
||||
|ID|OPERATOR |NAME |
|
||||
--------------------------------
|
||||
|0 |HASH UNION DISTINCT| |
|
||||
|1 | TABLE SCAN |t11_set|
|
||||
|2 | TABLE SCAN |t22_set|
|
||||
================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([UNION([1])], [UNION([2])]), filter(nil)
|
||||
1 - output([t11_set.c1], [t11_set.c2]), filter(nil),
|
||||
access([t11_set.c1], [t11_set.c2]), partitions(p0)
|
||||
2 - output([t22_set.c1], [t22_set.c2]), filter([t22_set.c1 < 22]),
|
||||
access([t22_set.c1], [t22_set.c2]), partitions(p0)
|
||||
|
||||
select c1,c2 from t11_set union select c1,c2 from t22_set where c1 <22;
|
||||
+------+------+
|
||||
| c1 | c2 |
|
||||
+------+------+
|
||||
| NULL | NULL |
|
||||
| 1 | 1 |
|
||||
| 5 | 5 |
|
||||
| 12 | 12 |
|
||||
| 22 | 22 |
|
||||
| 26 | 26 |
|
||||
+------+------+
|
||||
EXPLAIN BASIC select c1,c2 from t11_set intersect select c1,c2 from t22_set where c1 <22;
|
||||
Query Plan
|
||||
====================================
|
||||
|ID|OPERATOR |NAME |
|
||||
------------------------------------
|
||||
|0 |HASH INTERSECT DISTINCT| |
|
||||
|1 | TABLE SCAN |t11_set|
|
||||
|2 | TABLE SCAN |t22_set|
|
||||
====================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([INTERSECT([1])], [INTERSECT([2])]), filter(nil)
|
||||
1 - output([t11_set.c1], [t11_set.c2]), filter([t11_set.c1 < 22]),
|
||||
access([t11_set.c1], [t11_set.c2]), partitions(p0)
|
||||
2 - output([t22_set.c1], [t22_set.c2]), filter([t22_set.c1 < 22]),
|
||||
access([t22_set.c1], [t22_set.c2]), partitions(p0)
|
||||
|
||||
select c1,c2 from t11_set intersect select c1,c2 from t22_set where c1 <22;
|
||||
+------+------+
|
||||
| c1 | c2 |
|
||||
+------+------+
|
||||
| 1 | 1 |
|
||||
| 5 | 5 |
|
||||
| 12 | 12 |
|
||||
+------+------+
|
||||
EXPLAIN BASIC select c1,c2 from t11_set minus select c1,c2 from t22_set where c1 <22;
|
||||
Query Plan
|
||||
=================================
|
||||
|ID|OPERATOR |NAME |
|
||||
---------------------------------
|
||||
|0 |HASH EXCEPT DISTINCT| |
|
||||
|1 | TABLE SCAN |t11_set|
|
||||
|2 | TABLE SCAN |t22_set|
|
||||
=================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([EXCEPT([1])], [EXCEPT([2])]), filter(nil)
|
||||
1 - output([t11_set.c1], [t11_set.c2]), filter(nil),
|
||||
access([t11_set.c1], [t11_set.c2]), partitions(p0)
|
||||
2 - output([t22_set.c1], [t22_set.c2]), filter([t22_set.c1 < 22]),
|
||||
access([t22_set.c1], [t22_set.c2]), partitions(p0)
|
||||
|
||||
select c1,c2 from t11_set minus select c1,c2 from t22_set where c1 <22;
|
||||
+------+------+
|
||||
| c1 | c2 |
|
||||
+------+------+
|
||||
| NULL | NULL |
|
||||
| 22 | 22 |
|
||||
| 26 | 26 |
|
||||
+------+------+
|
||||
|
||||
## dump
|
||||
set ob_query_timeout=30000000;
|
||||
EXPLAIN BASIC select /*+ use_merge(a b) */SQL_CALC_FOUND_ROWS sum(c0),sum(length(c1)),count(c2),count(c3),count(c4),count(c5),count(c6),count(c7)
|
||||
from (select * from t111_var a union select * from t333_var b) order by c1 limit 1;
|
||||
Query Plan
|
||||
================================
|
||||
|ID|OPERATOR |NAME|
|
||||
--------------------------------
|
||||
|0 |LIMIT | |
|
||||
|1 | SCALAR GROUP BY | |
|
||||
|2 | SUBPLAN SCAN | |
|
||||
|3 | HASH UNION DISTINCT| |
|
||||
|4 | TABLE SCAN |a |
|
||||
|5 | TABLE SCAN |b |
|
||||
================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([T_FUN_SUM(.c0)], [T_FUN_SUM(length(.c1))], [T_FUN_COUNT(.c2)], [T_FUN_COUNT(.c3)], [T_FUN_COUNT(.c4)], [T_FUN_COUNT(.c5)], [T_FUN_COUNT(.c6)], [T_FUN_COUNT(.c7)]), filter(nil), limit(1), offset(nil)
|
||||
1 - output([T_FUN_SUM(.c0)], [T_FUN_SUM(length(.c1))], [T_FUN_COUNT(.c2)], [T_FUN_COUNT(.c3)], [T_FUN_COUNT(.c4)], [T_FUN_COUNT(.c5)], [T_FUN_COUNT(.c6)], [T_FUN_COUNT(.c7)]), filter(nil),
|
||||
group(nil), agg_func([T_FUN_SUM(.c0)], [T_FUN_SUM(length(.c1))], [T_FUN_COUNT(.c2)], [T_FUN_COUNT(.c3)], [T_FUN_COUNT(.c4)], [T_FUN_COUNT(.c5)], [T_FUN_COUNT(.c6)], [T_FUN_COUNT(.c7)])
|
||||
2 - output([.c0], [.c2], [.c3], [.c4], [.c5], [.c6], [.c7], [length(.c1)]), filter(nil),
|
||||
access([.c0], [.c1], [.c2], [.c3], [.c4], [.c5], [.c6], [.c7])
|
||||
3 - output([UNION([1])], [UNION([2])], [UNION([3])], [UNION([4])], [UNION([5])], [UNION([6])], [UNION([7])], [UNION([8])]), filter(nil)
|
||||
4 - output([a.c0], [a.c1], [a.c2], [a.c3], [a.c4], [a.c5], [a.c6], [a.c7]), filter(nil),
|
||||
access([a.c0], [a.c1], [a.c2], [a.c3], [a.c4], [a.c5], [a.c6], [a.c7]), partitions(p0)
|
||||
5 - output([b.c0], [b.c1], [b.c2], [b.c3], [b.c4], [b.c5], [b.c6], [b.c7]), filter(nil),
|
||||
access([b.c0], [b.c1], [b.c2], [b.c3], [b.c4], [b.c5], [b.c6], [b.c7]), partitions(p0)
|
||||
|
||||
select /*+ use_merge(a b) */SQL_CALC_FOUND_ROWS sum(c0),sum(length(c1)),count(c2),count(c3),count(c4),count(c5),count(c6),count(c7)
|
||||
from (select * from t111_var a union select * from t333_var b) order by c1 limit 1;
|
||||
+-------------+-----------------+-----------+-----------+-----------+-----------+-----------+-----------+
|
||||
| sum(c0) | sum(length(c1)) | count(c2) | count(c3) | count(c4) | count(c5) | count(c6) | count(c7) |
|
||||
+-------------+-----------------+-----------+-----------+-----------+-----------+-----------+-----------+
|
||||
| 28444444928 | 1024000 | 512 | 512 | 512 | 512 | 512 | 512 |
|
||||
+-------------+-----------------+-----------+-----------+-----------+-----------+-----------+-----------+
|
||||
|
||||
EXPLAIN BASIC select /*+ use_merge(a b) */SQL_CALC_FOUND_ROWS sum(c0),sum(length(c1)),count(c2),count(c3),count(c4),count(c5),count(c6),count(c7)
|
||||
from (select * from t111_var a intersect select * from t333_var b) order by c1 limit 1;
|
||||
Query Plan
|
||||
====================================
|
||||
|ID|OPERATOR |NAME|
|
||||
------------------------------------
|
||||
|0 |LIMIT | |
|
||||
|1 | SCALAR GROUP BY | |
|
||||
|2 | SUBPLAN SCAN | |
|
||||
|3 | HASH INTERSECT DISTINCT| |
|
||||
|4 | TABLE SCAN |b |
|
||||
|5 | TABLE SCAN |a |
|
||||
====================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([T_FUN_SUM(.c0)], [T_FUN_SUM(length(.c1))], [T_FUN_COUNT(.c2)], [T_FUN_COUNT(.c3)], [T_FUN_COUNT(.c4)], [T_FUN_COUNT(.c5)], [T_FUN_COUNT(.c6)], [T_FUN_COUNT(.c7)]), filter(nil), limit(1), offset(nil)
|
||||
1 - output([T_FUN_SUM(.c0)], [T_FUN_SUM(length(.c1))], [T_FUN_COUNT(.c2)], [T_FUN_COUNT(.c3)], [T_FUN_COUNT(.c4)], [T_FUN_COUNT(.c5)], [T_FUN_COUNT(.c6)], [T_FUN_COUNT(.c7)]), filter(nil),
|
||||
group(nil), agg_func([T_FUN_SUM(.c0)], [T_FUN_SUM(length(.c1))], [T_FUN_COUNT(.c2)], [T_FUN_COUNT(.c3)], [T_FUN_COUNT(.c4)], [T_FUN_COUNT(.c5)], [T_FUN_COUNT(.c6)], [T_FUN_COUNT(.c7)])
|
||||
2 - output([.c0], [.c2], [.c3], [.c4], [.c5], [.c6], [.c7], [length(.c1)]), filter(nil),
|
||||
access([.c0], [.c1], [.c2], [.c3], [.c4], [.c5], [.c6], [.c7])
|
||||
3 - output([INTERSECT([1])], [INTERSECT([2])], [INTERSECT([3])], [INTERSECT([4])], [INTERSECT([5])], [INTERSECT([6])], [INTERSECT([7])], [INTERSECT([8])]), filter(nil)
|
||||
4 - output([b.c0], [b.c1], [b.c2], [b.c3], [b.c4], [b.c5], [b.c6], [b.c7]), filter(nil),
|
||||
access([b.c0], [b.c1], [b.c2], [b.c3], [b.c4], [b.c5], [b.c6], [b.c7]), partitions(p0)
|
||||
5 - output([a.c0], [a.c1], [a.c2], [a.c3], [a.c4], [a.c5], [a.c6], [a.c7]), filter(nil),
|
||||
access([a.c0], [a.c1], [a.c2], [a.c3], [a.c4], [a.c5], [a.c6], [a.c7]), partitions(p0)
|
||||
|
||||
select /*+ use_merge(a b) */SQL_CALC_FOUND_ROWS sum(c0),sum(length(c1)),count(c2),count(c3),count(c4),count(c5),count(c6),count(c7)
|
||||
from (select * from t111_var a intersect select * from t333_var b) order by c1 limit 1;
|
||||
+-------------+-----------------+-----------+-----------+-----------+-----------+-----------+-----------+
|
||||
| sum(c0) | sum(length(c1)) | count(c2) | count(c3) | count(c4) | count(c5) | count(c6) | count(c7) |
|
||||
+-------------+-----------------+-----------+-----------+-----------+-----------+-----------+-----------+
|
||||
| 28444444928 | 1024000 | 512 | 512 | 512 | 512 | 512 | 512 |
|
||||
+-------------+-----------------+-----------+-----------+-----------+-----------+-----------+-----------+
|
||||
|
||||
EXPLAIN BASIC select /*+ use_merge(a b) */SQL_CALC_FOUND_ROWS sum(c0),sum(length(c1)),count(c2),count(c3),count(c4),count(c5),count(c6),count(c7)
|
||||
from (select * from t111_var a minus select * from t333_var b) order by c1 limit 1;
|
||||
Query Plan
|
||||
=================================
|
||||
|ID|OPERATOR |NAME|
|
||||
---------------------------------
|
||||
|0 |LIMIT | |
|
||||
|1 | SCALAR GROUP BY | |
|
||||
|2 | SUBPLAN SCAN | |
|
||||
|3 | HASH EXCEPT DISTINCT| |
|
||||
|4 | TABLE SCAN |a |
|
||||
|5 | TABLE SCAN |b |
|
||||
=================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([T_FUN_SUM(.c0)], [T_FUN_SUM(length(.c1))], [T_FUN_COUNT(.c2)], [T_FUN_COUNT(.c3)], [T_FUN_COUNT(.c4)], [T_FUN_COUNT(.c5)], [T_FUN_COUNT(.c6)], [T_FUN_COUNT(.c7)]), filter(nil), limit(1), offset(nil)
|
||||
1 - output([T_FUN_SUM(.c0)], [T_FUN_SUM(length(.c1))], [T_FUN_COUNT(.c2)], [T_FUN_COUNT(.c3)], [T_FUN_COUNT(.c4)], [T_FUN_COUNT(.c5)], [T_FUN_COUNT(.c6)], [T_FUN_COUNT(.c7)]), filter(nil),
|
||||
group(nil), agg_func([T_FUN_SUM(.c0)], [T_FUN_SUM(length(.c1))], [T_FUN_COUNT(.c2)], [T_FUN_COUNT(.c3)], [T_FUN_COUNT(.c4)], [T_FUN_COUNT(.c5)], [T_FUN_COUNT(.c6)], [T_FUN_COUNT(.c7)])
|
||||
2 - output([.c0], [.c2], [.c3], [.c4], [.c5], [.c6], [.c7], [length(.c1)]), filter(nil),
|
||||
access([.c0], [.c1], [.c2], [.c3], [.c4], [.c5], [.c6], [.c7])
|
||||
3 - output([EXCEPT([1])], [EXCEPT([2])], [EXCEPT([3])], [EXCEPT([4])], [EXCEPT([5])], [EXCEPT([6])], [EXCEPT([7])], [EXCEPT([8])]), filter(nil)
|
||||
4 - output([a.c0], [a.c1], [a.c2], [a.c3], [a.c4], [a.c5], [a.c6], [a.c7]), filter(nil),
|
||||
access([a.c0], [a.c1], [a.c2], [a.c3], [a.c4], [a.c5], [a.c6], [a.c7]), partitions(p0)
|
||||
5 - output([b.c0], [b.c1], [b.c2], [b.c3], [b.c4], [b.c5], [b.c6], [b.c7]), filter(nil),
|
||||
access([b.c0], [b.c1], [b.c2], [b.c3], [b.c4], [b.c5], [b.c6], [b.c7]), partitions(p0)
|
||||
|
||||
select /*+ use_merge(a b) */SQL_CALC_FOUND_ROWS sum(c0),sum(length(c1)),count(c2),count(c3),count(c4),count(c5),count(c6),count(c7)
|
||||
from (select * from t111_var a minus select * from t333_var b) order by c1 limit 1;
|
||||
+---------+-----------------+-----------+-----------+-----------+-----------+-----------+-----------+
|
||||
| sum(c0) | sum(length(c1)) | count(c2) | count(c3) | count(c4) | count(c5) | count(c6) | count(c7) |
|
||||
+---------+-----------------+-----------+-----------+-----------+-----------+-----------+-----------+
|
||||
| NULL | NULL | 0 | 0 | 0 | 0 | 0 | 0 |
|
||||
+---------+-----------------+-----------+-----------+-----------+-----------+-----------+-----------+
|
||||
|
||||
explain_protocol: 0
|
||||
select operation_type,
|
||||
case when sum(optimal_executions)>0 then 1 else 0 end pass1,
|
||||
case when sum(onepass_executions)>0 then 1 else 0 end pass2,
|
||||
case when sum(multipasses_executions)>0 then 1 else 0 end pass3
|
||||
from oceanbase.gv$sql_workarea where con_id =xxx group by operation_type order by 1,2,3,4;
|
||||
+--------------------+-------+-------+-------+
|
||||
| operation_type | pass1 | pass2 | pass3 |
|
||||
+--------------------+-------+-------+-------+
|
||||
| PHY_HASH_EXCEPT | 0 | 1 | 0 |
|
||||
| PHY_HASH_INTERSECT | 0 | 1 | 0 |
|
||||
| PHY_HASH_UNION | 0 | 1 | 0 |
|
||||
+--------------------+-------+-------+-------+
|
||||
|
||||
drop tenant dump_tenant force;
|
||||
drop resource pool new_pool1;
|
||||
drop resource unit new_box1;
|
||||
@ -0,0 +1,99 @@
|
||||
result_format: 4
|
||||
explain_protocol: 0
|
||||
|
||||
|
||||
|
||||
drop table if exists t1;
|
||||
drop table if exists t2;
|
||||
create table t1(c1 int,c2 int,c3 int);
|
||||
create table t2(c1 int,c2 int,c3 int);
|
||||
|
||||
insert into t1 values(1,2,3);
|
||||
insert into t1 values(1,2,3);
|
||||
insert into t1 values(0,2,3);
|
||||
insert into t1 values(2,2,3);
|
||||
insert into t1 values(3,2,3);
|
||||
|
||||
insert into t2 values(2,2,3);
|
||||
insert into t2 values(2,2,3);
|
||||
insert into t2 values(0,2,3);
|
||||
insert into t2 values(1,2,3);
|
||||
insert into t2 values(null,2,3);
|
||||
commit;
|
||||
|
||||
|
||||
explain_protocol: 2
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
explain select * from t1,t2;
|
||||
Query Plan
|
||||
===================================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
---------------------------------------------------
|
||||
|0 |NESTED-LOOP JOIN CARTESIAN| |25 |95 |
|
||||
|1 | TABLE SCAN |t1 |5 |37 |
|
||||
|2 | MATERIAL | |5 |40 |
|
||||
|3 | TABLE SCAN |t2 |5 |37 |
|
||||
===================================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2], [t1.c3], [t2.c1], [t2.c2], [t2.c3]), filter(nil),
|
||||
conds(nil), nl_params_(nil)
|
||||
1 - output([t1.c1], [t1.c2], [t1.c3]), filter(nil),
|
||||
access([t1.c1], [t1.c2], [t1.c3]), partitions(p0)
|
||||
2 - output([t2.c1], [t2.c2], [t2.c3]), filter(nil)
|
||||
3 - output([t2.c1], [t2.c2], [t2.c3]), filter(nil),
|
||||
access([t2.c1], [t2.c2], [t2.c3]), partitions(p0)
|
||||
|
||||
EXPLAIN select * from t1,t2;
|
||||
Query Plan
|
||||
===================================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
---------------------------------------------------
|
||||
|0 |NESTED-LOOP JOIN CARTESIAN| |25 |95 |
|
||||
|1 | TABLE SCAN |t1 |5 |37 |
|
||||
|2 | MATERIAL | |5 |40 |
|
||||
|3 | TABLE SCAN |t2 |5 |37 |
|
||||
===================================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2], [t1.c3], [t2.c1], [t2.c2], [t2.c3]), filter(nil),
|
||||
conds(nil), nl_params_(nil)
|
||||
1 - output([t1.c1], [t1.c2], [t1.c3]), filter(nil),
|
||||
access([t1.c1], [t1.c2], [t1.c3]), partitions(p0)
|
||||
2 - output([t2.c1], [t2.c2], [t2.c3]), filter(nil)
|
||||
3 - output([t2.c1], [t2.c2], [t2.c3]), filter(nil),
|
||||
access([t2.c1], [t2.c2], [t2.c3]), partitions(p0)
|
||||
|
||||
select * from t1,t2;
|
||||
+------+------+------+------+------+------+
|
||||
| c1 | c2 | c3 | c1 | c2 | c3 |
|
||||
+------+------+------+------+------+------+
|
||||
| 1 | 2 | 3 | 2 | 2 | 3 |
|
||||
| 1 | 2 | 3 | 2 | 2 | 3 |
|
||||
| 1 | 2 | 3 | 0 | 2 | 3 |
|
||||
| 1 | 2 | 3 | 1 | 2 | 3 |
|
||||
| 1 | 2 | 3 | NULL | 2 | 3 |
|
||||
| 1 | 2 | 3 | 2 | 2 | 3 |
|
||||
| 1 | 2 | 3 | 2 | 2 | 3 |
|
||||
| 1 | 2 | 3 | 0 | 2 | 3 |
|
||||
| 1 | 2 | 3 | 1 | 2 | 3 |
|
||||
| 1 | 2 | 3 | NULL | 2 | 3 |
|
||||
| 0 | 2 | 3 | 2 | 2 | 3 |
|
||||
| 0 | 2 | 3 | 2 | 2 | 3 |
|
||||
| 0 | 2 | 3 | 0 | 2 | 3 |
|
||||
| 0 | 2 | 3 | 1 | 2 | 3 |
|
||||
| 0 | 2 | 3 | NULL | 2 | 3 |
|
||||
| 2 | 2 | 3 | 2 | 2 | 3 |
|
||||
| 2 | 2 | 3 | 2 | 2 | 3 |
|
||||
| 2 | 2 | 3 | 0 | 2 | 3 |
|
||||
| 2 | 2 | 3 | 1 | 2 | 3 |
|
||||
| 2 | 2 | 3 | NULL | 2 | 3 |
|
||||
| 3 | 2 | 3 | 2 | 2 | 3 |
|
||||
| 3 | 2 | 3 | 2 | 2 | 3 |
|
||||
| 3 | 2 | 3 | 0 | 2 | 3 |
|
||||
| 3 | 2 | 3 | 1 | 2 | 3 |
|
||||
| 3 | 2 | 3 | NULL | 2 | 3 |
|
||||
+------+------+------+------+------+------+
|
||||
|
||||
@ -0,0 +1,71 @@
|
||||
drop table t11_set;
|
||||
drop table t22_set;
|
||||
create table t11_set(c1 int,c2 int);
|
||||
create table t22_set(c1 int,c2 int);
|
||||
insert into t11_set values(null,null);
|
||||
insert into t11_set values(1,1);
|
||||
insert into t11_set values(5,5);
|
||||
insert into t11_set values(1,1);
|
||||
insert into t11_set values(5,5);
|
||||
insert into t11_set values(12,12);
|
||||
insert into t11_set values(12,12);
|
||||
insert into t11_set values(22,22);
|
||||
insert into t11_set values(26,26);
|
||||
insert into t11_set values(22,22);
|
||||
insert into t11_set values(26,26);
|
||||
insert into t22_set select * from t11_set;
|
||||
create index idx_t11_set on t11_set(c1,c2);
|
||||
create index idx_t22_set on t22_set(c1,c2);
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
select c1,c2 from t11_set union select c1,c2 from t22_set where c1 > 5 and c1 != 12;
|
||||
c1 c2
|
||||
NULL NULL
|
||||
1 1
|
||||
5 5
|
||||
12 12
|
||||
22 22
|
||||
26 26
|
||||
select c1,c2 from t11_set intersect select c1,c2 from t22_set where c1 > 5 and c1 != 12;
|
||||
c1 c2
|
||||
22 22
|
||||
26 26
|
||||
select c1,c2 from t11_set minus select c1,c2 from t22_set where c1 > 5 and c1 != 12;
|
||||
c1 c2
|
||||
NULL NULL
|
||||
1 1
|
||||
5 5
|
||||
12 12
|
||||
select c1,c2 from t11_set where c1 > 5 and c1 != 12 union select c1,c2 from t22_set;
|
||||
c1 c2
|
||||
NULL NULL
|
||||
1 1
|
||||
5 5
|
||||
12 12
|
||||
22 22
|
||||
26 26
|
||||
select c1,c2 from t11_set where c1 > 5 and c1 != 12 intersect select c1,c2 from t22_set;
|
||||
c1 c2
|
||||
22 22
|
||||
26 26
|
||||
select c1,c2 from t11_set where c1 > 5 and c1 != 12 minus select c1,c2 from t22_set;
|
||||
c1 c2
|
||||
select c1,c2 from t11_set union select c1,c2 from t22_set where c1 <22;
|
||||
c1 c2
|
||||
NULL NULL
|
||||
1 1
|
||||
5 5
|
||||
12 12
|
||||
22 22
|
||||
26 26
|
||||
select c1,c2 from t11_set intersect select c1,c2 from t22_set where c1 <22;
|
||||
c1 c2
|
||||
1 1
|
||||
5 5
|
||||
12 12
|
||||
select c1,c2 from t11_set minus select c1,c2 from t22_set where c1 <22;
|
||||
c1 c2
|
||||
NULL NULL
|
||||
22 22
|
||||
26 26
|
||||
drop table t11_set;
|
||||
drop table t22_set;
|
||||
@ -0,0 +1,40 @@
|
||||
result_format: 4
|
||||
alter system flush plan cache global;
|
||||
|
||||
|
||||
|
||||
drop table if exists t;
|
||||
create table t(c1 int, c2 int, primary key(c1, c2));
|
||||
insert into t values(1,1);
|
||||
insert into t values(2,2);
|
||||
insert into t values(3,3);
|
||||
insert into t values(4,4);
|
||||
insert into t values(5,5);
|
||||
insert into t values(6,6);
|
||||
|
||||
alter table t partition by range(c1) (partition p0 values less than (4), partition p1 values less than MAXVALUE);
|
||||
select c2 from t partition(p1);
|
||||
+----+
|
||||
| c2 |
|
||||
+----+
|
||||
| 4 |
|
||||
| 5 |
|
||||
| 6 |
|
||||
+----+
|
||||
|
||||
explain select c2 from t partition(p1);
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t |6 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t.c2]), filter([calc_partition_id(t.c1) = ?]),
|
||||
access([t.c2], [t.c1]), partitions(p2)
|
||||
|
||||
|
||||
drop table t;
|
||||
|
||||
@ -0,0 +1,423 @@
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
drop table t3;
|
||||
drop table t4;
|
||||
drop table t5;
|
||||
create table t3(c1 int primary key,c2 int) partition by hash(c1) partitions 5;
|
||||
create table t4(c1 int primary key,c2 int) partition by hash(c1) partitions 6;
|
||||
insert into t3 values(0,0);
|
||||
insert into t3 values(1,0);
|
||||
insert into t3 values(2,1);
|
||||
insert into t3 values(3,2);
|
||||
insert into t3 values(4,3);
|
||||
insert into t3 values(5,4);
|
||||
insert into t3 values(6,5);
|
||||
insert into t4 values(1,0);
|
||||
insert into t4 values(2,1);
|
||||
insert into t4 values(3,2);
|
||||
insert into t4 values(4,3);
|
||||
insert into t4 values(5,4);
|
||||
insert into t4 values(6,5);
|
||||
insert into t4 values(7,5);
|
||||
commit;
|
||||
create table t5(c1 int primary key,c2 int);
|
||||
insert into t5 values(1,1);
|
||||
insert into t5 values(2,2);
|
||||
insert into t5 values(3,3);
|
||||
insert into t5 values(4,4);
|
||||
insert into t5 values(5,5);
|
||||
insert into t5 values(6,6);
|
||||
commit;
|
||||
create table t1(c1 int,c2 int) partition by hash(c1) partitions 5;
|
||||
create table t2(c1 int,c2 int) partition by hash(c2) partitions 6;
|
||||
insert into t1 values(1,1);
|
||||
insert into t1 values(2,2);
|
||||
insert into t1 values(3,3);
|
||||
insert into t1 values(4,4);
|
||||
insert into t1 values(5,5);
|
||||
insert into t1 values(6,6);
|
||||
insert into t2 values(1,1);
|
||||
insert into t2 values(2,2);
|
||||
insert into t2 values(3,3);
|
||||
insert into t2 values(4,4);
|
||||
insert into t2 values(5,5);
|
||||
insert into t2 values(6,6);
|
||||
commit;
|
||||
result_format: 4
|
||||
explain_protocol: 1
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
EXPLAIN BASIC select * from t3 a ;
|
||||
Query Plan
|
||||
=====================================
|
||||
|ID|OPERATOR |NAME |
|
||||
-------------------------------------
|
||||
|0 |PX COORDINATOR | |
|
||||
|1 | EXCHANGE OUT DISTR |:EX10000|
|
||||
|2 | PX PARTITION ITERATOR| |
|
||||
|3 | TABLE SCAN |a |
|
||||
=====================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([a.c1], [a.c2]), filter(nil)
|
||||
1 - output([a.c1], [a.c2]), filter(nil), dop=1
|
||||
2 - output([a.c1], [a.c2]), filter(nil)
|
||||
3 - output([a.c1], [a.c2]), filter(nil),
|
||||
access([a.c1], [a.c2]), partitions(p[0-4])
|
||||
|
||||
select * from t3 a ;
|
||||
+----+------+
|
||||
| c1 | c2 |
|
||||
+----+------+
|
||||
| 0 | 0 |
|
||||
| 5 | 4 |
|
||||
| 1 | 0 |
|
||||
| 6 | 5 |
|
||||
| 2 | 1 |
|
||||
| 3 | 2 |
|
||||
| 4 | 3 |
|
||||
+----+------+
|
||||
|
||||
##ms coord output 列与child不一致,所以后续就改成了拿数据时直接采用child_expxs
|
||||
EXPLAIN BASIC select /*+ parallel(2) NO_USE_HASH_AGGREGATION */ a.c1,a.c2+a.c1 from t3 a group by a.c1,a.c2 order by a.c2+1+a.c1;
|
||||
Query Plan
|
||||
========================================
|
||||
|ID|OPERATOR |NAME |
|
||||
----------------------------------------
|
||||
|0 |PX COORDINATOR MERGE SORT | |
|
||||
|1 | EXCHANGE OUT DISTR |:EX10000|
|
||||
|2 | SORT | |
|
||||
|3 | PX BLOCK ITERATOR | |
|
||||
|4 | TABLE SCAN |a |
|
||||
========================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([a.c1], [a.c2 + a.c1]), filter(nil), sort_keys([a.c2 + 1 + a.c1, ASC])
|
||||
1 - output([a.c1], [a.c2 + a.c1], [a.c2 + 1 + a.c1]), filter(nil), dop=2
|
||||
2 - output([a.c1], [a.c2 + a.c1], [a.c2 + 1 + a.c1]), filter(nil), sort_keys([a.c2 + 1 + a.c1, ASC])
|
||||
3 - output([a.c1], [a.c2], [a.c2 + 1 + a.c1]), filter(nil)
|
||||
4 - output([a.c1], [a.c2], [a.c2 + 1 + a.c1]), filter(nil),
|
||||
access([a.c1], [a.c2]), partitions(p[0-4])
|
||||
|
||||
select /*+ parallel(2) NO_USE_HASH_AGGREGATION */ a.c1,a.c2+a.c1 from t3 a group by a.c1,a.c2 order by a.c2+1+a.c1;
|
||||
+----+-----------+
|
||||
| c1 | a.c2+a.c1 |
|
||||
+----+-----------+
|
||||
| 0 | 0 |
|
||||
| 1 | 1 |
|
||||
| 2 | 3 |
|
||||
| 3 | 5 |
|
||||
| 4 | 7 |
|
||||
| 5 | 9 |
|
||||
| 6 | 11 |
|
||||
+----+-----------+
|
||||
|
||||
##ms receieve local order
|
||||
EXPLAIN BASIC select /*+ parallel(2) pq_distribute(a hash hash) NO_USE_HASH_AGGREGATION */ a.c1,a.c2 from t3 a right outer join t3 b on a.c2=b.c1 order by a.c1,a.c2;
|
||||
Query Plan
|
||||
==============================================
|
||||
|ID|OPERATOR |NAME |
|
||||
----------------------------------------------
|
||||
|0 |PX COORDINATOR MERGE SORT | |
|
||||
|1 | EXCHANGE OUT DISTR |:EX10002|
|
||||
|2 | SORT | |
|
||||
|3 | MERGE OUTER JOIN | |
|
||||
|4 | EXCHANGE IN MERGE SORT DISTR| |
|
||||
|5 | EXCHANGE OUT DISTR (HASH) |:EX10000|
|
||||
|6 | PX BLOCK ITERATOR | |
|
||||
|7 | TABLE SCAN |b |
|
||||
|8 | SORT | |
|
||||
|9 | EXCHANGE IN DISTR | |
|
||||
|10| EXCHANGE OUT DISTR (HASH) |:EX10001|
|
||||
|11| PX BLOCK ITERATOR | |
|
||||
|12| TABLE SCAN |a |
|
||||
==============================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([a.c1], [a.c2]), filter(nil), sort_keys([a.c1, ASC], [a.c2, ASC])
|
||||
1 - output([a.c1], [a.c2]), filter(nil), dop=2
|
||||
2 - output([a.c1], [a.c2]), filter(nil), sort_keys([a.c1, ASC], [a.c2, ASC])
|
||||
3 - output([a.c1], [a.c2]), filter(nil),
|
||||
equal_conds([a.c2 = b.c1]), other_conds(nil)
|
||||
4 - output([b.c1]), filter(nil), sort_keys([b.c1, ASC]), Local Order
|
||||
5 - (#keys=1, [b.c1]), output([b.c1]), filter(nil), dop=2
|
||||
6 - output([b.c1]), filter(nil)
|
||||
7 - output([b.c1]), filter(nil),
|
||||
access([b.c1]), partitions(p[0-4])
|
||||
8 - output([a.c1], [a.c2]), filter(nil), sort_keys([a.c2, ASC])
|
||||
9 - output([a.c1], [a.c2]), filter(nil)
|
||||
10 - (#keys=1, [a.c2]), output([a.c1], [a.c2]), filter(nil), dop=2
|
||||
11 - output([a.c1], [a.c2]), filter(nil)
|
||||
12 - output([a.c1], [a.c2]), filter(nil),
|
||||
access([a.c1], [a.c2]), partitions(p[0-4])
|
||||
|
||||
select /*+ parallel(2) pq_distribute(a hash hash) NO_USE_HASH_AGGREGATION */ a.c1,a.c2 from t3 a right outer join t3 b on a.c2=b.c1 order by a.c1,a.c2;
|
||||
+----+------+
|
||||
| c1 | c2 |
|
||||
+----+------+
|
||||
| NULL | NULL |
|
||||
| 0 | 0 |
|
||||
| 1 | 0 |
|
||||
| 2 | 1 |
|
||||
| 3 | 2 |
|
||||
| 4 | 3 |
|
||||
| 5 | 4 |
|
||||
| 6 | 5 |
|
||||
+----+------+
|
||||
EXPLAIN BASIC select /*+ parallel(2) pq_distribute(a hash hash) NO_USE_HASH_AGGREGATION */ a.c1,a.c2 from t3 a right outer join t3 b on a.c2+2=b.c1+1 order by a.c1,a.c2+2;
|
||||
Query Plan
|
||||
============================================
|
||||
|ID|OPERATOR |NAME |
|
||||
--------------------------------------------
|
||||
|0 |PX COORDINATOR MERGE SORT | |
|
||||
|1 | EXCHANGE OUT DISTR |:EX10002|
|
||||
|2 | SORT | |
|
||||
|3 | HASH OUTER JOIN | |
|
||||
|4 | EXCHANGE IN DISTR | |
|
||||
|5 | EXCHANGE OUT DISTR (HASH)|:EX10000|
|
||||
|6 | PX BLOCK ITERATOR | |
|
||||
|7 | TABLE SCAN |b |
|
||||
|8 | EXCHANGE IN DISTR | |
|
||||
|9 | EXCHANGE OUT DISTR (HASH)|:EX10001|
|
||||
|10| PX BLOCK ITERATOR | |
|
||||
|11| TABLE SCAN |a |
|
||||
============================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([a.c1], [a.c2]), filter(nil), sort_keys([a.c1, ASC], [a.c2 + 2, ASC])
|
||||
1 - output([a.c1], [a.c2], [a.c2 + 2]), filter(nil), dop=2
|
||||
2 - output([a.c1], [a.c2], [a.c2 + 2]), filter(nil), sort_keys([a.c1, ASC], [a.c2 + 2, ASC])
|
||||
3 - output([a.c1], [a.c2], [a.c2 + 2]), filter(nil),
|
||||
equal_conds([a.c2 + 2 = b.c1 + 1]), other_conds(nil)
|
||||
4 - output([b.c1 + 1]), filter(nil)
|
||||
5 - (#keys=1, [b.c1 + 1]), output([b.c1 + 1]), filter(nil), dop=2
|
||||
6 - output([b.c1 + 1]), filter(nil)
|
||||
7 - output([b.c1 + 1]), filter(nil),
|
||||
access([b.c1]), partitions(p[0-4])
|
||||
8 - output([a.c1], [a.c2], [a.c2 + 2]), filter(nil)
|
||||
9 - (#keys=1, [a.c2 + 2]), output([a.c1], [a.c2], [a.c2 + 2]), filter(nil), dop=2
|
||||
10 - output([a.c1], [a.c2], [a.c2 + 2]), filter(nil)
|
||||
11 - output([a.c1], [a.c2], [a.c2 + 2]), filter(nil),
|
||||
access([a.c1], [a.c2]), partitions(p[0-4])
|
||||
|
||||
select /*+ parallel(2) pq_distribute(a hash hash) NO_USE_HASH_AGGREGATION */ a.c1,a.c2 from t3 a right outer join t3 b on a.c2+2=b.c1+1 order by a.c1,a.c2+2;
|
||||
+----+------+
|
||||
| c1 | c2 |
|
||||
+----+------+
|
||||
| NULL | NULL |
|
||||
| 0 | 0 |
|
||||
| 1 | 0 |
|
||||
| 2 | 1 |
|
||||
| 3 | 2 |
|
||||
| 4 | 3 |
|
||||
| 5 | 4 |
|
||||
| 6 | 5 |
|
||||
+----+------+
|
||||
EXPLAIN BASIC select /*+ parallel(2) pq_distribute(a hash hash) NO_USE_HASH_AGGREGATION */ a.c1,a.c2 from t3 a right outer join t3 b on abs(a.c2)+2=b.c1 order by a.c1,a.c2+2;
|
||||
Query Plan
|
||||
==============================================
|
||||
|ID|OPERATOR |NAME |
|
||||
----------------------------------------------
|
||||
|0 |PX COORDINATOR MERGE SORT | |
|
||||
|1 | EXCHANGE OUT DISTR |:EX10002|
|
||||
|2 | SORT | |
|
||||
|3 | MERGE OUTER JOIN | |
|
||||
|4 | EXCHANGE IN MERGE SORT DISTR| |
|
||||
|5 | EXCHANGE OUT DISTR (HASH) |:EX10000|
|
||||
|6 | PX BLOCK ITERATOR | |
|
||||
|7 | TABLE SCAN |b |
|
||||
|8 | SORT | |
|
||||
|9 | EXCHANGE IN DISTR | |
|
||||
|10| EXCHANGE OUT DISTR (HASH) |:EX10001|
|
||||
|11| PX BLOCK ITERATOR | |
|
||||
|12| TABLE SCAN |a |
|
||||
==============================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([a.c1], [a.c2]), filter(nil), sort_keys([a.c1, ASC], [a.c2 + 2, ASC])
|
||||
1 - output([a.c1], [a.c2], [a.c2 + 2]), filter(nil), dop=2
|
||||
2 - output([a.c1], [a.c2], [a.c2 + 2]), filter(nil), sort_keys([a.c1, ASC], [a.c2 + 2, ASC])
|
||||
3 - output([a.c1], [a.c2], [a.c2 + 2]), filter(nil),
|
||||
equal_conds([abs(cast(a.c2, BIGINT(-1, 0))) + 2 = b.c1]), other_conds(nil)
|
||||
4 - output([b.c1]), filter(nil), sort_keys([b.c1, ASC]), Local Order
|
||||
5 - (#keys=1, [b.c1]), output([b.c1]), filter(nil), dop=2
|
||||
6 - output([b.c1]), filter(nil)
|
||||
7 - output([b.c1]), filter(nil),
|
||||
access([b.c1]), partitions(p[0-4])
|
||||
8 - output([a.c1], [a.c2], [abs(cast(a.c2, BIGINT(-1, 0))) + 2]), filter(nil), sort_keys([abs(cast(a.c2, BIGINT(-1, 0))) + 2, ASC])
|
||||
9 - output([a.c1], [a.c2], [abs(cast(a.c2, BIGINT(-1, 0))) + 2]), filter(nil)
|
||||
10 - (#keys=1, [abs(cast(a.c2, BIGINT(-1, 0))) + 2]), output([a.c1], [a.c2], [abs(cast(a.c2, BIGINT(-1, 0))) + 2]), filter(nil), dop=2
|
||||
11 - output([a.c1], [a.c2], [abs(cast(a.c2, BIGINT(-1, 0))) + 2]), filter(nil)
|
||||
12 - output([a.c1], [a.c2], [abs(cast(a.c2, BIGINT(-1, 0))) + 2]), filter(nil),
|
||||
access([a.c1], [a.c2]), partitions(p[0-4])
|
||||
|
||||
select /*+ parallel(2) pq_distribute(a hash hash) NO_USE_HASH_AGGREGATION */ a.c1,a.c2 from t3 a right outer join t3 b on abs(a.c2)+2=b.c1 order by a.c1,a.c2+2;
|
||||
+----+------+
|
||||
| c1 | c2 |
|
||||
+----+------+
|
||||
| NULL | NULL |
|
||||
| NULL | NULL |
|
||||
| 0 | 0 |
|
||||
| 1 | 0 |
|
||||
| 2 | 1 |
|
||||
| 3 | 2 |
|
||||
| 4 | 3 |
|
||||
| 5 | 4 |
|
||||
+----+------+
|
||||
|
||||
## ms receive global order subplan not supported, core, ignore
|
||||
## broadcast shuffle
|
||||
EXPLAIN BASIC select /*+ parallel(2) pq_distribute(b broadcast none) */ * from t1 a, t2 b where a.c1=b.c2 order by a.c1,b.c1;
|
||||
Query Plan
|
||||
=================================================
|
||||
|ID|OPERATOR |NAME |
|
||||
-------------------------------------------------
|
||||
|0 |PX COORDINATOR MERGE SORT | |
|
||||
|1 | EXCHANGE OUT DISTR |:EX10001|
|
||||
|2 | SORT | |
|
||||
|3 | MERGE JOIN | |
|
||||
|4 | EXCHANGE IN MERGE SORT DISTR | |
|
||||
|5 | EXCHANGE OUT DISTR (BROADCAST)|:EX10000|
|
||||
|6 | PX BLOCK ITERATOR | |
|
||||
|7 | TABLE SCAN |a |
|
||||
|8 | SORT | |
|
||||
|9 | PX BLOCK ITERATOR | |
|
||||
|10| TABLE SCAN |b |
|
||||
=================================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([a.c1], [a.c2], [b.c1], [b.c2]), filter(nil), sort_keys([a.c1, ASC], [b.c1, ASC])
|
||||
1 - output([a.c1], [a.c2], [b.c1], [b.c2]), filter(nil), dop=2
|
||||
2 - output([a.c1], [a.c2], [b.c1], [b.c2]), filter(nil), sort_keys([a.c1, ASC], [b.c1, ASC]), prefix_pos(1)
|
||||
3 - output([a.c1], [a.c2], [b.c1], [b.c2]), filter(nil),
|
||||
equal_conds([a.c1 = b.c2]), other_conds(nil)
|
||||
4 - output([a.c1], [a.c2]), filter(nil), sort_keys([a.c1, ASC]), Local Order
|
||||
5 - output([a.c1], [a.c2]), filter(nil), dop=2
|
||||
6 - output([a.c1], [a.c2]), filter(nil)
|
||||
7 - output([a.c1], [a.c2]), filter(nil),
|
||||
access([a.c1], [a.c2]), partitions(p[0-4])
|
||||
8 - output([b.c1], [b.c2]), filter(nil), sort_keys([b.c2, ASC]), local merge sort
|
||||
9 - output([b.c2], [b.c1]), filter(nil)
|
||||
10 - output([b.c2], [b.c1]), filter(nil),
|
||||
access([b.c2], [b.c1]), partitions(p[0-5])
|
||||
|
||||
select /*+ parallel(2) pq_distribute(b broadcast none) */ * from t1 a, t2 b where a.c1=b.c2 order by a.c1,b.c1;
|
||||
+------+------+------+------+
|
||||
| c1 | c2 | c1 | c2 |
|
||||
+------+------+------+------+
|
||||
| 1 | 1 | 1 | 1 |
|
||||
| 2 | 2 | 2 | 2 |
|
||||
| 3 | 3 | 3 | 3 |
|
||||
| 4 | 4 | 4 | 4 |
|
||||
| 5 | 5 | 5 | 5 |
|
||||
| 6 | 6 | 6 | 6 |
|
||||
+------+------+------+------+
|
||||
|
||||
EXPLAIN BASIC select /*+ parallel(2) pq_distribute(b broadcast none) */ * from t1 a, t2 b where a.c1+2=b.c2 + 1 order by a.c1,b.c1+2;
|
||||
Query Plan
|
||||
=================================================
|
||||
|ID|OPERATOR |NAME |
|
||||
-------------------------------------------------
|
||||
|0 |PX COORDINATOR MERGE SORT | |
|
||||
|1 | EXCHANGE OUT DISTR |:EX10001|
|
||||
|2 | SORT | |
|
||||
|3 | HASH JOIN | |
|
||||
|4 | EXCHANGE IN DISTR | |
|
||||
|5 | EXCHANGE OUT DISTR (BROADCAST)|:EX10000|
|
||||
|6 | PX BLOCK ITERATOR | |
|
||||
|7 | TABLE SCAN |a |
|
||||
|8 | PX BLOCK ITERATOR | |
|
||||
|9 | TABLE SCAN |b |
|
||||
=================================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([a.c1], [a.c2], [b.c1], [b.c2]), filter(nil), sort_keys([a.c1, ASC], [b.c1 + 2, ASC])
|
||||
1 - output([a.c1], [a.c2], [b.c1], [b.c2], [b.c1 + 2]), filter(nil), dop=2
|
||||
2 - output([a.c1], [a.c2], [b.c1], [b.c2], [b.c1 + 2]), filter(nil), sort_keys([a.c1, ASC], [b.c1 + 2, ASC])
|
||||
3 - output([a.c1], [a.c2], [b.c1], [b.c2], [b.c1 + 2]), filter(nil),
|
||||
equal_conds([a.c1 + 2 = b.c2 + 1]), other_conds(nil)
|
||||
4 - output([a.c1], [a.c2], [a.c1 + 2]), filter(nil)
|
||||
5 - output([a.c1], [a.c2], [a.c1 + 2]), filter(nil), dop=2
|
||||
6 - output([a.c1], [a.c2], [a.c1 + 2]), filter(nil)
|
||||
7 - output([a.c1], [a.c2], [a.c1 + 2]), filter(nil),
|
||||
access([a.c1], [a.c2]), partitions(p[0-4])
|
||||
8 - output([b.c2], [b.c1], [b.c2 + 1]), filter(nil)
|
||||
9 - output([b.c2], [b.c1], [b.c2 + 1]), filter(nil),
|
||||
access([b.c2], [b.c1]), partitions(p[0-5])
|
||||
|
||||
select /*+ parallel(2) pq_distribute(b broadcast none) */ * from t1 a, t2 b where a.c1+2=b.c2 + 1 order by a.c1,b.c1+2;
|
||||
+------+------+------+------+
|
||||
| c1 | c2 | c1 | c2 |
|
||||
+------+------+------+------+
|
||||
| 1 | 1 | 2 | 2 |
|
||||
| 2 | 2 | 3 | 3 |
|
||||
| 3 | 3 | 4 | 4 |
|
||||
| 4 | 4 | 5 | 5 |
|
||||
| 5 | 5 | 6 | 6 |
|
||||
+------+------+------+------+
|
||||
|
||||
EXPLAIN BASIC select /*+ use_px parallel(2) */ c2,sum(c1) from (select a.c1,b.c2 from t5 a , t5 b where a.c1=b.c2) group by c2 order by 1,2;
|
||||
Query Plan
|
||||
===================================================
|
||||
|ID|OPERATOR |NAME |
|
||||
---------------------------------------------------
|
||||
|0 |PX COORDINATOR MERGE SORT | |
|
||||
|1 | EXCHANGE OUT DISTR |:EX10002|
|
||||
|2 | MERGE GROUP BY | |
|
||||
|3 | EXCHANGE IN MERGE SORT DISTR | |
|
||||
|4 | EXCHANGE OUT DISTR (HASH) |:EX10001|
|
||||
|5 | MERGE JOIN | |
|
||||
|6 | EXCHANGE IN MERGE SORT DISTR | |
|
||||
|7 | EXCHANGE OUT DISTR (BROADCAST)|:EX10000|
|
||||
|8 | PX BLOCK ITERATOR | |
|
||||
|9 | TABLE SCAN |a |
|
||||
|10| SORT | |
|
||||
|11| PX BLOCK ITERATOR | |
|
||||
|12| TABLE SCAN |b |
|
||||
===================================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([b.c2], [T_FUN_SUM(a.c1)]), filter(nil), sort_keys([b.c2, ASC], [T_FUN_SUM(a.c1), ASC])
|
||||
1 - output([b.c2], [T_FUN_SUM(a.c1)]), filter(nil), dop=2
|
||||
2 - output([b.c2], [T_FUN_SUM(a.c1)]), filter(nil),
|
||||
group([b.c2]), agg_func([T_FUN_SUM(a.c1)])
|
||||
3 - output([b.c2], [a.c1]), filter(nil), sort_keys([b.c2, ASC])
|
||||
4 - (#keys=1, [b.c2]), output([b.c2], [a.c1]), filter(nil), dop=2
|
||||
5 - output([b.c2], [a.c1]), filter(nil),
|
||||
equal_conds([a.c1 = b.c2]), other_conds(nil)
|
||||
6 - output([a.c1]), filter(nil), sort_keys([a.c1, ASC]), Local Order
|
||||
7 - output([a.c1]), filter(nil), dop=2
|
||||
8 - output([a.c1]), filter(nil)
|
||||
9 - output([a.c1]), filter(nil),
|
||||
access([a.c1]), partitions(p0)
|
||||
10 - output([b.c2]), filter(nil), sort_keys([b.c2, ASC])
|
||||
11 - output([b.c2]), filter(nil)
|
||||
12 - output([b.c2]), filter(nil),
|
||||
access([b.c2]), partitions(p0)
|
||||
|
||||
select /*+ use_px parallel(2) */ c2,sum(c1) from (select a.c1,b.c2 from t5 a , t5 b where a.c1=b.c2) group by c2 order by 1,2;
|
||||
+------+---------+
|
||||
| c2 | sum(c1) |
|
||||
+------+---------+
|
||||
| 1 | 1 |
|
||||
| 2 | 2 |
|
||||
| 3 | 3 |
|
||||
| 4 | 4 |
|
||||
| 5 | 5 |
|
||||
| 6 | 6 |
|
||||
+------+---------+
|
||||
|
||||
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
drop table t3;
|
||||
drop table t4;
|
||||
drop table t5;
|
||||
@ -0,0 +1,479 @@
|
||||
result_format: 4
|
||||
explain_protocol: 2
|
||||
|
||||
// Case1: normal test,测试是否将带参数的case转为不带参数的case
|
||||
// Case2: 测试case表达式里面有列的情况
|
||||
// Case3: 测试空串以及NULL的情况
|
||||
alter system flush plan cache global;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
// Case1: normal test.
|
||||
// 所有带参数的case表达式都被转为不带参数的case表达式
|
||||
EXPLAIN select case 1 when 1 then 'a' when 2 then 'b' else 'c' end from dual;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN ? THEN 'a' WHEN ? THEN 'b' ELSE 'c' END]), filter(nil)
|
||||
values({CASE WHEN ? THEN 'a' WHEN ? THEN 'b' ELSE 'c' END})
|
||||
|
||||
select case 1 when 1 then 'a' when 2 then 'b' else 'c' end from dual;
|
||||
+-----------------------------------------------------+
|
||||
| case 1 when 1 then 'a' when 2 then 'b' else 'c' end |
|
||||
+-----------------------------------------------------+
|
||||
| a |
|
||||
+-----------------------------------------------------+
|
||||
// 应该命中else expr
|
||||
EXPLAIN select case 100 when 1 then 'a' when 2 then 'b' else 'c' end from dual;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN ? THEN 'a' WHEN ? THEN 'b' ELSE 'c' END]), filter(nil)
|
||||
values({CASE WHEN ? THEN 'a' WHEN ? THEN 'b' ELSE 'c' END})
|
||||
|
||||
select case 100 when 1 then 'a' when 2 then 'b' else 'c' end from dual;
|
||||
+-------------------------------------------------------+
|
||||
| case 100 when 1 then 'a' when 2 then 'b' else 'c' end |
|
||||
+-------------------------------------------------------+
|
||||
| c |
|
||||
+-------------------------------------------------------+
|
||||
|
||||
// MySQL允许各个when/then expr结果类型不一致
|
||||
// 1和'1'的类型不一致,会被加上cast,都被转为decimal再进行比较,返回'a'
|
||||
EXPLAIN select case 1 when '1' then 'a' when 2 then 'b' else 'c' end from dual;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN ? THEN 'a' WHEN ? THEN 'b' ELSE 'c' END]), filter(nil)
|
||||
values({CASE WHEN ? THEN 'a' WHEN ? THEN 'b' ELSE 'c' END})
|
||||
|
||||
select case 1 when '1' then 'a' when 2 then 'b' else 'c' end from dual;
|
||||
+-------------------------------------------------------+
|
||||
| case 1 when '1' then 'a' when 2 then 'b' else 'c' end |
|
||||
+-------------------------------------------------------+
|
||||
| a |
|
||||
+-------------------------------------------------------+
|
||||
// 第二个then 应该要加cast,返回'a'
|
||||
EXPLAIN select case 1 when 1 then 'a' when 2 then 'b' else 3 end from dual;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN ? THEN 'a' WHEN ? THEN 'b' ELSE ? END]), filter(nil)
|
||||
values({CASE WHEN ? THEN 'a' WHEN ? THEN 'b' ELSE ? END})
|
||||
|
||||
select case 1 when 1 then 'a' when 2 then 'b' else 3 end from dual;
|
||||
+---------------------------------------------------+
|
||||
| case 1 when 1 then 'a' when 2 then 'b' else 3 end |
|
||||
+---------------------------------------------------+
|
||||
| a |
|
||||
+---------------------------------------------------+
|
||||
|
||||
// 不带参数的case的测试
|
||||
// normal test
|
||||
// 应该返回'a'
|
||||
EXPLAIN select case when 1=1 then 'a' when 2 then 'b' else 'c' end from dual;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN ? THEN 'a' WHEN 2 THEN 'b' ELSE 'c' END]), filter(nil)
|
||||
values({CASE WHEN ? THEN 'a' WHEN 2 THEN 'b' ELSE 'c' END})
|
||||
|
||||
select case when 1=1 then 'a' when 2 then 'b' else 'c' end from dual;
|
||||
+-----------------------------------------------------+
|
||||
| case when 1=1 then 'a' when 2 then 'b' else 'c' end |
|
||||
+-----------------------------------------------------+
|
||||
| a |
|
||||
+-----------------------------------------------------+
|
||||
// 应该返回'c'
|
||||
EXPLAIN select case when 0=1 then 'a' when 0.0 then 'b' else 'c' end from dual;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN ? THEN 'a' WHEN ? THEN 'b' ELSE 'c' END]), filter(nil)
|
||||
values({CASE WHEN ? THEN 'a' WHEN ? THEN 'b' ELSE 'c' END})
|
||||
|
||||
select case when 0=1 then 'a' when 0.0 then 'b' else 'c' end from dual;
|
||||
+-------------------------------------------------------+
|
||||
| case when 0=1 then 'a' when 0.0 then 'b' else 'c' end |
|
||||
+-------------------------------------------------------+
|
||||
| c |
|
||||
+-------------------------------------------------------+
|
||||
|
||||
// 应该返回'a',且0='1'中要加cast
|
||||
EXPLAIN select case when 1='1' then 'a' when 2 then 'b' else 'c' end from dual;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN ? THEN 'a' WHEN 2 THEN 'b' ELSE 'c' END]), filter(nil)
|
||||
values({CASE WHEN ? THEN 'a' WHEN 2 THEN 'b' ELSE 'c' END})
|
||||
|
||||
select case when 1='1' then 'a' when 2 then 'b' else 'c' end from dual;
|
||||
+-------------------------------------------------------+
|
||||
| case when 1='1' then 'a' when 2 then 'b' else 'c' end |
|
||||
+-------------------------------------------------------+
|
||||
| a |
|
||||
+-------------------------------------------------------+
|
||||
// 应该返回'c',且0='1'中要加cast
|
||||
EXPLAIN select case when 0='1' then 'a' when 0.0 then 'b' else 'c' end from dual;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN ? THEN 'a' WHEN ? THEN 'b' ELSE 'c' END]), filter(nil)
|
||||
values({CASE WHEN ? THEN 'a' WHEN ? THEN 'b' ELSE 'c' END})
|
||||
|
||||
select case when 0='1' then 'a' when 0.0 then 'b' else 'c' end from dual;
|
||||
+---------------------------------------------------------+
|
||||
| case when 0='1' then 'a' when 0.0 then 'b' else 'c' end |
|
||||
+---------------------------------------------------------+
|
||||
| c |
|
||||
+---------------------------------------------------------+
|
||||
|
||||
explain_protocol: 0
|
||||
// Case2: 测试建表的情况
|
||||
drop table if exists t1;
|
||||
create table t1 (col_null int, col_int int, col_char char);
|
||||
insert into t1 values(null, 1, 'a');
|
||||
|
||||
explain_protocol: 2
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
alter system flush plan cache global;
|
||||
// 测试int的normal case,应该返回'a'
|
||||
EXPLAIN select case col_int when 1 then 'a' when 2 then 'b' else 'c' end from t1;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t1 |1 |36 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN t1.col_int = 1 THEN 'a' WHEN t1.col_int = 2 THEN 'b' ELSE 'c' END]), filter(nil),
|
||||
access([t1.col_int]), partitions(p0)
|
||||
|
||||
select case col_int when 1 then 'a' when 2 then 'b' else 'c' end from t1;
|
||||
+-----------------------------------------------------------+
|
||||
| case col_int when 1 then 'a' when 2 then 'b' else 'c' end |
|
||||
+-----------------------------------------------------------+
|
||||
| a |
|
||||
+-----------------------------------------------------------+
|
||||
// 测试int需要加cast的情况,第一个when需要加cast, 第二个when不需要
|
||||
EXPLAIN select case col_int when '1' then 'a' when 2 then 'b' else 'c' end from t1;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t1 |1 |36 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN cast(t1.col_int, DECIMAL(11, 0)) = ? THEN 'a' WHEN t1.col_int = 2 THEN 'b' ELSE 'c' END]), filter(nil),
|
||||
access([t1.col_int]), partitions(p0)
|
||||
|
||||
select case col_int when '1' then 'a' when 2 then 'b' else 'c' end from t1;
|
||||
+-------------------------------------------------------------+
|
||||
| case col_int when '1' then 'a' when 2 then 'b' else 'c' end |
|
||||
+-------------------------------------------------------------+
|
||||
| a |
|
||||
+-------------------------------------------------------------+
|
||||
// 测试null的情况,应该返回'c',而且没有cast出现
|
||||
EXPLAIN select case col_null when 1 then 'a' when 2 then 'b' else 'c' end from t1;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t1 |1 |36 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN t1.col_null = 1 THEN 'a' WHEN t1.col_null = 2 THEN 'b' ELSE 'c' END]), filter(nil),
|
||||
access([t1.col_null]), partitions(p0)
|
||||
|
||||
select case col_null when 1 then 'a' when 2 then 'b' else 'c' end from t1;
|
||||
+------------------------------------------------------------+
|
||||
| case col_null when 1 then 'a' when 2 then 'b' else 'c' end |
|
||||
+------------------------------------------------------------+
|
||||
| c |
|
||||
+------------------------------------------------------------+
|
||||
|
||||
// Case3: 测试空串以及NULL的情况
|
||||
// 应该返回1, MySQL没有把空串看成NULL
|
||||
EXPLAIN select case '' when '' then 1 when 'here' then 2 else 'hh' end from dual;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN ? THEN ? WHEN ? THEN ? ELSE 'hh' END]), filter(nil)
|
||||
values({CASE WHEN ? THEN ? WHEN ? THEN ? ELSE 'hh' END})
|
||||
|
||||
select case '' when '' then 1 when 'here' then 2 else 'hh' end from dual;
|
||||
+---------------------------------------------------------+
|
||||
| case '' when '' then 1 when 'here' then 2 else 'hh' end |
|
||||
+---------------------------------------------------------+
|
||||
| 1 |
|
||||
+---------------------------------------------------------+
|
||||
// 应该返回'hh'
|
||||
EXPLAIN select case NULL when NULL then 1 when 'here' then 2 else 'hh' end from dual;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN ? THEN ? WHEN ? THEN ? ELSE 'hh' END]), filter(nil)
|
||||
values({CASE WHEN ? THEN ? WHEN ? THEN ? ELSE 'hh' END})
|
||||
|
||||
select case NULL when NULL then 1 when 'here' then 2 else 'hh' end from dual;
|
||||
+-------------------------------------------------------------+
|
||||
| case NULL when NULL then 1 when 'here' then 2 else 'hh' end |
|
||||
+-------------------------------------------------------------+
|
||||
| hh |
|
||||
+-------------------------------------------------------------+
|
||||
// 应该返回1, MySQL没有把空串看成NULL
|
||||
EXPLAIN select case when '' = '' then 1 when 'here' then 2 else 'hh' end from dual;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN ? THEN ? WHEN ? THEN ? ELSE 'hh' END]), filter(nil)
|
||||
values({CASE WHEN ? THEN ? WHEN ? THEN ? ELSE 'hh' END})
|
||||
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'here'
|
||||
select case when '' = '' then 1 when 'here' then 2 else 'hh' end from dual;
|
||||
+-----------------------------------------------------------+
|
||||
| case when '' = '' then 1 when 'here' then 2 else 'hh' end |
|
||||
+-----------------------------------------------------------+
|
||||
| 1 |
|
||||
+-----------------------------------------------------------+
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'here'
|
||||
// 应该返回'hh', 因为'here'cast为double会失败,返回值应该是0
|
||||
EXPLAIN select case when NULL=NULL then 1 when 'here' then 2 else 'hh' end from dual;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |EXPRESSION| |1 |1 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN ? THEN ? WHEN ? THEN ? ELSE 'hh' END]), filter(nil)
|
||||
values({CASE WHEN ? THEN ? WHEN ? THEN ? ELSE 'hh' END})
|
||||
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'here'
|
||||
select case when NULL=NULL then 1 when 'here' then 2 else 'hh' end from dual;
|
||||
+-------------------------------------------------------------+
|
||||
| case when NULL=NULL then 1 when 'here' then 2 else 'hh' end |
|
||||
+-------------------------------------------------------------+
|
||||
| hh |
|
||||
+-------------------------------------------------------------+
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'here'
|
||||
|
||||
// Case4: 测试不同字符集,大小写问题
|
||||
drop table t1;
|
||||
create table t1 (a varchar(100) collate utf8_general_ci, cond1 varchar(100) collate utf8_bin, cond2 varchar(100) collate utf8_general_ci);
|
||||
EXPLAIN insert into t1 values('cond', 'COND', 'COND');
|
||||
Query Plan
|
||||
====================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
------------------------------------
|
||||
|0 |INSERT | |1 |1 |
|
||||
|1 | EXPRESSION| |1 |1 |
|
||||
====================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([column_conv(BIGINT UNSIGNED,PS:(-1,-1),NOT NULL,nextval(1))], [column_conv(VARCHAR,utf8mb4_general_ci,length:100,NULL,__values.a)], [column_conv(VARCHAR,utf8mb4_bin,length:100,NULL,__values.cond1)], [column_conv(VARCHAR,utf8mb4_general_ci,length:100,NULL,__values.cond2)]), filter(nil),
|
||||
columns([{t1: ({t1: (t1.__pk_increment, t1.a, t1.cond1, t1.cond2)})}]), partitions(p0)
|
||||
1 - output([__values.a], [__values.cond1], [__values.cond2]), filter(nil)
|
||||
values({'cond', 'COND', 'COND'})
|
||||
|
||||
insert into t1 values('cond', 'COND', 'COND');
|
||||
explain_protocol: 2
|
||||
// 返回Null,a和cond1以及a和cond2比较都会使用utf8_bin作为collation type(因为有aggregate collation的过程)
|
||||
EXPLAIN select case a when cond1 then '1' when cond2 then '2' end from t1;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t1 |1 |36 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN cast(t1.a, VARCHAR(1048576)) = t1.cond1 THEN '1' WHEN cast(t1.a, VARCHAR(1048576)) = cast(t1.cond2, VARCHAR(1048576)) THEN '2' ELSE NULL END]), filter(nil),
|
||||
access([t1.a], [t1.cond1], [t1.cond2]), partitions(p0)
|
||||
|
||||
select case a when cond1 then '1' when cond2 then '2' end from t1;
|
||||
+----------------------------------------------------+
|
||||
| case a when cond1 then '1' when cond2 then '2' end |
|
||||
+----------------------------------------------------+
|
||||
| NULL |
|
||||
+----------------------------------------------------+
|
||||
// 返回'neq', a和cond1比较使用的是utf8_bin
|
||||
EXPLAIN select case a when cond1 then 'eq' else 'neq' end from t1;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t1 |1 |36 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN cast(t1.a, VARCHAR(1048576)) = t1.cond1 THEN 'eq' ELSE 'neq' END]), filter(nil),
|
||||
access([t1.a], [t1.cond1]), partitions(p0)
|
||||
|
||||
select case a when cond1 then 'eq' else 'neq' end from t1;
|
||||
+--------------------------------------------+
|
||||
| case a when cond1 then 'eq' else 'neq' end |
|
||||
+--------------------------------------------+
|
||||
| neq |
|
||||
+--------------------------------------------+
|
||||
// 返回'eq', a和cond1比较使用的是utf8_general_ci
|
||||
EXPLAIN select case a when cond2 then 'eq' else 'neq' end from t1;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t1 |1 |36 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN t1.a = t1.cond2 THEN 'eq' ELSE 'neq' END]), filter(nil),
|
||||
access([t1.a], [t1.cond2]), partitions(p0)
|
||||
|
||||
select case a when cond2 then 'eq' else 'neq' end from t1;
|
||||
+--------------------------------------------+
|
||||
| case a when cond2 then 'eq' else 'neq' end |
|
||||
+--------------------------------------------+
|
||||
| eq |
|
||||
+--------------------------------------------+
|
||||
// arg case子节点也是arg case的情况测试,应该都被改为case expr(应该返回'ok')
|
||||
EXPLAIN select case case a when 'cond' then 'eq' else 'neq' end when 'eq' then 'ok' else 'not ok' end from t1;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t1 |1 |36 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([CASE WHEN CASE WHEN t1.a = 'cond' THEN 'eq' ELSE 'neq' END = 'eq' THEN 'ok' ELSE 'not ok' END]), filter(nil),
|
||||
access([t1.a]), partitions(p0)
|
||||
|
||||
select case case a when 'cond' then 'eq' else 'neq' end when 'eq' then 'ok' else 'not ok' end from t1;
|
||||
+----------------------------------------------------------------------------------------+
|
||||
| case case a when 'cond' then 'eq' else 'neq' end when 'eq' then 'ok' else 'not ok' end |
|
||||
+----------------------------------------------------------------------------------------+
|
||||
| ok |
|
||||
+----------------------------------------------------------------------------------------+
|
||||
explain_protocol: 0
|
||||
// Case5: show create view/table
|
||||
drop view if exists v1;
|
||||
drop table if exists t2;
|
||||
create view v1 as select case case a when 'cond' then 'eq' else 'neq' end when 'eq' then 'ok' else 'not ok' end from t1;
|
||||
select * from v1;
|
||||
+------------+
|
||||
| Name_exp_1 |
|
||||
+------------+
|
||||
| ok |
|
||||
+------------+
|
||||
// arg case expr的改写不应该影响show create view,结果应该还是arg case expr 而非改写后的case expr
|
||||
show create view v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE VIEW `v1` AS select (case (case `test`.`t1`.`a` when 'cond' then 'eq' else 'neq' end) when 'eq' then 'ok' else 'not ok' end) AS `Name_exp_1` from `test`.`t1` utf8mb4 utf8mb4_general_ci
|
||||
drop view v1;
|
||||
create table t2 as select case case a when 'cond' then 'eq' else 'neq' end when 'eq' then 'ok' else 'not ok' end from t1;
|
||||
select * from t2;
|
||||
+----------------------------------------------------------------------------------------+
|
||||
| case case a when 'cond' then 'eq' else 'neq' end when 'eq' then 'ok' else 'not ok' end |
|
||||
+----------------------------------------------------------------------------------------+
|
||||
| ok |
|
||||
+----------------------------------------------------------------------------------------+
|
||||
// arg case expr的改写不应该影响show create table,结果应该还是arg case expr 而非改写后的case expr
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`case case a when 'cond' then 'eq' else 'neq' end when 'eq' then 'ok' else 'not ok' end` varchar(6) NOT NULL
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10
|
||||
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
|
||||
## bugfix#https://work.aone.alibaba-inc.com/issue/37018706
|
||||
SELECT CASE 'A' WHEN 0 THEN 0 ELSE 1 END VAL;
|
||||
+-----+
|
||||
| VAL |
|
||||
+-----+
|
||||
| 0 |
|
||||
+-----+
|
||||
|
||||
alter system set _enable_static_typing_engine = false;
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,59 @@
|
||||
result_format: 4
|
||||
alter system set enable_async_syslog = false;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
drop table if exists t1;
|
||||
drop table if exists t2;
|
||||
drop table if exists t3;
|
||||
|
||||
create table t1(c1 tinyint, c2 smallint, c3 mediumint, c4 int, c5 bigint, c6 tinyint unsigned, c7 smallint unsigned, c8 mediumint unsigned, c9 int unsigned, c10 bigint unsigned, c11 float, c12 double, c13 float unsigned, c14 double unsigned);
|
||||
insert into t1 values(null,null,null,null,null,null,null,null,null,null,null,null,null,null);
|
||||
insert into t1 values(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11.1, 12.2, 13.3, 14.4);
|
||||
create table t2(c1 date, c2 time, c3 datetime, c4 timestamp, c5 year);
|
||||
insert into t2 values(null,null,null,null,null);
|
||||
insert into t2 values('0000-00-00', '12:34:56', '2019-12-25 12:34:56', '2019-12-25 12:34:56', 2020);
|
||||
create table t3(c1 char(10), c2 varchar(10), c3 binary(10), c4 varbinary(10), c5 blob, c6 text, c7 enum('','abc'), c8 set('','abc'));
|
||||
insert into t3 values(null,null,null,null,null,null,null,null);
|
||||
insert into t3 values('abc', 'abc', 'abc', 'abc', 'abc', 'abc', 'abc', 'abc');
|
||||
|
||||
|
||||
select c1, partition_key_v2(null), partition_key_v2(c1), partition_key_v2(c2), partition_key_v2(c3), partition_key_v2(c4), partition_key_v2(c5), partition_key_v2(c6), partition_key_v2(c7), partition_key_v2(c8), partition_key_v2(c9), partition_key_v2(c10), partition_key_v2(c11), partition_key_v2(c12), partition_key_v2(c13), partition_key_v2(c14) from t1;
|
||||
+------+------------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
|
||||
| c1 | partition_key_v2(null) | partition_key_v2(c1) | partition_key_v2(c2) | partition_key_v2(c3) | partition_key_v2(c4) | partition_key_v2(c5) | partition_key_v2(c6) | partition_key_v2(c7) | partition_key_v2(c8) | partition_key_v2(c9) | partition_key_v2(c10) | partition_key_v2(c11) | partition_key_v2(c12) | partition_key_v2(c13) | partition_key_v2(c14) |
|
||||
+------+------------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
|
||||
| NULL | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 |
|
||||
| 1 | 6960269033020761575 | 8089716718896805586 | 4083905729319787502 | 5173830478357570162 | 4802761344231991206 | 208465272938114760 | 3091397795597481564 | 6469252686979372057 | 5312865287321056581 | 3253817828616337504 | 7188666914263997357 | 554171766401687642 | 1209923708429642637 | 3652659264439090126 | 1116622728199546839 |
|
||||
+------+------------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
|
||||
select partition_key_v2(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14) from t1;
|
||||
+-------------------------------------------------------------------------------+
|
||||
| partition_key_v2(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14) |
|
||||
+-------------------------------------------------------------------------------+
|
||||
| 8669936285899323595 |
|
||||
| 3319342296135249634 |
|
||||
+-------------------------------------------------------------------------------+
|
||||
select c1, partition_key_v2(c1), partition_key_v2(c2), partition_key_v2(c3), partition_key_v2(c4), partition_key_v2(c5) from t2;
|
||||
+------------+----------------------+----------------------+----------------------+----------------------+----------------------+
|
||||
| c1 | partition_key_v2(c1) | partition_key_v2(c2) | partition_key_v2(c3) | partition_key_v2(c4) | partition_key_v2(c5) |
|
||||
+------------+----------------------+----------------------+----------------------+----------------------+----------------------+
|
||||
| NULL | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 |
|
||||
| 0000-00-00 | 4118494407655268559 | 7068692680032799961 | 905094948208870081 | 6483578642322323262 | 1051853082033653591 |
|
||||
+------------+----------------------+----------------------+----------------------+----------------------+----------------------+
|
||||
select partition_key_v2(c1, c2, c3, c4, c5 from t2;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'from t2' at line 1
|
||||
select c1, partition_key_v2(c1), partition_key_v2(c2), partition_key_v2(c3), partition_key_v2(c4), partition_key_v2(c5), partition_key_v2(c6), partition_key_v2(c7), partition_key_v2(c8) from t3;
|
||||
+------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
|
||||
| c1 | partition_key_v2(c1) | partition_key_v2(c2) | partition_key_v2(c3) | partition_key_v2(c4) | partition_key_v2(c5) | partition_key_v2(c6) | partition_key_v2(c7) | partition_key_v2(c8) |
|
||||
+------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
|
||||
| NULL | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 | 6960269033020761575 |
|
||||
| abc | 258901174748407223 | 258901174748407223 | 1050281475281956529 | 7076783908008484943 | 7076783908008484943 | 258901174748407223 | 4083905729319787502 | 4083905729319787502 |
|
||||
+------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
|
||||
select partition_key_v2(c1, c2, c3, c4, c5, c6, c7, c8) from t3;
|
||||
+--------------------------------------------------+
|
||||
| partition_key_v2(c1, c2, c3, c4, c5, c6, c7, c8) |
|
||||
+--------------------------------------------------+
|
||||
| 6029179996760524639 |
|
||||
| 644396205906272596 |
|
||||
+--------------------------------------------------+
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
drop table t3;
|
||||
@ -0,0 +1,667 @@
|
||||
result_format: 4
|
||||
|
||||
drop table if exists t1;
|
||||
drop table if exists t2;
|
||||
create table t1 (c1 int primary key, c2 decimal, c3 int, c4 varchar(20));
|
||||
create table t2 (c1 int primary key, c2 decimal, c3 int, c4 varchar(20));
|
||||
insert into t1 (c1, c2, c3, c4) values (1, 1, 1, 'a');
|
||||
insert into t1 (c1, c2, c3, c4) values (2, 2, null, 'a');
|
||||
insert into t1 (c1, c2, c3, c4) values (3, 3, null, 'a');
|
||||
insert into t2 (c1, c2, c3, c4) values (1, 1, 1, 'a');
|
||||
insert into t2 (c1, c2, c3, c4) values (2, 2, null, 'a');
|
||||
insert into t2 (c1, c2, c3, c4) values (3, 3, null, 'a');
|
||||
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
set ob_enable_transformation = off;
|
||||
select (1, 1) = (1, 0);
|
||||
+-----------------+
|
||||
| (1, 1) = (1, 0) |
|
||||
+-----------------+
|
||||
| 0 |
|
||||
+-----------------+
|
||||
select (1, 1) = (1, 1);
|
||||
+-----------------+
|
||||
| (1, 1) = (1, 1) |
|
||||
+-----------------+
|
||||
| 1 |
|
||||
+-----------------+
|
||||
|
||||
select 1 <=> 1;
|
||||
+---------+
|
||||
| 1 <=> 1 |
|
||||
+---------+
|
||||
| 1 |
|
||||
+---------+
|
||||
select 1 <=> 0;
|
||||
+---------+
|
||||
| 1 <=> 0 |
|
||||
+---------+
|
||||
| 0 |
|
||||
+---------+
|
||||
select 1 <=> null;
|
||||
+------------+
|
||||
| 1 <=> null |
|
||||
+------------+
|
||||
| 0 |
|
||||
+------------+
|
||||
select null <=> 1;
|
||||
+------------+
|
||||
| null <=> 1 |
|
||||
+------------+
|
||||
| 0 |
|
||||
+------------+
|
||||
select null <=> null;
|
||||
+---------------+
|
||||
| null <=> null |
|
||||
+---------------+
|
||||
| 1 |
|
||||
+---------------+
|
||||
|
||||
select (1, 1) <=> (1, 1);
|
||||
+-------------------+
|
||||
| (1, 1) <=> (1, 1) |
|
||||
+-------------------+
|
||||
| 1 |
|
||||
+-------------------+
|
||||
select (1, null) <=> (1, 1);
|
||||
+----------------------+
|
||||
| (1, null) <=> (1, 1) |
|
||||
+----------------------+
|
||||
| 0 |
|
||||
+----------------------+
|
||||
select (1, null) <=> (1, null);
|
||||
+-------------------------+
|
||||
| (1, null) <=> (1, null) |
|
||||
+-------------------------+
|
||||
| 1 |
|
||||
+-------------------------+
|
||||
select (1, null) <=> (null, null);
|
||||
+----------------------------+
|
||||
| (1, null) <=> (null, null) |
|
||||
+----------------------------+
|
||||
| 0 |
|
||||
+----------------------------+
|
||||
select (null, null) <=> (null, null);
|
||||
+-------------------------------+
|
||||
| (null, null) <=> (null, null) |
|
||||
+-------------------------------+
|
||||
| 1 |
|
||||
+-------------------------------+
|
||||
|
||||
select (select c1, c2 from t1 where c1 = 1) = (1, 1) from t2 where c1 = 1;
|
||||
+-----------------------------------------------+
|
||||
| (select c1, c2 from t1 where c1 = 1) = (1, 1) |
|
||||
+-----------------------------------------------+
|
||||
| 1 |
|
||||
+-----------------------------------------------+
|
||||
select (select c1, c2 from t1 where c1 = 1) = (c2, c1) from t2 where c1 = 1;
|
||||
+-------------------------------------------------+
|
||||
| (select c1, c2 from t1 where c1 = 1) = (c2, c1) |
|
||||
+-------------------------------------------------+
|
||||
| 1 |
|
||||
+-------------------------------------------------+
|
||||
|
||||
select (select c1 from t1 where c1 = 1) + 1 from t2 where c1 = 1;
|
||||
+--------------------------------------+
|
||||
| (select c1 from t1 where c1 = 1) + 1 |
|
||||
+--------------------------------------+
|
||||
| 2 |
|
||||
+--------------------------------------+
|
||||
select (select c1 from t1 where 1 = 0) + 1 from t2 where c1 = 1;
|
||||
+-------------------------------------+
|
||||
| (select c1 from t1 where 1 = 0) + 1 |
|
||||
+-------------------------------------+
|
||||
| NULL |
|
||||
+-------------------------------------+
|
||||
|
||||
select c2 in (select c2 from t2) from t1;
|
||||
+---------------------------+
|
||||
| c2 in (select c2 from t2) |
|
||||
+---------------------------+
|
||||
| 1 |
|
||||
| 1 |
|
||||
| 1 |
|
||||
+---------------------------+
|
||||
select c2 = any(select c2 from t2) from t1;
|
||||
+-----------------------------+
|
||||
| c2 = any(select c2 from t2) |
|
||||
+-----------------------------+
|
||||
| 1 |
|
||||
| 1 |
|
||||
| 1 |
|
||||
+-----------------------------+
|
||||
select c2 != any(select c2 from t2) from t1;
|
||||
+------------------------------+
|
||||
| c2 != any(select c2 from t2) |
|
||||
+------------------------------+
|
||||
| 1 |
|
||||
| 1 |
|
||||
| 1 |
|
||||
+------------------------------+
|
||||
select c2 < any(select c2 from t2) from t1;
|
||||
+-----------------------------+
|
||||
| c2 < any(select c2 from t2) |
|
||||
+-----------------------------+
|
||||
| 1 |
|
||||
| 1 |
|
||||
| 0 |
|
||||
+-----------------------------+
|
||||
select c2 <= any(select c2 from t2) from t1;
|
||||
+------------------------------+
|
||||
| c2 <= any(select c2 from t2) |
|
||||
+------------------------------+
|
||||
| 1 |
|
||||
| 1 |
|
||||
| 1 |
|
||||
+------------------------------+
|
||||
select c2 > any(select c2 from t2) from t1;
|
||||
+-----------------------------+
|
||||
| c2 > any(select c2 from t2) |
|
||||
+-----------------------------+
|
||||
| 0 |
|
||||
| 1 |
|
||||
| 1 |
|
||||
+-----------------------------+
|
||||
select c2 >= any(select c2 from t2) from t1;
|
||||
+------------------------------+
|
||||
| c2 >= any(select c2 from t2) |
|
||||
+------------------------------+
|
||||
| 1 |
|
||||
| 1 |
|
||||
| 1 |
|
||||
+------------------------------+
|
||||
select c2 <=> any(select c2 from t2) from t1;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near '(select c2 from t2) from t1' at line 1
|
||||
select exists (select * from t2), not exists (select * from t2) from t1;
|
||||
+---------------------------+-------------------------------+
|
||||
| exists (select * from t2) | not exists (select * from t2) |
|
||||
+---------------------------+-------------------------------+
|
||||
| 1 | 0 |
|
||||
| 1 | 0 |
|
||||
| 1 | 0 |
|
||||
+---------------------------+-------------------------------+
|
||||
select exists (select * from t2 where 1 = 0), not exists (select * from t2 where 1 = 0) from t1;
|
||||
+---------------------------------------+-------------------------------------------+
|
||||
| exists (select * from t2 where 1 = 0) | not exists (select * from t2 where 1 = 0) |
|
||||
+---------------------------------------+-------------------------------------------+
|
||||
| 0 | 1 |
|
||||
| 0 | 1 |
|
||||
| 0 | 1 |
|
||||
+---------------------------------------+-------------------------------------------+
|
||||
|
||||
select c2 = all (select c2 from t2) from t1;
|
||||
+------------------------------+
|
||||
| c2 = all (select c2 from t2) |
|
||||
+------------------------------+
|
||||
| 0 |
|
||||
| 0 |
|
||||
| 0 |
|
||||
+------------------------------+
|
||||
select c2 = any (select c2 from t2) from t1;
|
||||
+------------------------------+
|
||||
| c2 = any (select c2 from t2) |
|
||||
+------------------------------+
|
||||
| 1 |
|
||||
| 1 |
|
||||
| 1 |
|
||||
+------------------------------+
|
||||
|
||||
select c2 = all (select c3 from t2) from t1;
|
||||
+------------------------------+
|
||||
| c2 = all (select c3 from t2) |
|
||||
+------------------------------+
|
||||
| NULL |
|
||||
| 0 |
|
||||
| 0 |
|
||||
+------------------------------+
|
||||
select c2 = any (select c3 from t2) from t1;
|
||||
+------------------------------+
|
||||
| c2 = any (select c3 from t2) |
|
||||
+------------------------------+
|
||||
| 1 |
|
||||
| NULL |
|
||||
| NULL |
|
||||
+------------------------------+
|
||||
|
||||
select c3 = all (select c2 from t2) from t1;
|
||||
+------------------------------+
|
||||
| c3 = all (select c2 from t2) |
|
||||
+------------------------------+
|
||||
| 0 |
|
||||
| NULL |
|
||||
| NULL |
|
||||
+------------------------------+
|
||||
select c3 = any (select c2 from t2) from t1;
|
||||
+------------------------------+
|
||||
| c3 = any (select c2 from t2) |
|
||||
+------------------------------+
|
||||
| 1 |
|
||||
| NULL |
|
||||
| NULL |
|
||||
+------------------------------+
|
||||
|
||||
select c3 <=> (select c2 from t2) from t1;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
|
||||
select (c1, c3) = all (select c1, c2 from t2) from t1;
|
||||
+----------------------------------------+
|
||||
| (c1, c3) = all (select c1, c2 from t2) |
|
||||
+----------------------------------------+
|
||||
| 0 |
|
||||
| 0 |
|
||||
| 0 |
|
||||
+----------------------------------------+
|
||||
select (c1, c3) = any (select c1, c2 from t2) from t1;
|
||||
+----------------------------------------+
|
||||
| (c1, c3) = any (select c1, c2 from t2) |
|
||||
+----------------------------------------+
|
||||
| 1 |
|
||||
| NULL |
|
||||
| NULL |
|
||||
+----------------------------------------+
|
||||
select (c1, c3) <=> (select c1, c2 from t2) from t1;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
|
||||
select exists (select 1);
|
||||
+-------------------+
|
||||
| exists (select 1) |
|
||||
+-------------------+
|
||||
| 1 |
|
||||
+-------------------+
|
||||
select not exists (select 1);
|
||||
+-----------------------+
|
||||
| not exists (select 1) |
|
||||
+-----------------------+
|
||||
| 0 |
|
||||
+-----------------------+
|
||||
select 1 from dual where exists (select c1 from t2);
|
||||
+---+
|
||||
| 1 |
|
||||
+---+
|
||||
| 1 |
|
||||
+---+
|
||||
select 1 from dual where not exists (select c1 from t2);
|
||||
+---+
|
||||
| 1 |
|
||||
+---+
|
||||
+---+
|
||||
select * from t1 where exists (select * from t2 where c1 < 0);
|
||||
+----+------+------+------+
|
||||
| c1 | c2 | c3 | c4 |
|
||||
+----+------+------+------+
|
||||
+----+------+------+------+
|
||||
select * from t1 where exists (select * from t2 where c1 > 0);
|
||||
+----+------+------+------+
|
||||
| c1 | c2 | c3 | c4 |
|
||||
+----+------+------+------+
|
||||
| 1 | 1 | 1 | a |
|
||||
| 2 | 2 | NULL | a |
|
||||
| 3 | 3 | NULL | a |
|
||||
+----+------+------+------+
|
||||
|
||||
select (select c1, c2 from t1 where c1 = 1) = (select c1, c2 from t2 where c1 = 1);
|
||||
+-----------------------------------------------------------------------------+
|
||||
| (select c1, c2 from t1 where c1 = 1) = (select c1, c2 from t2 where c1 = 1) |
|
||||
+-----------------------------------------------------------------------------+
|
||||
| 1 |
|
||||
+-----------------------------------------------------------------------------+
|
||||
select (select c1, c2 from t1 where c1 = 0) = (select c1, c2 from t2 where c1 = 1);
|
||||
+-----------------------------------------------------------------------------+
|
||||
| (select c1, c2 from t1 where c1 = 0) = (select c1, c2 from t2 where c1 = 1) |
|
||||
+-----------------------------------------------------------------------------+
|
||||
| NULL |
|
||||
+-----------------------------------------------------------------------------+
|
||||
select (select c1, c2 from t1 where c1 = 1) = (select c1, c2 from t2 where c1 = 0);
|
||||
+-----------------------------------------------------------------------------+
|
||||
| (select c1, c2 from t1 where c1 = 1) = (select c1, c2 from t2 where c1 = 0) |
|
||||
+-----------------------------------------------------------------------------+
|
||||
| NULL |
|
||||
+-----------------------------------------------------------------------------+
|
||||
select (select c1, c2 from t1 where c1 = 0) = (select c1, c2 from t2 where c1 = 0);
|
||||
+-----------------------------------------------------------------------------+
|
||||
| (select c1, c2 from t1 where c1 = 0) = (select c1, c2 from t2 where c1 = 0) |
|
||||
+-----------------------------------------------------------------------------+
|
||||
| NULL |
|
||||
+-----------------------------------------------------------------------------+
|
||||
select (select c1, c2 from t1 where c1 = 1) <=> (select c1, c2 from t2 where c1 = 1);
|
||||
+-------------------------------------------------------------------------------+
|
||||
| (select c1, c2 from t1 where c1 = 1) <=> (select c1, c2 from t2 where c1 = 1) |
|
||||
+-------------------------------------------------------------------------------+
|
||||
| 1 |
|
||||
+-------------------------------------------------------------------------------+
|
||||
select (select c1, c2 from t1 where c1 = 0) <=> (select c1, c2 from t2 where c1 = 1);
|
||||
+-------------------------------------------------------------------------------+
|
||||
| (select c1, c2 from t1 where c1 = 0) <=> (select c1, c2 from t2 where c1 = 1) |
|
||||
+-------------------------------------------------------------------------------+
|
||||
| 0 |
|
||||
+-------------------------------------------------------------------------------+
|
||||
select (select c1, c2 from t1 where c1 = 1) <=> (select c1, c2 from t2 where c1 = 0);
|
||||
+-------------------------------------------------------------------------------+
|
||||
| (select c1, c2 from t1 where c1 = 1) <=> (select c1, c2 from t2 where c1 = 0) |
|
||||
+-------------------------------------------------------------------------------+
|
||||
| 0 |
|
||||
+-------------------------------------------------------------------------------+
|
||||
select (select c1, c2 from t1 where c1 = 0) <=> (select c1, c2 from t2 where c1 = 0);
|
||||
+-------------------------------------------------------------------------------+
|
||||
| (select c1, c2 from t1 where c1 = 0) <=> (select c1, c2 from t2 where c1 = 0) |
|
||||
+-------------------------------------------------------------------------------+
|
||||
| 1 |
|
||||
+-------------------------------------------------------------------------------+
|
||||
select (select c1, c2 from t1 where c1 > 1) = (select c1, c2 from t2 where c1 = 1);
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
select (select c1, c2 from t1 where c1 = 1) = (select c1, c2 from t2 where c1 > 1);
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
select (select c1, c2 from t1 where c1 > 1) = (select c1, c2 from t2 where c1 > 1);
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
|
||||
explain_protocol: 2
|
||||
EXPLAIN select c1 + (select c2 from t2 where c1 = 2), c2 in (select c3 from t2) from t1;
|
||||
Query Plan
|
||||
=======================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
---------------------------------------
|
||||
|0 |SUBPLAN FILTER| |3 |128 |
|
||||
|1 | TABLE SCAN |t1 |3 |37 |
|
||||
|2 | TABLE GET |t2 |1 |52 |
|
||||
|3 | TABLE SCAN |t2 |3 |37 |
|
||||
=======================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([cast(t1.c1, DECIMAL(11, 0)) + ?], [t1.c2 = ANY(subquery(2))]), filter(nil),
|
||||
exec_params_(nil), onetime_exprs_([subquery(1)]), init_plan_idxs_([2])
|
||||
1 - output([t1.c1], [t1.c2]), filter(nil),
|
||||
access([t1.c1], [t1.c2]), partitions(p0)
|
||||
2 - output([t2.c2]), filter(nil),
|
||||
access([t2.c2]), partitions(p0)
|
||||
3 - output([cast(t2.c3, DECIMAL(11, 0))]), filter(nil),
|
||||
access([t2.c3]), partitions(p0)
|
||||
|
||||
select c1 + (select c2 from t2 where c1 = 2), c2 in (select c3 from t2) from t1;
|
||||
+---------------------------------------+---------------------------+
|
||||
| c1 + (select c2 from t2 where c1 = 2) | c2 in (select c3 from t2) |
|
||||
+---------------------------------------+---------------------------+
|
||||
| 3 | 1 |
|
||||
| 4 | NULL |
|
||||
| 5 | NULL |
|
||||
+---------------------------------------+---------------------------+
|
||||
EXPLAIN select c1 + (select c2 from t2 where c1 = t1.c2 and c3 <= t1.c2) from t1;
|
||||
Query Plan
|
||||
=======================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
---------------------------------------
|
||||
|0 |SUBPLAN FILTER| |3 |146 |
|
||||
|1 | TABLE SCAN |t1 |3 |37 |
|
||||
|2 | TABLE GET |t2 |1 |37 |
|
||||
=======================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([cast(t1.c1, DECIMAL(11, 0)) + subquery(1)]), filter(nil),
|
||||
exec_params_([t1.c2]), onetime_exprs_(nil), init_plan_idxs_(nil)
|
||||
1 - output([t1.c2], [t1.c1]), filter(nil),
|
||||
access([t1.c2], [t1.c1]), partitions(p0)
|
||||
2 - output([t2.c2]), filter([cast(t2.c3, DECIMAL(11, 0)) <= ?]),
|
||||
access([t2.c3], [t2.c2]), partitions(p0)
|
||||
|
||||
select c1 + (select c2 from t2 where c1 = t1.c2 and c3 <= t1.c2) from t1;
|
||||
+-----------------------------------------------------------+
|
||||
| c1 + (select c2 from t2 where c1 = t1.c2 and c3 <= t1.c2) |
|
||||
+-----------------------------------------------------------+
|
||||
| 2 |
|
||||
| NULL |
|
||||
| NULL |
|
||||
+-----------------------------------------------------------+
|
||||
EXPLAIN select * from t1 where c1 + (select c2 from t2 where c1 = t1.c2 and c3 <= t1.c2) < 10;
|
||||
Query Plan
|
||||
=======================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
---------------------------------------
|
||||
|0 |SUBPLAN FILTER| |1 |146 |
|
||||
|1 | TABLE SCAN |t1 |3 |37 |
|
||||
|2 | TABLE GET |t2 |1 |37 |
|
||||
=======================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4]), filter([cast(t1.c1, DECIMAL(11, 0)) + subquery(1) < ?]),
|
||||
exec_params_([t1.c2]), onetime_exprs_(nil), init_plan_idxs_(nil)
|
||||
1 - output([t1.c2], [t1.c1], [t1.c3], [t1.c4]), filter(nil),
|
||||
access([t1.c2], [t1.c1], [t1.c3], [t1.c4]), partitions(p0)
|
||||
2 - output([t2.c2]), filter([cast(t2.c3, DECIMAL(11, 0)) <= ?]),
|
||||
access([t2.c3], [t2.c2]), partitions(p0)
|
||||
|
||||
select * from t1 where c1 + (select c2 from t2 where c1 = t1.c2 and c3 <= t1.c2) < 10;
|
||||
+----+------+------+------+
|
||||
| c1 | c2 | c3 | c4 |
|
||||
+----+------+------+------+
|
||||
| 1 | 1 | 1 | a |
|
||||
+----+------+------+------+
|
||||
|
||||
EXPLAIN select (select c1, c2 from t2 where c1 = 1) = (c2, c1) from t1;
|
||||
Query Plan
|
||||
=======================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
---------------------------------------
|
||||
|0 |SUBPLAN FILTER| |3 |90 |
|
||||
|1 | TABLE SCAN |t1 |3 |37 |
|
||||
|2 | TABLE GET |t2 |1 |52 |
|
||||
=======================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([subquery(1) = (t1.c2, cast(t1.c1, DECIMAL(11, 0)))]), filter(nil),
|
||||
exec_params_(nil), onetime_exprs_(nil), init_plan_idxs_([1])
|
||||
1 - output([t1.c2], [t1.c1]), filter(nil),
|
||||
access([t1.c2], [t1.c1]), partitions(p0)
|
||||
2 - output([cast(t2.c1, DECIMAL(11, 0))], [t2.c2]), filter(nil),
|
||||
access([t2.c1], [t2.c2]), partitions(p0)
|
||||
|
||||
select (select c1, c2 from t2 where c1 = 1) = (c2, c1) from t1;
|
||||
+-------------------------------------------------+
|
||||
| (select c1, c2 from t2 where c1 = 1) = (c2, c1) |
|
||||
+-------------------------------------------------+
|
||||
| 1 |
|
||||
| 0 |
|
||||
| 0 |
|
||||
+-------------------------------------------------+
|
||||
EXPLAIN select (select c1, c2 from t2 where c1 = 1) = (c1, c2) from t1;
|
||||
Query Plan
|
||||
=======================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
---------------------------------------
|
||||
|0 |SUBPLAN FILTER| |3 |90 |
|
||||
|1 | TABLE SCAN |t1 |3 |37 |
|
||||
|2 | TABLE GET |t2 |1 |52 |
|
||||
=======================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([subquery(1) = (t1.c1, t1.c2)]), filter(nil),
|
||||
exec_params_(nil), onetime_exprs_(nil), init_plan_idxs_([1])
|
||||
1 - output([t1.c1], [t1.c2]), filter(nil),
|
||||
access([t1.c1], [t1.c2]), partitions(p0)
|
||||
2 - output([t2.c1], [t2.c2]), filter(nil),
|
||||
access([t2.c1], [t2.c2]), partitions(p0)
|
||||
|
||||
select (select c1, c2 from t2 where c1 = 1) = (c1, c2) from t1;
|
||||
+-------------------------------------------------+
|
||||
| (select c1, c2 from t2 where c1 = 1) = (c1, c2) |
|
||||
+-------------------------------------------------+
|
||||
| 1 |
|
||||
| 0 |
|
||||
| 0 |
|
||||
+-------------------------------------------------+
|
||||
EXPLAIN select (c2, c1) <= (select c1, c2 from t2 where c1 = 1) from t1;
|
||||
Query Plan
|
||||
=======================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
---------------------------------------
|
||||
|0 |SUBPLAN FILTER| |3 |90 |
|
||||
|1 | TABLE SCAN |t1 |3 |37 |
|
||||
|2 | TABLE GET |t2 |1 |52 |
|
||||
=======================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([(t1.c2, cast(t1.c1, DECIMAL(11, 0))) <= subquery(1)]), filter(nil),
|
||||
exec_params_(nil), onetime_exprs_(nil), init_plan_idxs_([1])
|
||||
1 - output([t1.c2], [t1.c1]), filter(nil),
|
||||
access([t1.c2], [t1.c1]), partitions(p0)
|
||||
2 - output([cast(t2.c1, DECIMAL(11, 0))], [t2.c2]), filter(nil),
|
||||
access([t2.c1], [t2.c2]), partitions(p0)
|
||||
|
||||
select (c2, c1) <= (select c1, c2 from t2 where c1 = 1) from t1;
|
||||
+--------------------------------------------------+
|
||||
| (c2, c1) <= (select c1, c2 from t2 where c1 = 1) |
|
||||
+--------------------------------------------------+
|
||||
| 1 |
|
||||
| 0 |
|
||||
| 0 |
|
||||
+--------------------------------------------------+
|
||||
EXPLAIN select (c1, c2) <= (select c1, c2 from t2 where c1 = 1) from t1;
|
||||
Query Plan
|
||||
=======================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
---------------------------------------
|
||||
|0 |SUBPLAN FILTER| |3 |90 |
|
||||
|1 | TABLE SCAN |t1 |3 |37 |
|
||||
|2 | TABLE GET |t2 |1 |52 |
|
||||
=======================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([(t1.c1, t1.c2) <= subquery(1)]), filter(nil),
|
||||
exec_params_(nil), onetime_exprs_(nil), init_plan_idxs_([1])
|
||||
1 - output([t1.c1], [t1.c2]), filter(nil),
|
||||
access([t1.c1], [t1.c2]), partitions(p0)
|
||||
2 - output([t2.c1], [t2.c2]), filter(nil),
|
||||
access([t2.c1], [t2.c2]), partitions(p0)
|
||||
|
||||
select (c1, c2) <= (select c1, c2 from t2 where c1 = 1) from t1;
|
||||
+--------------------------------------------------+
|
||||
| (c1, c2) <= (select c1, c2 from t2 where c1 = 1) |
|
||||
+--------------------------------------------------+
|
||||
| 1 |
|
||||
| 0 |
|
||||
| 0 |
|
||||
+--------------------------------------------------+
|
||||
EXPLAIN select (select c2, c1 from t2 where c1 = 2) >= (select c1, c2 from t2 where c1 = 1) from t1;
|
||||
Query Plan
|
||||
=======================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
---------------------------------------
|
||||
|0 |SUBPLAN FILTER| |3 |141 |
|
||||
|1 | TABLE SCAN |t1 |3 |37 |
|
||||
|2 | TABLE GET |t2 |1 |52 |
|
||||
|3 | TABLE GET |t2 |1 |52 |
|
||||
=======================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([?]), filter(nil),
|
||||
exec_params_(nil), onetime_exprs_([subquery(1) >= subquery(2)]), init_plan_idxs_(nil)
|
||||
1 - output([1]), filter(nil),
|
||||
access([t1.c1]), partitions(p0)
|
||||
2 - output([t2.c2], [cast(t2.c1, DECIMAL(11, 0))]), filter(nil),
|
||||
access([t2.c1], [t2.c2]), partitions(p0)
|
||||
3 - output([cast(t2.c1, DECIMAL(11, 0))], [t2.c2]), filter(nil),
|
||||
access([t2.c1], [t2.c2]), partitions(p0)
|
||||
|
||||
select (select c2, c1 from t2 where c1 = 2) >= (select c1, c2 from t2 where c1 = 1) from t1;
|
||||
+------------------------------------------------------------------------------+
|
||||
| (select c2, c1 from t2 where c1 = 2) >= (select c1, c2 from t2 where c1 = 1) |
|
||||
+------------------------------------------------------------------------------+
|
||||
| 1 |
|
||||
| 1 |
|
||||
| 1 |
|
||||
+------------------------------------------------------------------------------+
|
||||
EXPLAIN select (select c1, c1 from t2 where c1 = 2) >= (select c1, c2 from t2 where c1 = 1) from t1;
|
||||
Query Plan
|
||||
=======================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
---------------------------------------
|
||||
|0 |SUBPLAN FILTER| |3 |141 |
|
||||
|1 | TABLE SCAN |t1 |3 |37 |
|
||||
|2 | TABLE GET |t2 |1 |52 |
|
||||
|3 | TABLE GET |t2 |1 |52 |
|
||||
=======================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([?]), filter(nil),
|
||||
exec_params_(nil), onetime_exprs_([subquery(1) >= subquery(2)]), init_plan_idxs_(nil)
|
||||
1 - output([1]), filter(nil),
|
||||
access([t1.c1]), partitions(p0)
|
||||
2 - output([t2.c1], [cast(t2.c1, DECIMAL(11, 0))]), filter(nil),
|
||||
access([t2.c1]), partitions(p0)
|
||||
3 - output([t2.c1], [t2.c2]), filter(nil),
|
||||
access([t2.c1], [t2.c2]), partitions(p0)
|
||||
|
||||
select (select c1, c1 from t2 where c1 = 2) >= (select c1, c2 from t2 where c1 = 1) from t1;
|
||||
+------------------------------------------------------------------------------+
|
||||
| (select c1, c1 from t2 where c1 = 2) >= (select c1, c2 from t2 where c1 = 1) |
|
||||
+------------------------------------------------------------------------------+
|
||||
| 1 |
|
||||
| 1 |
|
||||
| 1 |
|
||||
+------------------------------------------------------------------------------+
|
||||
|
||||
EXPLAIN select c2 > (select c1 from t2 where c3 is not null) from t1;
|
||||
Query Plan
|
||||
=======================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
---------------------------------------
|
||||
|0 |SUBPLAN FILTER| |3 |74 |
|
||||
|1 | TABLE SCAN |t1 |3 |37 |
|
||||
|2 | TABLE SCAN |t2 |3 |37 |
|
||||
=======================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c2 > ?]), filter(nil),
|
||||
exec_params_(nil), onetime_exprs_([cast(subquery(1), DECIMAL(11, 0))]), init_plan_idxs_(nil)
|
||||
1 - output([t1.c2]), filter(nil),
|
||||
access([t1.c2]), partitions(p0)
|
||||
2 - output([t2.c1]), filter([(T_OP_IS_NOT, t2.c3, NULL, 0)]),
|
||||
access([t2.c3], [t2.c1]), partitions(p0)
|
||||
|
||||
select c2 > (select c1 from t2 where c3 is not null) from t1;
|
||||
+-----------------------------------------------+
|
||||
| c2 > (select c1 from t2 where c3 is not null) |
|
||||
+-----------------------------------------------+
|
||||
| 0 |
|
||||
| 1 |
|
||||
| 1 |
|
||||
+-----------------------------------------------+
|
||||
EXPLAIN select * from t1 where c2 + (select c1 from t2 where c1 = t1.c2) < 10;
|
||||
Query Plan
|
||||
=======================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
---------------------------------------
|
||||
|0 |SUBPLAN FILTER| |1 |145 |
|
||||
|1 | TABLE SCAN |t1 |3 |37 |
|
||||
|2 | TABLE GET |t2 |1 |36 |
|
||||
=======================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4]), filter([t1.c2 + cast(subquery(1), DECIMAL(11, 0)) < ?]),
|
||||
exec_params_([t1.c2]), onetime_exprs_(nil), init_plan_idxs_(nil)
|
||||
1 - output([t1.c2], [t1.c1], [t1.c3], [t1.c4]), filter(nil),
|
||||
access([t1.c2], [t1.c1], [t1.c3], [t1.c4]), partitions(p0)
|
||||
2 - output([t2.c1]), filter(nil),
|
||||
access([t2.c1]), partitions(p0)
|
||||
|
||||
select * from t1 where c2 + (select c1 from t2 where c1 = t1.c2) < 10;
|
||||
+----+------+------+------+
|
||||
| c1 | c2 | c3 | c4 |
|
||||
+----+------+------+------+
|
||||
| 1 | 1 | 1 | a |
|
||||
| 2 | 2 | NULL | a |
|
||||
| 3 | 3 | NULL | a |
|
||||
+----+------+------+------+
|
||||
|
||||
set ob_enable_transformation = on;
|
||||
@ -0,0 +1,144 @@
|
||||
result_format: 4
|
||||
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 int, c2 int);
|
||||
insert into t1 (c1, c2) values (1, 1);
|
||||
insert into t1 (c1, c2) values (1, 1);
|
||||
insert into t1 (c1, c2) values (1, 2);
|
||||
insert into t1 (c1, c2) values (10, 10);
|
||||
insert into t1 (c1, c2) values (10, 10);
|
||||
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
explain select c2, sum(c1) from (select distinct c2, c1 from t1) x group by c2;
|
||||
Query Plan
|
||||
=========================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------------
|
||||
|0 |MERGE GROUP BY | |5 |45 |
|
||||
|1 | SUBPLAN SCAN |x |5 |44 |
|
||||
|2 | MERGE DISTINCT| |5 |43 |
|
||||
|3 | SORT | |5 |42 |
|
||||
|4 | TABLE SCAN |t1 |5 |37 |
|
||||
=========================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([x.c2], [T_FUN_SUM(x.c1)]), filter(nil),
|
||||
group([x.c2]), agg_func([T_FUN_SUM(x.c1)])
|
||||
1 - output([x.c2], [x.c1]), filter(nil),
|
||||
access([x.c2], [x.c1])
|
||||
2 - output([t1.c2], [t1.c1]), filter(nil),
|
||||
distinct([t1.c2], [t1.c1])
|
||||
3 - output([t1.c2], [t1.c1]), filter(nil), sort_keys([t1.c2, ASC], [t1.c1, ASC])
|
||||
4 - output([t1.c2], [t1.c1]), filter(nil),
|
||||
access([t1.c2], [t1.c1]), partitions(p0)
|
||||
|
||||
select c2, sum(c1) from (select distinct c2, c1 from t1) x group by c2;
|
||||
+------+---------+
|
||||
| c2 | sum(c1) |
|
||||
+------+---------+
|
||||
| 1 | 1 |
|
||||
| 2 | 1 |
|
||||
| 10 | 10 |
|
||||
+------+---------+
|
||||
|
||||
explain select c2, sum(c1 + c2) from (select distinct c2, c1 from t1) x group by c2;
|
||||
Query Plan
|
||||
=========================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------------
|
||||
|0 |MERGE GROUP BY | |5 |45 |
|
||||
|1 | SUBPLAN SCAN |x |5 |44 |
|
||||
|2 | MERGE DISTINCT| |5 |43 |
|
||||
|3 | SORT | |5 |42 |
|
||||
|4 | TABLE SCAN |t1 |5 |37 |
|
||||
=========================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([x.c2], [T_FUN_SUM(x.c1 + x.c2)]), filter(nil),
|
||||
group([x.c2]), agg_func([T_FUN_SUM(x.c1 + x.c2)])
|
||||
1 - output([x.c2], [x.c1 + x.c2]), filter(nil),
|
||||
access([x.c2], [x.c1])
|
||||
2 - output([t1.c2], [t1.c1]), filter(nil),
|
||||
distinct([t1.c2], [t1.c1])
|
||||
3 - output([t1.c2], [t1.c1]), filter(nil), sort_keys([t1.c2, ASC], [t1.c1, ASC])
|
||||
4 - output([t1.c2], [t1.c1]), filter(nil),
|
||||
access([t1.c2], [t1.c1]), partitions(p0)
|
||||
|
||||
select c2, sum(c1 + c2) from (select distinct c2, c1 from t1) x group by c2;
|
||||
+------+--------------+
|
||||
| c2 | sum(c1 + c2) |
|
||||
+------+--------------+
|
||||
| 1 | 2 |
|
||||
| 2 | 3 |
|
||||
| 10 | 20 |
|
||||
+------+--------------+
|
||||
|
||||
explain select c2, sum(c1 + c2), max(c3) from (select c1, c2, c1 + 2 as c3 from (select distinct c2, c1 from t1) x ) y group by c2;
|
||||
Query Plan
|
||||
=========================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------------
|
||||
|0 |MERGE GROUP BY | |5 |46 |
|
||||
|1 | SUBPLAN SCAN |x |5 |44 |
|
||||
|2 | MERGE DISTINCT| |5 |43 |
|
||||
|3 | SORT | |5 |42 |
|
||||
|4 | TABLE SCAN |t1 |5 |37 |
|
||||
=========================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([x.c2], [T_FUN_SUM(x.c1 + x.c2)], [T_FUN_MAX(x.c1 + 2)]), filter(nil),
|
||||
group([x.c2]), agg_func([T_FUN_SUM(x.c1 + x.c2)], [T_FUN_MAX(x.c1 + 2)])
|
||||
1 - output([x.c2], [x.c1 + x.c2], [x.c1 + 2]), filter(nil),
|
||||
access([x.c1], [x.c2])
|
||||
2 - output([t1.c2], [t1.c1]), filter(nil),
|
||||
distinct([t1.c2], [t1.c1])
|
||||
3 - output([t1.c2], [t1.c1]), filter(nil), sort_keys([t1.c2, ASC], [t1.c1, ASC])
|
||||
4 - output([t1.c2], [t1.c1]), filter(nil),
|
||||
access([t1.c2], [t1.c1]), partitions(p0)
|
||||
|
||||
select c2, sum(c1 + c2), max(c3) from (select c1, c2, c1 + 2 as c3 from (select distinct c2, c1 from t1) x ) y group by c2;
|
||||
+------+--------------+---------+
|
||||
| c2 | sum(c1 + c2) | max(c3) |
|
||||
+------+--------------+---------+
|
||||
| 1 | 2 | 3 |
|
||||
| 2 | 3 | 3 |
|
||||
| 10 | 20 | 12 |
|
||||
+------+--------------+---------+
|
||||
|
||||
explain select * from t1 where c2 in (select 1 from t1);
|
||||
Query Plan
|
||||
=======================================
|
||||
|ID|OPERATOR |NAME |EST. ROWS|COST|
|
||||
---------------------------------------
|
||||
|0 |HASH JOIN | |1 |77 |
|
||||
|1 | SUBPLAN SCAN|VIEW1|1 |37 |
|
||||
|2 | TABLE SCAN |t1 |1 |36 |
|
||||
|3 | TABLE SCAN |t1 |5 |37 |
|
||||
=======================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2]), filter(nil),
|
||||
equal_conds([t1.c2 = VIEW1.1]), other_conds(nil)
|
||||
1 - output([VIEW1.1]), filter(nil),
|
||||
access([VIEW1.1])
|
||||
2 - output([1]), filter(nil),
|
||||
access([t1.__pk_increment]), partitions(p0),
|
||||
limit(1), offset(nil)
|
||||
3 - output([t1.c2], [t1.c1]), filter(nil),
|
||||
access([t1.c2], [t1.c1]), partitions(p0)
|
||||
|
||||
select * from t1 where c2 in (select 1 from t1);
|
||||
+------+------+
|
||||
| c1 | c2 |
|
||||
+------+------+
|
||||
| 1 | 1 |
|
||||
| 1 | 1 |
|
||||
+------+------+
|
||||
|
||||
@ -0,0 +1,172 @@
|
||||
result_format: 4
|
||||
alter system set enable_async_syslog = false;
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
drop table if exists t1, t2;
|
||||
create table t1 (c1 int primary key, c2 int unsigned,
|
||||
c3 tinyint, c4 tinyint unsigned,
|
||||
c5 smallint, c6 smallint unsigned,
|
||||
c7 mediumint, c8 mediumint unsigned,
|
||||
c9 integer, c10 integer unsigned,
|
||||
c11 bigint, c12 bigint unsigned,
|
||||
c13 float, c14 float unsigned,
|
||||
c15 double, c16 double unsigned,
|
||||
c17 decimal, c18 decimal unsigned,
|
||||
c19 datetime, c20 timestamp,
|
||||
c21 varchar(30), c22 char(30));
|
||||
|
||||
insert into t1 values(1, 1, 1, 1, -1, 6, 7, 8, 9, 10, -11, 12, -13.1, 14.2, -15.01, 16.10, 17.001, 18.002, '2019-10-10 10:00:00', '2019-10-10 10:00:00', '21varchar', '22char');
|
||||
insert into t1 values('2', '1', '1', '1', '-1', '6', '7', '8', '9', '10', '-11', '12', '-13.1', '14.2', '-15.01', '16.10', '17.001', '18.002', '2019-10-10 10:00:00', '2019-10-10 10:00:00', '21varchar', '22char');
|
||||
insert into t1 values('3', '1', '1', '1', '-1', '6', '7', '8', '9', '10', '-11', '12', '-13.1', '14.2', '-15.01', '16.10', '17.001', '18.002', '2019-10-10 10:00:00', '2019-10-10 10:00:00', '21varchar', '22char'), ('4', '1', '1', '1', '-1', '16', '17', '18', '19', '11', '-11', '121', '-13.11', '14.21', '-15.011', '16.101', '17.1001', '18.1002', '2019-10-10 10:00:00.00', '2019-10-10 10:00:00.000', '21varchar1', '22char1');
|
||||
|
||||
explain_protocol: 2
|
||||
EXPLAIN select * from t1;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t1 |4 |39 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10], [t1.c11], [t1.c12], [t1.c13], [t1.c14], [t1.c15], [t1.c16], [t1.c17], [t1.c18], [t1.c19], [t1.c20], [t1.c21], [t1.c22]), filter(nil),
|
||||
access([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5], [t1.c6], [t1.c7], [t1.c8], [t1.c9], [t1.c10], [t1.c11], [t1.c12], [t1.c13], [t1.c14], [t1.c15], [t1.c16], [t1.c17], [t1.c18], [t1.c19], [t1.c20], [t1.c21], [t1.c22]), partitions(p0)
|
||||
|
||||
select * from t1;
|
||||
+----+------+------+------+------+------+------+------+------+------+------+------+--------+-------+---------+--------+------+------+---------------------+---------------------+------------+---------+
|
||||
| c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 | c9 | c10 | c11 | c12 | c13 | c14 | c15 | c16 | c17 | c18 | c19 | c20 | c21 | c22 |
|
||||
+----+------+------+------+------+------+------+------+------+------+------+------+--------+-------+---------+--------+------+------+---------------------+---------------------+------------+---------+
|
||||
| 1 | 1 | 1 | 1 | -1 | 6 | 7 | 8 | 9 | 10 | -11 | 12 | -13.1 | 14.2 | -15.01 | 16.1 | 17 | 18 | 2019-10-10 10:00:00 | 2019-10-10 10:00:00 | 21varchar | 22char |
|
||||
| 2 | 1 | 1 | 1 | -1 | 6 | 7 | 8 | 9 | 10 | -11 | 12 | -13.1 | 14.2 | -15.01 | 16.1 | 17 | 18 | 2019-10-10 10:00:00 | 2019-10-10 10:00:00 | 21varchar | 22char |
|
||||
| 3 | 1 | 1 | 1 | -1 | 6 | 7 | 8 | 9 | 10 | -11 | 12 | -13.1 | 14.2 | -15.01 | 16.1 | 17 | 18 | 2019-10-10 10:00:00 | 2019-10-10 10:00:00 | 21varchar | 22char |
|
||||
| 4 | 1 | 1 | 1 | -1 | 16 | 17 | 18 | 19 | 11 | -11 | 121 | -13.11 | 14.21 | -15.011 | 16.101 | 17 | 18 | 2019-10-10 10:00:00 | 2019-10-10 10:00:00 | 21varchar1 | 22char1 |
|
||||
+----+------+------+------+------+------+------+------+------+------+------+------+--------+-------+---------+--------+------+------+---------------------+---------------------+------------+---------+
|
||||
explain_protocol: 0
|
||||
set @@ob_enable_plan_cache = 1;
|
||||
// test ObDatumCaster::to_type() in ObExprValuesOp
|
||||
drop table t1;
|
||||
create table t1(c1 varchar(100) collate utf16_bin,
|
||||
c2 varchar(100) collate utf8_general_ci,
|
||||
c3 char(100) collate utf16_bin,
|
||||
c4 char(100) collate utf8_general_ci);
|
||||
ERROR HY000: Unknown collation: 'utf16_bin'
|
||||
// different value type, but will use same plan, so will to ObDatumCaster::to_type()
|
||||
insert into t1 values(123, 123, 123, 123);
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
insert into t1 values(null, 123, null, 123);
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
insert into t1 values('123', '123', '123', 123);
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
insert into t1 values('', '123', '123', 123);
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
select c1, length(c1),
|
||||
c2, length(c2),
|
||||
c3, length(c3),
|
||||
c4, length(c4) from t1;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
|
||||
// insert decimal/int using different collation string
|
||||
delete from t1;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
insert into t1 values('123.123', '123.123', '123.123', '123.123');
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
create table t2(c1 decimal(10, 1), c2 int unsigned, c3 int);
|
||||
insert into t2 values(null, null, 1);
|
||||
insert into t2 select null, null, null from dual;
|
||||
insert into t2 select c1, c1, c1 from t1;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
insert into t2 select c2, c2, c2 from t1;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
insert into t2 select c3, c3, c3 from t1;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
insert into t2 select c4, c4, c4 from t1;
|
||||
ERROR 42S02: Table 'test.t1' doesn't exist
|
||||
select * from t2;
|
||||
+------+------+------+
|
||||
| c1 | c2 | c3 |
|
||||
+------+------+------+
|
||||
| NULL | NULL | 1 |
|
||||
| NULL | NULL | NULL |
|
||||
+------+------+------+
|
||||
|
||||
// test enumset
|
||||
drop table t1;
|
||||
ERROR 42S02: Unknown table 'test.t1'
|
||||
create table t1(c1 enum('a', 'b', 'c'), c2 set('a', 'b', 'c'));
|
||||
insert into t1 values(1, 1), (2, 2);
|
||||
select * from t1;
|
||||
+------+------+
|
||||
| c1 | c2 |
|
||||
+------+------+
|
||||
| a | a |
|
||||
| b | b |
|
||||
+------+------+
|
||||
drop table t2;
|
||||
create table t2(col_utf16 varchar(100) collate utf16_bin,
|
||||
col_gbk varchar(100) collate gbk_chinese_ci,
|
||||
col_utf8 varchar(100) collate utf8_general_ci);
|
||||
ERROR HY000: Unknown collation: 'utf16_bin'
|
||||
insert into t2 values('a', 'a', 'a');
|
||||
ERROR 42S02: Table 'test.t2' doesn't exist
|
||||
// insert enum/set using different collation string
|
||||
insert into t1 select col_utf16, col_utf16 from t2;
|
||||
ERROR 42S02: Table 'test.t2' doesn't exist
|
||||
insert into t1 select col_gbk, col_gbk from t2;
|
||||
ERROR 42S02: Table 'test.t2' doesn't exist
|
||||
insert into t1 select col_utf8, col_utf8 from t2;
|
||||
ERROR 42S02: Table 'test.t2' doesn't exist
|
||||
select * from t1;
|
||||
+------+------+
|
||||
| c1 | c2 |
|
||||
+------+------+
|
||||
| a | a |
|
||||
| b | b |
|
||||
+------+------+
|
||||
|
||||
delete from t1;
|
||||
delete from t2;
|
||||
ERROR 42S02: Table 'test.t2' doesn't exist
|
||||
insert into t1 values('a', 'b'), ('b', 'c');
|
||||
select * from t1;
|
||||
+------+------+
|
||||
| c1 | c2 |
|
||||
+------+------+
|
||||
| a | b |
|
||||
| b | c |
|
||||
+------+------+
|
||||
// insert different collation string using enum/set
|
||||
insert into t2 select c1, c1, c1 from t1;
|
||||
ERROR 42S02: Table 'test.t2' doesn't exist
|
||||
insert into t2 select c2, c2, c2 from t1;
|
||||
ERROR 42S02: Table 'test.t2' doesn't exist
|
||||
select * from t2;
|
||||
ERROR 42S02: Table 'test.t2' doesn't exist
|
||||
delete from t2;
|
||||
ERROR 42S02: Table 'test.t2' doesn't exist
|
||||
// test again(using different column)
|
||||
insert into t2 select c1, c2, c1 from t1;
|
||||
ERROR 42S02: Table 'test.t2' doesn't exist
|
||||
insert into t2 select c2, c2, c1 from t1;
|
||||
ERROR 42S02: Table 'test.t2' doesn't exist
|
||||
insert into t2 select c1, c1, c2 from t1;
|
||||
ERROR 42S02: Table 'test.t2' doesn't exist
|
||||
select * from t2;
|
||||
ERROR 42S02: Table 'test.t2' doesn't exist
|
||||
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
ERROR 42S02: Unknown table 'test.t2'
|
||||
|
||||
drop table if exists t2;
|
||||
create table t2 (c1 int primary key, c2 int) partition by hash(c1) partitions 3;
|
||||
insert into t2 select -127,30 from dual;
|
||||
select * from t2 partition (p1);
|
||||
+------+------+
|
||||
| c1 | c2 |
|
||||
+------+------+
|
||||
| -127 | 30 |
|
||||
+------+------+
|
||||
drop table t2;
|
||||
|
||||
@ -0,0 +1,309 @@
|
||||
result_format: 4
|
||||
explain_protocol: 0
|
||||
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 number, c2 number, c3 char(20), c4 varchar(20), primary key(c1, c2), index i1 (c2));
|
||||
|
||||
insert into t1 (c1, c2, c3, c4) values (1, 2, 'a', 'b');
|
||||
insert into t1 (c1, c2, c3, c4) values (3, 4, 'c', 'd');
|
||||
insert into t1 (c1, c2, c3, c4) values (5, 1, 'xx', 'yy');
|
||||
insert into t1 (c1, c2, c3, c4) values (5, 2, 'xx', 'yy');
|
||||
insert into t1 (c1, c2, c3, c4) values (7, 5, 'xx1', 'yy2');
|
||||
insert into t1 (c1, c2, c3, c4) values (7, 6, 'xx1', 'yy2');
|
||||
insert into t1 (c1, c2, c3, c4) values (8, 7, 'xx1', 'yy2');
|
||||
|
||||
alter table t1 add column c5 varchar(20) default 'c5_default';
|
||||
|
||||
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
explain_protocol: 2
|
||||
EXPLAIN select * from t1;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t1 |7 |38 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5]), filter(nil),
|
||||
access([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5]), partitions(p0)
|
||||
|
||||
select * from t1;
|
||||
+----+----+------+------+------------+
|
||||
| c1 | c2 | c3 | c4 | c5 |
|
||||
+----+----+------+------+------------+
|
||||
| 1 | 2 | a | b | c5_default |
|
||||
| 3 | 4 | c | d | c5_default |
|
||||
| 5 | 1 | xx | yy | c5_default |
|
||||
| 5 | 2 | xx | yy | c5_default |
|
||||
| 7 | 5 | xx1 | yy2 | c5_default |
|
||||
| 7 | 6 | xx1 | yy2 | c5_default |
|
||||
| 8 | 7 | xx1 | yy2 | c5_default |
|
||||
+----+----+------+------+------------+
|
||||
EXPLAIN select * from t1 order by c1 desc, c2 desc;
|
||||
Query Plan
|
||||
==========================================
|
||||
|ID|OPERATOR |NAME |EST. ROWS|COST|
|
||||
------------------------------------------
|
||||
|0 |TABLE SCAN|t1(Reverse)|7 |38 |
|
||||
==========================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5]), filter(nil),
|
||||
access([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5]), partitions(p0)
|
||||
|
||||
select * from t1 order by c1 desc, c2 desc;
|
||||
+----+----+------+------+------------+
|
||||
| c1 | c2 | c3 | c4 | c5 |
|
||||
+----+----+------+------+------------+
|
||||
| 8 | 7 | xx1 | yy2 | c5_default |
|
||||
| 7 | 6 | xx1 | yy2 | c5_default |
|
||||
| 7 | 5 | xx1 | yy2 | c5_default |
|
||||
| 5 | 2 | xx | yy | c5_default |
|
||||
| 5 | 1 | xx | yy | c5_default |
|
||||
| 3 | 4 | c | d | c5_default |
|
||||
| 1 | 2 | a | b | c5_default |
|
||||
+----+----+------+------+------------+
|
||||
EXPLAIN select * from t1 where c1 + c2 < 10;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t1 |3 |39 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5]), filter([t1.c1 + t1.c2 < ?]),
|
||||
access([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5]), partitions(p0)
|
||||
|
||||
select * from t1 where c1 + c2 < 10;
|
||||
+----+----+------+------+------------+
|
||||
| c1 | c2 | c3 | c4 | c5 |
|
||||
+----+----+------+------+------------+
|
||||
| 1 | 2 | a | b | c5_default |
|
||||
| 3 | 4 | c | d | c5_default |
|
||||
| 5 | 1 | xx | yy | c5_default |
|
||||
| 5 | 2 | xx | yy | c5_default |
|
||||
+----+----+------+------+------------+
|
||||
EXPLAIN select * from t1 limit 2;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t1 |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5]), filter(nil),
|
||||
access([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5]), partitions(p0),
|
||||
limit(2), offset(nil)
|
||||
|
||||
select * from t1 limit 2;
|
||||
+----+----+------+------+------------+
|
||||
| c1 | c2 | c3 | c4 | c5 |
|
||||
+----+----+------+------+------------+
|
||||
| 1 | 2 | a | b | c5_default |
|
||||
| 3 | 4 | c | d | c5_default |
|
||||
+----+----+------+------+------------+
|
||||
EXPLAIN select * from t1 where c1 = 5;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t1 |2 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5]), filter(nil),
|
||||
access([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5]), partitions(p0)
|
||||
|
||||
select * from t1 where c1 = 5;
|
||||
+----+----+------+------+------------+
|
||||
| c1 | c2 | c3 | c4 | c5 |
|
||||
+----+----+------+------+------------+
|
||||
| 5 | 1 | xx | yy | c5_default |
|
||||
| 5 | 2 | xx | yy | c5_default |
|
||||
+----+----+------+------+------------+
|
||||
EXPLAIN select * from t1 where c1 = 5 or c1 = 7;
|
||||
Query Plan
|
||||
===================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
-----------------------------------
|
||||
|0 |TABLE SCAN|t1 |4 |37 |
|
||||
===================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5]), filter(nil),
|
||||
access([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5]), partitions(p0)
|
||||
|
||||
select * from t1 where c1 = 5 or c1 = 7;
|
||||
+----+----+------+------+------------+
|
||||
| c1 | c2 | c3 | c4 | c5 |
|
||||
+----+----+------+------+------------+
|
||||
| 5 | 1 | xx | yy | c5_default |
|
||||
| 5 | 2 | xx | yy | c5_default |
|
||||
| 7 | 5 | xx1 | yy2 | c5_default |
|
||||
| 7 | 6 | xx1 | yy2 | c5_default |
|
||||
+----+----+------+------+------------+
|
||||
EXPLAIN select * from t1 where (c1 = 2 and c2 = 4) or (c1 = 7 and c2 = 5) or (c1 = 8 and c2 = 7);
|
||||
Query Plan
|
||||
==================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
----------------------------------
|
||||
|0 |TABLE GET|t1 |3 |63 |
|
||||
==================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5]), filter(nil),
|
||||
access([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5]), partitions(p0)
|
||||
|
||||
select * from t1 where (c1 = 2 and c2 = 4) or (c1 = 7 and c2 = 5) or (c1 = 8 and c2 = 7);
|
||||
+----+----+------+------+------------+
|
||||
| c1 | c2 | c3 | c4 | c5 |
|
||||
+----+----+------+------+------------+
|
||||
| 7 | 5 | xx1 | yy2 | c5_default |
|
||||
| 8 | 7 | xx1 | yy2 | c5_default |
|
||||
+----+----+------+------+------------+
|
||||
|
||||
EXPLAIN select * from t1 where c2 = 2 and c1 + c2 < 10 and c4 > c3;
|
||||
Query Plan
|
||||
=====================================
|
||||
|ID|OPERATOR |NAME |EST. ROWS|COST|
|
||||
-------------------------------------
|
||||
|0 |TABLE SCAN|t1(i1)|1 |88 |
|
||||
=====================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2], [t1.c3], [t1.c4], [t1.c5]), filter([t1.c1 + t1.c2 < ?], [t1.c4 > t1.c3]),
|
||||
access([t1.c2], [t1.c1], [t1.c4], [t1.c3], [t1.c5]), partitions(p0)
|
||||
|
||||
select * from t1 where c2 = 2 and c1 + c2 < 10 and c4 > c3;
|
||||
+----+----+------+------+------------+
|
||||
| c1 | c2 | c3 | c4 | c5 |
|
||||
+----+----+------+------+------------+
|
||||
| 1 | 2 | a | b | c5_default |
|
||||
| 5 | 2 | xx | yy | c5_default |
|
||||
+----+----+------+------+------------+
|
||||
|
||||
EXPLAIN select c1, c2 from t1 where c2 > 4;
|
||||
Query Plan
|
||||
=====================================
|
||||
|ID|OPERATOR |NAME |EST. ROWS|COST|
|
||||
-------------------------------------
|
||||
|0 |TABLE SCAN|t1(i1)|3 |37 |
|
||||
=====================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2]), filter(nil),
|
||||
access([t1.c2], [t1.c1]), partitions(p0)
|
||||
|
||||
select c1, c2 from t1 where c2 > 4;
|
||||
+----+----+
|
||||
| c1 | c2 |
|
||||
+----+----+
|
||||
| 7 | 5 |
|
||||
| 7 | 6 |
|
||||
| 8 | 7 |
|
||||
+----+----+
|
||||
|
||||
***** test index back
|
||||
drop table t1;
|
||||
create table t1(c1 int primary key, c2 int, c3 int, index idx(c2));
|
||||
EXPLAIN insert into t1 values(1,1,1), (2,2,2), (3,3,3), (4,4,4),(5,5,5), (6,6,6), (7,7,7);
|
||||
Query Plan
|
||||
====================================
|
||||
|ID|OPERATOR |NAME|EST. ROWS|COST|
|
||||
------------------------------------
|
||||
|0 |INSERT | |7 |2 |
|
||||
|1 | EXPRESSION| |7 |1 |
|
||||
====================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([column_conv(INT,PS:(11,0),NOT NULL,__values.c1)], [column_conv(INT,PS:(11,0),NULL,__values.c2)], [column_conv(INT,PS:(11,0),NULL,__values.c3)]), filter(nil),
|
||||
columns([{t1: ({t1: (t1.c1, t1.c2, t1.c3)})}]), partitions(p0)
|
||||
1 - output([__values.c1], [__values.c2], [__values.c3]), filter(nil)
|
||||
values({1, 1, 1}, {2, 2, 2}, {3, 3, 3}, {4, 4, 4}, {5, 5, 5}, {6, 6, 6}, {7, 7, 7})
|
||||
|
||||
insert into t1 values(1,1,1), (2,2,2), (3,3,3), (4,4,4),(5,5,5), (6,6,6), (7,7,7);
|
||||
|
||||
|
||||
# case 1: index back with before_index_back_filter
|
||||
EXPLAIN select /*+index(t1 idx)*/ c1, c2, c3 from t1 where c2 > 1 and c1 < 4;
|
||||
Query Plan
|
||||
======================================
|
||||
|ID|OPERATOR |NAME |EST. ROWS|COST|
|
||||
--------------------------------------
|
||||
|0 |TABLE SCAN|t1(idx)|1 |88 |
|
||||
======================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2], [t1.c3]), filter([t1.c1 < 4]),
|
||||
access([t1.c2], [t1.c1], [t1.c3]), partitions(p0)
|
||||
|
||||
select /*+index(t1 idx)*/ c1, c2, c3 from t1 where c2 > 1 and c1 < 4;
|
||||
+----+------+------+
|
||||
| c1 | c2 | c3 |
|
||||
+----+------+------+
|
||||
| 2 | 2 | 2 |
|
||||
| 3 | 3 | 3 |
|
||||
+----+------+------+
|
||||
|
||||
|
||||
# case 2: index back without before_index_back_filter
|
||||
EXPLAIN select /*+index(t1 idx)*/ c1, c2, c3 from t1 where c2 > 1 and c3 < 4;
|
||||
Query Plan
|
||||
======================================
|
||||
|ID|OPERATOR |NAME |EST. ROWS|COST|
|
||||
--------------------------------------
|
||||
|0 |TABLE SCAN|t1(idx)|1 |116 |
|
||||
======================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2], [t1.c3]), filter([t1.c3 < 4]),
|
||||
access([t1.c2], [t1.c3], [t1.c1]), partitions(p0)
|
||||
|
||||
select /*+index(t1 idx)*/ c1, c2, c3 from t1 where c2 > 1 and c3 < 4;
|
||||
+----+------+------+
|
||||
| c1 | c2 | c3 |
|
||||
+----+------+------+
|
||||
| 2 | 2 | 2 |
|
||||
| 3 | 3 | 3 |
|
||||
+----+------+------+
|
||||
|
||||
EXPLAIN select /*+index(t1 idx)*/ c1, c2, c3 from t1 where c3 != 1 limit 2;
|
||||
Query Plan
|
||||
======================================
|
||||
|ID|OPERATOR |NAME |EST. ROWS|COST|
|
||||
--------------------------------------
|
||||
|0 |TABLE SCAN|t1(idx)|2 |96 |
|
||||
======================================
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([t1.c1], [t1.c2], [t1.c3]), filter([t1.c3 != 1]),
|
||||
access([t1.c3], [t1.c1], [t1.c2]), partitions(p0),
|
||||
limit(2), offset(nil)
|
||||
|
||||
select /*+index(t1 idx)*/ c1, c2, c3 from t1 where c3 != 1 limit 2;
|
||||
+----+------+------+
|
||||
| c1 | c2 | c3 |
|
||||
+----+------+------+
|
||||
| 2 | 2 | 2 |
|
||||
| 3 | 3 | 3 |
|
||||
+----+------+------+
|
||||
|
||||
drop table t1;
|
||||
@ -0,0 +1,86 @@
|
||||
# owner: luofan.zp
|
||||
# owner group: sql2
|
||||
|
||||
--result_format 4
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
connection conn_admin;
|
||||
--disable_warnings
|
||||
drop database if exists shaoge;
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
create database shaoge;
|
||||
use shaoge;
|
||||
|
||||
create table t1(col_float float, col_char char(100), col_text text);
|
||||
insert into t1 values (1.1, '1.1', '1.1');
|
||||
insert into t1 values (1.9, '1.9', '1.9');
|
||||
insert into t1 values (2.1, '2.1', '2.1');
|
||||
insert into t1 values (2.9, '2.9', '2.9');
|
||||
insert into t1 values (9223372036854775807, '9223372036854775807', '9223372036854775807');
|
||||
insert into t1 values (9223372036854775807.5, '9223372036854775807.5', '9223372036854775807.5');
|
||||
insert into t1 values (9223372036854775806.5, '9223372036854775806.5', '9223372036854775806.5');
|
||||
insert into t1 values (null, '1234567890123456789012345678901234567890.5', '1234567890123456789012345678901234567890.5');
|
||||
|
||||
insert into t1 values (-1.1, '-1.1', '-1.1');
|
||||
insert into t1 values (-1.9, '-1.9', '-1.9');
|
||||
insert into t1 values (-2.1, '-2.1', '-2.1');
|
||||
insert into t1 values (-2.9, '-2.9', '-2.9');
|
||||
insert into t1 values (-9223372036854775807, '-9223372036854775808', '-9223372036854775808');
|
||||
insert into t1 values (-9223372036854775807.5, '-9223372036854775807.5', '-9223372036854775807.5');
|
||||
insert into t1 values (-9223372036854775806.5, '-9223372036854775806.5', '-9223372036854775806.5');
|
||||
insert into t1 values (null, '-1234567890123456789012345678901234567890.5', '-1234567890123456789012345678901234567890.5');
|
||||
|
||||
create table tbl_check_zerofill(col_zf int(3) zerofill, col_no_zf int(3));
|
||||
insert into tbl_check_zerofill values(1, 1);
|
||||
|
||||
--echo // sql engine 3.0 test
|
||||
--echo // string->int/uint will trunc
|
||||
--echo // otherwise will round
|
||||
select col_float, cast(col_float as signed) from t1;
|
||||
select col_char, cast(col_char as signed) from t1;
|
||||
select col_text, cast(col_text as signed) from t1;
|
||||
|
||||
select col_float, cast(col_float as unsigned) from t1;
|
||||
select col_char, cast(col_char as unsigned) from t1;
|
||||
select col_text, cast(col_text as unsigned) from t1;
|
||||
|
||||
--echo // 测试zerofill
|
||||
--echo // 应该有warning: Truncated incorrect CHAR(1) value: '001'
|
||||
select cast(col_zf as char(1)) from tbl_check_zerofill;
|
||||
select cast(col_zf as char(2)) from tbl_check_zerofill;
|
||||
select cast(col_zf as char(3)) from tbl_check_zerofill;
|
||||
select cast(col_zf as char(4)) from tbl_check_zerofill;
|
||||
select cast(col_no_zf as char(1)) from tbl_check_zerofill;
|
||||
select cast(col_no_zf as char(1)) from tbl_check_zerofill;
|
||||
select cast(col_no_zf as char(2)) from tbl_check_zerofill;
|
||||
select cast(col_no_zf as char(3)) from tbl_check_zerofill;
|
||||
select cast(col_no_zf as char(4)) from tbl_check_zerofill;
|
||||
|
||||
|
||||
drop table t1;
|
||||
create table t1(c1 varchar(3));
|
||||
insert into t1 values('abc');
|
||||
select cast(c1 as char(10)), concat(c1, '123') from t1;
|
||||
select cast(c1 as char(1)), concat(c1, '123') from t1;
|
||||
select concat(cast(c1 as char(10)), '123') from t1;
|
||||
select concat(cast(c1 as char(1)), '123') from t1;
|
||||
|
||||
drop table t1;
|
||||
create table t1(c1 decimal(10, 3));
|
||||
insert into t1 values(1.123);
|
||||
select cast(c1 as decimal(10,1)), concat(c1, 'abc') from t1;
|
||||
select c1, cast(c1 as binary(10)), hex(cast(c1 as binary(10))) from t1;
|
||||
|
||||
drop table t1;
|
||||
create table t1(c1 time(6));
|
||||
insert into t1 values('11:11:11.123456');
|
||||
select cast(c1 as time), concat(c1, 'abc') from t1;
|
||||
|
||||
drop table t1;
|
||||
create table t1(c1 bigint unsigned);
|
||||
insert into t1 values(18446744073709551615);
|
||||
select cast(c1 as signed) from t1;
|
||||
select c1, cast(c1 as binary(30)), hex(cast(c1 as binary(30))) from t1;
|
||||
|
||||
drop table t1;
|
||||
108
tools/deploy/mysql_test/test_suite/static_engine/t/expr_abs.test
Normal file
108
tools/deploy/mysql_test/test_suite/static_engine/t/expr_abs.test
Normal file
@ -0,0 +1,108 @@
|
||||
#owner: peihan.dph
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
connection conn_admin;
|
||||
|
||||
--sleep 2
|
||||
alter system flush plan cache global;
|
||||
|
||||
connection default;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t;
|
||||
--enable_warnings
|
||||
|
||||
create table t (t1 tinyint,
|
||||
t2 smallint,
|
||||
t3 mediumint,
|
||||
t4 integer,
|
||||
t5 bigint,
|
||||
t6 tinyint unsigned,
|
||||
t7 smallint unsigned,
|
||||
t8 mediumint unsigned,
|
||||
t9 integer unsigned,
|
||||
t10 bigint unsigned,
|
||||
t11 float,
|
||||
t12 float unsigned,
|
||||
t13 double,
|
||||
t14 double unsigned,
|
||||
t15 number,
|
||||
t16 number unsigned,
|
||||
t17 datetime,
|
||||
t18 timestamp,
|
||||
t19 date,
|
||||
t20 time,
|
||||
t21 year,
|
||||
t22 varchar(255),
|
||||
t23 char(255),
|
||||
t24 tinytext,
|
||||
t25 mediumtext,
|
||||
t26 longtext,
|
||||
t27 bit,
|
||||
t28 enum('a', 'b', 'c'),
|
||||
t29 set('a', 'b', 'c'));
|
||||
|
||||
insert into t values (1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -0.2, 0.3, 0.4, 0.5, -0.6, 0.7,
|
||||
'1993-03-20', '1993-03-20', '1993-03-20', '10:10:10', '1993', '0.8', '0.9', '1.0', '1.1',
|
||||
'1.2', 1, 'b', 'b');
|
||||
insert into t(t1) values (null);
|
||||
|
||||
connection conn_admin;
|
||||
|
||||
--sleep 2
|
||||
alter system flush plan cache global;
|
||||
|
||||
connection default;
|
||||
set ob_enable_plan_cache=false;
|
||||
|
||||
select abs(1.0);
|
||||
explain select abs(1.0);
|
||||
select abs(1);
|
||||
explain select abs(1);
|
||||
select abs(1+2+3-4-1-2+5-5);
|
||||
explain select abs(1+2+3-4-1-2+5-5);
|
||||
select abs(abs(1+2+3-4-1-2+5-5)-abs(-3));
|
||||
explain select abs(abs(1+2+3-4-1-2+5-5)-abs(-3));
|
||||
select abs(true and false);
|
||||
explain select abs(true and false);
|
||||
select abs(10/0);
|
||||
SELECT ABS(-9223372036854775808);
|
||||
explain SELECT ABS(-9223372036854775808);
|
||||
select abs(-9999999999999999999999);
|
||||
explain select abs(-9999999999999999999999);
|
||||
select abs(9999999999999999999999);
|
||||
explain select abs(9999999999999999999999);
|
||||
select abs(repeat('1',100));
|
||||
explain select abs(repeat('1',100));
|
||||
select abs(repeat('1',46));
|
||||
explain select abs(repeat('1',46));
|
||||
select abs(0-repeat('1',46));
|
||||
explain select abs(0-repeat('1',46));
|
||||
|
||||
let $cnt=1;
|
||||
|
||||
while ($cnt <= 29)
|
||||
{
|
||||
eval select abs(t$cnt) from t;
|
||||
eval explain select abs(t$cnt) from t;
|
||||
inc $cnt;
|
||||
}
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1(c1 decimal unsigned, c2 smallint unsigned);
|
||||
insert into t1 values(1, 1);
|
||||
select mod(round(abs(c1)), c2) from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo // abs(hex_string)
|
||||
select abs(X'31');
|
||||
select abs(binary'-100');
|
||||
select abs(_utf8'-100');
|
||||
connection conn_admin;
|
||||
--sleep 2
|
||||
|
||||
@ -0,0 +1,207 @@
|
||||
# owner: peihan.dph
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
connection conn_admin;
|
||||
|
||||
sleep 2;
|
||||
set ob_enable_plan_cache = 0;
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1(col_int int,
|
||||
col_zero int,
|
||||
col_null int,
|
||||
col_varchar varchar(100),
|
||||
col_varchar_num varchar(100),
|
||||
col_empty_str varchar(100),
|
||||
col_varchar_zero varchar(100));
|
||||
insert into t1 values(1, 0, null, 'abc', '1', '', '0');
|
||||
|
||||
--explain_protocol 2
|
||||
--echo // Case1: normal test
|
||||
--echo // Case1.1: int test
|
||||
--echo // bool expr exists, no cast expr, res is NULL
|
||||
select col_int and col_null from t1;
|
||||
--echo // same as above
|
||||
select col_null and col_int from t1;
|
||||
|
||||
--echo // bool expr exists for col_varchar, cast expr exists, res is 0
|
||||
select col_int and col_varchar from t1;
|
||||
--echo // same as above
|
||||
select col_varchar and col_int from t1;
|
||||
|
||||
--echo // bool expr and cast expr exists for col_varchar_num, res is 0
|
||||
select col_int and col_varchar_num from t1;
|
||||
--echo // same as above
|
||||
select col_varchar_num and col_int from t1;
|
||||
|
||||
--echo // bool expr exists, no cast expr, res is 0
|
||||
select col_int and 0 from t1;
|
||||
--echo // same as above
|
||||
select 0 and col_int from t1;
|
||||
|
||||
--echo // Case1.1: null test
|
||||
--echo // bool expr exists, no cast expr, res is NULL
|
||||
select col_null and col_null from t1;
|
||||
--echo // bool expr and cast expr exists for col_varchar_num, res is NULL
|
||||
select col_null and col_varchar_num from t1;
|
||||
--echo // same as above
|
||||
select col_varchar_num and col_null from t1;
|
||||
|
||||
--echo // bool expr and cast expr exists for col_varchar_num, res is 0
|
||||
select col_null and col_varchar from t1;
|
||||
--echo // same as above
|
||||
select col_varchar and col_null from t1;
|
||||
|
||||
--echo // same as above
|
||||
select col_null and 0 from t1;
|
||||
|
||||
--echo // Case1.2: 0 test
|
||||
--echo // bool expr exists, no cast expr, res is 0
|
||||
select col_varchar_num and 0 from t1;
|
||||
--echo // same as above
|
||||
select col_varchar_num and 0 from t1;
|
||||
|
||||
--echo // Case1.3: empty str test
|
||||
--echo // bool expr and cast expr exists for empty str, res is 0
|
||||
select col_int and '' from t1;
|
||||
--echo // same as above
|
||||
select '' and col_int from t1;
|
||||
|
||||
--echo // bool expr and cast expr exists for empty str and col_varchar, res is 0
|
||||
select col_varchar and '' from t1;
|
||||
--echo // same as above
|
||||
select '' and col_varchar from t1;
|
||||
--echo // bool expr and cast expr exists for empty str and col_varchar_num, res is 0
|
||||
select col_varchar_num and '' from t1;
|
||||
|
||||
--echo // same as above
|
||||
select '' and col_varchar_num from t1;
|
||||
|
||||
--echo // Case2: create table as test. 因为select/explain语句对应的cast mode
|
||||
--echo // 有WARN_ON_FAIL。其他的没有,所以结果是有区别的
|
||||
--echo // TODO: 目前没法测试,建表语句还不完善
|
||||
|
||||
--echo // Case3: or test
|
||||
--echo // Case3.1 normal test
|
||||
--echo // bool expr exists, res is 1
|
||||
select col_int or col_int from t1;
|
||||
--echo // bool expr exists, res is 0
|
||||
select col_zero or col_zero from t1;
|
||||
--echo // bool expr exists, cast expr exists res is 0
|
||||
select col_varchar_zero or col_varchar_zero from t1;
|
||||
|
||||
--echo // Case3.2 null test
|
||||
--echo // bool expr exists, res is NULL
|
||||
select col_null or col_null from t1;
|
||||
--echo // bool expr exists, res is 1
|
||||
select col_int or col_null from t1;
|
||||
--echo // same as above
|
||||
select col_null or col_int from t1;
|
||||
|
||||
--echo // bool expr exists, res is NULL
|
||||
select col_zero or col_null from t1;
|
||||
--echo // same as above
|
||||
select col_null or col_zero from t1;
|
||||
|
||||
--echo // bool expr exists, res is 1
|
||||
select col_varchar_num or col_null from t1;
|
||||
--echo // same as above
|
||||
select col_null or col_varchar_num from t1;
|
||||
|
||||
--echo // bool expr exists, res is NULL
|
||||
select col_varchar_zero or col_null from t1;
|
||||
--echo // same as above
|
||||
select col_null or col_varchar_zero from t1;
|
||||
|
||||
--echo // Case3.3 empty str test
|
||||
--echo // bool expr exists, res is NULL
|
||||
select col_null or '' from t1;
|
||||
--echo // same as above
|
||||
select '' or col_null from t1;
|
||||
|
||||
--echo // bool expr exists, res is 1
|
||||
select col_int or '' from t1;
|
||||
--echo // same as above
|
||||
select '' or col_int from t1;
|
||||
|
||||
--echo // bool expr exists, res is 0
|
||||
select col_zero or '' from t1;
|
||||
--echo // same as above
|
||||
select '' or col_zero from t1;
|
||||
|
||||
--echo // res is 0
|
||||
select col_empty_str or '' from t1;
|
||||
|
||||
--echo // Case4: multi and test
|
||||
--echo // res is 1
|
||||
select 1 and 2 and 3 and col_int from t1;
|
||||
--echo // res is NULL
|
||||
select 1 and col_null and 3 and col_int from t1;
|
||||
--echo // res is 0
|
||||
select 1 and col_null and 3 and col_zero from t1;
|
||||
--echo // res is 0
|
||||
select 1 and col_null and 3 and col_empty_str from t1;
|
||||
|
||||
--echo // Case5: multi or test
|
||||
--echo // res is 1
|
||||
select 1 or 2 or col_int from t1;
|
||||
--echo // res is NULL
|
||||
select 1 or 2 or col_null from t1;
|
||||
--echo // res is 0
|
||||
select '' or 0 or col_null from t1;
|
||||
|
||||
--echo // Case6: 0, 1, null三个值组合测试,结果跟不开新引擎的结果进行对比
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
--explain_protocol 0
|
||||
create table t1 (c1 int, c2 int, c3 int,
|
||||
c4 float, c5 float, c6 float,
|
||||
c7 double, c8 double, c9 double,
|
||||
c10 decimal, c11 decimal, c12 decimal,
|
||||
c13 datetime, c14 datetime, c15 datetime,
|
||||
c16 timestamp, c17 timestamp, c18 timestamp,
|
||||
c19 date, c20 date, c21 date,
|
||||
c22 varchar(10), c23 varchar(10), c24 varchar(10),
|
||||
c25 char(11), c26 char(11), c27 char(12),
|
||||
c28 char(10), c29 char(10), c30 char(10));
|
||||
insert into t1 values(0, 1, null,
|
||||
0.0, 1.0, null,
|
||||
0.0, 1.0, null,
|
||||
0.0, 1.0, null,
|
||||
0, '2019-01-01 00:00:00', null,
|
||||
0, '2019-01-01 00:00:00', null,
|
||||
0, '2019-01-01', null,
|
||||
'0', '123', null,
|
||||
'0', '123', null,
|
||||
'0', 'abc', null);
|
||||
|
||||
--explain_protocol 2
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
let $cnt=3;
|
||||
let $left=1;
|
||||
while ($left <= $cnt)
|
||||
{
|
||||
let $right=1;
|
||||
while ($right <= $cnt)
|
||||
{
|
||||
eval select c$left, c$right, c$left and c$right from t1;
|
||||
eval select c$left, c$right, c$left or c$right from t1;
|
||||
|
||||
inc $right;
|
||||
}
|
||||
inc $left;
|
||||
}
|
||||
|
||||
--sleep 2
|
||||
drop table t1;
|
||||
CREATE TABLE t1(c0 VARCHAR(500), c1 DECIMAL);
|
||||
insert into t1 values('', 123);
|
||||
SELECT ALL t1.c0 AS ref0 FROM t1 WHERE (NULL AND ( CAST(COALESCE(t1.c0, EXISTS (SELECT 1)) AS SIGNED) IS NOT NULL)) IS NULL;
|
||||
drop table t1;
|
||||
@ -0,0 +1,65 @@
|
||||
# owner: dachuan.sdc
|
||||
# owner group: SQL2
|
||||
|
||||
--result_format 4
|
||||
--explain_protocol 0
|
||||
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
connection conn_admin;
|
||||
sleep 2;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1 (c1 int, c2 int unsigned,
|
||||
c3 tinyint, c4 tinyint unsigned,
|
||||
c5 smallint, c6 smallint unsigned,
|
||||
c7 mediumint, c8 mediumint unsigned,
|
||||
c9 integer, c10 integer unsigned,
|
||||
c11 bigint, c12 bigint unsigned,
|
||||
c13 float, c14 float unsigned,
|
||||
c15 double, c16 double unsigned,
|
||||
c17 decimal, c18 decimal unsigned,
|
||||
c19 datetime, c20 timestamp,
|
||||
c21 varchar(30), c22 char(30));
|
||||
insert into t1 values(1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
3.5, 4.5,
|
||||
5.5, 6.5,
|
||||
7.5, 8.5,
|
||||
'2019-12-01 12:00:00', '2019-12-03 06:00:00',
|
||||
'9.5', '10.5');
|
||||
|
||||
select @var1, @var2;
|
||||
|
||||
let $cnt=22;
|
||||
let $left=1;
|
||||
while ($left <= $cnt)
|
||||
{
|
||||
eval select @var2_$left := @var1_$left := c$left from t1;
|
||||
eval select @var1_$left, @var2_$left;
|
||||
inc $left;
|
||||
}
|
||||
|
||||
set @a = 1;
|
||||
select @a := @someval;
|
||||
select @a;
|
||||
--disable_warnings
|
||||
drop view if exists vv;
|
||||
--enable_warnings
|
||||
create view vv as select @a;
|
||||
desc vv;
|
||||
|
||||
select @a := null;
|
||||
select @a;
|
||||
--disable_warnings
|
||||
drop view if exists vv;
|
||||
--enable_warnings
|
||||
create view vv as select @a;
|
||||
desc vv;
|
||||
|
||||
sleep 2;
|
||||
@ -0,0 +1,184 @@
|
||||
# owner: peihan.dph
|
||||
# owner group: SQL2
|
||||
|
||||
--result_format 4
|
||||
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
connection conn_admin;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1, t2;
|
||||
--enable_warnings
|
||||
--explain_protocol 0
|
||||
create table t1 (
|
||||
col_tinyint tinyint,
|
||||
col_smallint smallint,
|
||||
col_mediumint tinyint,
|
||||
col_int int,
|
||||
col_bigint bigint,
|
||||
col_float float,
|
||||
col_double double,
|
||||
col_decimal decimal,
|
||||
|
||||
col_utinyint tinyint unsigned,
|
||||
col_usmallint smallint unsigned,
|
||||
col_umediumint tinyint unsigned,
|
||||
col_uint int unsigned,
|
||||
col_ubigint bigint unsigned,
|
||||
col_ufloat float unsigned,
|
||||
col_udouble double unsigned,
|
||||
col_udecimal decimal unsigned,
|
||||
|
||||
col_char char(100),
|
||||
col_varchar varchar(100),
|
||||
col_blob blob,
|
||||
col_text text,
|
||||
|
||||
col_date date,
|
||||
col_datetime datetime,
|
||||
col_timestamp timestamp,
|
||||
col_year year,
|
||||
col_time time,
|
||||
|
||||
col_bit bit
|
||||
);
|
||||
|
||||
insert into t1 values(
|
||||
-1,
|
||||
-2,
|
||||
-3,
|
||||
-4,
|
||||
-5,
|
||||
-1.0,
|
||||
-2.0,
|
||||
-111.11,
|
||||
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1.0,
|
||||
2.0,
|
||||
111.11,
|
||||
|
||||
'0',
|
||||
'varchar type',
|
||||
'blob type',
|
||||
'text type',
|
||||
|
||||
'2019-01-01',
|
||||
'2019-01-01 00:00:00',
|
||||
'2019-01-01 00:00:00',
|
||||
'1997',
|
||||
'00:12:12',
|
||||
|
||||
b'001'
|
||||
);
|
||||
create table t2 (c1 int);
|
||||
insert into t2 values(1);
|
||||
|
||||
--echo // Case1: AND/OR测试
|
||||
set ob_enable_plan_cache = 0;
|
||||
--sleep 2
|
||||
--explain_protocol 2
|
||||
--echo // 两个col_int上面应该有bool expr
|
||||
select col_int and col_int from t1;
|
||||
--echo // 两个col_xxx上面都应该有bool expr,col_varchar上面应该有cast,转换为decimal
|
||||
select col_int and col_varchar from t1;
|
||||
--echo // 两个col_int上面应该有bool expr
|
||||
select col_int or col_int from t1;
|
||||
--echo // 两个col_xxx上面都应该有bool expr,col_varchar上面应该有cast,转换为decimal
|
||||
select col_int or col_varchar from t1;
|
||||
|
||||
--echo // 两个col_uint上面应该有bool expr, 结果为0
|
||||
select 1 and col_uint from t1;
|
||||
--echo // 两个col_xxx上面都应该有bool expr,col_char上面应该有cast,转换为decimal, 结果为0
|
||||
select 1 and col_char from t1;
|
||||
--echo // 两个col_uint上面应该有bool expr, 结果为0
|
||||
select col_uint or col_uint from t1;
|
||||
--echo // 两个col_xxx上面都应该有bool expr,col_char上面应该有cast,转换为decimal, 结果为0
|
||||
select col_uint or col_char from t1;
|
||||
--echo // 两个col_uint上面应该有bool expr, 结果为1
|
||||
select col_uint or 1 from t1;
|
||||
--echo // 两个col_xxx上面都应该有bool expr,col_char上面应该有cast,转换为decimal, 结果为1
|
||||
select 1 or col_char from t1;
|
||||
|
||||
--echo // Case2: 有布尔语义的表达式,不会有bool expr被插入
|
||||
--echo // and表达式的两个子节点都是有布尔语义的,所以bool expr不会出现
|
||||
select col_int from t1 where (col_int = col_int) and (col_uint = col_uint);
|
||||
--echo // 同上,也不会有bool expr
|
||||
select 1 from t1 where t1.col_int = t1.col_uint;
|
||||
--echo // 同上,也不会有bool expr
|
||||
select col_int from t1 having avg(col_int) = 1;
|
||||
--echo // 同上,也不会有bool expr
|
||||
select 1 from t1 inner join t2 on t2.c1 = t1.col_int;
|
||||
|
||||
--echo // Case3: TODO: 测试where/having/join condition,
|
||||
--echo // 需要想一些不带有布尔语义的作为各个子句的条件
|
||||
|
||||
--echo // Case4: 对各种类型进行测试,看能否顺利转换,且结果跟不加bool expr是一致的
|
||||
--explain_protocol 0
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1 (c1 int, c2 int unsigned,
|
||||
c3 tinyint, c4 tinyint unsigned,
|
||||
c5 smallint, c6 smallint unsigned,
|
||||
c7 mediumint, c8 mediumint unsigned,
|
||||
c9 integer, c10 integer unsigned,
|
||||
c11 bigint, c12 bigint unsigned,
|
||||
c13 float, c14 float unsigned,
|
||||
c15 double, c16 double unsigned,
|
||||
c17 decimal, c18 decimal unsigned,
|
||||
c19 datetime, c20 timestamp,
|
||||
c21 varchar(30), c22 char(30), c23 blob, c24 text);
|
||||
insert into t1 values(1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
3.5, 4.5,
|
||||
5.5, 6.5,
|
||||
7.5, 8.5,
|
||||
'2019-12-01 12:00:00', '2019-12-03 06:00:00',
|
||||
'9.5', '10.5', 'blob type', 'text type');
|
||||
-- sleep 2
|
||||
set ob_enable_plan_cache = 0;
|
||||
--explain_protocol 2
|
||||
let $cnt=24;
|
||||
let $left=1;
|
||||
while ($left <= $cnt)
|
||||
{
|
||||
let $right=1;
|
||||
while ($right <= $cnt)
|
||||
{
|
||||
eval select c$left and c$right from t1;
|
||||
eval select c$left or c$right from t1;
|
||||
|
||||
inc $right;
|
||||
}
|
||||
inc $left;
|
||||
}
|
||||
|
||||
--echo // Case5: case/if表达式测试
|
||||
--echo // 结果应该为'branch1',第一个when expr上面不应该有bool expr,其余的应该有bool expr
|
||||
select case when 'a' = 'a' then 'branch1' when 'b' then c1 else c2 end from t1;
|
||||
--echo // 结果应该为2,且when expr上面都应该 有bool expr
|
||||
--echo // TODO: 没有出现预期的warning
|
||||
select case when 'a' then 'str' when 'b' then c1 else c2 end from t1;
|
||||
--echo // 结果应该为'branch2',且if表达式会被转为case表达式,但是不应该有bool expr,因为判断本身就带有布尔语义
|
||||
select if ('a' = 'b', c1, 'branch2') from t1;
|
||||
--echo // 结果应该为'branch2',且if表达式会被转为case表达式,0上面应该有一个bool expr
|
||||
select if (0, c1, 'branch2') from t1;
|
||||
|
||||
--echo // Case6: not表达式测试
|
||||
--echo // c1是1,所以结果为0,且c1上面应该有bool expr
|
||||
select not c1 from t1;
|
||||
--echo // c1-1是0,所以结果为0,且c1上面应该有bool expr
|
||||
select not c1-1 from t1;
|
||||
--echo // 结果为1,且not的子节点上面没有bool expr
|
||||
select not (c1 and 0) from t1;
|
||||
|
||||
--sleep 2
|
||||
@ -0,0 +1,49 @@
|
||||
# owner: luofan.zp
|
||||
# owner group: SQL2
|
||||
|
||||
--result_format 4
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
connection conn_admin;
|
||||
alter system flush plan cache global;
|
||||
sleep 2;
|
||||
|
||||
set ob_enable_plan_cache = 0;
|
||||
select char_length(1234);
|
||||
select char_length(1);
|
||||
select char_length(null);
|
||||
select char_length('');
|
||||
select char_length('a');
|
||||
select char_length(' a ');
|
||||
select char_length(' a b');
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1 (c1 int, c2 char(10), c3 varchar(10), c4 timestamp, c5 decimal);
|
||||
# ,c6 varchar(100) charset utf16);
|
||||
insert into t1 values(1, 'a ', 'a ', '2010-01-01 11:11:11', 10.1);
|
||||
#, 123);
|
||||
|
||||
select char_length(c1) from t1;
|
||||
select char_length(c2) from t1;
|
||||
select char_length(c3) from t1;
|
||||
select char_length(c4) from t1;
|
||||
select char_length(c5) from t1;
|
||||
# select char_length(c6) from t1;
|
||||
|
||||
|
||||
sleep 2;
|
||||
|
||||
#bug 43837470
|
||||
|
||||
drop table if exists t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1), (2);
|
||||
--error 1242
|
||||
select CHAR_LENGTH(
|
||||
case when 62 <= (
|
||||
select a from t1
|
||||
) then '1' else '22' end);
|
||||
|
||||
drop table t1;
|
||||
|
||||
@ -0,0 +1,76 @@
|
||||
#owner: luofan.zp
|
||||
#owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
--explain_protocol 0
|
||||
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
|
||||
connection conn_admin;
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
#set @@ob_log_level='debug';
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
create table t1 (c1 int, c2 int unsigned,
|
||||
c3 tinyint, c4 tinyint unsigned,
|
||||
c5 smallint, c6 smallint unsigned,
|
||||
c7 mediumint, c8 mediumint unsigned,
|
||||
c9 integer, c10 integer unsigned,
|
||||
c11 bigint, c12 bigint unsigned,
|
||||
c13 float, c14 float unsigned,
|
||||
c15 double, c16 double unsigned,
|
||||
c17 decimal, c18 decimal unsigned,
|
||||
c19 datetime, c20 timestamp,
|
||||
c21 varchar(30), c22 char(30),
|
||||
c23 varchar(30) charset utf8);
|
||||
|
||||
insert into t1 values(1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
3.5, 4.5,
|
||||
5.5, 6.5,
|
||||
7.5, 8.5,
|
||||
'2019-12-01 12:00:00', '2019-12-03 06:00:00',
|
||||
'9.5', '10.5', 'utf8 col');
|
||||
insert into t1 values(-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-3.5, 4.5,
|
||||
-5.5, 6.5,
|
||||
-7.5, 8.5,
|
||||
'2019-12-01 12:00:00', '2019-12-03 06:00:00',
|
||||
'-9.5', '10.5', 'utf8 col');
|
||||
|
||||
--sleep 1
|
||||
|
||||
#--explain_protocol 2
|
||||
let $cnt=22;
|
||||
let $left=1;
|
||||
while ($left <= $cnt)
|
||||
{
|
||||
eval select c$left, charset(c$left), collation(c$left), coercibility(c$left) from t1;
|
||||
inc $left;
|
||||
}
|
||||
|
||||
--echo // test set_collation expr
|
||||
--echo // set_collation表达式检查charset与collate不匹配,报错
|
||||
--echo // 下面的是等号表达式在类型推导时,进行aggregate collation发现collation不一致报错
|
||||
--error 1267
|
||||
select _utf8mb4'a' collate utf8mb4_general_ci = _utf8mb4'A' collate utf8mb4_bin;
|
||||
select _utf8mb4'a' collate utf8mb4_general_ci = _utf8mb4'A' collate utf8mb4_general_ci;
|
||||
select _utf8mb4'a' collate utf8mb4_bin = _utf8mb4'A' collate utf8mb4_bin;
|
||||
|
||||
|
||||
drop table t1;
|
||||
--sleep 2
|
||||
@ -0,0 +1,76 @@
|
||||
# owner: bin.lb
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
connection syscon;
|
||||
--sleep 2
|
||||
connection default;
|
||||
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 varchar(2000), c2 varchar(2000));
|
||||
insert into t1 (c1, c2) values ('a', 'b');
|
||||
insert into t1 (c1, c2) values (repeat('a', 50), repeat('b', 50));
|
||||
insert into t1 (c1, c2) values (repeat('a', 100), repeat('b', 100));
|
||||
insert into t1 (c1, c2) values (repeat('a', 200), repeat('b', 300));
|
||||
insert into t1 (c1, c2) values (repeat('a', 1000), repeat('b', 800));
|
||||
insert into t1 (c1, c2) values ('a', 'b');
|
||||
insert into t1 (c1, c2) values (repeat('a', 50), repeat('b', 50));
|
||||
insert into t1 (c1, c2) values (repeat('a', 100), repeat('b', 100));
|
||||
insert into t1 (c1, c2) values (repeat('a', 200), repeat('b', 300));
|
||||
--enable_warnings
|
||||
|
||||
connection syscon;
|
||||
|
||||
sleep 2;
|
||||
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select concat('abc') from dual;
|
||||
select concat(NULL) from dual;
|
||||
select concat('abc', NULL) from dual;
|
||||
select concat(NULL, 'abc') from dual;
|
||||
select concat('def', 'abc') from dual;
|
||||
select concat(NULL, 'def', 'abc') from dual;
|
||||
select concat('ABC', 'def', 'abc') from dual;
|
||||
|
||||
select concat(c1, c2) from t1;
|
||||
|
||||
--disable_warnings
|
||||
set group_concat_max_len=9223372036854775807;
|
||||
select group_concat('x') UNION ALL select 1;
|
||||
|
||||
set group_concat_max_len=20;
|
||||
select group_concat(c1) from (select 'abcdefg' c1 union select '012345678910123456789' c1)a;
|
||||
select group_concat(c1) from (select 'abcdefg' c1 union select '012345678910123456' c1)a;
|
||||
|
||||
drop table if exists t111_var;
|
||||
create table t111_var(c0 bigint ,c1 varchar(4000), c2 varchar(4000), c3 varchar(4000), c4 varchar(4000));
|
||||
insert into t111_var values(1,repeat('ab',2000),repeat('ab',2000),repeat('ab',2000),repeat('ab',2000));
|
||||
insert into t111_var select c0+1,c1,c2,c3,c4 from t111_var;
|
||||
insert into t111_var select c0+10,c1,c2,c3,c4 from t111_var;
|
||||
insert into t111_var select c0+100,c1,c2,c3,c4 from t111_var;
|
||||
insert into t111_var select c0+1000,c1,c2,c3,c4 from t111_var;
|
||||
insert into t111_var select c0+10000,c1,c2,c3,c4 from t111_var;
|
||||
insert into t111_var select c0+100000,c1,c2,c3,c4 from t111_var;
|
||||
insert into t111_var select c0+1000000,c1,c2,c3,c4 from t111_var;
|
||||
insert into t111_var select c0+10000000,c1,c2,c3,c4 from t111_var;
|
||||
insert into t111_var select c0+100000000,c1,c2,c3,c4 from t111_var;
|
||||
insert into t111_var values(null,null,null,null,null);
|
||||
insert into t111_var select * from t111_var;
|
||||
commit;
|
||||
|
||||
set group_concat_max_len=10485;
|
||||
select length(group_concat(c1)) from t111_var;
|
||||
select group_concat(c1) from t111_var;
|
||||
|
||||
set group_concat_max_len=1024;
|
||||
--enable_warnings
|
||||
|
||||
connection syscon;
|
||||
--sleep 2
|
||||
@ -0,0 +1,22 @@
|
||||
# owner: xiaoyi.xy
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (sys, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
--sleep 2
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select conv('a',16,2) from dual;
|
||||
select conv('6E',18,8) from dual;
|
||||
select conv(-17,10,-18) from dual;
|
||||
select conv(10+'10'+'10'+X'0a',10,10) from dual;
|
||||
select conv(null, 16, 2) from dual;
|
||||
select conv('6E',null,8) from dual;
|
||||
select conv('6E',18, null) from dual;
|
||||
|
||||
connection sys;
|
||||
|
||||
--sleep 2
|
||||
@ -0,0 +1,26 @@
|
||||
# owner: xiaoyi.xy
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (sys, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
--sleep 2
|
||||
connection default;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 varchar(2000));
|
||||
insert into t1 values("2019-10-11");
|
||||
|
||||
connection sys;
|
||||
sleep 2;
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
select date(c1) from t1;
|
||||
select date("2019-10-10") from dual;
|
||||
select date(null) from dual;
|
||||
|
||||
connection sys;
|
||||
|
||||
--sleep 2
|
||||
@ -0,0 +1,32 @@
|
||||
# owner: xiaoyi.xy
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (sys, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
--sleep 2
|
||||
connection default;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 varchar(30), c2 date, c3 date);
|
||||
insert into t1 values("2019-10-11", "2019-01-10", "2018-01-01");
|
||||
insert into t1 values(null, "2019-01-10", null);
|
||||
insert into t1 values("2019-10-11", "0000-00-00", "2019-10-19");
|
||||
|
||||
connection sys;
|
||||
sleep 2;
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
select datediff(c1, c2), datediff(c2, c3) from t1;
|
||||
select datediff(20080701, "2008-08-01");
|
||||
select datediff("20080701", "2012-05-25");
|
||||
select datediff("2012-05-25","20080701");
|
||||
select datediff(null,null);
|
||||
select datediff(null,"2012-05-25");
|
||||
select datediff("2012-05-25","0000-00-00");
|
||||
|
||||
connection sys;
|
||||
|
||||
--sleep 2
|
||||
@ -0,0 +1,25 @@
|
||||
# owner: bin.lb
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
|
||||
connection syscon;
|
||||
|
||||
sleep 2;
|
||||
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select des_hex_str("11053FFF80EAB6BADEE6F501");
|
||||
select des_hex_str("0C053FFFB8BD94DC9E8A8E8B40");
|
||||
select des_hex_str("0C053FFFB8BD94DC9E8A8E8B40");
|
||||
select des_hex_str("04053FFF05");
|
||||
select des_hex_str("0C053FFFADE4F6FCFED4F1F83F");
|
||||
select des_hex_str("0B053FFF8080C08504");
|
||||
select des_hex_str(NULL);
|
||||
|
||||
connection syscon;
|
||||
--sleep 2
|
||||
@ -0,0 +1,25 @@
|
||||
# owner: bin.lb
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
|
||||
connection syscon;
|
||||
|
||||
sleep 2;
|
||||
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select dump(NULL);
|
||||
select dump(0.2);
|
||||
select dump(2);
|
||||
select dump('abcdef');
|
||||
select dump('abcdef');
|
||||
select dump(date'2020-01-01');
|
||||
select dump(timestamp'2020-01-01');
|
||||
|
||||
connection syscon;
|
||||
--sleep 2
|
||||
@ -0,0 +1,75 @@
|
||||
#owner: dachuan.sdc
|
||||
#owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
--explain_protocol 0
|
||||
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
|
||||
connection conn_admin;
|
||||
--sleep 2
|
||||
alter system set enable_async_syslog = false;
|
||||
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
set @@ob_log_level='debug';
|
||||
|
||||
|
||||
--disable_warnings
|
||||
drop view if exists v1;
|
||||
--enable_warnings
|
||||
|
||||
#--enable_metadata
|
||||
#select connection_id() from dual limit 10;
|
||||
#select utc_timestamp() from dual limit 10;
|
||||
#select utc_timestamp(3) from dual limit 10;
|
||||
#select current_timestamp() from dual limit 10;
|
||||
#select current_timestamp(3) from dual limit 10;
|
||||
#select sysdate() from dual limit 10;
|
||||
#select sysdate(3) from dual limit 10;
|
||||
#select cur_date() from dual limit 10;
|
||||
#select curtime() from dual limit 10;
|
||||
#select current_user() from dual limit 10;
|
||||
#select database() from dual limit 10;
|
||||
#select effective_tenant_id() from dual limit 10;
|
||||
#select effective_tenant() from dual limit 10;
|
||||
#select found_rows() from dual limit 10;
|
||||
#select host_ip() from dual limit 10;
|
||||
#select last_execution_id() from dual limit 10;
|
||||
#select last_trace_id() from dual limit 10;
|
||||
#select mysql_port() from dual limit 10;
|
||||
#select rpc_port() from dual limit 10;
|
||||
#select row_count() from dual limit 10;
|
||||
#select uuid() from dual limit 10;
|
||||
#select user() from dual limit 10;
|
||||
#select version() from dual limit 10;
|
||||
#--disable_metadata
|
||||
|
||||
create view v1 as select connection_id() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select utc_timestamp() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select utc_timestamp(3) from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select current_timestamp() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select current_timestamp(3) from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select sysdate() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select sysdate(3) from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select cur_date() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select curtime() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select current_user() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select database() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select effective_tenant_id() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select effective_tenant() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select found_rows() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select host_ip() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select last_execution_id() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select last_trace_id() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select mysql_port() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select rpc_port() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select row_count() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select uuid() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select user() from dual limit 10;desc v1;drop view v1;
|
||||
create view v1 as select version() from dual limit 10;desc v1;drop view v1;
|
||||
|
||||
|
||||
connection conn_admin;
|
||||
--sleep 2
|
||||
@ -0,0 +1,25 @@
|
||||
# owner: bin.lb
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
|
||||
connection syscon;
|
||||
|
||||
sleep 2;
|
||||
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select field(1, 3, 2, 1, NULL);
|
||||
select field(1, 3, 2, 1, NULL, 1);
|
||||
select field(NULL, 3, 2, 1, NULL);
|
||||
select field(2, 3, NULL, 2, 1, NULL);
|
||||
select field(1, 3, 2, "1", NULL);
|
||||
select field(1, 3, 2.2, "1", NULL);
|
||||
select field("abc", 3.2, "def", 'abc');
|
||||
|
||||
connection syscon;
|
||||
--sleep 2
|
||||
@ -0,0 +1,34 @@
|
||||
#owner: peihan.dph
|
||||
#owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
--explain_protocol 0
|
||||
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
|
||||
connection conn_admin;
|
||||
--sleep 2
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
--echo // res type is string
|
||||
select @@ob_log_level;
|
||||
set @@ob_log_level='debug';
|
||||
select @@ob_log_level;
|
||||
set @@ob_log_level='info';
|
||||
|
||||
--echo // res type is bool
|
||||
set @@ob_enable_plan_cache = 1;
|
||||
select @@ob_enable_plan_cache = 0;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
select @@ob_enable_plan_cache = 0;
|
||||
|
||||
--echo // res type is int
|
||||
select @@ob_plan_cache_percentage;
|
||||
|
||||
--echo // test null
|
||||
set character_set_results=NULL;
|
||||
select @@character_set_results;
|
||||
|
||||
--sleep 2
|
||||
@ -0,0 +1,33 @@
|
||||
#owner: peihan.dph
|
||||
#owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
connection conn_admin;
|
||||
alter system flush plan cache global;
|
||||
set ob_enable_plan_cache = 0;
|
||||
sleep 2;
|
||||
|
||||
set @var1 = NULL;
|
||||
select @var1 from dual;
|
||||
|
||||
set @var1 = 1;
|
||||
select @var1 from dual;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1 (c1 int);
|
||||
insert into t1 values(@var1);
|
||||
select * from t1;
|
||||
|
||||
set @a=0,@b=0;
|
||||
select @a:=10, @b:=1, @a > @b, @a < @b;
|
||||
select @a:="10", @b:="1", @a > @b, @a < @b;
|
||||
select @a:=10, @b:=2, @a > @b, @a < @b;
|
||||
select @a:="10", @b:="2", @a > @b, @a < @b;
|
||||
|
||||
sleep 2;
|
||||
|
||||
104
tools/deploy/mysql_test/test_suite/static_engine/t/expr_is.test
Normal file
104
tools/deploy/mysql_test/test_suite/static_engine/t/expr_is.test
Normal file
@ -0,0 +1,104 @@
|
||||
# owner: dachuan.sdc
|
||||
# owner group: SQL2
|
||||
--result_format 4
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
connection conn_admin;
|
||||
--sleep 2
|
||||
connection default;
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
create table t1 (c1 int, c2 int unsigned,
|
||||
c3 tinyint, c4 tinyint unsigned,
|
||||
c5 smallint, c6 smallint unsigned,
|
||||
c7 mediumint, c8 mediumint unsigned,
|
||||
c9 integer, c10 integer unsigned,
|
||||
c11 bigint, c12 bigint unsigned,
|
||||
c13 float, c14 float unsigned,
|
||||
c15 double, c16 double unsigned,
|
||||
c17 decimal, c18 decimal unsigned,
|
||||
c19 date, c20 date not null,
|
||||
c21 datetime, c22 datetime not null,
|
||||
c23 timestamp, c24 timestamp not null,
|
||||
c25 varchar(30), c26 char(30));
|
||||
|
||||
select * from t1;
|
||||
|
||||
insert into t1 values(NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, '0000-00-00',
|
||||
NULL, '0000-00-00 00:00:00',
|
||||
NULL, '0000-00-00 00:00:00',
|
||||
NULL, NULL);
|
||||
|
||||
insert into t1 values(0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0.0, 0.0,
|
||||
0.0, 0.0,
|
||||
0.0, 0.0,
|
||||
'0000-00-00', '0000-00-00',
|
||||
'0000-00-00 00:00:00', '0000-00-00 00:00:00',
|
||||
'0000-00-00 00:00:00', '0000-00-00 00:00:00',
|
||||
'0', '0.0');
|
||||
|
||||
insert into t1 values(1, 1,
|
||||
1, 1,
|
||||
1, 1,
|
||||
1, 1,
|
||||
1, 1,
|
||||
1, 1,
|
||||
-0.1, 0.1,
|
||||
-0.1, 0.1,
|
||||
-0.1, 0.1,
|
||||
'0001-01-01', '0001-01-01',
|
||||
'0001-01-01 00:00:00', '0001-01-01 00:00:00',
|
||||
'0001-01-01 00:00:00', '0001-01-01 00:00:00',
|
||||
'1', '1.0');
|
||||
|
||||
insert into t1 values(11, 11,
|
||||
11, 11,
|
||||
11, 11,
|
||||
11, 11,
|
||||
11, 11,
|
||||
11, 11,
|
||||
11.0, 11.0,
|
||||
11.0, 11.0,
|
||||
11.0, 11.0,
|
||||
'2019-12-01 12:00:00', '2019-12-01 12:00:00',
|
||||
'2019-12-01 12:00:00', '2019-12-01 12:00:00',
|
||||
'2019-12-01 12:00:00', '2019-12-01 12:00:00',
|
||||
'11', '11.0');
|
||||
|
||||
connection conn_admin;
|
||||
--sleep 2
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
|
||||
|
||||
let $cnt=26;
|
||||
let $left=1;
|
||||
while ($left <= $cnt)
|
||||
{
|
||||
eval select c$left, c$left is true, c$left is false, c$left is null, c$left is unknown from t1;
|
||||
eval select c$left, c$left is not true, c$left is not false, c$left is not null, c$left is not unknown from t1;
|
||||
inc $left;
|
||||
}
|
||||
drop table t1;
|
||||
|
||||
|
||||
|
||||
connection conn_admin;
|
||||
--sleep 2
|
||||
@ -0,0 +1,24 @@
|
||||
# owner: bin.lb
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
|
||||
connection syscon;
|
||||
|
||||
sleep 2;
|
||||
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select is_serving_tenant(host_ip(), rpc_port(), effective_tenant_id());
|
||||
select is_serving_tenant(host_ip(), rpc_port(), 1);
|
||||
select is_serving_tenant(host_ip(), rpc_port(), 888);
|
||||
select is_serving_tenant('abc', rpc_port(), effective_tenant_id());
|
||||
select is_serving_tenant('abc', rpc_port(), 1);
|
||||
select is_serving_tenant('abc', rpc_port(), 888);
|
||||
|
||||
connection syscon;
|
||||
--sleep 2
|
||||
@ -0,0 +1,41 @@
|
||||
# owner: dachuan.sdc
|
||||
# owner group: SQL2
|
||||
--result_format 4
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
connection conn_admin;
|
||||
--sleep 2
|
||||
connection default;
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1 (c1 int, c2 int unsigned,
|
||||
c3 tinyint, c4 tinyint unsigned,
|
||||
c5 bigint, c6 bigint unsigned,
|
||||
c7 float, c8 float unsigned,
|
||||
c9 double, c10 double unsigned,
|
||||
c11 decimal, c12 decimal unsigned,
|
||||
c13 date, c14 datetime, c15 timestamp,
|
||||
c16 varchar(30), c17 char(30));
|
||||
select * from t1;
|
||||
insert into t1 values(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
|
||||
insert into t1 values(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0000-00-00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '', '');
|
||||
insert into t1 values(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, '0013-01-01', '0014-01-01', '0015-01-01', '16', '17');
|
||||
insert into t1 values(-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, '0013-01-01', '0014-01-01 00:00:00', '0015-01-01 00:00:00', '-16', '-17');
|
||||
insert into t1 values(1234567, 7654321, -33, 44, 555555555, 666666666, 777.777, 8888.888, 99999.999999, 10000.00000, 1111, 121212121, '0013-01-01', '0014-01-01 00:00:11', '0015-01-01 00:00:11', 'sadfsadfdsafasasdf', 'asdffdsafadsfdsafsad');
|
||||
|
||||
connection conn_admin;
|
||||
--sleep 2
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
let $cnt=17;
|
||||
let $left=1;
|
||||
while ($left <= $cnt)
|
||||
{
|
||||
eval select c$left, length(c$left) from t1;
|
||||
inc $left;
|
||||
}
|
||||
|
||||
drop table t1;
|
||||
connection conn_admin;
|
||||
--sleep 2
|
||||
@ -0,0 +1,23 @@
|
||||
# owner: bin.lb
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
|
||||
connection syscon;
|
||||
|
||||
sleep 2;
|
||||
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select lnnvl(1) from dual;
|
||||
select lnnvl(-1) from dual;
|
||||
select lnnvl(0) from dual;
|
||||
select lnnvl(NULL) from dual;
|
||||
select lnnvl('abc') from dual;
|
||||
|
||||
connection syscon;
|
||||
--sleep 2
|
||||
@ -0,0 +1,39 @@
|
||||
#owner: luofan.zp
|
||||
#owner group: sql2
|
||||
#description: locate/instr/reverse test
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
--explain_protocol 0
|
||||
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
connection conn_admin;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
--sleep 2
|
||||
|
||||
--echo // locate(substr, oristr), instr(oristr, substr)
|
||||
select locate(null, 'a'), locate('a', null), locate('a', 'a', null);
|
||||
select locate('abc', 'a'), instr('abc', 'a');
|
||||
select locate('a', 'aaaa', 1), locate('a', 'aaaa', 0), locate('a', 'aaaa', -1);
|
||||
select locate('a', 'aaaa', '1.9'), locate('a', 'aaaa', '0.9'), locate('a', 'aaaa', '-1.9');
|
||||
select locate('a', 'aaaa', '1.1'), locate('a', 'aaaa', '0.1'), locate('a', 'aaaa', '-1.1');
|
||||
select locate('中', 'a中测试', 1);
|
||||
select locate('a', 'abcdabcd', '2.a');
|
||||
select locate('a', 'abcdabcd', 'a');
|
||||
select locate('a', 'abcdabcd', '-2.a');
|
||||
select locate('a', 'a', 10000);
|
||||
select locate('a', 'a', 1000000000000000000000000000000000000000000000000000000000000000);
|
||||
|
||||
select instr('abc', 'a'), instr('aaaa','a'), instr('a中测试', '中'), instr(null, 'a'), instr('a', null);
|
||||
|
||||
select reverse(''), reverse(null), reverse('你好abc中文'), reverse(12345.123), reverse(null);
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1(c1 bigint unsigned);
|
||||
insert into t1 values(locate('a','b',9223372036854775808));
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
--sleep 2
|
||||
@ -0,0 +1,41 @@
|
||||
# owner: dachuan.sdc
|
||||
# owner group: SQL2
|
||||
--result_format 4
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
connection conn_admin;
|
||||
--sleep 2
|
||||
connection default;
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1 (c1 int, c2 int unsigned,
|
||||
c3 tinyint, c4 tinyint unsigned,
|
||||
c5 bigint, c6 bigint unsigned,
|
||||
c7 float, c8 float unsigned,
|
||||
c9 double, c10 double unsigned,
|
||||
c11 decimal, c12 decimal unsigned,
|
||||
c13 date, c14 datetime, c15 timestamp,
|
||||
c16 varchar(60), c17 char(60));
|
||||
select * from t1;
|
||||
insert into t1 values(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
|
||||
insert into t1 values(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0000-00-00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '', '');
|
||||
insert into t1 values(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, '0013-01-01', '0014-01-01', '0015-01-01', '16abcDeFG00', '16abcDeFG00');
|
||||
insert into t1 values(-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, '0013-01-01', '0014-01-01 00:00:00', '0015-01-01 00:00:00', '=[]-+,/;<>?.*~!@#$%^&*()', '=[]-+,/;<>?.*~!@#$%^&*()');
|
||||
insert into t1 values(1234567, 7654321, -33, 44, 555555555, 666666666, 777.777, 8888.888, 99999.999999, 10000.00000, 1111, 121212121, '0013-01-01', '0014-01-01 00:00:11', '0015-01-01 00:00:11', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
|
||||
|
||||
connection conn_admin;
|
||||
--sleep 2
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
let $cnt=17;
|
||||
let $left=1;
|
||||
while ($left <= $cnt)
|
||||
{
|
||||
eval select c$left, lower(c$left), upper(c$left) from t1;
|
||||
inc $left;
|
||||
}
|
||||
|
||||
drop table t1;
|
||||
connection conn_admin;
|
||||
--sleep 2
|
||||
@ -0,0 +1,87 @@
|
||||
# owner: bin.lb
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
connection default;
|
||||
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 int, c2 int);
|
||||
drop table if exists t2;
|
||||
create table t2 (c1 int auto_increment primary key, c2 int);
|
||||
drop table if exists t3;
|
||||
create table t3 (c1 int unsigned auto_increment primary key, c2 int);
|
||||
drop table if exists t4;
|
||||
create table t4 (c1 float auto_increment primary key, c2 int);
|
||||
drop table if exists t5;
|
||||
create table t5 (c1 double auto_increment primary key, c2 int);
|
||||
--enable_warnings
|
||||
|
||||
connection syscon;
|
||||
|
||||
sleep 2;
|
||||
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
# hidden PK
|
||||
insert into t1 (c1, c2) values (1, 1);
|
||||
insert into t1 (c1, c2) values (1, 1);
|
||||
select * from t1;
|
||||
|
||||
# column conv added befoer nextval
|
||||
explain insert into t2 (c1, c2) values ('0', '1');
|
||||
|
||||
insert into t2 (c1, c2) values (NULL, '1');
|
||||
insert into t2 (c1, c2) values (0, '2');
|
||||
insert into t2 (c2) values ('3');
|
||||
insert into t2 (c1, c2) values (-5, '4');
|
||||
insert into t2 (c1, c2) values (10, '5');
|
||||
insert into t2 (c1, c2) values (0, '6');
|
||||
insert into t2 (c1, c2) values ('0', '7');
|
||||
insert into t2 (c1, c2) values ('-10', '8');
|
||||
insert into t2 (c1, c2) values (-12.1, '9');
|
||||
insert into t2 (c1, c2) values (-13.9, '10');
|
||||
# error and no new values generated
|
||||
insert into t2 (c1, c2) values ('abc', '11');
|
||||
insert into t2 (c1, c2) values (0.0, '12');
|
||||
select * from t2;
|
||||
|
||||
insert into t3 (c1, c2) values (NULL, '1');
|
||||
insert into t3 (c1, c2) values (-1, '2');
|
||||
insert into t3 (c1, c2) values (0, '3');
|
||||
insert into t3 (c1, c2) values (10, '4');
|
||||
insert into t3 (c1, c2) values (0, '5');
|
||||
select * from t3;
|
||||
|
||||
|
||||
insert into t4 (c1, c2) values (NULL, '1');
|
||||
insert into t4 (c1, c2) values (0, '2');
|
||||
insert into t4 (c1, c2) values ('0', '3');
|
||||
insert into t4 (c1, c2) values (0.0, '4');
|
||||
insert into t4 (c1, c2) values (-10.12, '5');
|
||||
insert into t4 (c1, c2) values (0, '6');
|
||||
insert into t4 (c1, c2) values (10.5, '7');
|
||||
insert into t4 (c1, c2) values (0, '8');
|
||||
select * from t4;
|
||||
|
||||
insert into t5 (c1, c2) values (NULL, '1');
|
||||
insert into t5 (c1, c2) values (0, '2');
|
||||
insert into t5 (c1, c2) values ('0', '3');
|
||||
insert into t5 (c1, c2) values (0.0, '4');
|
||||
insert into t5 (c1, c2) values (-10.12, '5');
|
||||
insert into t5 (c1, c2) values (0, '6');
|
||||
insert into t5 (c1, c2) values (10.5, '7');
|
||||
insert into t5 (c1, c2) values (0, '8');
|
||||
select * from t5;
|
||||
|
||||
# no strict mode
|
||||
set sql_mode = '';
|
||||
insert into t3 (c1, c2) values ("abc", '6');
|
||||
select * from t3;
|
||||
|
||||
connection syscon;
|
||||
@ -0,0 +1,73 @@
|
||||
#owner: dachuan.sdc
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
connection conn_admin;
|
||||
|
||||
--sleep 2
|
||||
alter system flush plan cache global;
|
||||
|
||||
connection default;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t;
|
||||
--enable_warnings
|
||||
|
||||
create table t (t1 tinyint,
|
||||
t2 smallint,
|
||||
t3 mediumint,
|
||||
t4 integer,
|
||||
t5 bigint,
|
||||
t6 tinyint unsigned,
|
||||
t7 smallint unsigned,
|
||||
t8 mediumint unsigned,
|
||||
t9 integer unsigned,
|
||||
t10 bigint unsigned,
|
||||
t11 float,
|
||||
t12 float unsigned,
|
||||
t13 double,
|
||||
t14 double unsigned,
|
||||
t15 number,
|
||||
t16 number unsigned,
|
||||
t17 datetime,
|
||||
t18 timestamp,
|
||||
t19 date,
|
||||
t20 time,
|
||||
t21 year,
|
||||
t22 varchar(255),
|
||||
t23 char(255),
|
||||
t24 tinytext,
|
||||
t25 mediumtext,
|
||||
t26 longtext,
|
||||
t27 bit,
|
||||
t28 enum('a', 'b', 'c'),
|
||||
t29 set('a', 'b', 'c'));
|
||||
|
||||
insert into t values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7,
|
||||
'1993-03-20', '1993-03-20', '1993-03-20', '10:10:10', '1993', '0.8', '0.9', '1.0', '1.1',
|
||||
'1.2', 1, 'b', 'b');
|
||||
insert into t(t1) values (null);
|
||||
|
||||
connection conn_admin;
|
||||
|
||||
--sleep 2
|
||||
alter system flush plan cache global;
|
||||
|
||||
connection default;
|
||||
|
||||
set ob_enable_plan_cache = false;
|
||||
select not 1 from dual;
|
||||
select not 1.0 from dual;
|
||||
select not null from dual;
|
||||
select not 'hello' from dual;
|
||||
|
||||
let $cnt = 1;
|
||||
while ($cnt <= 29)
|
||||
{
|
||||
eval select not t$cnt from t;
|
||||
inc $cnt;
|
||||
}
|
||||
|
||||
--sleep 2
|
||||
@ -0,0 +1,187 @@
|
||||
#owner: peihan.dph
|
||||
#owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
--explain_protocol 0
|
||||
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
|
||||
connection conn_admin;
|
||||
--sleep 2
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
#set @@ob_log_level='debug';
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
create table t1 (c1 int, c2 int unsigned,
|
||||
c3 tinyint, c4 tinyint unsigned,
|
||||
c5 smallint, c6 smallint unsigned,
|
||||
c7 mediumint, c8 mediumint unsigned,
|
||||
c9 integer, c10 integer unsigned,
|
||||
c11 bigint, c12 bigint unsigned,
|
||||
c13 float, c14 float unsigned,
|
||||
c15 double, c16 double unsigned,
|
||||
c17 decimal, c18 decimal unsigned,
|
||||
c19 datetime, c20 timestamp,
|
||||
c21 varchar(30), c22 char(30), c_null int);
|
||||
|
||||
insert into t1 values(1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
3.5, 4.5,
|
||||
5.5, 6.5,
|
||||
7.5, 8.5,
|
||||
'2019-12-01 12:00:00', '2019-12-03 06:00:00',
|
||||
'9.5', '10.5', null);
|
||||
insert into t1 values(-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-3.5, 4.5,
|
||||
-5.5, 6.5,
|
||||
-7.5, 8.5,
|
||||
'2019-12-01 12:00:00', '2019-12-03 06:00:00',
|
||||
'-9.5', '10.5', null);
|
||||
|
||||
--sleep 2
|
||||
|
||||
#--explain_protocol 2
|
||||
eval select nullif(null, null), nullif(1, null), nullif(null, 1);
|
||||
eval select ifnull(null, null), ifnull(1, null), ifnull(null, 1);
|
||||
let $cnt=22;
|
||||
let $left=1;
|
||||
while ($left <= $cnt)
|
||||
{
|
||||
let $right=1;
|
||||
while ($right <= $cnt)
|
||||
{
|
||||
eval select c$left, c$right, nullif(c$left, c$right), ifnull(c$left, c$right) from t1;
|
||||
eval select c$left, nullif(c$left, c$left) from t1;
|
||||
|
||||
inc $right;
|
||||
}
|
||||
inc $left;
|
||||
}
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
drop view if exists v1;
|
||||
--enable_warnings
|
||||
create table t1 (c1 datetime(5), c2 year);
|
||||
insert into t1 values('1901-01-01', 1901);
|
||||
--echo // transformed to case when expr
|
||||
--explain_protocol 2
|
||||
select nullif(c1, c2) from t1;
|
||||
select nullif(c2, c1) from t1;
|
||||
select nullif(c1, c1) from t1;
|
||||
select nullif(c2, c2) from t1;
|
||||
--explain_protocol 0
|
||||
|
||||
--echo // nullif改写不应该影响show create view,所以show create view还应该是nullif,而非case expr
|
||||
create view v1 as select nullif(c1, c2) from t1;
|
||||
show create view v1;
|
||||
--echo // 类型应该是c1的类型(datetime)
|
||||
desc v1;
|
||||
select * from v1;
|
||||
|
||||
drop view v1;
|
||||
create view v1 as select nullif(c2, c1) from t1;
|
||||
show create view v1;
|
||||
--echo // 类型应该是c1的类型(year)
|
||||
desc v1;
|
||||
select * from v1;
|
||||
|
||||
drop view v1;
|
||||
create view v1 as select nullif(c1, c1) from t1;
|
||||
show create view v1;
|
||||
--echo // 类型应该是c1的类型(datetime)
|
||||
desc v1;
|
||||
select * from v1;
|
||||
|
||||
drop view v1;
|
||||
create view v1 as select nullif(c2, c2) from t1;
|
||||
show create view v1;
|
||||
--echo // 类型应该是c1的类型(datetime)
|
||||
desc v1;
|
||||
select * from v1;
|
||||
|
||||
select collation(nullif('a', binary'b'));
|
||||
select NULLIF(14152561829011783680, 1);
|
||||
|
||||
drop table t1;
|
||||
create table t1 (
|
||||
col_decimal_20_0_unsigned decimal(20,0) unsigned,
|
||||
col_decimal_30_5_signed decimal(30,5) signed,
|
||||
col_tinyint_unsigned tinyint unsigned);
|
||||
select mod( nullif( col_decimal_20_0_unsigned, col_decimal_30_5_signed ), col_tinyint_unsigned ) from t1;
|
||||
|
||||
--echo // check param num
|
||||
select nullif(1) from dual;
|
||||
select nullif(1, 2) from dual;
|
||||
select nullif(1, 2, 3) from dual;
|
||||
select nullif(1, 2, 3, 4) from dual;
|
||||
select nullif(1, 2, 3, 4, 5) from dual;
|
||||
select nullif(1, 2, 3, 4, 5, 6) from dual;
|
||||
select nullif(1, 2, 3, 4, 5, 6, 7) from dual;
|
||||
|
||||
drop table t1;
|
||||
select 1 from dual where null <= nullif(null,null);
|
||||
|
||||
select ifnull(null, 15531789214893998080);
|
||||
select ifnull(15531789214893998080, 0);
|
||||
SELECT trim(Ifnull(15531789214893998080, 0)) as X from dual;
|
||||
create table t1 as select ifnull(15531789214893998080, 0) ;
|
||||
desc t1;
|
||||
|
||||
drop table t1;
|
||||
|
||||
create table t1(z0_test0 enum('中文字符','123456','ABCabc','!@#$%^&*','2020-10-10','2020-10-10 10:10:10','10:10:10') not NULL);
|
||||
|
||||
insert into t1 values('中文字符');
|
||||
insert into t1 values('123456');
|
||||
insert into t1 values('ABCabc');
|
||||
insert into t1 values('!@#$%^&*');
|
||||
insert into t1 values('2020-10-10');
|
||||
insert into t1 values('2020-10-10 10:10:10');
|
||||
insert into t1 values('10:10:10');
|
||||
|
||||
select nullif(z0_test0,'中文字符') from t1;
|
||||
drop table t1;
|
||||
--sleep 2
|
||||
|
||||
|
||||
|
||||
--echo ##bugfix: https://work.aone.alibaba-inc.com/issue/37798920
|
||||
create table t1 (pk double) PARTITION BY key (pk) partitions 1;
|
||||
insert into t1 values( NULLIF( 100.2345, 1 ));
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
--disable_result_log
|
||||
select
|
||||
subq_0.c3,
|
||||
nullif(subq_0.c3, cast(32 as decimal)) as c14
|
||||
from
|
||||
(
|
||||
select
|
||||
cast(
|
||||
(
|
||||
select
|
||||
help_keyword_id
|
||||
from
|
||||
mysql.help_keyword
|
||||
limit
|
||||
1 offset 4
|
||||
) as DECIMAL
|
||||
) as c3
|
||||
) as subq_0;
|
||||
--enable_result_log
|
||||
@ -0,0 +1,85 @@
|
||||
#owner: dachuan.sdc
|
||||
#owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
--explain_protocol 0
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
#set @@ob_log_level='debug';
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
create table t1 (c1 int, c2 int unsigned,
|
||||
c3 tinyint, c4 tinyint unsigned,
|
||||
c5 smallint, c6 smallint unsigned,
|
||||
c7 mediumint, c8 mediumint unsigned,
|
||||
c9 integer, c10 integer unsigned,
|
||||
c11 bigint, c12 bigint unsigned,
|
||||
c13 float, c14 float unsigned,
|
||||
c15 double, c16 double unsigned,
|
||||
c17 decimal, c18 decimal unsigned,
|
||||
c19 datetime, c20 timestamp,
|
||||
c21 varchar(30), c22 char(30), c_null int);
|
||||
|
||||
select * from t1;
|
||||
|
||||
insert into t1 values(1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
3.5, 4.5,
|
||||
5.5, 6.5,
|
||||
7.5, 8.5,
|
||||
'2019-12-01 12:00:00', '2019-12-03 06:00:00',
|
||||
'9.5', '10.5', null);
|
||||
insert into t1 values(-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-3.5, 4.5,
|
||||
-5.5, 6.5,
|
||||
-7.5, 8.5,
|
||||
'2019-12-01 12:00:00', '2019-12-03 06:00:00',
|
||||
'-9.5', '10.5', null);
|
||||
|
||||
--sleep 1
|
||||
|
||||
--explain_protocol 2
|
||||
eval select nvl(c_null, c_null) from t1;
|
||||
eval select nvl2(c_null, c_null, c_null) from t1;
|
||||
let $cnt=22;
|
||||
let $left=1;
|
||||
while ($left <= $cnt)
|
||||
{
|
||||
let $right=1;
|
||||
while ($right <= $cnt)
|
||||
{
|
||||
eval select nvl(c$left, c$right) from t1;
|
||||
eval select nvl(null, c$left) from t1;
|
||||
|
||||
inc $right;
|
||||
}
|
||||
inc $left;
|
||||
}
|
||||
|
||||
--sleep 2
|
||||
--explain_protocol 0
|
||||
set timestamp = 1600000000;
|
||||
--echo ##bugfix: https://work.aone.alibaba-inc.com/issue/37931049
|
||||
select ifnull(null, utc_time(4));
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1 (a bigint primary key, b datetime(3));
|
||||
insert into t1 values(1, now());
|
||||
insert into t1 values(2, now(6));
|
||||
select nvl(null,b) from t1;
|
||||
drop table t1;
|
||||
119
tools/deploy/mysql_test/test_suite/static_engine/t/expr_pad.test
Normal file
119
tools/deploy/mysql_test/test_suite/static_engine/t/expr_pad.test
Normal file
@ -0,0 +1,119 @@
|
||||
# owner: luofan.zp
|
||||
# owner group: SQL2
|
||||
# description: test lpad/rpad/pad
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
connection conn_admin;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1 (c1 int, c2 int unsigned,
|
||||
c3 tinyint, c4 tinyint unsigned,
|
||||
c5 smallint, c6 smallint unsigned,
|
||||
c7 mediumint, c8 mediumint unsigned,
|
||||
c9 integer, c10 integer unsigned,
|
||||
c11 bigint, c12 bigint unsigned,
|
||||
c13 float, c14 float unsigned,
|
||||
c15 double, c16 double unsigned,
|
||||
c17 decimal, c18 decimal unsigned,
|
||||
c19 datetime, c20 timestamp,
|
||||
c21 varchar(30), c22 char(30));
|
||||
insert into t1 values(1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
3.5, 4.5,
|
||||
5.5, 6.5,
|
||||
7.5, 8.5,
|
||||
'2019-12-01 12:00:00', '2019-12-03 06:00:00',
|
||||
'9.5', '10.5');
|
||||
|
||||
--echo // Case1: normal test.测试各种类型组合, 跟不开新引擎开关进行对比
|
||||
alter system flush plan cache global;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
select rpad(null, null, null), rpad('a', 1, null), rpad(null, 1, 'a') from dual;
|
||||
select lpad(null, null, null), lpad('a', 1, null), lpad(null, 1, 'a') from dual;
|
||||
|
||||
let $cnt=22;
|
||||
let $left=1;
|
||||
while ($left <= $cnt)
|
||||
{
|
||||
let $right=1;
|
||||
while ($right <= $cnt)
|
||||
{
|
||||
eval select c$left, c$right, rpad(c$left, c$left, c$right), lpad(c$left, c$left, c$right) from t1;
|
||||
eval select c$left, c$right, pad(c$left, c$left, c$right) from t1;
|
||||
inc $right;
|
||||
}
|
||||
inc $left;
|
||||
}
|
||||
|
||||
--disable_query_log
|
||||
SET GLOBAL max_allowed_packet = 4194304;
|
||||
connection default;
|
||||
disconnect conn_admin;
|
||||
connect (conn_admin1, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
connection conn_admin1;
|
||||
--enable_query_log
|
||||
|
||||
--error 1582
|
||||
select lpad();
|
||||
--error 1582
|
||||
select lpad(2, 2);
|
||||
--error 1582
|
||||
select lpad(2, 2, 2, 2);
|
||||
|
||||
select lpad(2, 2, 2);
|
||||
|
||||
select lpad('a', 5, 'b');
|
||||
select lpad('a', 5, '12');
|
||||
select lpad('a', '5', 12);
|
||||
select lpad('bb', 0, 'c');
|
||||
select lpad('bb', -1, 'c');
|
||||
|
||||
select lpad('a', 5, NULL);
|
||||
select lpad('a', 5, '');
|
||||
select lpad(NULL, 5, 'a');
|
||||
select lpad('', 5, 'a');
|
||||
|
||||
select lpad('a', 0.49, 'b');
|
||||
select lpad('a', 0.5, 'b');
|
||||
select lpad('a', -0.49, 'b');
|
||||
select lpad('a', -0.5, 'b');
|
||||
|
||||
|
||||
set character_set_client=utf8;
|
||||
set character_set_connection=utf8;
|
||||
set character_set_database=utf8;
|
||||
set character_set_results=utf8;
|
||||
set character_set_server=utf8;
|
||||
|
||||
set character_set_connection=binary;
|
||||
select hex(lpad('钡', 2, 'c'));
|
||||
set character_set_connection=utf8;
|
||||
select hex(lpad('钡', 2, 'c'));
|
||||
|
||||
select lpad('a', 1, '阿斯'), length(lpad('a', 1, '阿斯')) from dual;
|
||||
select lpad('a', 2, '阿斯'), length(lpad('a', 2, '阿斯')) from dual;
|
||||
select lpad('a', 3, '阿斯'), length(lpad('a', 3, '阿斯')) from dual;
|
||||
select lpad('a', 4, '阿斯'), length(lpad('a', 4, '阿斯')) from dual;
|
||||
select lpad('a', 5, '阿斯'), length(lpad('a', 5, '阿斯')) from dual;
|
||||
select lpad('a', 6, '阿斯'), length(lpad('a', 6, '阿斯')) from dual;
|
||||
select lpad('a', 7, '阿斯'), length(lpad('a', 7, '阿斯')) from dual;
|
||||
select lpad('a', 8, '阿斯'), length(lpad('a', 8, '阿斯')) from dual;
|
||||
|
||||
select rpad('a', 1, '阿斯'), length(rpad('a', 1, '阿斯')) from dual;
|
||||
select rpad('a', 2, '阿斯'), length(rpad('a', 2, '阿斯')) from dual;
|
||||
select rpad('a', 3, '阿斯'), length(rpad('a', 3, '阿斯')) from dual;
|
||||
select rpad('a', 4, '阿斯'), length(rpad('a', 4, '阿斯')) from dual;
|
||||
select rpad('a', 5, '阿斯'), length(rpad('a', 5, '阿斯')) from dual;
|
||||
select rpad('a', 6, '阿斯'), length(rpad('a', 6, '阿斯')) from dual;
|
||||
select rpad('a', 7, '阿斯'), length(rpad('a', 7, '阿斯')) from dual;
|
||||
select rpad('a', 8, '阿斯'), length(rpad('a', 8, '阿斯')) from dual;
|
||||
|
||||
--sleep 2
|
||||
@ -0,0 +1,34 @@
|
||||
# owner: bin.lb
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
--sleep 2
|
||||
connection default;
|
||||
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 int, c2 bigint, c3 decimal);
|
||||
insert into t1 (c1, c2, c3) values (1, NULL, 1);
|
||||
--enable_warnings
|
||||
|
||||
connection syscon;
|
||||
|
||||
sleep 2;
|
||||
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select c1, partition_hash(c1) from t1;
|
||||
select c2, partition_hash(c2) from t1;
|
||||
select c3, partition_hash(c3) from t1;
|
||||
select partition_hash(c1, c2) from t1;
|
||||
|
||||
select partition_hash(10) from t1;
|
||||
select partition_hash(-10) from t1;
|
||||
|
||||
connection syscon;
|
||||
--sleep 2
|
||||
@ -0,0 +1,53 @@
|
||||
# owner: bin.lb
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
connection syscon;
|
||||
sleep 2;
|
||||
connection default;
|
||||
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 int, c2 bigint, c3 decimal, c4 char(20), c5 varchar(20), c6 date, c7 datetime, c8 timestamp);
|
||||
insert into t1 (c1, c2, c3, c4, c5, c6, c7, c8) values (1, NULL, 1, "abc ", "abc ", '2020-01-01', '2020-01-01 01:01:01', '2020-01-01 01:01:01');
|
||||
--enable_warnings
|
||||
|
||||
connection syscon;
|
||||
|
||||
sleep 2;
|
||||
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select c1, partition_key(c1) from t1;
|
||||
select c2, partition_key(c2) from t1;
|
||||
select c3, partition_key(c3) from t1;
|
||||
select c4, partition_key(c4) from t1;
|
||||
select c5, partition_key(c5) from t1;
|
||||
select c6, partition_key(c6) from t1;
|
||||
select c7, partition_key(c7) from t1;
|
||||
select c8, partition_key(c8) from t1;
|
||||
|
||||
select partition_key(c1, c2) from t1;
|
||||
select partition_key(c1, c2, c3) from t1;
|
||||
select partition_key(c1, c3) from t1;
|
||||
|
||||
select c1, partition_key_v2(c1) from t1;
|
||||
select c2, partition_key_v2(c2) from t1;
|
||||
select c3, partition_key_v2(c3) from t1;
|
||||
select c4, partition_key_v2(c4) from t1;
|
||||
select c5, partition_key_v2(c5) from t1;
|
||||
select c6, partition_key_v2(c6) from t1;
|
||||
select c7, partition_key_v2(c7) from t1;
|
||||
select c8, partition_key_v2(c8) from t1;
|
||||
|
||||
select partition_key_v2(c1, c2) from t1;
|
||||
select partition_key_v2(c1, c2, c3) from t1;
|
||||
select partition_key_v2(c1, c3) from t1;
|
||||
|
||||
connection syscon;
|
||||
--sleep 2
|
||||
@ -0,0 +1,44 @@
|
||||
# owner: bin.lb
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
connection default;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 varchar(50), c2 varchar(50));
|
||||
insert into t1 (c1, c2) values ('abc1', '^abc[0-9]?$');
|
||||
insert into t1 (c1, c2) values ('abc1', '^abd');
|
||||
|
||||
drop table if exists t2;
|
||||
create table t2 (a varchar(50));
|
||||
insert into t2 values ("abc1");
|
||||
--enable_warnings
|
||||
|
||||
connection syscon;
|
||||
|
||||
sleep 2;
|
||||
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select 'abcdef' regexp '^abc.*';
|
||||
select 'abcdef' regexp '^abd.*';
|
||||
|
||||
select '' regexp '^$';
|
||||
select 'a' regexp '';
|
||||
select NULL regexp 'a';
|
||||
select 'a' regexp NULL;
|
||||
|
||||
# pattern is const string
|
||||
select c2, c2 regexp 'abc' from t1;
|
||||
# pattern exec param
|
||||
select c2, (select a regexp c2 from t2) from t1;
|
||||
# pattern not const
|
||||
select c1, c2, c1 regexp c2 from t1;
|
||||
|
||||
connection syscon;
|
||||
--sleep 2
|
||||
@ -0,0 +1,87 @@
|
||||
# owner: bin.lb
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
|
||||
sleep 2;
|
||||
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select regexp_like('abc', 'a.*') from dual;
|
||||
select regexp_like('abc', 'a.* ') from dual;
|
||||
select regexp_like('abc', 'a.* ', NULL) from dual;
|
||||
select regexp_like('abc', 'a.* ', 'x') from dual;
|
||||
select regexp_like('abc', NULL) from dual;
|
||||
select regexp_like(NULL, 'a.*') from dual;
|
||||
|
||||
select regexp_like(123, 123) from dual;
|
||||
select regexp_like('我是好人', '.是.*') from dual;
|
||||
|
||||
|
||||
select regexp_instr('abcadef', 'a.') from dual;
|
||||
select regexp_instr('abcadef', 'a.', 1, 2) from dual;
|
||||
select regexp_instr('abcadef', 'a.', 1, 2, 0) from dual;
|
||||
select regexp_instr('abcadef', 'a.', 1, 2, 1) from dual;
|
||||
select regexp_instr('abcadef', 'a.', 0, 2, 1) from dual;
|
||||
select regexp_instr('abcadef', 'a.', 1, 0, 1) from dual;
|
||||
select regexp_instr('abcadef', 'a.', 1, 2, -1) from dual;
|
||||
select regexp_instr('abcadef', 'a.', 100, 2) from dual;
|
||||
select regexp_instr('abcadef', 'a.', 1, 200) from dual;
|
||||
select regexp_instr('abcadef', 'a. ', 1, 2, 1, 'x') from dual;
|
||||
select regexp_instr('', 'a. ', 1, 2, 1, 'x') from dual;
|
||||
select regexp_instr('abcadef', '', 1, 2, 1, 'x') from dual;
|
||||
select regexp_instr('abcadef', 'a. ', NULL, 2, 1, 'x') from dual;
|
||||
select regexp_instr('abcadef', 'a. ', 1, NULL, 1, 'x') from dual;
|
||||
select regexp_instr('abcadef', 'a. ', 1, 2, NULL, 'x') from dual;
|
||||
select regexp_instr('abcadef', 'a. ', 1, 2, 1, NULL) from dual;
|
||||
|
||||
select regexp_instr(12341834, 1.3, '1', '2', 1) from dual;
|
||||
select regexp_instr('我是好人', '是.') from dual;
|
||||
|
||||
|
||||
select regexp_substr('abcadef', 'a.', 1) from dual;
|
||||
select regexp_substr('abcadef', 'a.', 1, 2) from dual;
|
||||
select regexp_substr('abcadef', 'a.', 0, 2) from dual;
|
||||
select regexp_substr('abcadef', 'a.', 1, 0) from dual;
|
||||
select regexp_substr('abcadef', 'a.', 10, 2) from dual;
|
||||
select regexp_substr('abcadef', 'a.', 1, 10) from dual;
|
||||
select regexp_substr('abcadef', 'a. ', 1, 2, 'x') from dual;
|
||||
select regexp_substr('', 'a. ', 1, 2, 'x') from dual;
|
||||
select regexp_substr('abcadef', '', 1, 2, 'x') from dual;
|
||||
select regexp_substr('abcadef', 'a. ', NULL, 2, 'x') from dual;
|
||||
select regexp_substr('abcadef', 'a. ', 1, NULL, 'x') from dual;
|
||||
select regexp_substr('abcadef', 'a. ', 1, 2, NULL) from dual;
|
||||
|
||||
select regexp_substr(12341834, 1.3, '1.9', '2') from dual;
|
||||
select regexp_replace('我是好人', '是.') from dual;
|
||||
|
||||
|
||||
select regexp_replace('abcadef', 'a.') from dual;
|
||||
select regexp_replace('abcadef', 'a.*') from dual;
|
||||
select regexp_replace('abcadef', 'a.', 'X') from dual;
|
||||
select regexp_replace('abcadef', 'a.', 'X', 1) from dual;
|
||||
select regexp_replace('abcadef', 'a.', 'X', 1, 2) from dual;
|
||||
select regexp_replace('abcadef', 'a.', 'X', 2, 1) from dual;
|
||||
select regexp_replace('abcadef', 'a.', 'X', 2, 2) from dual;
|
||||
select regexp_replace('abcadef', 'a.', 'X', 1, 0) from dual;
|
||||
select regexp_replace('abcadef', 'a.', 'X', 1, -1) from dual;
|
||||
select regexp_replace('abcadef', 'a.', 'X', 10, 2) from dual;
|
||||
select regexp_replace('abcadef', 'a.', 'X', 1, 100) from dual;
|
||||
select regexp_replace('abcadef', 'a. ', 'X', 1, 2) from dual;
|
||||
select regexp_replace('abcadef', 'a. ', 'X', 1, 2, 'x') from dual;
|
||||
select regexp_replace('', 'a. ', 'X', 1, 2, 'x') from dual;
|
||||
select regexp_replace('abcadef', '', 'X', 1, 2, 'x') from dual;
|
||||
select regexp_replace('abcadef', 'a. ', NULL, 1, 2, 'x') from dual;
|
||||
select regexp_replace('abcadef', 'a. ', 'X', NULL, 2, 'x') from dual;
|
||||
select regexp_replace('abcadef', 'a. ', 'X', 1, NULL, 'x') from dual;
|
||||
select regexp_replace('abcadef', 'a. ', 'X', 1, 2, NULL) from dual;
|
||||
|
||||
select regexp_replace(12341834, 1.3, 99, '1', '2') from dual;
|
||||
select regexp_replace('我是好人', '是.', '.....') from dual;
|
||||
|
||||
connection syscon;
|
||||
--sleep 2
|
||||
@ -0,0 +1,38 @@
|
||||
# owner: bin.lb
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
|
||||
connection syscon;
|
||||
|
||||
sleep 2;
|
||||
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
--disable_warnings
|
||||
|
||||
select repeat("abc", -1);
|
||||
select repeat("abc", 0);
|
||||
select repeat("abc", 1);
|
||||
select repeat("abc", 2);
|
||||
select repeat("abc", 3);
|
||||
|
||||
select repeat("abc", "2.1");
|
||||
select repeat("abc", "2.9");
|
||||
|
||||
select repeat("", 2);
|
||||
select repeat(NULL, 2);
|
||||
select repeat("abc", NULL);
|
||||
select repeat(1.414, 1);
|
||||
select repeat(1.414, 2);
|
||||
|
||||
select repeat("abc", 200000000);
|
||||
|
||||
--enable_warnings
|
||||
|
||||
connection syscon;
|
||||
--sleep 2
|
||||
@ -0,0 +1,33 @@
|
||||
# owner: bin.lb
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
connection default;
|
||||
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
connection syscon;
|
||||
|
||||
sleep 2;
|
||||
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select replace('abcdbf', 'b', 'cc');
|
||||
select replace('abcdbf', 'b');
|
||||
select replace('abcdbf', 'b', '');
|
||||
select replace('abcdbf', '', 'cc');
|
||||
select replace('', 'b', 'cc');
|
||||
select replace(NULL, 'b', 'cc');
|
||||
select replace('abcdbf', NULL, 'cc');
|
||||
select replace('abcdbf', 'b', NULL);
|
||||
select replace('abc', 'abc', '');
|
||||
|
||||
connection syscon;
|
||||
--sleep 2
|
||||
@ -0,0 +1,143 @@
|
||||
# owner: dachuan.sdc
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
--explain_protocol 0
|
||||
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
connection conn_admin;
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1, t2;
|
||||
--enable_warnings
|
||||
|
||||
create table t1 (c1 int, c2 int unsigned,
|
||||
c3 tinyint, c4 tinyint unsigned,
|
||||
c5 smallint, c6 smallint unsigned,
|
||||
c7 mediumint, c8 mediumint unsigned,
|
||||
c9 integer, c10 integer unsigned,
|
||||
c11 bigint, c12 bigint unsigned,
|
||||
c13 float, c14 float unsigned,
|
||||
c15 double, c16 double unsigned,
|
||||
c17 decimal, c18 decimal unsigned,
|
||||
c19 datetime, c20 timestamp,
|
||||
c21 varchar(30), c22 char(30), c_null int);
|
||||
|
||||
insert into t1 values(1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
3.5, 4.5,
|
||||
5.5, 6.5,
|
||||
7.5, 8.5,
|
||||
'2019-12-01 12:00:00', '2019-12-03 06:00:00',
|
||||
'9.5', '10.5', null);
|
||||
insert into t1 values(-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-3.5, 4.5,
|
||||
-5.5, 6.5,
|
||||
-7.5, 8.5,
|
||||
'2019-12-01 12:00:00', '2019-12-03 06:00:00',
|
||||
'-9.5', '10.5', null);
|
||||
|
||||
create table t2(
|
||||
a1 char(3) primary key,
|
||||
a2 int,
|
||||
a3 char(3),
|
||||
a4 float,
|
||||
a5 datetime
|
||||
);
|
||||
insert into t2 values('AME',0,'SEA',0.100,date'1942-02-19');
|
||||
insert into t2 values('HBR',1,'SEA',0.085,date'1948-03-05');
|
||||
insert into t2 values('BOT',-2,'SEA',-0.085,date'1951-11-29');
|
||||
insert into t2 values('BMC',3,'SEA',-0.085,date'1958-09-08');
|
||||
insert into t2 values('TWU',+0,'LAX',-0.080,date'1969-10-05');
|
||||
insert into t2 values('BDL',-0,'DEN',-0.080,date'1960-11-27');
|
||||
insert into t2 values('DTX',1,'NYC',0.080,date'1961-05-04');
|
||||
insert into t2 values('PLS',-1,'WDC',-0.075,date'1949-01-02');
|
||||
insert into t2 values('ZAJ',2,'CHI',-0.075,date'1960-06-15');
|
||||
insert into t2 values('VVV',-2,'MON',0.075,date'1959-06-28');
|
||||
insert into t2 values('GTM',3,'DAL',-0.070,date'1977-09-23');
|
||||
insert into t2 values('SSJ',null,'CHI',null,date'1974-03-19');
|
||||
insert into t2 values('KKK',-3,'ATL',null,null);
|
||||
insert into t2 values('XXX',null,'MIN',null,null);
|
||||
insert into t2 values('WWW',1,'LED',null,null);
|
||||
insert into t2 values('GG3',-3,'DD3',-0.051,date'1974-03-19');
|
||||
insert into t2 values('GG2',-3,'DD2',0.052,date'1974-03-19');
|
||||
insert into t2 values('GG1',3,'DD1',0.053,date'1974-03-19');
|
||||
|
||||
--sleep 1
|
||||
|
||||
--explain_protocol 2
|
||||
select sign(null) from dual;
|
||||
|
||||
let $cnt=22;
|
||||
let $left=1;
|
||||
while ($left <= $cnt)
|
||||
{
|
||||
let $right=1;
|
||||
eval select c$left, sign(c$left) from t1;
|
||||
inc $left;
|
||||
}
|
||||
|
||||
select sign(a1) from t2;
|
||||
select sign(a3) from t2;
|
||||
select sign(a1),a2 from t2;
|
||||
select sign(a2) from t2 where sign(a4) >= 0;
|
||||
select sign(a4) from t2 where sign(a2) <=0 AND a2 < 2;
|
||||
--replace_column 5 timestamp
|
||||
select * from t2 group by sign(a2);
|
||||
--replace_column 5 timestamp
|
||||
select * from t2 order by sign(a4) ;
|
||||
--replace_column 5 timestamp
|
||||
select * from t2 order by sign(a4) , a4 ;
|
||||
--replace_column 5 timestamp
|
||||
select * from t2 order by sign(a4) , a1 ;
|
||||
--sorted_result
|
||||
select abs(a2) , sum(a4) from t2 group by abs(a2) having sum(sign(a4)) > 0;
|
||||
--replace_column 5 timestamp
|
||||
select * from t2 where a2 = sign ( floor(1.5) - ceil(1.5) + round(1.5) - abs(-1.5) + neg(-1) );
|
||||
select sign( sum(a2) ) , sign( sum(a4) ) from t2;
|
||||
select sign( avg(a2) ) , sign( avg(a4) ) from t2;
|
||||
select sign( max(a2) ) , sign( min(a4) ) from t2;
|
||||
select sign(count(*)) from t2;
|
||||
--replace_column 5 timestamp
|
||||
select * from t2 where sign( length(a1) ) = 1;
|
||||
#cast
|
||||
select sign( cast(a1 as char(1024)) ) , sign( cast(a3 as char(1024)) ) from t2;
|
||||
select sign( cast(a2 as char(1024)) ) , sign( cast(a4 as char(1024)) ) from t2;
|
||||
# sign in join
|
||||
select * from t2 as t21 join t2 as t22 on sign(t21.a2) = sign(t22.a4);
|
||||
#col alias
|
||||
select tmp.a1 , sign(tmp.a2) , tmp.a3 , sign(tmp.a4) from t2 as tmp;
|
||||
|
||||
## select for update
|
||||
select sign(a2) from t2 where sign(a4) >= 0 for update;
|
||||
select sign(a4) from t2 where sign(a2) <=0 AND a2 < 2 for update;
|
||||
select * from t2 group by sign(a2) for update;
|
||||
select * from t2 order by sign(a4) for update;
|
||||
--sorted_result
|
||||
select abs(a2) , sum(a4) from t2 group by abs(a2) having sum(sign(a4)) > 0 for update;
|
||||
--replace_column 5 timestamp
|
||||
select * from t2 where a2 = sign ( floor(1.5) - ceil(1.5) + round(1.5) - abs(-1.5) + neg(-1) ) for update;
|
||||
select sign( sum(a2) ) , sign( sum(a4) ) from t2 for update;
|
||||
select sign( avg(a2) ) , sign( avg(a4) ) from t2 for update;
|
||||
select sign( max(a2) ) , sign( min(a4) ) from t2 for update;
|
||||
select sign(count(*)) from t2 for update;
|
||||
--replace_column 5 timestamp
|
||||
select * from t2 where sign( length(a1) ) = 1 for update;
|
||||
--replace_column 5 timestamp
|
||||
select sign( cast(a1 as char(1024)) ) , sign( cast(a3 as char(1024)) ) from t2 for update;
|
||||
select sign( cast(a2 as char(1024)) ) , sign( cast(a4 as char(1024)) ) from t2 for update;
|
||||
|
||||
|
||||
--sleep 2
|
||||
@ -0,0 +1,96 @@
|
||||
#owner: luofan.zp
|
||||
#owner group: sql2
|
||||
# description: quote/interval/make_set/concat_ws/sys_op_opnsize
|
||||
|
||||
--result_format 4
|
||||
--explain_protocol 0
|
||||
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
|
||||
connection conn_admin;
|
||||
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
#set @@ob_log_level='debug';
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
create table t1 (c1 int, c2 int unsigned,
|
||||
c3 tinyint, c4 tinyint unsigned,
|
||||
c5 smallint, c6 smallint unsigned,
|
||||
c7 mediumint, c8 mediumint unsigned,
|
||||
c9 integer, c10 integer unsigned,
|
||||
c11 bigint, c12 bigint unsigned,
|
||||
c13 float, c14 float unsigned,
|
||||
c15 double, c16 double unsigned,
|
||||
c17 decimal, c18 decimal unsigned,
|
||||
c19 datetime, c20 timestamp,
|
||||
c21 varchar(30), c22 char(30), c_null int);
|
||||
|
||||
select * from t1;
|
||||
|
||||
insert into t1 values(1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
1, 2,
|
||||
3.5, 4.5,
|
||||
5.5, 6.5,
|
||||
7.5, 8.5,
|
||||
'2019-12-01 12:00:00', '2019-12-03 06:00:00',
|
||||
'9.5', '10.5', null);
|
||||
insert into t1 values(-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-1, 2,
|
||||
-3.5, 4.5,
|
||||
-5.5, 6.5,
|
||||
-7.5, 8.5,
|
||||
'2019-12-01 12:00:00', '2019-12-03 06:00:00',
|
||||
'-9.5', '10.5', null);
|
||||
|
||||
--sleep 1
|
||||
|
||||
# --explain_protocol 2
|
||||
select quote(null);
|
||||
select interval(null, null), interval(null, 1), interval(null, 1, 2), interval(null, 1, null),
|
||||
interval(1, 1,1,2), interval('1', '2');
|
||||
select interval('a', 1);
|
||||
select interval(1, 1, 1,1);
|
||||
|
||||
select make_set(null, null), make_set(null, 1), make_set(1, null);
|
||||
select concat_ws(null, null), concat_ws(',', null), concat_ws(',', null, 1, null),concat_ws(',', null, 1), concat_ws(',', 1, null),
|
||||
concat_ws(',', ''), concat_ws(',','',''), concat_ws(',','','1','', '2');
|
||||
select sys_op_opnsize(null);
|
||||
|
||||
let $cnt=22;
|
||||
let $left=1;
|
||||
while ($left <= $cnt)
|
||||
{
|
||||
let $right=1;
|
||||
eval select c$left, quote(c$left) from t1;
|
||||
eval select c$left, sys_op_opnsize(c$left) from t1;
|
||||
while ($right <= $cnt)
|
||||
{
|
||||
eval select c$left, c$right, make_set(c$left, c$right) from t1;
|
||||
eval select c$left, c$right, concat_ws(c$left, c$right) from t1;
|
||||
eval select c$left, c$right, interval(c$left, c$right) from t1;
|
||||
|
||||
inc $right;
|
||||
}
|
||||
inc $left;
|
||||
}
|
||||
|
||||
select interval(4, 3, 0, 0, 0, 0, 0, 8, 3, -3, 0 -6);
|
||||
select interval(4, 3, 0, 0, 0, 0, 0, 8, null, -3, 0 -6);
|
||||
drop table t1;
|
||||
create table t1(c1 int);
|
||||
insert into t1 values(0);
|
||||
select interval(4, 3, 0, 0, 0, 0, c1, 8, 3, -3, 0 -6) from t1;
|
||||
drop table t1;
|
||||
|
||||
--sleep 2
|
||||
@ -0,0 +1,50 @@
|
||||
# owner: bin.lb
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
|
||||
connection syscon;
|
||||
|
||||
sleep 2;
|
||||
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select substr('abcdef', 0) from dual;
|
||||
select substr('abcdef', -1) from dual;
|
||||
select substr('abcdef', 1) from dual;
|
||||
select substr('abcdef', 2) from dual;
|
||||
select substr('abcdef', 10) from dual;
|
||||
select substr('', 1) from dual;
|
||||
select substr('abcdef', 10) from dual;
|
||||
select substr('abcdef', 2, 1) from dual;
|
||||
select substr('abcdef', 2, 2) from dual;
|
||||
select substr('abcdef', 2, 0) from dual;
|
||||
select substr('abcdef', 2, -1) from dual;
|
||||
select substr('abcdef', 2, 100) from dual;
|
||||
select substr('', 2, 100) from dual;
|
||||
|
||||
select substr(NULL, 2, 1) from dual;
|
||||
select substr('abcdef', NULL, 1) from dual;
|
||||
select substr('abcdef', 2, NULL) from dual;
|
||||
|
||||
|
||||
--disable_warnings
|
||||
select substr(3.14159, 2, 3) from dual;
|
||||
explain select substr(3.14159, '2', '3') from dual;
|
||||
select substr(3.14159, '2', '2.1') from dual;
|
||||
select substr(3.14159, '2', '2.9') from dual;
|
||||
select substr(3.14159, '2', '2.9') from dual;
|
||||
select substr(3.14159, '2.1', '2.9') from dual;
|
||||
select substr(3.14159, '2.9', '2.9') from dual;
|
||||
select substr(3.14159, 2.1, '2.9') from dual;
|
||||
select substr(3.14159, 2.9, '2.9') from dual;
|
||||
select substr(3.14159, 2.9, 2.9) from dual;
|
||||
select substr(3.14159, 2.1, 2.1) from dual;
|
||||
--enable_warnings
|
||||
|
||||
connection syscon;
|
||||
--sleep 2
|
||||
@ -0,0 +1,70 @@
|
||||
# owner: bin.lb
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
connection default;
|
||||
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
create table t1 (c1 bigint, c2 bigint unsigned, c3 decimal(40,2), c4 varchar(40));
|
||||
insert into t1 (c1, c2, c3, c4) values (-1, 0, 1, "2.1");
|
||||
insert into t1 (c1, c2, c3, c4) values (-2, 0, 2.1, "2.9");
|
||||
insert into t1 (c1, c2, c3, c4) values (-2, 0, 2.9, "2.9");
|
||||
insert into t1 (c1, c2, c3, c4) values (-10, 0, 10, "10");
|
||||
insert into t1 (c1, c2, c3, c4) values (4294967296, 4294967296, 4294967296, "4294967296");
|
||||
insert into t1 (c1, c2, c3, c4) values (4294967297, 4294967297, 4294967295, "4294967295");
|
||||
insert into t1 (c1, c2, c3, c4) values (-4294967296, 4294967296, -4294967296, "-4294967296");
|
||||
insert into t1 (c1, c2, c3, c4) values (-4294967297, 4294967297, -4294967295, "-4294967295");
|
||||
insert into t1 (c1, c2, c3, c4) values (9223372036854775806, 9223372036854775808, 9223372036854775808, "9223372036854775808");
|
||||
insert into t1 (c1, c2, c3, c4) values (9223372036854775807, 9223372036854775807, 9223372036854775807, "9223372036854775807");
|
||||
insert into t1 (c1, c2, c3, c4) values (9223372036854775806, 9223372036854775809, 9223372036854775809, "9223372036854775809");
|
||||
insert into t1 (c1, c2, c3, c4) values (-9223372036854775807, 9223372036854775807, -9223372036854775807, "-9223372036854775807");
|
||||
--enable_warnings
|
||||
|
||||
connection syscon;
|
||||
|
||||
sleep 1;
|
||||
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select substring_index("a,b,c,d", ",", -1);
|
||||
select substring_index("a,b,c,d", ",", 0);
|
||||
select substring_index("a,b,c,d", ",", 1);
|
||||
select substring_index("a,b,c,d", ",", 2);
|
||||
select substring_index("", ",", 2);
|
||||
select substring_index("a,b,c,d", "", 2);
|
||||
select substring_index(NULL, ",", 2);
|
||||
select substring_index("a,b,c,d", NULL, 2);
|
||||
select substring_index("a,b,c,d", ",", NULL);
|
||||
select substring_index(1.414, 1, 2);
|
||||
|
||||
--disable_warnings
|
||||
select c1, substring_index("a,b,c,d", ",", c1), c2, substring_index("a,b,c,d", ",", c2), c3, substring_index("a,b,c,d", ",", c3), c4, substring_index("a,b,c,d", ",", c4) from t1;
|
||||
|
||||
drop table if exists t2, t3;
|
||||
create table t2(c1 varchar(20));
|
||||
create table t3(c1 varchar(20));
|
||||
insert into t2 values(null), (''), ('1');
|
||||
insert into t3 values(''), (null), ('1');
|
||||
|
||||
--echo //the result of next 2 sqls should be same
|
||||
select c1, substring_index(c1, 'vpprm', -47) from t2 order by c1;
|
||||
select c1, substring_index(c1, 'vpprm', -47) from t3 order by c1;
|
||||
|
||||
drop table t1, t2,t3;
|
||||
--enable_warnings
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1(c1 char(10));
|
||||
insert into t1 values(null), ('');
|
||||
select substring_index(c1, 'a', 1) from t1;
|
||||
|
||||
connection syscon;
|
||||
--sleep 2
|
||||
@ -0,0 +1,41 @@
|
||||
# owner: bin.lb
|
||||
# owner group: sql2
|
||||
|
||||
--disable_abort_on_error
|
||||
--result_format 4
|
||||
|
||||
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
|
||||
connect (rootcon, $OBMYSQL_MS0,root@$TENANT,,test,$OBMYSQL_PORT);
|
||||
|
||||
connection syscon;
|
||||
|
||||
sleep 2;
|
||||
|
||||
connection default;
|
||||
set @@ob_enable_plan_cache = 0;
|
||||
|
||||
select sys_privilege_check('table_acc', effective_tenant_id(), 'oceanbase', '__all_user');
|
||||
select sys_privilege_check('db_acc', effective_tenant_id(), 'oceanbase_', '__all_user_');
|
||||
|
||||
--disable_warnings
|
||||
drop database if exists espcndb;
|
||||
--enable_warnings
|
||||
create database espcndb;
|
||||
|
||||
connection rootcon;
|
||||
create user espcnouser;
|
||||
grant all on test.* to espcnouser;
|
||||
|
||||
sleep 2;
|
||||
connect (con1, $OBMYSQL_MS0,espcnouser@$TENANT,,test,$OBMYSQL_PORT);
|
||||
|
||||
connection con1;
|
||||
select sys_privilege_check('db_acc', effective_tenant_id(), 'test', 't');
|
||||
select sys_privilege_check('db_acc', effective_tenant_id(), 'espcndb', 't');
|
||||
|
||||
connection default;
|
||||
drop user espcnouser;
|
||||
drop database espcnouser;
|
||||
|
||||
connection syscon;
|
||||
--sleep 2
|
||||
@ -0,0 +1,41 @@
|
||||
# owner: dachuan.sdc
|
||||
# owner group: SQL2
|
||||
# tag: expr
|
||||
--disable_abort_on_error
|
||||
--disable_warnings
|
||||
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
|
||||
connection conn_admin;
|
||||
alter system flush plan cache global;
|
||||
--sleep 2
|
||||
|
||||
connection default;
|
||||
drop table if exists t1;
|
||||
create table t1(c1 datetime, c2 timestamp, c3 date, c4 time);
|
||||
insert into t1 values('1234-12-12 01:23:45', '2020-01-01 01:23:45', '1234-12-12', '01:23:45');
|
||||
insert into t1 values('2000-2-29 01:23:45.678', '2000-2-29 01:23:45.678', '2000-2-29', '01:23:45.678');
|
||||
insert into t1 values('2001-12-31 12:00:00', '2001-12-31 12:00:00', '2001-12-31', '12:00:00');
|
||||
insert into t1 values(null, null, null, null);
|
||||
|
||||
|
||||
connection conn_admin;
|
||||
--sleep 2
|
||||
connection default;
|
||||
select a.c1, b.c1, timediff(a.c1, b.c1) from t1 a, t1 b;
|
||||
select a.c2, b.c2, timediff(a.c2, b.c2) from t1 a, t1 b;
|
||||
select a.c3, b.c3, timediff(a.c3, b.c3) from t1 a, t1 b;
|
||||
select a.c4, b.c4, timediff(a.c4, b.c4) from t1 a, t1 b;
|
||||
let $cnt = 4;
|
||||
let $idx1 = 1;
|
||||
while ($idx1 <= $cnt)
|
||||
{
|
||||
let $idx2 = 1;
|
||||
while ($idx2 <= $cnt)
|
||||
{
|
||||
eval select timediff(c$idx1, c$idx2) from t1;
|
||||
inc $idx2;
|
||||
}
|
||||
inc $idx1;
|
||||
}
|
||||
|
||||
connection conn_admin;
|
||||
--sleep 2
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user