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 insert_selet.test,insert_update.test,update_v1.test,alter_table_v1.test..(#497) #536

Merged
merged 3 commits into from
Sep 22, 2022
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
2 changes: 1 addition & 1 deletion mysql-test/include/default_mysqld.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ loose-innodb_read_io_threads= 2
loose-innodb_log_buffer_size= 1M
loose-innodb_log_file_size= 5M
loose-innodb_log_files_in_group= 2
default-storage-engine=InnoDB
default-storage-engine=tianmu

tianmu_insert_delayed=off

Expand Down
31 changes: 22 additions & 9 deletions mysql-test/suite/tianmu/r/create_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ drop table t1;
#
# Test of primary key with 32 index
#
create table t1 (a int not null, b int, primary key(a), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b))engine=tianmu;
create table t1 (a int not null, b int, primary key(a),
key (b), key (b), key (b), key (b), key (b), key (b),
key (b), key (b), key (b), key (b), key (b), key (b),
key (b), key (b), key (b), key (b), key (b), key (b),
key (b), key (b), key (b), key (b), key (b), key (b),
key (b), key (b), key (b), key (b), key (b), key (b),
key (b))engine=tianmu;
Warnings:
Warning 1831 Duplicate index 'b_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Warning 1831 Duplicate index 'b_3' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Expand Down Expand Up @@ -278,7 +284,9 @@ drop table t1,t3;
#
# Test types of data for create select with functions
#
create table t1(a int,b int,c int,d date,e char,f datetime,g time,h blob)engine=tianmu;
create table t1(a int,b int,c int,
d date,e char,f datetime,g time,
h blob)engine=tianmu;
insert into t1(a)values(1);
insert into t1(a,b,c,d,e,f,g,h)values(2,-2,2,'1825-12-14','a','2003-1-1 3:2:1','4:3:2','binary data');
select * from t1;
Expand Down Expand Up @@ -309,7 +317,11 @@ f datetime YES NULL
g time YES NULL
h blob YES NULL
drop table t1;
create table t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), i year, j date, k timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, l datetime, o char(10))engine=tianmu;
create table t1 (a tinyint, b smallint, c mediumint,
d int, e bigint, f float(3,2), g double(4,3),
h decimal(5,4), i year, j date,
k timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
l datetime, o char(10))engine=tianmu;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
Expand All @@ -328,7 +340,8 @@ t1 CREATE TABLE `t1` (
`o` char(10) DEFAULT NULL
) ENGINE=TIANMU DEFAULT CHARSET=latin1
drop table t1;
create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14')engine=tianmu;
create table t1(str varchar(10) default 'def',strnull varchar(10),
intg int default '10',rel double default '3.14')engine=tianmu;
insert into t1 values ('','',0,0.0);
describe t1;
Field Type Null Key Default Extra
Expand Down Expand Up @@ -457,7 +470,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`c1` year(4) DEFAULT '2008',
`c2` year(4) DEFAULT '0000'
) ENGINE=InnoDB DEFAULT CHARSET=latin1
) ENGINE=TIANMU DEFAULT CHARSET=latin1
insert into t1 values();
select * FROM t1;
c1 c2
Expand All @@ -481,12 +494,12 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`dt` datetime DEFAULT '2008-02-31 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=latin1
) ENGINE=TIANMU DEFAULT CHARSET=latin1
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`dt` datetime DEFAULT '2008-02-31 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=latin1
) ENGINE=TIANMU DEFAULT CHARSET=latin1
set @@sql_mode= @old_mode;
drop tables t1,t2;
#
Expand Down Expand Up @@ -565,7 +578,7 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`fld1` datetime NOT NULL DEFAULT '1111-11-11 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=latin1
) ENGINE=TIANMU DEFAULT CHARSET=latin1
drop table t1;
# create table..select based on trigger fields.
create table t1 (fld1 int, fld2 DATETIME DEFAULT '1211:1:1');
Expand All @@ -574,4 +587,4 @@ Table Create Table
t1 CREATE TABLE `t1` (
`fld1` int(11) DEFAULT NULL,
`fld2` datetime DEFAULT '1211-01-01 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=latin1
) ENGINE=TIANMU DEFAULT CHARSET=latin1
74 changes: 35 additions & 39 deletions mysql-test/suite/tianmu/r/delete.result
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,16 @@ sum(c_int)
10200000
drop table column_type_test;
drop table if exists t1,t2,t3,t11,t12;
CREATE TABLE t1 (a tinyint(3), b tinyint(5));
CREATE TABLE t1 (a tinyint(3), b tinyint(5))ENGINE=TIANMU;
INSERT INTO t1 VALUES (1,1);
INSERT LOW_PRIORITY INTO t1 VALUES (1,2);
INSERT INTO t1 VALUES (1,3);
DELETE from t1 where a=1 limit 1;
DELETE LOW_PRIORITY from t1 where a=1;
INSERT INTO t1 VALUES (1,1);
DELETE from t1;
LOCK TABLE t1 write;
INSERT INTO t1 VALUES (1,2);
DELETE from t1;
UNLOCK TABLES;
INSERT INTO t1 VALUES (1,2);
SET AUTOCOMMIT=0;
DELETE from t1;
Expand All @@ -106,7 +104,7 @@ g bigint not null default 0,
h bigint not null default 0,
i bigint not null default 0,
j bigint not null default 0,
primary key (a,b,c,d,e,f,g,h,i,j));
primary key (a,b,c,d,e,f,g,h,i,j))ENGINE=TIANMU;
insert into t1 (a) values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23);
delete from t1 where a=26;
drop table t1;
Expand All @@ -129,7 +127,7 @@ CREATE TABLE `t1` (
`i` int(10) NOT NULL default '0',
`i2` int(10) NOT NULL default '0',
PRIMARY KEY (`i`)
);
)ENGINE=TIANMU;
DELETE FROM t1 USING t1 WHERE post='1';
ERROR 42S22: Unknown column 'post' in 'where clause'
drop table t1;
Expand All @@ -138,7 +136,7 @@ bool char(0) default NULL,
not_null varchar(20) binary NOT NULL default '',
misc integer not null,
PRIMARY KEY (not_null)
);
)ENGINE=TIANMU;
INSERT INTO t1 VALUES (NULL,'a',4), (NULL,'b',5), (NULL,'c',6), (NULL,'d',7);
select * from t1 where misc > 5 and bool is null;
bool not_null misc
Expand All @@ -159,9 +157,9 @@ select count(*) from t1;
count(*)
0
drop table t1;
create table t11 (a int NOT NULL, b int, primary key (a));
create table t12 (a int NOT NULL, b int, primary key (a));
create table t2 (a int NOT NULL, b int, primary key (a));
create table t11 (a int NOT NULL, b int, primary key (a))ENGINE=TIANMU;
create table t12 (a int NOT NULL, b int, primary key (a))ENGINE=TIANMU;
create table t2 (a int NOT NULL, b int, primary key (a))ENGINE=TIANMU;
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(0, 11),(2, 12);
insert into t2 values (1, 21),(2, 12),(3, 23);
Expand All @@ -172,9 +170,9 @@ a b
2 12
select * from t12;
a b
33 10
0 11
2 12
33 10
select * from t2;
a b
1 21
Expand All @@ -189,21 +187,23 @@ a b
2 12
select * from t12;
a b
33 10
0 11
2 12
33 10
delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
Warnings:
Warning 1242 Subquery returns more than 1 row
Warning 1242 Subquery returns more than 1 row
select * from t11;
a b
0 10
1 11
2 12
select * from t12;
a b
0 11
33 10
insert into t11 values (2, 12);
0 11
2 12
delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
ERROR 21000: Subquery returns more than 1 row
select * from t11;
Expand All @@ -221,30 +221,30 @@ a b
1 11
drop table t11, t12, t2;
# sql_safe_updates mode with multi-table DELETE
CREATE TABLE t1(a INTEGER PRIMARY KEY);
CREATE TABLE t1(a INTEGER PRIMARY KEY)ENGINE=TIANMU;
INSERT INTO t1 VALUES(10),(20);
CREATE TABLE t2(b INTEGER);
CREATE TABLE t2(b INTEGER)ENGINE=TIANMU;
INSERT INTO t2 VALUES(10),(20);
SET SESSION sql_safe_updates=1;
EXPLAIN DELETE t2 FROM t1 JOIN t2 WHERE t1.a = 10;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL const PRIMARY PRIMARY 4 const 1 100.00 Using index
1 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 const 1 100.00 NULL
1 DELETE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL
DELETE t2 FROM t1 JOIN t2 WHERE t1.a = 10;
ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column.
SET SESSION sql_safe_updates=default;
DROP TABLE t1, t2;
create table t1 (a int, b int, unique key (a), key (b));
create table t1 (a int, b int, unique key (a), key (b))ENGINE=TIANMU;
insert into t1 values (3, 3), (7, 7);
delete t1 from t1 where a = 3;
delete from t1 where a = 3;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
test.t1 check note The storage engine for the table doesn't support check
select * from t1;
a b
7 7
drop table t1;
CREATE TABLE t1 ( a int PRIMARY KEY );
CREATE TABLE t1 ( a int PRIMARY KEY )ENGINE=TIANMU;
DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;
INSERT INTO t1 VALUES (0),(1),(2);
DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a LIMIT 1;
Expand All @@ -253,35 +253,33 @@ a
0
2
DROP TABLE t1;
CREATE TABLE t1 (a int not null,b int not null);
CREATE TABLE t2 (a int not null, b int not null, primary key (a,b));
CREATE TABLE t3 (a int not null, b int not null, primary key (a,b));
CREATE TABLE t1 (a int not null,b int not null)ENGINE=TIANMU;
CREATE TABLE t2 (a int not null, b int not null, primary key (a,b))ENGINE=TIANMU;
CREATE TABLE t3 (a int not null, b int not null, primary key (a,b))ENGINE=TIANMU;
insert into t1 values (1,1),(2,1),(1,3);
insert into t2 values (1,1),(2,2),(3,3);
insert into t3 values (1,1),(2,1),(1,3);
select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
a b a b a b
1 1 1 1 1 1
2 1 2 2 2 1
1 3 1 1 1 3
explain select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL
1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index
1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b,test.t1.b 1 100.00 Using index
1 SIMPLE t2 NULL ref PRIMARY PRIMARY 4 test.t1.a 2 100.00 NULL
1 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 8 test.t2.b,test.t1.b 1 100.00 NULL
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`b` = `test`.`t1`.`b`) and (`test`.`t3`.`a` = `test`.`t2`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`))
delete t2.*,t3.* from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
select * from t3;
a b
1 1
2 1
1 3
drop table t1,t2,t3;
create table t1(a date not null);
insert ignore into t1 values (0);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
create table t1(a date not null)ENGINE=TIANMU;
insert into t1 values (0);
ERROR 22007: Incorrect date value: '0' for column 'a' at row 1
select * from t1 where a is null;
a
0000-00-00
delete from t1 where a is null;
select count(*) from t1;
count(*)
Expand All @@ -290,17 +288,15 @@ drop table t1;
#
# Adds some test cases for unicode. such as insert unicode chars, in values, table name, or etc.
#
CREATE TABLE `abc def` (i int)engine=tianmu;
CREATE TABLE `abc def` (i int)ENGINE=TIANMU;
INSERT INTO `abc def` VALUES (1);
delete from `abc def` where i=1;
drop table `abc def`;
CREATE TABLE t1 (`abc def1` int, `abc def2` int);
CREATE TABLE t1 (`abc def1` int, `abc def2` int)ENGINE=TIANMU;
INSERT INTO t1 VALUES (1,1);
DELETE from t1 where `abc def1` = 1;
LOCK TABLE t1 write;
INSERT INTO t1 VALUES (1,2);
DELETE from t1 where `abc def1` = 1;
UNLOCK TABLES;
INSERT INTO t1 VALUES (1,2);
SET AUTOCOMMIT=0;
DELETE from t1 where `abc def2` = 2;
Expand All @@ -309,9 +305,9 @@ drop table t1;
#
# deleting rows from a temporary tables
#
CREATE TABLE t1 (c int not null, d char (10) not null);
CREATE TABLE t1 (c int not null, d char (10) not null)ENGINE=TIANMU;
insert into t1 values(1,""),(2,"a"),(3,"b");
CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null)ENGINE=TIANMU;
insert into t1 values(4,"e"),(5,"f"),(6,"g");
alter table t1 rename t2;
select * from t1;
Expand Down
8 changes: 2 additions & 6 deletions mysql-test/suite/tianmu/r/delete_all_rows.result
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,16 @@ c1 c2
2 test2
delete from t1;
drop table t1;
CREATE TABLE t1 (a tinyint(3), b tinyint(5));
CREATE TABLE t1 (a tinyint(3), b tinyint(5))ENGINE=TIANMU;
INSERT INTO t1 VALUES (1,1);
INSERT LOW_PRIORITY INTO t1 VALUES (1,2);
INSERT INTO t1 VALUES (1,3);
DELETE from t1 where a=1 limit 1;
DELETE LOW_PRIORITY from t1 where a=1;
INSERT INTO t1 VALUES (1,1);
DELETE from t1;
LOCK TABLE t1 write;
INSERT INTO t1 VALUES (1,2);
DELETE from t1;
UNLOCK TABLES;
INSERT INTO t1 VALUES (1,2);
SET AUTOCOMMIT=0;
DELETE from t1;
Expand All @@ -161,13 +159,11 @@ CREATE TABLE `abc def` (i int)engine=tianmu;
INSERT INTO `abc def` VALUES (1);
delete from `abc def`;
drop table `abc def`;
CREATE TABLE t1 (`abc def1` tinyint(3), `abc def2` tinyint(5));
CREATE TABLE t1 (`abc def1` tinyint(3), `abc def2` tinyint(5))ENGINE=TIANMU;
INSERT INTO t1 VALUES (1,1);
DELETE from t1;
LOCK TABLE t1 write;
INSERT INTO t1 VALUES (1,2);
DELETE from t1;
UNLOCK TABLES;
INSERT INTO t1 VALUES (1,2);
SET AUTOCOMMIT=0;
DELETE from t1;
Expand Down
Loading