Skip to content

Commit

Permalink
test(mtr): add some mtr test cases(stoneatom#497)
Browse files Browse the repository at this point in the history
[summary]
add mtr test cases about unsigned/escape/replace into/zerofill
  • Loading branch information
davidshiz committed Jan 6, 2023
1 parent 74160c0 commit 9f106bb
Show file tree
Hide file tree
Showing 12 changed files with 2,317 additions and 0 deletions.
121 changes: 121 additions & 0 deletions mysql-test/suite/tianmu/r/escape.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#
# Test escape
#
DROP DATABASE IF EXISTS escape_test;
CREATE DATABASE escape_test;
USE escape_test;
CREATE TABLE `st1` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) DEFAULT NULL,
`uid` VARCHAR(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8;
INSERT INTO st1 (NAME,uid) VALUES('zhangsan','hello');
INSERT INTO st1 (NAME,uid) VALUES('lisi_wu','world');
INSERT INTO st1 (NAME,uid) VALUES('wangwu%','world');
INSERT INTO st1 (NAME,uid) VALUES('%a','world');
INSERT INTO st1 (NAME,uid) VALUES('%_','world');
select * from st1;
id name uid
1 zhangsan hello
2 lisi_wu world
3 wangwu% world
4 %a world
5 %_ world
SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "san", "%");
id name uid
1 zhangsan hello
SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "%", "%");
id name uid
1 zhangsan hello
2 lisi_wu world
3 wangwu% world
4 %a world
5 %_ world
SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "\%", "%");
id name uid
3 wangwu% world
4 %a world
5 %_ world
SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "\%", "%");
id name uid
3 wangwu% world
4 %a world
5 %_ world
SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "$%", "%") ESCAPE "$";
id name uid
3 wangwu% world
4 %a world
5 %_ world
SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "\_", "%");
id name uid
2 lisi_wu world
5 %_ world
SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "a_", "%") ESCAPE "a";
id name uid
2 lisi_wu world
5 %_ world
SELECT * FROM st1 WHERE NAME LIKE "a%_" ESCAPE "a" ;
id name uid
4 %a world
5 %_ world
SELECT * FROM st1 WHERE NAME LIKE "a%a" ESCAPE "a" ;
id name uid
4 %a world
drop table st1;
CREATE TABLE `st1` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) DEFAULT NULL,
`uid` VARCHAR(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8;
INSERT INTO st1 (NAME,uid) VALUES('123hello','hello');
INSERT INTO st1 (NAME,uid) VALUES('123hello123','world');
INSERT INTO st1 (NAME,uid) VALUES('hello123','world');
INSERT INTO st1 (NAME,uid) VALUES('_hello','world');
select * from st1;
id name uid
1 123hello hello
2 123hello123 world
3 hello123 world
4 _hello world
select * from st1 where name like '%hello%';
id name uid
1 123hello hello
2 123hello123 world
3 hello123 world
4 _hello world
select * from st1 where name like '_hello';
id name uid
4 _hello world
select * from st1 where name like 'hello12_';
id name uid
3 hello123 world
create table st2(id int ,column_2 varchar(10),column_3 varchar(10));
insert into st2 values(1,'_a\\\\','111111');
insert into st2 values(2,'12%','%12%');
insert into st2 values(3,'a_a','a%');
insert into st2 values(4,'_a\\','_12%');
insert into st2 values(5,'\\a','\\\\_a%12%');
select * from st2 where column_2 like '%\\\%' ;
id column_2 column_3
1 _a\\ 111111
4 _a\ _12%
5 \a \\_a%12%
select * from st2 where column_2 like '%\%' ;
id column_2 column_3
2 12% %12%
select * from st2 where column_2 like '%\\%' ;
id column_2 column_3
2 12% %12%
select * from st2 where column_2 like '%\_%' ;
id column_2 column_3
1 _a\\ 111111
3 a_a a%
4 _a\ _12%
select * from st2 where column_2 like '%?_%' escape '?';
id column_2 column_3
1 _a\\ 111111
3 a_a a%
4 _a\ _12%
DROP DATABASE escape_test;
109 changes: 109 additions & 0 deletions mysql-test/suite/tianmu/r/replace_into.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#
# Test replace into
#
DROP DATABASE IF EXISTS replace_into_test;
CREATE DATABASE replace_into_test;
USE replace_into_test;
CREATE TABLE test (
id INT NOT NULL,
test VARCHAR(64) DEFAULT NULL,
name TIMESTAMP NOT NULL,
PRIMARY KEY (id)
);
insert into test values(1,'old','2014-08-20 18:47:00');
insert into test values(2,'old','2014-08-20 18:47:00');
REPLACE INTO test VALUES (1, 'New', '2014-08-20 18:47:42');
REPLACE INTO test VALUES (2, 'New', '2014-08-20 18:47:42');
delete from test where id=1;
REPLACE INTO test VALUES (2, 'Newnew', '2014-08-20 18:47:42');
REPLACE INTO test VALUES (1, 'New', '2014-08-20 18:47:42');
REPLACE INTO test VALUES (1, 'Newnew', '2014-08-20 18:47:42');
select * from test;
id test name
2 Newnew 2014-08-20 18:47:42
1 Newnew 2014-08-20 18:47:42
CREATE TABLE test1 (
id INT NOT NULL,
test VARCHAR(64) DEFAULT NULL,
id1 int NOT NULL,
PRIMARY KEY (id,id1)
);
insert into test1 values(1,'old',1);
insert into test1 values(2,'old',2);
REPLACE INTO test1 VALUES (1, 'New', '8');
REPLACE INTO test1 VALUES (1, 'New', '1');
REPLACE INTO test1 VALUES (8, 'New', '2');
select * from test1;
id test id1
1 New 1
2 old 2
1 New 8
8 New 2
CREATE TABLE `insert_relpace_into_test` (
`id` int(10),
`uniq_id` varchar(32),
`filed_a` varchar(32) DEFAULT '' ,
`filed_b` varchar(32) DEFAULT '',
`version` int(10) DEFAULT '0',
PRIMARY KEY (`id`)
);
CREATE TABLE `insert_relpace_into_test2` (
`id` int(10),
`uniq_id` varchar(32) DEFAULT NULL,
`filed_a` varchar(32) DEFAULT '',
`filed_b` varchar(32) DEFAULT '',
`version` int(10) DEFAULT '0',
PRIMARY KEY (`id`)
);
REPLACE INTO insert_relpace_into_test2
VALUES
( 1,'1003', 'ziduan a', 'ziduan b', 1 ),
( 2,'1005', 'ziduan _2_2', 'ziduan b_2', 1 );
REPLACE INTO insert_relpace_into_test
VALUES
( 3,'1003', 'ziduan a', 'ziduan b', 1 ),
( 4,'1005', 'ziduan _2_2', 'ziduan b_2', 1 );
REPLACE INTO insert_relpace_into_test ( id,uniq_id, filed_a, filed_b, version )
SELECT id,uniq_id, filed_a, filed_b, version FROM insert_relpace_into_test2;
select * from insert_relpace_into_test;
id uniq_id filed_a filed_b version
3 1003 ziduan a ziduan b 1
4 1005 ziduan _2_2 ziduan b_2 1
1 1003 ziduan a ziduan b 1
2 1005 ziduan _2_2 ziduan b_2 1
REPLACE INTO insert_relpace_into_test
SET id=5,uniq_id='1003',filed_a='ziduan _2_2',filed_b='ziduan b_2';
select * from insert_relpace_into_test;
id uniq_id filed_a filed_b version
3 1003 ziduan a ziduan b 1
4 1005 ziduan _2_2 ziduan b_2 1
1 1003 ziduan a ziduan b 1
2 1005 ziduan _2_2 ziduan b_2 1
5 1003 ziduan _2_2 ziduan b_2 0
REPLACE INTO insert_relpace_into_test
VALUES
( 3,'1003new', 'ziduan a', 'ziduan b', 1 ),
( 4,'1005new', 'ziduan _2_2', 'ziduan b_2', 1 );
select * from insert_relpace_into_test;
id uniq_id filed_a filed_b version
3 1003new ziduan a ziduan b 1
4 1005new ziduan _2_2 ziduan b_2 1
1 1003 ziduan a ziduan b 1
2 1005 ziduan _2_2 ziduan b_2 1
5 1003 ziduan _2_2 ziduan b_2 0
REPLACE INTO insert_relpace_into_test ( id,uniq_id, filed_a, filed_b, version )
SELECT id,uniq_id, filed_a, filed_b, version FROM insert_relpace_into_test2;
REPLACE INTO insert_relpace_into_test
SET id=5,uniq_id='1003new',filed_a='ziduan _2_2',filed_b='ziduan b_2';
select * from insert_relpace_into_test;
id uniq_id filed_a filed_b version
3 1003new ziduan a ziduan b 1
4 1005new ziduan _2_2 ziduan b_2 1
1 1003 ziduan a ziduan b 1
2 1005 ziduan _2_2 ziduan b_2 1
5 1003new ziduan _2_2 ziduan b_2 0
drop table insert_relpace_into_test;
drop table insert_relpace_into_test2;
drop table test;
drop table test1;
DROP DATABASE replace_into_test;
153 changes: 153 additions & 0 deletions mysql-test/suite/tianmu/r/unsigned.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#
# Test unsigned
#
DROP DATABASE IF EXISTS unsigned_test;
CREATE DATABASE unsigned_test;
USE unsigned_test;
create table st1 (ukey int, c1 tinyint unsigned, c2 smallint unsigned, c3 int unsigned, c4 bigint unsigned);
insert into st1 values (1,2,3,4,5), (2,127,32767,2147483647,9223372036854775807);
select 'q1', st1.* from st1 order by 1;
q1 ukey c1 c2 c3 c4
q1 1 2 3 4 5
q1 2 127 32767 2147483647 9223372036854775807
insert into st1 values (3,-127,-32766,-2147483646,-9223372036854775806);
ERROR 22003: Out of range value for column 'c1' at row 1
insert into st1 values (4,126,32766,2147483646,9223372036854775806),(5,125,32765,2147483645,9223372036854775805);
insert into st1 values (6,1255,165535,14294967295,118446744073709551615);
ERROR 22003: Out of range value for column 'c1' at row 1
select 'q2', st1.* from st1 where ukey > 2 order by 1;
q2 ukey c1 c2 c3 c4
q2 4 126 32766 2147483646 9223372036854775806
q2 5 125 32765 2147483645 9223372036854775805
insert into st1 values (7,NULL,NULL,NULL,NULL);
select 'q3', st1.* from st1 where ukey=7;
q3 ukey c1 c2 c3 c4
q3 7 NULL NULL NULL NULL
update st1 set c4=-9223372036854775806 where ukey=1;
ERROR 22003: Out of range value for column 'c4' at row 1
update st1 set c3=-2147483646 where ukey=1;
ERROR 22003: Out of range value for column 'c3' at row 1
update st1 set c2=-32766 where ukey=1;
ERROR 22003: Out of range value for column 'c2' at row 1
update st1 set c1=-127 where ukey between 0 and 2;
ERROR 22003: Out of range value for column 'c1' at row 1
select 'q4', st1.* from st1 where ukey<2;
q4 ukey c1 c2 c3 c4
q4 1 2 3 4 5
update st1 set c3=2147483646 where ukey=4;
update st1 set c2=32766 where ukey=4;
update st1 set c1=125 where ukey between 4 and 5;
select 'q5', st1.* from st1 where ukey>3 order by 2;
q5 ukey c1 c2 c3 c4
q5 4 125 32766 2147483646 9223372036854775806
q5 5 125 32765 2147483645 9223372036854775805
q5 7 NULL NULL NULL NULL
create table st2 (ukey int, c1 tinyint unsigned, c2 smallint unsigned, c3 int unsigned, c4 bigint unsigned);
insert into st2 values (8,125,32764,2147483645,9223372036854775800), (9,126,32766,2147483646,9223372036854775800),(10,127,32767,2147483647,9223372036854775801);
select 'q6', st2.* from st2 where c1 between 125 and 127;
q6 ukey c1 c2 c3 c4
q6 8 125 32764 2147483645 9223372036854775800
q6 9 126 32766 2147483646 9223372036854775800
q6 10 127 32767 2147483647 9223372036854775801
select 'q7', st2.* from st2 where c2 between 32764 and 32767;
q7 ukey c1 c2 c3 c4
q7 8 125 32764 2147483645 9223372036854775800
q7 9 126 32766 2147483646 9223372036854775800
q7 10 127 32767 2147483647 9223372036854775801
select 'q8', st2.* from st2 where c3 between 2147483645 and 2147483647;
q8 ukey c1 c2 c3 c4
q8 8 125 32764 2147483645 9223372036854775800
q8 9 126 32766 2147483646 9223372036854775800
q8 10 127 32767 2147483647 9223372036854775801
select 'q9', st2.* from st2 where c4 between 9223372036854775800 and 9223372036854775801;
q9 ukey c1 c2 c3 c4
q9 8 125 32764 2147483645 9223372036854775800
q9 9 126 32766 2147483646 9223372036854775800
q9 10 127 32767 2147483647 9223372036854775801
drop table if exists st1;
drop table if exists st2;
DROP TABLE if exists st3;
create table st3 (ukey bigint unsigned, c1 float unsigned, c2 double unsigned, c3 decimal(5,2) unsigned, c4 decimal(18,6) unsigned);
insert into st3 values (0,2.22507385E-18, 2.225073858507201E-307, 123.45, 1234567890.12345678);
Warnings:
Note 1265 Data truncated for column 'c4' at row 1
select 'q10', st3.* from st3 order by st3.ukey;
q10 ukey c1 c2 c3 c4
q10 0 2.22507e-18 2.225073858507201e-307 123.45 1234567890.123457
insert into st3 values (0,-2.22507385E-18, -2.225073858507201E-307, -123.45, -1234567890.12345678);
ERROR 22003: Out of range value for column 'c1' at row 1
select 'q11', st3.* from st3 order by st3.ukey;
q11 ukey c1 c2 c3 c4
q11 0 2.22507e-18 2.225073858507201e-307 123.45 1234567890.123457
insert into st3 values (0,0.0, 0.0, 43123.45, 34321234567890.12345678);
ERROR 22003: Out of range value for column 'c3' at row 1
select 'q12', st3.* from st3 order by st3.ukey;
q12 ukey c1 c2 c3 c4
q12 0 2.22507e-18 2.225073858507201e-307 123.45 1234567890.123457
select 'q13', st3.* from st3 where c2 > 0 order by st3.ukey;
q13 ukey c1 c2 c3 c4
q13 0 2.22507e-18 2.225073858507201e-307 123.45 1234567890.123457
insert into st3 values (0,0.0, 0.0, 0.0, 0);
select 'q12', st3.* from st3 order by st3.ukey;
q12 ukey c1 c2 c3 c4
q12 0 2.22507e-18 2.225073858507201e-307 123.45 1234567890.123457
q12 0 0 0 0.00 0.000000
DROP TABLE if exists st3;
DROP TABLE IF EXISTS st4;
CREATE TABLE st4 (ukey TINYINT UNSIGNED, c1 INT UNSIGNED);
INSERT INTO st4 VALUES (0,1);
INSERT INTO st4 VALUES (0,2);
INSERT INTO st4 VALUES (0,3);
INSERT INTO st4 VALUES (0,4);
INSERT INTO st4 VALUES (0,5);
SELECT 'q13', st4.* FROM st4 ORDER BY st4.ukey;
q13 ukey c1
q13 0 1
q13 0 2
q13 0 3
q13 0 4
q13 0 5
DROP TABLE IF EXISTS st4;
CREATE TABLE st4 (ukey SMALLINT UNSIGNED, c1 INT UNSIGNED);
INSERT INTO st4 VALUES (0,1);
INSERT INTO st4 VALUES (0,2);
INSERT INTO st4 VALUES (0,3);
INSERT INTO st4 VALUES (0,4);
INSERT INTO st4 VALUES (0,5);
SELECT 'q13', st4.* FROM st4 ORDER BY st4.ukey;
q13 ukey c1
q13 0 1
q13 0 2
q13 0 3
q13 0 4
q13 0 5
DROP TABLE IF EXISTS st4;
CREATE TABLE st4 (ukey INT UNSIGNED, c1 INT UNSIGNED);
INSERT INTO st4 VALUES (0,1);
INSERT INTO st4 VALUES (0,2);
INSERT INTO st4 VALUES (0,3);
INSERT INTO st4 VALUES (0,4);
INSERT INTO st4 VALUES (0,5);
SELECT 'q13', st4.* FROM st4 ORDER BY st4.ukey;
q13 ukey c1
q13 0 1
q13 0 2
q13 0 3
q13 0 4
q13 0 5
DROP TABLE IF EXISTS st4;
CREATE TABLE st4 (ukey BIGINT UNSIGNED, c1 INT UNSIGNED);
INSERT INTO st4 VALUES (0,1);
INSERT INTO st4 VALUES (0,2);
INSERT INTO st4 VALUES (0,3);
INSERT INTO st4 VALUES (0,4);
INSERT INTO st4 VALUES (0,5);
SELECT 'q13', st4.* FROM st4 ORDER BY st4.ukey;
q13 ukey c1
q13 0 1
q13 0 2
q13 0 3
q13 0 4
q13 0 5
DROP TABLE IF EXISTS st4;
DROP DATABASE unsigned_test;
Loading

0 comments on commit 9f106bb

Please sign in to comment.