Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(mtr): add more test cases for tianmu(#1196) #1888

Merged
merged 2 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 192 additions & 0 deletions mysql-test/suite/tianmu/r/case_when.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
#
# test case when
#
DROP DATABASE IF EXISTS case_when_test;
CREATE DATABASE case_when_test;
USE case_when_test;
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
select CASE "b" when "a" then 1 when "b" then 2 END;
CASE "b" when "a" then 1 when "b" then 2 END
2
select CASE "c" when "a" then 1 when "b" then 2 END;
CASE "c" when "a" then 1 when "b" then 2 END
NULL
select CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END;
CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END
3
select CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END;
CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END
ok
select CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END;
CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END
ok
select CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end;
CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end
a
select CASE when 1=0 then "true" else "false" END;
CASE when 1=0 then "true" else "false" END
false
select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END;
CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END
one
select CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END;
CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END
two
select (CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0;
(CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0
2
select (CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0;
(CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0
2.00
select case 1/0 when "a" then "true" else "false" END;
case 1/0 when "a" then "true" else "false" END
false
select case 1/0 when "a" then "true" END;
case 1/0 when "a" then "true" END
NULL
select (case 1/0 when "a" then "true" END) | 0;
(case 1/0 when "a" then "true" END) | 0
NULL
select (case 1/0 when "a" then "true" END) + 0.0;
(case 1/0 when "a" then "true" END) + 0.0
NULL
select case when 1>0 then "TRUE" else "FALSE" END;
case when 1>0 then "TRUE" else "FALSE" END
TRUE
select case when 1<0 then "TRUE" else "FALSE" END;
case when 1<0 then "TRUE" else "FALSE" END
FALSE
create table t1 (a int);
insert into t1 values(1),(2),(3),(4);
select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase order by fcase;
fcase count(*)
0 2
2 1
3 1
select case a when 1 then "one" when 2 then "two" else "nothing" end as fcase, count(*) from t1 group by fcase order by fcase;
fcase count(*)
nothing 2
one 1
two 1
drop table t1;
create table t1 (row int not null, col int not null, val varchar(255) not null);
insert into t1 values (1,1,'orange'),(1,2,'large'),(2,1,'yellow'),(2,2,'medium'),(3,1,'green'),(3,2,'small');
select max(case col when 1 then val else null end) as color from t1 group by row;
color
orange
yellow
green
drop table t1;
SET NAMES latin1;
CREATE TABLE t1 SELECT
CASE WHEN 1 THEN _latin1'a' COLLATE latin1_danish_ci ELSE _latin1'a' END AS c1,
CASE WHEN 1 THEN _latin1'a' ELSE _latin1'a' COLLATE latin1_danish_ci END AS c2,
CASE WHEN 1 THEN 'a' ELSE 1 END AS c3,
CASE WHEN 1 THEN 1 ELSE 'a' END AS c4,
CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5,
CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6,
CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7,
CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8,
CASE WHEN 1 THEN 1.0 END AS c9,
CASE WHEN 1 THEN 0.1e1 else 0.1 END AS c10,
CASE WHEN 1 THEN 0.1e1 else 1 END AS c11,
CASE WHEN 1 THEN 0.1e1 else '1' END AS c12
;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '',
`c2` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '',
`c3` varchar(1) NOT NULL DEFAULT '',
`c4` varchar(1) NOT NULL DEFAULT '',
`c5` varchar(4) NOT NULL DEFAULT '',
`c6` varchar(4) NOT NULL DEFAULT '',
`c7` decimal(2,1) NOT NULL DEFAULT '0.0',
`c8` decimal(2,1) NOT NULL DEFAULT '0.0',
`c9` decimal(2,1) DEFAULT NULL,
`c10` double NOT NULL DEFAULT '0',
`c11` double NOT NULL DEFAULT '0',
`c12` varchar(5) NOT NULL DEFAULT ''
) ENGINE=TIANMU DEFAULT CHARSET=latin1
DROP TABLE t1;
SELECT CASE
WHEN 1
THEN _latin1'a' COLLATE latin1_danish_ci
ELSE _latin1'a' COLLATE latin1_swedish_ci
END;
ERROR HY000: Illegal mix of collations (latin1_danish_ci,EXPLICIT) and (latin1_swedish_ci,EXPLICIT) for operation 'case'
SELECT CASE _latin1'a' COLLATE latin1_general_ci
WHEN _latin1'a' COLLATE latin1_danish_ci THEN 1
WHEN _latin1'a' COLLATE latin1_swedish_ci THEN 2
END;
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_danish_ci,EXPLICIT), (latin1_swedish_ci,EXPLICIT) for operation 'case'
SELECT
CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END,
CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END,
CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END,
CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END;
CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END
1 2 1 2
CREATE TABLE t1 SELECT IFNULL('a' COLLATE latin1_swedish_ci, 'b' COLLATE latin1_bin);
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'ifnull'
SELECT 'case+union+test'
UNION
SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END;
case+union+test
case+union+test
nobug
SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END;
CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END
nobug
SELECT 'case+union+test'
UNION
SELECT CASE '1' WHEN '2' THEN 'BUG' ELSE 'nobug' END;
case+union+test
case+union+test
nobug
create table t1(a float, b int default 3);
insert into t1 (a) values (2), (11), (8);
select min(a), min(case when 1=1 then a else NULL end),
min(case when 1!=1 then NULL else a end)
from t1 where b=3 group by b;
min(a) min(case when 1=1 then a else NULL end) min(case when 1!=1 then NULL else a end)
2 2 2
drop table t1;
CREATE TABLE t1 (EMPNUM INT);
INSERT INTO t1 VALUES (0), (2);
CREATE TABLE t2 (EMPNUM DECIMAL (4, 2));
INSERT INTO t2 VALUES (0.0), (9.0);
SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM,
t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2
FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM;
CEMPNUM EMPMUM1 EMPNUM2
0.00 0 0.00
2.00 2 NULL
SELECT IFNULL(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM,
t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2
FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM;
CEMPNUM EMPMUM1 EMPNUM2
0.00 0 0.00
2.00 2 NULL
DROP TABLE t1,t2;
create table t1 (a int, b bigint unsigned);
create table t2 (c int);
insert into t1 (a, b) values (1,457279462277), (2,1819694241997),
(3,1114190595086);
insert into t2 (c) values (1), (2), (3);
select t1.a, (case t1.a when 0 then 0 else t1.b end) d from t1
join t2 on t1.a=t2.c order by d;
a d
1 457279462277
3 1114190595086
2 1819694241997
select t1.a, (case t1.a when 0 then 0 else t1.b end) d from t1
join t2 on t1.a=t2.c where b=1114190595086 order by d;
a d
3 1114190595086
drop table t1, t2;
CREATE TABLE t1(a YEAR);
SELECT 1 FROM t1 WHERE a=1 AND CASE 1 WHEN a THEN 1 ELSE 1 END;
1
DROP TABLE t1;
drop database case_when_test;
25 changes: 25 additions & 0 deletions mysql-test/suite/tianmu/r/drop_restric.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# DROP TABLE RESTRICT
# The RESTRICT clause limits the table to being dropped in the front end only.
# This could be useful when the table has been dropped on one user module,
# and needs to be synced to others.
#
DROP DATABASE IF EXISTS drop_restric_test;
CREATE DATABASE drop_restric_test;
USE drop_restric_test;
CREATE TABLE t1 (id INT, name CHAR(25));
INSERT INTO t1 VALUES (1, 'one'), (2, 'two'), (3, 'three'), (4, 'four'), (5, 'five');
SELECT * FROM t1 ORDER BY id;
id name
1 one
2 two
3 three
4 four
5 five
SELECT COUNT(*) FROM t1;
COUNT(*)
5
DROP TABLE IF EXISTS t1 RESTRICT;
DROP TABLE t1;
ERROR 42S02: Unknown table 'drop_restric_test.t1'
DROP DATABASE IF EXISTS drop_restric_test;
80 changes: 80 additions & 0 deletions mysql-test/suite/tianmu/r/empty_string_not_null.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#
# tests updates that sets invalid range when we set value at max boundary that is less than max.
#
DROP DATABASE IF EXISTS empty_string_not_null;
CREATE DATABASE empty_string_not_null;
USE empty_string_not_null;
CREATE TABLE t(s text);
INSERT INTO t(s) VALUES (''), (NULL);
SELECT COUNT(*) FROM t WHERE s IS NULL;
COUNT(*)
1
SELECT COUNT(*) FROM t WHERE s IS NOT NULL;
COUNT(*)
1
SELECT * FROM t;
s

NULL
DROP TABLE t;
CREATE TABLE t(s text);
INSERT INTO t(s) VALUES ('');
INSERT INTO t(s) VALUES (NULL);
SELECT * FROM t;
s

NULL
SELECT COUNT(*) FROM t WHERE s IS NULL;
COUNT(*)
1
DROP TABLE t;
CREATE TABLE t(s text) ;
INSERT INTO t(s) VALUES ('_CpNuLl_'),(''), (NULL);
SELECT * FROM t;
s
_CpNuLl_

NULL
SELECT COUNT(*) FROM t WHERE s IS NULL;
COUNT(*)
1
DROP TABLE t;
CREATE TABLE t(c6 CHAR(6)) ;
INSERT INTO t(c6) VALUES ('a'), ('b'), ('c');
SELECT 2, COUNT(*) FROM t WHERE (c6 <= 'b' OR c6 <= '');
2 COUNT(*)
2 2
SELECT 2, COUNT(*) FROM t WHERE (c6 <= 'b');
2 COUNT(*)
2 2
SELECT 0, COUNT(*) FROM t WHERE (c6 <= '');
0 COUNT(*)
0 0
SELECT 0, COUNT(*) FROM t WHERE (c6 <= ' ');
0 COUNT(*)
0 0
SELECT 2, COUNT(*) FROM t WHERE (c6 <= 'b' OR c6 <= ' ');
2 COUNT(*)
2 2
SELECT 0, COUNT(*) FROM t WHERE (c6 < '');
0 COUNT(*)
0 0
SELECT 0, COUNT(*) FROM t WHERE (c6 < ' ');
0 COUNT(*)
0 0
DROP TABLE IF EXISTS t;
CREATE TABLE t(a CHAR(10));
INSERT INTO t(a) VALUES (''), (NULL), (' '), (' a ');
SELECT LTRIM(a) FROM t;
LTRIM(a)

NULL

a
SELECT RTRIM(a) FROM t;
RTRIM(a)

NULL

a
DROP DATABASE empty_string_not_null;
36 changes: 36 additions & 0 deletions mysql-test/suite/tianmu/r/left_right_func.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# left and right func test
#
DROP DATABASE IF EXISTS left_right_func_test;
CREATE DATABASE left_right_func_test;
USE left_right_func_test;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (`time_tk` INT(11) UNSIGNED NOT NULL) DEFAULT CHARSET=latin1;
INSERT INTO t1 VALUES
(2013113023),
(1900010100),
(2199123100),
(2199123100),
(2147483646),
(2147483647),
(2147483648);
SELECT LEFT(time_tk,6) AS time_tk_left FROM t1;
time_tk_left
201311
190001
219912
219912
214748
214748
214748
SELECT RIGHT(time_tk,6) AS time_tk_right FROM t1;
time_tk_right
113023
010100
123100
123100
483646
483647
483648
DROP TABLE IF EXISTS t1;
DROP DATABASE left_right_func_test;
17 changes: 17 additions & 0 deletions mysql-test/suite/tianmu/r/like_not_like.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# This test tests the (NOT) LIKE test in filters that is added
# to a FilterCommand in primproc.
# This is a very rare situation, yet somehow I managed to trigger it.
#
DROP DATABASE IF EXISTS like_not_like;
CREATE DATABASE like_not_like;
USE like_not_like;
CREATE TABLE tcs(d1 CHAR(6), d2 CHAR(6));
INSERT INTO tcs(d1, d2) VALUES ('a','a'), ('a', 'b');
SELECT 'stonedb like', d1, d2 FROM tcs WHERE (d1 LIKE d2);
stonedb like d1 d2
stonedb like a a
SELECT 'stonedb not like', d1, d2 FROM tcs WHERE (d1 NOT LIKE d2);
stonedb not like d1 d2
stonedb not like a b
DROP DATABASE like_not_like;
29 changes: 29 additions & 0 deletions mysql-test/suite/tianmu/r/multi_join.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# right join/left join/inner join /full join
#
DROP DATABASE IF EXISTS multi_join_test;
CREATE DATABASE multi_join_test;
USE multi_join_test;
drop table if exists all_datatype_table;
Warnings:
Note 1051 Unknown table 'multi_join_test.all_datatype_table'
create table all_datatype_table(id int not null,c_intger integer,c_char char(10));
insert into all_datatype_table values(1,1000,1000);
insert into all_datatype_table values(2,2000,1000);
insert into all_datatype_table values(3,2001,null);
insert into all_datatype_table values(4,2002,'a');
select count(*) from all_datatype_table t1 right join all_datatype_table t2 on t1.id=t2.id
inner join all_datatype_table t3 on t1.id=t3.id
right join all_datatype_table t4 on t1.id=t4.id
left join all_datatype_table t5 on t1.id=t5.id
inner join all_datatype_table t6 on t1.id=t6.id
left join all_datatype_table t7 on t1.id=t7.id
right join all_datatype_table t8 on t1.id=t8.id
right join all_datatype_table t10 on t1.id=t10.id
right join all_datatype_table t11 on t1.id=t11.id
right join all_datatype_table t13 on t1.id=t13.id
right join all_datatype_table t15 on t1.id=t15.id
right join all_datatype_table t16 on t1.id=t16.id;
count(*)
4
drop DATABASE multi_join_test;
Loading