move test folder

This commit is contained in:
wangzelin.wzl
2022-08-12 19:29:16 +08:00
parent 29e0cb7475
commit d5269307a9
419 changed files with 275972 additions and 77007 deletions

View File

@ -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;

View 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

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View 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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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;

View 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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,166 @@
# owner: dachuan.sdc
# owner group: sql2
--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;
--explain_protocol 2
set @@ob_enable_plan_cache = 0;
let $cnt=22;
let $left=1;
## timestampadd(second, c14/c16, c19/c20)四种情况结果有误
while ($left <= $cnt)
{
let $right=1;
while ($right <= $cnt)
{
eval select timestampadd(second, null, c$right) from t1;
eval select timestampadd(second, c$left, c$right) from t1;
eval select timestampadd(year, c$left, c$right) from t1;
inc $right;
}
inc $left;
}
--echo Case2: copied from timestampadd.test
select timestampadd(second,NULL,NULL);
select timestampadd(second, 123,"2011-05-09 13:45:55");
select timestampadd(second, -123,"2011-05-09 13:45:55");
select timestampadd(second, 123, NULL);
select timestampadd(second, 1,"2011-12-31 23:59:59");
select timestampadd(minute,46,"2011-05-09 13:45:55");
select timestampadd(minute,-46,"2010-05-09 13:45:55");
select timestampadd(minute,45,"2011-05-09 13:45:55");
select timestampadd(minute,-45,"2010-05-09 13:45:55");
select timestampadd(minute, 1,"2011-12-31 23:59:59");
select timestampadd(hour,5,"2011-05-09 00:00:00");
select timestampadd(hour,-5,"2012-04-08 23:59:59");
select timestampadd(hour, 1,"2011-12-31 23:59:59");
select timestampadd(day,1,"2011-05-09 00:00:00");
select timestampadd(day,-10,"2012-04-08 23:59:59");
select timestampadd(day, 1,"2011-12-31 23:59:59");
select timestampadd(week,1,"2011-05-09 00:00:00");
select timestampadd(week,2,"2012-04-08 23:59:59");
select timestampadd(week,3,"2011-05-09 00:00:00");
select timestampadd(week,4,"2012-04-08 23:59:59");
select timestampadd(week,-1,"2011-05-09 00:00:00");
select timestampadd(week,-2,"2012-04-08 23:59:59");
select timestampadd(week,-3,"2011-05-09 00:00:00");
select timestampadd(week,-4,"2012-04-08 23:59:59");
select timestampadd(week,1,"2011-12-25 00:00:00");
select timestampadd(month,1,"2011-05-07 02:00:00");
select timestampadd(month,3,"2011-10-07 01:11:11");
select timestampadd(month,5,"2015-09-07 02:00:00");
select timestampadd(month,-6,"2011-05-07 02:00:00");
select timestampadd(month,-12,"2011-10-07 01:11:11");
select timestampadd(month,-54,"2015-09-07 02:00:00");
select timestampadd(month,1,"2015-12-07 02:00:00");
select timestampadd(quarter,1,"2015-05-09");
select timestampadd(quarter,2,"2015-04-07");
select timestampadd(quarter,3,"2015-05-07");
select timestampadd(quarter,-1,"2015-05-09");
select timestampadd(quarter,-2,"2015-04-07");
select timestampadd(quarter,-3,"2015-05-07");
select timestampadd(quarter,1,"2015-11-07");
select timestampadd(year,1,"2015-05-09");
select timestampadd(year,2,"2015-04-07");
select timestampadd(year,3,"2015-05-07");
select timestampadd(year,-1,"2015-05-09");
select timestampadd(year,-2,"2015-04-07");
select timestampadd(year,-3,"2015-05-07");
select timestampadd(year,1,"2036-05-07");
select timestampadd(second, 123456789,"2011-05-09 13:45:55");
select timestampadd(second, -123456789,"2011-05-09 13:45:55");
select timestampadd(second, 123456789, NULL);
select timestampadd(minute,123456789,"2011-05-09 13:45:55");
select timestampadd(minute,-123456789,"2010-05-09 13:45:55");
select timestampadd(minute,123456789,"2011-05-09 13:45:55");
select timestampadd(minute,-123456789,"2010-05-09 13:45:55");
select timestampadd(hour,123456789,"2011-05-09 00:00:00");
select timestampadd(hour,-123456789,"2012-04-08 23:59:59");
select timestampadd(day,123456789,"2011-05-09 00:00:00");
select timestampadd(day,-123456789,"2012-04-08 23:59:59");
select timestampadd(week,123456789,"2011-05-09 00:00:00");
select timestampadd(week,123456789,"2012-04-08 23:59:59");
select timestampadd(week,123456789,"2011-05-09 00:00:00");
select timestampadd(week,123456789,"2012-04-08 23:59:59");
select timestampadd(week,-123456789,"2011-05-09 00:00:00");
select timestampadd(week,-123456789,"2012-04-08 23:59:59");
select timestampadd(week,-123456789,"2011-05-09 00:00:00");
select timestampadd(week,-123456789,"2012-04-08 23:59:59");
select timestampadd(month,123456789,"2011-05-07 02:00:00");
select timestampadd(month,123456789,"2011-10-07 01:11:11");
select timestampadd(month,123456789,"2015-09-07 02:00:00");
select timestampadd(month,-123456789,"2011-05-07 02:00:00");
select timestampadd(month,-123456789,"2011-10-07 01:11:11");
select timestampadd(month,-123456789,"2015-09-07 02:00:00");
select timestampadd(quarter,123456789,"2015-05-09");
select timestampadd(quarter,123456789,"2015-04-07");
select timestampadd(quarter,123456789,"2015-05-07");
select timestampadd(quarter,-123456789,"2015-05-09");
select timestampadd(quarter,-123456789,"2015-04-07");
select timestampadd(quarter,-123456789,"2015-05-07");
select timestampadd(year,123456789,"2015-05-09");
select timestampadd(year,123456789,"2015-04-07");
select timestampadd(year,123456789,"2015-05-07");
select timestampadd(year,-123456789,"2015-05-09");
select timestampadd(year,-123456789,"2015-04-07");
select timestampadd(year,-123456789,"2015-05-07");
select timestampadd(year,1,"9999-05-07");
select timestampadd(year,1,"2036-05-07");
--explain_protocol 0
set time_zone='-5:00';
create table sb(a timestamp);
insert into sb values ("2010-01-01 00:00:00");
set time_zone='-5:00';
alter system flush plan cache global;
--explain_protocol 2
set @@ob_enable_plan_cache = 0;
select timestampadd(hour,1,a) from sb;
select timestampadd(hour,-1,a) from sb;
drop table sb;
--explain_protocol 0
set time_zone='+6:00';
create table sb(a datetime);
insert into sb values ("2010-08-06 12:34:56");
set time_zone='-7:00';
alter system flush plan cache global;
--explain_protocol 2
select timestampadd(hour,1,a) from sb;
select timestampadd(hour,-1,a) from sb;
drop table sb;
--sleep 2

View File

@ -0,0 +1,105 @@
# owner: dachuan.sdc
# owner group: sql2
# description: to_days, time_to_usec, usec_to_time, str_to_day
--result_format 4
--disable_abort_on_error
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
connection conn_admin;
set @@ob_enable_plan_cache = 0;
--echo // sleep 2
--sleep 2
--disable_warnings
drop table if exists t1, t2;
--enable_warnings
create table t1(col_int int, col_decimal decimal, col_varchar varchar(100),
col_date date, col_datetime datetime, col_timestamp timestamp,
col_null int);
insert into t1 values(123, 123.123, 'invalid char', '2020-01-01 12:12:12', '0000-00-00 00:00:00.000', '2020-01-01 12:12:12.1234', null);
insert into t1 values(123, 123.123, '2020-01-01', '2019-01-01', '0000-00-00', '2020-01-01', null);
--echo // to check type
create table t2 (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 t2 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');
insert into t2 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 // sleep 2
--sleep 2
select col_int, to_days(col_int) from t1;
select col_decimal, to_days(col_decimal) from t1;
select col_varchar, to_days(col_varchar) from t1;
select col_date, to_days(col_date) from t1;
select col_datetime, to_days(col_datetime) from t1;
select col_timestamp, to_days(col_timestamp) from t1;
select to_days(col_null) from t1;
select col_int, time_to_usec(col_int) from t1;
select col_decimal, time_to_usec(col_decimal) from t1;
select col_varchar, time_to_usec(col_varchar) from t1;
select col_date, time_to_usec(col_date) from t1;
select col_datetime, time_to_usec(col_datetime) from t1;
select col_timestamp, time_to_usec(col_timestamp) from t1;
select time_to_usec(col_null) from t1;
select col_int, usec_to_time(col_int) from t1;
select col_decimal, usec_to_time(col_decimal) from t1;
select col_varchar, usec_to_time(col_varchar) from t1;
select col_date, usec_to_time(col_date) from t1;
select col_datetime, usec_to_time(col_datetime) from t1;
select col_timestamp, usec_to_time(col_timestamp) from t1;
select usec_to_time(col_null) from t1;
select str_to_date(null, null);
select str_to_date('2019-01-01 10:10:10', null);
select str_to_date(null, '%Y-%c-%d %T');
select str_to_date('2019-01-01 10:10:10', '%Y-%c-%d %T');
select str_to_date('invalid char', '%Y-%c-%d %T');
select str_to_date('2019-01-01 10:10:10', 'invalid char');
let $cnt=22;
let $left=1;
while ($left <= $cnt)
{
eval select to_days(c$left), time_to_usec(c$left), usec_to_time(c$left) from t2;
let $right=1;
while ($right <= $cnt)
{
eval select str_to_date(c$left, c$right) from t2;
inc $right;
}
inc $left;
}
drop table t1;
--sleep 2

View File

@ -0,0 +1,58 @@
# 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 trim(' abc ') x from dual;
select trim(leading from ' abc ') x from dual;
select trim(trailing from ' abc ') x from dual;
select trim(both from ' abc ') x from dual;
select trim(both '' from ' abc ') x from dual;
select trim(both ' ' from ' abc ') x from dual;
select trim(both 'abc' from 'abcabdefabcabc') x from dual;
select trim(both ' ' from ' abc ') x from dual;
select trim(both NULL from ' abc ') x from dual;
select trim(both ' ' from NULL) x from dual;
select trim(both 1 from 112311) x from dual;
select ltrim(' abc ') x from dual;
select ltrim(' ') x from dual;
select ltrim(NULL) x from dual;
select rtrim(' abc ') x from dual;
select rtrim(' ') x from dual;
select rtrim(NULL) x from dual;
--disable_warnings
drop table if exists t1;
drop view if exists v1;
--enable_warnings
create view v1 as select nullif(trim(repeat('abc', 1+1)), 'a');
desc v1;
select * from v1;
create table t1(c1 longtext, c2 varchar(100));
insert into t1 values('abababa', 'a');
--echo // c1 and c2 will cast to longtext
select trim(leading c2 from c1) from t1;
drop view v1;
drop table t1;
connection syscon;
--sleep 2

View File

@ -0,0 +1,83 @@
# 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;
#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);
# int
insert into t1(c1) values(100), (123), (151);
# double
insert into t1(c15) values(100.156), (123.111), (151);
# float
insert into t1(c13) values(100.156), (123.111), (151);
--sleep 1
--explain_protocol 2
select truncate(c_null, c_null) from t1;
select truncate(1.11, c_null) from t1;
select truncate(c_null, -1) from t1;
## truncate(c20, c16) 结果与mysql不一致,cast(c16 as signed)的结果发生变化导致truncate的结果变化
let $cnt=22;
let $left=1;
while ($left <= $cnt)
{
let $right=1;
while ($right <= $cnt)
{
eval select c$left, c$right, truncate(c$left, c$right) from t1;
eval select c$left, truncate(c$left, -3), truncate(c$left, -2), truncate(c$left, -1), truncate(c$left, 0), truncate(c$left, 1), truncate(c$left, 2), truncate(c$left, 3), truncate(c$left, 4) from t1;
inc $right;
}
inc $left;
}
--sleep 2

View File

@ -0,0 +1,40 @@
# owner: xiaoyi.xy
# owner group: sql2
--disable_abort_on_error
--result_format 4
connect (sys, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection default;
--disable_warnings
drop table if exists t1;
create table t1 (c1 varchar(2000));
insert into t1 values(hex("ABC")), (hex("123"));
connection sys;
sleep 2;
connection default;
set @@ob_enable_plan_cache = 0;
select unhex(c1) from t1;
select unhex("4142") from dual;
--disable_warnings
drop table if exists t2;
CREATE TABLE t2 (a VARBINARY(2000));
set sql_mode = STRICT_TRANS_TABLES;
insert into t2 VALUES (UNHEX('54455354'));
--error 5342
insert into t2 VALUES (UNHEX('TEST'));
select a from t2 where a = UNHEX('TEST');
select a from t2 where a = UNHEX('54455354');
set sql_mode = "";
insert into t2 VALUES (UNHEX('54455354'));
insert into t2 VALUES (UNHEX('TEST'));
select a from t2 where a = UNHEX('TEST');
select a from t2 where a = UNHEX('54455354');
connection sys;
--sleep 2

View File

@ -0,0 +1,24 @@
# owner: xiaoyi.xy
# owner group: sql2
--disable_abort_on_error
--result_format 4
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
connection conn_admin;
alter system flush plan cache global;
set ob_enable_plan_cache = 0;
sleep 2;
select unix_timestamp(NULL);
select unix_timestamp('');
select unix_timestamp('2010-01-01 10:50:50.123');
select unix_timestamp(123);
--disable_warnings
drop table if exists t1;
--enable_warnings
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;
sleep 2;

View File

@ -0,0 +1,93 @@
#owner: peihan.dph
--disable_abort_on_error
--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
connection default;
set ob_enable_plan_cache = false;
select 1 xor 0 from dual;
select 1 xor 0 xor 1 from dual;
select 1 xor 1 xor 1 from dual;
select 0.4 xor 0.6 from dual;
select 0.5 xor 0.5 from dual;
explain select 1 xor 1 xor 1 from dual;
select null xor 0 from dual;
select 1 xor null xor pow(200, 2000000) from dual;
select pow(200m 2000000) xor null xor 1 from dual;
connection conn_admin;
--sleep 2
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');
connection conn_admin;
--sleep 2
connection default;
let $cnt1 = 1;
while ($cnt1 < 30)
{
let $cnt2 = 1;
while ($cnt2 < 30)
{
eval select t$cnt1 xor t$cnt2 from t;
eval explain select t$cnt1 xor t$cnt2 from t;
inc $cnt2;
}
inc $cnt1;
}
drop table t;
connection conn_admin;
--sleep 2

View File

@ -0,0 +1,87 @@
# owner: peihan.dph
# owner group: sql2
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
sleep 2;
connection default;
--disable_warnings
--error 0,1051
drop table t1;
--error 0,1051
drop table t2;
--error 0,1051
drop table t111_var;
--enable_warnings
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;
connection syscon;
sleep 2;
--result_format 4
--explain_protocol 1
connection default;
set @@ob_enable_plan_cache = 0;
select /*+ USE_HASH_AGGREGATION */distinct c1,c2 from t2;
select /*+ USE_HASH_AGGREGATION */distinct c2,c1 from t2;
select /*+ USE_HASH_AGGREGATION */distinct c2,c1,c1+c2 from t2;
select /*+ USE_HASH_AGGREGATION */distinct c1+c2,abs(c1) from t2;
select /*+ USE_HASH_AGGREGATION */distinct c1+c2 from t2;
select /*+ USE_HASH_AGGREGATION */distinct c2,c1,c3 from t2;
select /*+ USE_HASH_AGGREGATION */distinct 1,2,3,5,'ab' from t2;
select /*+ USE_HASH_AGGREGATION */distinct 1,c2,2,3,c1,5,'ab' from t2;
select /*+ USE_HASH_AGGREGATION */distinct 1,c2,2,3,c1,5,'ab' from t2 where c2=0;
## dump
set ob_query_timeout=30000000;
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;
connection syscon;
sleep 2;
connection default;
drop table t1;
drop table t2;
drop table t111_var;
--sleep 2

View File

@ -0,0 +1,140 @@
#owner: peihan.dph
#owner group: sql2
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
--error 0,5157
drop tenant dump_tenant force;
--error 0,4650
drop resource pool new_pool1;
--error 0,4648
drop resource unit new_box1;
let $cpu = 1;
let $memory = '768M';
let $min_memory = '768M';
let $disk = 536870912;
let $iops = 128;
let $session = 64;
--disable_query_log
eval create resource unit new_box1 max_cpu 1, max_memory $memory, max_iops $iops, max_disk_size $disk, max_session_num $session, MIN_CPU= 1, MIN_MEMORY=$min_memory, MIN_IOPS=128;
let $zone_name=query_get_value(select zone from oceanbase.__all_zone where zone != '' limit 1, zone, 1);
let $obs_num = query_get_value(select count(1) as cnt from oceanbase.__all_server group by zone limit 1,cnt, 1);
eval create resource pool new_pool1 unit = 'new_box1', unit_num = $obs_num;
eval create tenant dump_tenant primary_zone='$zone_name', resource_pool_list('new_pool1') set ob_tcp_invited_nodes='%';
let $t_id = query_get_value(select tenant_id as t_id from oceanbase.__all_tenant where tenant_name = 'dump_tenant' limit 1,t_id, 1);
--enable_result_log
--enable_query_log
--source mysql_test/include/check_tenant_sync.inc
sleep 2;
connect (conn1,$OBMYSQL_MS0,root@dump_tenant,,test,$OBMYSQL_PORT);
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';
sleep 2;
--disable_warnings
--error 0,1051
drop table t11_set;
--error 0,1051
drop table t22_set;
--error 0,1051
drop table t111_var;
--error 0,1051
drop table t333_var;
--enable_warnings
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
#union: first row left less than right
select c1,c2 from t11_set union select c1,c2 from t22_set where c1 > 5 and c1 != 12;
select c1,c2 from t11_set intersect select c1,c2 from t22_set where c1 > 5 and c1 != 12;
select c1,c2 from t11_set minus select c1,c2 from t22_set where c1 > 5 and c1 != 12;
#union: first row left is greater than right
select c1,c2 from t11_set where c1 > 5 and c1 != 12 union select c1,c2 from t22_set;
select c1,c2 from t11_set where c1 > 5 and c1 != 12 intersect select c1,c2 from t22_set;
select c1,c2 from t11_set where c1 > 5 and c1 != 12 minus select c1,c2 from t22_set;
#union: left has left row
select c1,c2 from t11_set union select c1,c2 from t22_set where c1 <22;
select c1,c2 from t11_set intersect select c1,c2 from t22_set where c1 <22;
select c1,c2 from t11_set minus select c1,c2 from t22_set where c1 <22;
## dump
set ob_query_timeout=30000000;
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;
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;
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;
--explain_protocol 0
--replace_regex /con_id =[0-9]*/con_id =xxx/
eval 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 =$t_id group by operation_type order by 1,2,3,4;
connection syscon;
drop tenant dump_tenant force;
drop resource pool new_pool1;
drop resource unit new_box1;

View File

@ -0,0 +1,46 @@
# owner: peihan.dph
# owner group: sql2
--result_format 4
--explain_protocol 0
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
sleep 2;
connection default;
--disable_warnings
drop table if exists t1;
drop table if exists t2;
--enable_warnings
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;
connection syscon;
sleep 2;
--explain_protocol 2
connection default;
set @@ob_enable_plan_cache = 0;
#set @@ob_enable_trace_log=1;
#set @@ob_log_level='trace';
explain select * from t1,t2;
select * from t1,t2;
connection syscon;
sleep 2;
--sleep 2

View File

@ -0,0 +1,73 @@
#owner: peihan.dph
#owner group: sql2
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
sleep 2;
connection default;
--disable_warnings
--error 0,1051
drop table t11_set;
--error 0,1051
drop table t22_set;
--enable_warnings
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);
connection syscon;
sleep 2;
connection default;
set @@ob_enable_plan_cache = 0;
#union: first row left less than right
select c1,c2 from t11_set union select c1,c2 from t22_set where c1 > 5 and c1 != 12;
select c1,c2 from t11_set intersect select c1,c2 from t22_set where c1 > 5 and c1 != 12;
select c1,c2 from t11_set minus select c1,c2 from t22_set where c1 > 5 and c1 != 12;
#union: first row left is greater than right
select c1,c2 from t11_set where c1 > 5 and c1 != 12 union select c1,c2 from t22_set;
select c1,c2 from t11_set where c1 > 5 and c1 != 12 intersect select c1,c2 from t22_set;
select c1,c2 from t11_set where c1 > 5 and c1 != 12 minus select c1,c2 from t22_set;
#union: left has left row
select c1,c2 from t11_set union select c1,c2 from t22_set where c1 <22;
select c1,c2 from t11_set intersect select c1,c2 from t22_set where c1 <22;
select c1,c2 from t11_set minus select c1,c2 from t22_set where c1 <22;
connection syscon;
sleep 2;
connection default;
drop table t11_set;
drop table t22_set;
--sleep 2

View File

@ -0,0 +1,33 @@
# owner: xiaoyi.xy
# owner group: sql2
--disable_abort_on_error
--result_format 4
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT);
connection conn_admin;
alter system flush plan cache global;
connection default;
--echo
--disable_warnings
drop table if exists t;
--enable_warnings
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);
--echo
explain select c2 from t partition(p1);
drop table t;
connection conn_admin;
--sleep 2

View File

@ -0,0 +1,122 @@
# owner: peihan.dph
# owner group: sql2
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
sleep 2;
connection default;
--disable_warnings
--error 0, 1051
drop table t1;
--error 0,1051
drop table t2;
--error 0,1051
drop table t3;
--error 0,1051
drop table t4;
--error 0,1051
drop table t5;
--enable_warnings
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;
connection syscon;
sleep 2;
--result_format 4
--explain_protocol 1
connection default;
set @@ob_enable_plan_cache = 0;
#set @@ob_enable_trace_log=1;
#set @@ob_log_level='trace';
select * from t3 a ;
##ms coord output 列与child不一致,所以后续就改成了拿数据时直接采用child_expxs
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;
##ms receieve local order
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;
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;
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;
## ms receive global order subplan not supported, core, ignore
#select /*+ parallel(2) pq_distribute(a hash hash) NO_USE_HASH_AGGREGATION */ * from (select a.c2,sum(a.c1) from t3 a group by a.c2)a, t3 b where a.c2=b.c2;
## broadcast shuffle
select /*+ parallel(2) pq_distribute(b broadcast none) */ * from t1 a, t2 b where a.c1=b.c2 order by a.c1,b.c1;
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;
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;
connection syscon;
sleep 2;
connection default;
drop table t1;
drop table t2;
drop table t3;
drop table t4;
drop table t5;
--sleep 2

View File

@ -0,0 +1,109 @@
# owner: peihan.dph
# owner group: SQL2
# description: 测试执行引擎3.0下case表达式
--result_format 4
--explain_protocol 2
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
--echo // Case1: normal test,测试是否将带参数的case转为不带参数的case
--echo // Case2: 测试case表达式里面有列的情况
--echo // Case3: 测试空串以及NULL的情况
connection conn_admin;
alter system flush plan cache global;
set @@ob_enable_plan_cache = 0;
--sleep 2
--echo // Case1: normal test.
--echo // 所有带参数的case表达式都被转为不带参数的case表达式
select case 1 when 1 then 'a' when 2 then 'b' else 'c' end from dual;
--echo // 应该命中else expr
select case 100 when 1 then 'a' when 2 then 'b' else 'c' end from dual;
--echo
--echo // MySQL允许各个when/then expr结果类型不一致
--echo // 1和'1'的类型不一致,会被加上cast,都被转为decimal再进行比较,返回'a'
select case 1 when '1' then 'a' when 2 then 'b' else 'c' end from dual;
--echo // 第二个then 应该要加cast,返回'a'
select case 1 when 1 then 'a' when 2 then 'b' else 3 end from dual;
--echo // 不带参数的case的测试
--echo // normal test
--echo // 应该返回'a'
select case when 1=1 then 'a' when 2 then 'b' else 'c' end from dual;
--echo // 应该返回'c'
select case when 0=1 then 'a' when 0.0 then 'b' else 'c' end from dual;
--echo // 应该返回'a',且0='1'中要加cast
select case when 1='1' then 'a' when 2 then 'b' else 'c' end from dual;
--echo // 应该返回'c',且0='1'中要加cast
select case when 0='1' then 'a' when 0.0 then 'b' else 'c' end from dual;
--explain_protocol 0
--echo // Case2: 测试建表的情况
--disable_warnings
drop table if exists t1;
--enable_warnings
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;
--echo // 测试int的normal case,应该返回'a'
select case col_int when 1 then 'a' when 2 then 'b' else 'c' end from t1;
--echo // 测试int需要加cast的情况,第一个when需要加cast, 第二个when不需要
select case col_int when '1' then 'a' when 2 then 'b' else 'c' end from t1;
--echo // 测试null的情况,应该返回'c',而且没有cast出现
select case col_null when 1 then 'a' when 2 then 'b' else 'c' end from t1;
--echo // Case3: 测试空串以及NULL的情况
--echo // 应该返回1, MySQL没有把空串看成NULL
select case '' when '' then 1 when 'here' then 2 else 'hh' end from dual;
--echo // 应该返回'hh'
select case NULL when NULL then 1 when 'here' then 2 else 'hh' end from dual;
--echo // 应该返回1, MySQL没有把空串看成NULL
select case when '' = '' then 1 when 'here' then 2 else 'hh' end from dual;
--echo // 应该返回'hh', 因为'here'cast为double会失败,返回值应该是0
select case when NULL=NULL then 1 when 'here' then 2 else 'hh' end from dual;
--echo // 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);
insert into t1 values('cond', 'COND', 'COND');
--explain_protocol 2
--echo // 返回Null,a和cond1以及a和cond2比较都会使用utf8_bin作为collation type(因为有aggregate collation的过程)
select case a when cond1 then '1' when cond2 then '2' end from t1;
--echo // 返回'neq', a和cond1比较使用的是utf8_bin
select case a when cond1 then 'eq' else 'neq' end from t1;
--echo // 返回'eq', a和cond1比较使用的是utf8_general_ci
select case a when cond2 then 'eq' else 'neq' end from t1;
--echo // arg case子节点也是arg case的情况测试,应该都被改为case expr(应该返回'ok')
select case case a when 'cond' then 'eq' else 'neq' end when 'eq' then 'ok' else 'not ok' end from t1;
--explain_protocol 0
--echo // Case5: show create view/table
--disable_warnings
drop view if exists v1;
drop table if exists t2;
--enable_warnings
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;
--echo // arg case expr的改写不应该影响show create view,结果应该还是arg case expr 而非改写后的case expr
--source mysql_test/include/show_create_table_old_version_replica2.inc
show create view v1;
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;
--echo // arg case expr的改写不应该影响show create table,结果应该还是arg case expr 而非改写后的case expr
--source mysql_test/include/show_create_table_old_version_replica2.inc
show create table t2;
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;
alter system set _enable_static_typing_engine = false;
--sleep 2

View File

@ -0,0 +1,153 @@
#owner: peihan.dph
--result_format 4
--disable_abort_on_error
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection conn_admin;
alter system flush plan cache global;
connection default;
set ob_enable_plan_cache=false;
--disable_warnings
drop table if exists t;
--enable_warnings
create table t (tinyint_t tinyint,
smallint_t smallint,
mediumint_t mediumint,
int32_t integer,
bigint_t bigint,
utinyint_t tinyint unsigned,
usmallint_t smallint unsigned,
umedium_t mediumint unsigned,
uint32_t integer unsigned,
ubigint_t bigint unsigned,
float_t float,
ufloat_t float unsigned,
double_t double,
udouble_t double unsigned,
number_t number,
unumber_t number unsigned,
datetime_t datetime,
timestamp_t timestamp,
date_t date,
time_t time,
year_t year,
varchar_t varchar(255),
char_t char(255),
tinytext_t tinytext,
mediumtext_t mediumtext,
longtext_t longtext,
bit_t bit,
enum_t enum('a', 'b', 'c'),
set_t set('a', 'b', 'c'));
insert into t values (NULL, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.0, 1.00, 1.000, 1.0000, 1.00000, 1.000000,
'1993-03-20', '1993-03-20', '1993-03-20', '10:10:10', '1993', '1.0', '1.00', '1.000', '1.0000',
'1.00000', 1, 'b', 'b');
connection conn_admin;
connection default;
--explain_protocol 2
select NULL = tinyint_t from t limit 1;
select NULL = smallint_t from t limit 1;
select NULL = mediumint_t from t limit 1;
select NULL = int32_t from t limit 1;
select NULL = bigint_t from t limit 1;
select NULL = utinyint_t from t limit 1;
select NULL = usmallint_t from t limit 1;
select NULL = umedium_t from t limit 1;
select NULL = uint32_t from t limit 1;
select NULL = ubigint_t from t limit 1;
select NULL = float_t from t limit 1;
select NULL = ufloat_t from t limit 1;
select NULL = double_t from t limit 1;
select NULL = udouble_t from t limit 1;
select NULL = number_t from t limit 1;
select NULL = unumber_t from t limit 1;
select NULL = datetime_t from t limit 1;
select NULL = timestamp_t from t limit 1;
select NULL = date_t from t limit 1;
select NULL = time_t from t limit 1;
select NULL = year_t from t limit 1;
select NULL = varchar_t from t limit 1;
select NULL = char_t from t limit 1;
select NULL = tinytext_t from t limit 1;
select NULL = mediumtext_t from t limit 1;
select NULL = longtext_t from t limit 1;
select NULL = bit_t from t limit 1;
select NULL = enum_t from t limit 1;
select NULL = set_t from t limit 1;
select tinyint_t = tinyint_t from t limit 1;
select tinyint_t = smallint_t from t limit 1;
select tinyint_t = mediumint_t from t limit 1;
select tinyint_t = int32_t from t limit 1;
select tinyint_t = bigint_t from t limit 1;
select tinyint_t = utinyint_t from t limit 1;
select tinyint_t = usmallint_t from t limit 1;
select tinyint_t = umedium_t from t limit 1;
select tinyint_t = uint32_t from t limit 1;
select tinyint_t = ubigint_t from t limit 1;
select tinyint_t = float_t from t limit 1;
select tinyint_t = ufloat_t from t limit 1;
select tinyint_t = double_t from t limit 1;
select tinyint_t = udouble_t from t limit 1;
select tinyint_t = number_t from t limit 1;
select tinyint_t = unumber_t from t limit 1;
select tinyint_t = datetime_t from t limit 1;
select tinyint_t = timestamp_t from t limit 1;
select tinyint_t = date_t from t limit 1;
select tinyint_t = time_t from t limit 1;
select tinyint_t = year_t from t limit 1;
select tinyint_t = varchar_t from t limit 1;
select tinyint_t = char_t from t limit 1;
select tinyint_t = tinytext_t from t limit 1;
select tinyint_t = mediumtext_t from t limit 1;
select tinyint_t = longtext_t from t limit 1;
select tinyint_t = bit_t from t limit 1;
select tinyint_t = enum_t from t limit 1;
select tinyint_t = set_t from t limit 1;
--echo Row With NULL
select (1, 1) = (1, null) from dual;
select (1, 1) = (2, null) from dual;
select (1, 1) < (1, null) from dual;
select (1, 1) < (2, null) from dual;
select (1, 1) <= (1, null) from dual;
select (1, 1) <= (2, null) from dual;
select (1, 1) > (1, null) from dual;
select (1, 1) > (2, null) from dual;
select (1, 1) >= (1, null) from dual;
select (1, 1) >= (2, null) from dual;
select (1, 1) != (1, null) from dual;
select (1, 1) != (2, null) from dual;
select (1, 1) = (1, tinyint_t) from t limit 1;
select (1, 1) = (2, tinyint_t) from t limit 1;
select (1, 1) < (1, tinyint_t) from t limit 1;
select (1, 1) < (2, tinyint_t) from t limit 1;
select (1, 1) <= (1, tinyint_t) from t limit 1;
select (1, 1) <= (2, tinyint_t) from t limit 1;
select (1, 1) > (1, tinyint_t) from t limit 1;
select (1, 1) > (2, tinyint_t) from t limit 1;
select (1, 1) >= (1, tinyint_t) from t limit 1;
select (1, 1) >= (2, tinyint_t) from t limit 1;
select (1, 1) != (1, tinyint_t) from t limit 1;
select (1, 1) != (2, tinyint_t) from t limit 1;
connection conn_admin;
--sleep 2

View File

@ -0,0 +1,42 @@
#owner: dachuan.sdc
#owner group: sql2
--disable_abort_on_error
--result_format 4
--disable_warnings
connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection conn_admin;
alter system set enable_async_syslog = false;
--sleep 2
connection default;
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');
connection conn_admin;
--sleep 2
connection default;
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;
select partition_key_v2(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14) from t1;
select c1, partition_key_v2(c1), partition_key_v2(c2), partition_key_v2(c3), partition_key_v2(c4), partition_key_v2(c5) from t2;
select partition_key_v2(c1, c2, c3, c4, c5 from t2;
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;
select partition_key_v2(c1, c2, c3, c4, c5, c6, c7, c8) from t3;
connection conn_admin;
connection default;
drop table t1;
drop table t2;
drop table t3;
--sleep 2

View File

@ -0,0 +1,132 @@
# 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;
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));
--enable_warnings
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');
connection syscon;
sleep 2;
connection default;
set @@ob_enable_plan_cache = 0;
set ob_enable_transformation = off;
# for row cmp bug (last column is ignored)
select (1, 1) = (1, 0);
select (1, 1) = (1, 1);
# for null safe euqal bug. (same with `=`)
select 1 <=> 1;
select 1 <=> 0;
select 1 <=> null;
select null <=> 1;
select null <=> null;
select (1, 1) <=> (1, 1);
select (1, null) <=> (1, 1);
select (1, null) <=> (1, null);
select (1, null) <=> (null, null);
select (null, null) <=> (null, null);
# single line
select (select c1, c2 from t1 where c1 = 1) = (1, 1) from t2 where c1 = 1;
select (select c1, c2 from t1 where c1 = 1) = (c2, c1) from t2 where c1 = 1;
select (select c1 from t1 where c1 = 1) + 1 from t2 where c1 = 1;
select (select c1 from t1 where 1 = 0) + 1 from t2 where c1 = 1;
# multi line
select c2 in (select c2 from t2) from t1;
select c2 = any(select c2 from t2) from t1;
select c2 != any(select c2 from t2) from t1;
select c2 < any(select c2 from t2) from t1;
select c2 <= any(select c2 from t2) from t1;
select c2 > any(select c2 from t2) from t1;
select c2 >= any(select c2 from t2) from t1;
select c2 <=> any(select c2 from t2) from t1;
select exists (select * from t2), not exists (select * from t2) from t1;
select exists (select * from t2 where 1 = 0), not exists (select * from t2 where 1 = 0) from t1;
select c2 = all (select c2 from t2) from t1;
select c2 = any (select c2 from t2) from t1;
select c2 = all (select c3 from t2) from t1;
select c2 = any (select c3 from t2) from t1;
select c3 = all (select c2 from t2) from t1;
select c3 = any (select c2 from t2) from t1;
select c3 <=> (select c2 from t2) from t1;
select (c1, c3) = all (select c1, c2 from t2) from t1;
select (c1, c3) = any (select c1, c2 from t2) from t1;
select (c1, c3) <=> (select c1, c2 from t2) from t1;
select exists (select 1);
select not exists (select 1);
select 1 from dual where exists (select c1 from t2);
select 1 from dual where not exists (select c1 from t2);
select * from t1 where exists (select * from t2 where c1 < 0);
select * from t1 where exists (select * from t2 where c1 > 0);
# empty set or to many rows
select (select c1, c2 from t1 where c1 = 1) = (select c1, c2 from t2 where c1 = 1);
select (select c1, c2 from t1 where c1 = 0) = (select c1, c2 from t2 where c1 = 1);
select (select c1, c2 from t1 where c1 = 1) = (select c1, c2 from t2 where c1 = 0);
select (select c1, c2 from t1 where c1 = 0) = (select c1, c2 from t2 where c1 = 0);
select (select c1, c2 from t1 where c1 = 1) <=> (select c1, c2 from t2 where c1 = 1);
select (select c1, c2 from t1 where c1 = 0) <=> (select c1, c2 from t2 where c1 = 1);
select (select c1, c2 from t1 where c1 = 1) <=> (select c1, c2 from t2 where c1 = 0);
select (select c1, c2 from t1 where c1 = 0) <=> (select c1, c2 from t2 where c1 = 0);
select (select c1, c2 from t1 where c1 > 1) = (select c1, c2 from t2 where c1 = 1);
select (select c1, c2 from t1 where c1 = 1) = (select c1, c2 from t2 where c1 > 1);
select (select c1, c2 from t1 where c1 > 1) = (select c1, c2 from t2 where c1 > 1);
--explain_protocol 2
# subplan filter
# onetime expr + init plan expr
select c1 + (select c2 from t2 where c1 = 2), c2 in (select c3 from t2) from t1;
# dynamic param store expr
select c1 + (select c2 from t2 where c1 = t1.c2 and c3 <= t1.c2) from t1;
select * from t1 where c1 + (select c2 from t2 where c1 = t1.c2 and c3 <= t1.c2) < 10;
# show implicit cast
# cast expr inside subquery
select (select c1, c2 from t2 where c1 = 1) = (c2, c1) from t1;
select (select c1, c2 from t2 where c1 = 1) = (c1, c2) from t1;
select (c2, c1) <= (select c1, c2 from t2 where c1 = 1) from t1;
select (c1, c2) <= (select c1, c2 from t2 where c1 = 1) from t1;
select (select c2, c1 from t2 where c1 = 2) >= (select c1, c2 from t2 where c1 = 1) from t1;
select (select c1, c1 from t2 where c1 = 2) >= (select c1, c2 from t2 where c1 = 1) from t1;
# cast expr add above subquery for scalar value
select c2 > (select c1 from t2 where c3 is not null) from t1;
select * from t1 where c2 + (select c1 from t2 where c1 = t1.c2) < 10;
set ob_enable_transformation = on;
connection syscon;
--sleep 2

View File

@ -0,0 +1,42 @@
# 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;
connection default;
--disable_warnings
drop table if exists t1;
create table t1 (c1 int, c2 int);
--enable_warnings
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);
connection syscon;
sleep 2;
connection default;
set @@ob_enable_plan_cache = 0;
explain select c2, sum(c1) from (select distinct c2, c1 from t1) x group by c2;
select c2, sum(c1) from (select distinct c2, c1 from t1) x group by c2;
explain select c2, sum(c1 + c2) from (select distinct c2, c1 from t1) x group by c2;
select c2, sum(c1 + c2) from (select distinct c2, c1 from t1) x group by c2;
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;
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;
explain select * from t1 where c2 in (select 1 from t1);
select * from t1 where c2 in (select 1 from t1);
connection syscon;

View File

@ -0,0 +1,110 @@
# owner: xiaoyi.xy
# 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 set enable_async_syslog = false;
connection default;
set @@ob_enable_plan_cache = 0;
--disable_warnings
drop table if exists t1, t2;
--enable_warnings
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
select * from t1;
--explain_protocol 0
set @@ob_enable_plan_cache = 1;
--echo // 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);
--echo // different value type, but will use same plan, so will to ObDatumCaster::to_type()
insert into t1 values(123, 123, 123, 123);
insert into t1 values(null, 123, null, 123);
insert into t1 values('123', '123', '123', 123);
insert into t1 values('', '123', '123', 123);
select c1, length(c1),
c2, length(c2),
c3, length(c3),
c4, length(c4) from t1;
--echo // insert decimal/int using different collation string
delete from t1;
insert into t1 values('123.123', '123.123', '123.123', '123.123');
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;
insert into t2 select c2, c2, c2 from t1;
insert into t2 select c3, c3, c3 from t1;
insert into t2 select c4, c4, c4 from t1;
select * from t2;
--echo // test enumset
drop table 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;
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);
insert into t2 values('a', 'a', 'a');
--echo // insert enum/set using different collation string
insert into t1 select col_utf16, col_utf16 from t2;
insert into t1 select col_gbk, col_gbk from t2;
insert into t1 select col_utf8, col_utf8 from t2;
select * from t1;
delete from t1;
delete from t2;
insert into t1 values('a', 'b'), ('b', 'c');
select * from t1;
--echo // insert different collation string using enum/set
insert into t2 select c1, c1, c1 from t1;
insert into t2 select c2, c2, c2 from t1;
select * from t2;
delete from t2;
--echo // test again(using different column)
insert into t2 select c1, c2, c1 from t1;
insert into t2 select c2, c2, c1 from t1;
insert into t2 select c1, c1, c2 from t1;
select * from t2;
drop table t1;
drop table t2;
--disable_warnings
drop table if exists t2;
--enable_warnings
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);
drop table t2;
connection conn_admin;
--sleep 2

View File

@ -0,0 +1,72 @@
# owner: bin.lb
# owner group: sql2
--result_format 4
--explain_protocol 0
connect (syscon, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
--sleep 2
connection default;
--disable_warnings
drop table if exists t1;
--enable_warnings
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';
connection syscon;
sleep 2;
connection default;
set @@ob_enable_plan_cache = 0;
--explain_protocol 2
# base table
select * from t1;
select * from t1 order by c1 desc, c2 desc;
select * from t1 where c1 + c2 < 10;
select * from t1 limit 2;
select * from t1 where c1 = 5;
select * from t1 where c1 = 5 or c1 = 7;
select * from t1 where (c1 = 2 and c2 = 4) or (c1 = 7 and c2 = 5) or (c1 = 8 and c2 = 7);
# index back
select * from t1 where c2 = 2 and c1 + c2 < 10 and c4 > c3;
#index only
select c1, c2 from t1 where c2 > 4;
--echo ***** test index back
--disable_warnings
drop table t1;
--enable_warnings
create table t1(c1 int primary key, c2 int, c3 int, index idx(c2));
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);
--echo
--echo # case 1: index back with before_index_back_filter
select /*+index(t1 idx)*/ c1, c2, c3 from t1 where c2 > 1 and c1 < 4;
--echo
--echo # case 2: index back without before_index_back_filter
select /*+index(t1 idx)*/ c1, c2, c3 from t1 where c2 > 1 and c3 < 4;
# index back + limit
select /*+index(t1 idx)*/ c1, c2, c3 from t1 where c3 != 1 limit 2;
--disable_warnings
drop table t1;
--enable_warnings
connection syscon;
--sleep 2