diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-07-15 18:01:22 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-07-15 18:01:22 +0200 |
commit | e1c76b80d91c43a9f17d9ec4c96e4dcb72efb1a2 (patch) | |
tree | ba4f3d737607d1a87e68b4e48e1f41119bee3b82 | |
parent | b427da7651f348550deb886024c0d3101720f00e (diff) | |
download | mariadb-git-e1c76b80d91c43a9f17d9ec4c96e4dcb72efb1a2.tar.gz |
Fixes for innodb suite, merging tests from 5.6.
Includes 5.6 changesets for:
*****
Fix for BUG#13489996 valgrind:conditional jump or move depends on uninitialised values-field_blob.
blob_ptr_size was not initialized properly: remove this variable.
*****
Bug#14021323 CRASH IN FIELD::SET_NULL WHEN INSERTING ROWS TO NEW TABLE
*****
31 files changed, 1059 insertions, 1454 deletions
diff --git a/mysql-test/include/have_innodb.combinations b/mysql-test/include/have_innodb.combinations index 55107204097..b76f783b928 100644 --- a/mysql-test/include/have_innodb.combinations +++ b/mysql-test/include/have_innodb.combinations @@ -7,6 +7,8 @@ innodb-trx innodb-buffer-pool-stats innodb-buffer-page innodb-buffer-page-lru +innodb-sys-foreign +innodb-sys-foreign-col [xtradb_plugin] ignore-builtin-innodb @@ -17,6 +19,8 @@ innodb-trx innodb-buffer-pool-stats innodb-buffer-page innodb-buffer-page-lru +innodb-sys-foreign +innodb-sys-foreign-col [xtradb] innodb @@ -26,3 +30,5 @@ innodb-metrics innodb-buffer-pool-stats innodb-buffer-page innodb-buffer-page-lru +innodb-sys-foreign +innodb-sys-foreign-col diff --git a/mysql-test/r/sp-bugs.result b/mysql-test/r/sp-bugs.result index eef51385fb1..e34f8f9e63a 100644 --- a/mysql-test/r/sp-bugs.result +++ b/mysql-test/r/sp-bugs.result @@ -132,6 +132,15 @@ DROP DATABASE testdb; USE test; End of 5.1 tests # +# BUG#13489996 valgrind:conditional jump or move depends on +# uninitialised values-field_blob +# +CREATE FUNCTION sf() RETURNS BLOB RETURN ""; +SELECT sf(); +sf() + +DROP FUNCTION sf; +# # Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE # SET @@SQL_MODE = ''; diff --git a/mysql-test/suite/innodb/r/innodb-autoinc-44030.result b/mysql-test/suite/innodb/r/innodb-autoinc-44030.result index 54e972843f5..93e6ede30f2 100644 --- a/mysql-test/suite/innodb/r/innodb-autoinc-44030.result +++ b/mysql-test/suite/innodb/r/innodb-autoinc-44030.result @@ -19,7 +19,9 @@ Table Create Table t1 CREATE TABLE `t1` ( `d1` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`d1`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES(null); +ERROR 23000: Duplicate entry '3' for key 'PRIMARY' INSERT INTO t1 VALUES(null); SELECT * FROM t1; d1 diff --git a/mysql-test/suite/innodb/r/innodb-index.result b/mysql-test/suite/innodb/r/innodb-index.result index 0f004772153..b34ea69bef6 100644 --- a/mysql-test/suite/innodb/r/innodb-index.result +++ b/mysql-test/suite/innodb/r/innodb-index.result @@ -1,125 +1,12 @@ set global innodb_file_per_table=on; set global innodb_file_format='Barracuda'; -CREATE TABLE t1_purge ( -A INT, -B BLOB, C BLOB, D BLOB, E BLOB, -F BLOB, G BLOB, H BLOB, -PRIMARY KEY (B(767), C(767), D(767), E(767), A), -INDEX (A) -) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; -INSERT INTO t1_purge VALUES (1, -REPEAT('b', 766), REPEAT('c', 766), REPEAT('d', 766), REPEAT('e', 766), -REPEAT('f', 766), REPEAT('g', 766), REPEAT('h', 766)); -CREATE TABLE t2_purge ( -A INT PRIMARY KEY, -B BLOB, C BLOB, D BLOB, E BLOB, -F BLOB, G BLOB, H BLOB, I BLOB, -J BLOB, K BLOB, L BLOB, -INDEX (B(767))) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; -INSERT INTO t2_purge VALUES (1, -REPEAT('b', 766), REPEAT('c', 766), REPEAT('d', 766), REPEAT('e', 766), -REPEAT('f', 766), REPEAT('g', 766), REPEAT('h', 766), REPEAT('i', 766), -REPEAT('j', 766), REPEAT('k', 766), REPEAT('l', 766)); -CREATE TABLE t3_purge ( -A INT, -B VARCHAR(800), C VARCHAR(800), D VARCHAR(800), E VARCHAR(800), -F VARCHAR(800), G VARCHAR(800), H VARCHAR(800), -PRIMARY KEY (B(767), C(767), D(767), E(767), A), -INDEX (A) -) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; -INSERT INTO t3_purge SELECT * FROM t1_purge; -CREATE TABLE t4_purge ( -A INT PRIMARY KEY, -B VARCHAR(800), C VARCHAR(800), D VARCHAR(800), E VARCHAR(800), -F VARCHAR(800), G VARCHAR(800), H VARCHAR(800), I VARCHAR(800), -J VARCHAR(800), K VARCHAR(800), L VARCHAR(800), -INDEX (B(767))) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; -INSERT INTO t4_purge SELECT * FROM t2_purge; -DELETE FROM t1_purge; -DELETE FROM t2_purge; -DELETE FROM t3_purge; -DELETE FROM t4_purge; -SET @r=REPEAT('a',500); -CREATE TABLE t12637786(a INT, -v1 VARCHAR(500), v2 VARCHAR(500), v3 VARCHAR(500), -v4 VARCHAR(500), v5 VARCHAR(500), v6 VARCHAR(500), -v7 VARCHAR(500), v8 VARCHAR(500), v9 VARCHAR(500), -v10 VARCHAR(500), v11 VARCHAR(500), v12 VARCHAR(500), -v13 VARCHAR(500), v14 VARCHAR(500), v15 VARCHAR(500), -v16 VARCHAR(500), v17 VARCHAR(500), v18 VARCHAR(500) -) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; -CREATE INDEX idx1 ON t12637786(a,v1); -INSERT INTO t12637786 VALUES(9,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r); -UPDATE t12637786 SET a=1000; -DELETE FROM t12637786; -create table t12963823(a blob,b blob,c blob,d blob,e blob,f blob,g blob,h blob, -i blob,j blob,k blob,l blob,m blob,n blob,o blob,p blob) -engine=innodb row_format=dynamic; -SET @r = repeat('a', 767); -insert into t12963823 values (@r,@r,@r,@r, @r,@r,@r,@r, @r,@r,@r,@r, @r,@r,@r,@r); -create index ndx_a on t12963823 (a(500)); -create index ndx_b on t12963823 (b(500)); -create index ndx_c on t12963823 (c(500)); -create index ndx_d on t12963823 (d(500)); -create index ndx_e on t12963823 (e(500)); -create index ndx_f on t12963823 (f(500)); -create index ndx_k on t12963823 (k(500)); -create index ndx_l on t12963823 (l(500)); -SET @r = repeat('b', 500); -update t12963823 set a=@r,b=@r,c=@r,d=@r; -update t12963823 set e=@r,f=@r,g=@r,h=@r; -update t12963823 set i=@r,j=@r,k=@r,l=@r; -update t12963823 set m=@r,n=@r,o=@r,p=@r; -alter table t12963823 drop index ndx_a; -alter table t12963823 drop index ndx_b; -create index ndx_g on t12963823 (g(500)); -create index ndx_h on t12963823 (h(500)); -create index ndx_i on t12963823 (i(500)); -create index ndx_j on t12963823 (j(500)); -create index ndx_m on t12963823 (m(500)); -create index ndx_n on t12963823 (n(500)); -create index ndx_o on t12963823 (o(500)); -create index ndx_p on t12963823 (p(500)); -show create table t12963823; -Table Create Table -t12963823 CREATE TABLE `t12963823` ( - `a` blob, - `b` blob, - `c` blob, - `d` blob, - `e` blob, - `f` blob, - `g` blob, - `h` blob, - `i` blob, - `j` blob, - `k` blob, - `l` blob, - `m` blob, - `n` blob, - `o` blob, - `p` blob, - KEY `ndx_c` (`c`(500)), - KEY `ndx_d` (`d`(500)), - KEY `ndx_e` (`e`(500)), - KEY `ndx_f` (`f`(500)), - KEY `ndx_k` (`k`(500)), - KEY `ndx_l` (`l`(500)), - KEY `ndx_g` (`g`(500)), - KEY `ndx_h` (`h`(500)), - KEY `ndx_i` (`i`(500)), - KEY `ndx_j` (`j`(500)), - KEY `ndx_m` (`m`(500)), - KEY `ndx_n` (`n`(500)), - KEY `ndx_o` (`o`(500)), - KEY `ndx_p` (`p`(500)) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC +SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS; create table t1(a varchar(2) primary key) engine=innodb; insert into t1 values(''); create index t1a1 on t1(a(1)); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 drop table t1; -set global innodb_file_per_table=0; -set global innodb_file_format=Antelope; create table t1(a int not null, b int, c char(10) not null, d varchar(20)) engine = innodb; insert into t1 values (5,5,'oo','oo'),(4,4,'tr','tr'),(3,4,'ad','ad'),(2,3,'ak','ak'); commit; @@ -128,6 +15,8 @@ ERROR 42000: Duplicate key name 'b' alter table t1 add index (b,b); ERROR 42S21: Duplicate column name 'b' alter table t1 add index d2 (d); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -137,6 +26,7 @@ t1 CREATE TABLE `t1` ( `d` varchar(20) DEFAULT NULL, KEY `d2` (`d`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 +analyze table t1; explain select * from t1 force index(d2) order by d; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL d2 23 NULL 4 @@ -158,6 +48,8 @@ t1 CREATE TABLE `t1` ( KEY `d2` (`d`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 alter table t1 add index (b); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -169,6 +61,8 @@ t1 CREATE TABLE `t1` ( KEY `b` (`b`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 alter table t1 add unique index (c), add index (d); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -181,10 +75,15 @@ t1 CREATE TABLE `t1` ( KEY `b` (`b`), KEY `d` (`d`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK explain select * from t1 force index(c) order by c; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL c 10 NULL 4 alter table t1 add primary key (a), drop index c; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -197,11 +96,14 @@ t1 CREATE TABLE `t1` ( KEY `b` (`b`), KEY `d` (`d`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 alter table t1 add primary key (c); ERROR 42000: Multiple primary key defined alter table t1 drop primary key, add primary key (b); ERROR 23000: Duplicate entry '4' for key 'PRIMARY' create unique index c on t1 (c); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -215,6 +117,9 @@ t1 CREATE TABLE `t1` ( KEY `b` (`b`), KEY `d` (`d`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK explain select * from t1 force index(c) order by c; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL c 10 NULL 4 @@ -225,6 +130,8 @@ a b c d 5 5 oo oo 4 4 tr tr alter table t1 drop index b, add index (b); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -235,8 +142,8 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`a`), UNIQUE KEY `c` (`c`), KEY `d2` (`d`), - KEY `d` (`d`), - KEY `b` (`b`) + KEY `b` (`b`), + KEY `d` (`d`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values(6,1,'ggg','ggg'); select * from t1; @@ -267,6 +174,7 @@ a b c d 6 1 ggg ggg 5 5 oo oo 4 4 tr tr +analyze table t1; explain select * from t1 force index(b) order by b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL b 5 NULL 5 @@ -286,14 +194,16 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`a`), UNIQUE KEY `c` (`c`), KEY `d2` (`d`), - KEY `d` (`d`), - KEY `b` (`b`) + KEY `b` (`b`), + KEY `d` (`d`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t1; create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb; insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,3,'ad','ad'),(4,4,'afe','afe'); commit; alter table t1 add index (c(2)); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -304,7 +214,10 @@ t1 CREATE TABLE `t1` ( PRIMARY KEY (`a`), KEY `c` (`c`(2)) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 alter table t1 add unique index (d(10)); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -316,7 +229,9 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `d` (`d`(10)), KEY `c` (`c`(2)) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 insert into t1 values(5,1,'ggg','ggg'); +analyze table t1; select * from t1; a b c d 1 1 ab ab @@ -359,6 +274,8 @@ t1 CREATE TABLE `t1` ( KEY `c` (`c`(2)) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 alter table t1 drop index d; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 insert into t1 values(8,9,'fff','fff'); select * from t1; a b c d @@ -376,6 +293,7 @@ a b c d 4 4 afe afe 8 9 fff fff 5 1 ggg ggg +analyze table t1; explain select * from t1 order by b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort @@ -400,6 +318,8 @@ create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe'); commit; alter table t1 add unique index (b,c); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 insert into t1 values(8,9,'fff','fff'); select * from t1; a b c d @@ -415,6 +335,7 @@ a b c d 3 2 ad ad 4 4 afe afe 8 9 fff fff +analyze table t1; explain select * from t1 force index(b) order by b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL b 16 NULL 5 @@ -429,6 +350,8 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `b` (`b`,`c`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 alter table t1 add index (b,c); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 insert into t1 values(11,11,'kkk','kkk'); select * from t1; a b c d @@ -446,6 +369,7 @@ a b c d 4 4 afe afe 8 9 fff fff 11 11 kkk kkk +analyze table t1; explain select * from t1 force index(b) order by b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL b 16 NULL 6 @@ -461,6 +385,8 @@ t1 CREATE TABLE `t1` ( KEY `b_2` (`b`,`c`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 alter table t1 add unique index (c,d); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 insert into t1 values(13,13,'yyy','aaa'); select * from t1; a b c d @@ -489,6 +415,7 @@ a b c d 8 9 fff fff 11 11 kkk kkk 13 13 yyy aaa +analyze table t1; explain select * from t1 force index(b) order by b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL b 16 NULL 7 @@ -511,9 +438,9 @@ drop table t1; create table t1(a int not null, b int not null, c int, primary key (a), key (b)) engine = innodb; create table t3(a int not null, c int not null, d int, primary key (a), key (c)) engine = innodb; create table t4(a int not null, d int not null, e int, primary key (a), key (d)) engine = innodb; -create table t2(a int not null, b int not null, c int not null, d int not null, e int, -foreign key (b) references t1(b) on delete cascade, -foreign key (c) references t3(c), foreign key (d) references t4(d)) +create table t2(a int not null, b int, c int, d int, e int, +foreign key (b) references t1(b) on delete set null, +foreign key (c) references t3(c), foreign key (d) references t4(d) on update set null) engine = innodb; alter table t1 drop index b; ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint @@ -525,15 +452,49 @@ alter table t2 drop index b; ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint alter table t2 drop index b, drop index c, drop index d; ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint +alter table t2 MODIFY b INT NOT NULL, ALGORITHM=COPY; +ERROR HY000: Cannot change column 'b': used in a foreign key constraint 't2_ibfk_1' +set @old_sql_mode = @@sql_mode; +set @@sql_mode = 'STRICT_TRANS_TABLES'; +alter table t2 MODIFY b INT NOT NULL, ALGORITHM=INPLACE; +ERROR HY000: Column 'b' cannot be NOT NULL: needed in a foreign key constraint 'test/t2_ibfk_1' SET NULL +set @@sql_mode = @old_sql_mode; +SET FOREIGN_KEY_CHECKS=0; +alter table t2 DROP COLUMN b, ALGORITHM=COPY; +ERROR HY000: Cannot drop column 'b': needed in a foreign key constraint 't2_ibfk_1' +alter table t2 DROP COLUMN b; +ERROR HY000: Cannot drop column 'b': needed in a foreign key constraint 'test/t2_ibfk_1' +alter table t1 DROP COLUMN b, ALGORITHM=COPY; +ERROR HY000: Cannot drop column 'b': needed in a foreign key constraint 't2_ibfk_1' of table 'test.t2' +alter table t1 DROP COLUMN b; +ERROR HY000: Cannot drop column 'b': needed in a foreign key constraint 'test/t2_ibfk_1' of table '"test"."t2"' +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; create unique index dc on t2 (d,c); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 create index dc on t1 (b,c); -alter table t2 add primary key (a); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +set @@sql_mode = 'STRICT_TRANS_TABLES'; +alter table t2 add primary key (alpha), change a alpha int, +change b beta int not null, change c charlie int not null; +ERROR HY000: Column 'b' cannot be NOT NULL: needed in a foreign key constraint 'test/t2_ibfk_1' SET NULL +alter table t2 add primary key (alpha), change a alpha int, +change c charlie int not null, change d delta int not null; +ERROR HY000: Column 'd' cannot be NOT NULL: needed in a foreign key constraint 'test/t2_ibfk_3' SET NULL +alter table t2 add primary key (alpha), change a alpha int, +change b beta int, modify c int not null; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +set @@sql_mode = @old_sql_mode; insert into t1 values (1,1,1); insert into t3 values (1,1,1); insert into t4 values (1,1,1); insert into t2 values (1,1,1,1,1); commit; alter table t4 add constraint dc foreign key (a) references t1(a); +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 0 show create table t4; Table Create Table t4 CREATE TABLE `t4` ( @@ -545,7 +506,11 @@ t4 CREATE TABLE `t4` ( CONSTRAINT `dc` FOREIGN KEY (`a`) REFERENCES `t1` (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 alter table t3 add constraint dc foreign key (a) references t1(a); -ERROR HY000: Can't create table '#sql-temporary' (errno: 121 "Duplicate key on write or update") +ERROR HY000: Can't create table 'test.#sql-temporary' (errno: 121 "Duplicate key on write or update") +SET FOREIGN_KEY_CHECKS=0; +alter table t3 add constraint dc foreign key (a) references t1(a); +ERROR HY000: Failed to add the foreign key constraint 'test/dc' to system tables +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; show create table t3; Table Create Table t3 CREATE TABLE `t3` ( @@ -555,37 +520,41 @@ t3 CREATE TABLE `t3` ( PRIMARY KEY (`a`), KEY `c` (`c`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -alter table t2 drop index b, add index (b); -ERROR 42000: Incorrect index name 'b' +alter table t2 drop index b, add index (beta); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 show create table t2; Table Create Table t2 CREATE TABLE `t2` ( - `a` int(11) NOT NULL, - `b` int(11) NOT NULL, + `alpha` int(11) NOT NULL DEFAULT '0', + `beta` int(11) DEFAULT NULL, `c` int(11) NOT NULL, - `d` int(11) NOT NULL, + `d` int(11) DEFAULT NULL, `e` int(11) DEFAULT NULL, - PRIMARY KEY (`a`), + PRIMARY KEY (`alpha`), UNIQUE KEY `dc` (`d`,`c`), - KEY `b` (`b`), KEY `c` (`c`), - CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`b`) ON DELETE CASCADE, + KEY `beta` (`beta`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`beta`) REFERENCES `t1` (`b`) ON DELETE SET NULL, CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`c`) REFERENCES `t3` (`c`), - CONSTRAINT `t2_ibfk_3` FOREIGN KEY (`d`) REFERENCES `t4` (`d`) + CONSTRAINT `t2_ibfk_3` FOREIGN KEY (`d`) REFERENCES `t4` (`d`) ON UPDATE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 delete from t1; ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `dc` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)) drop index dc on t4; ERROR 42000: Can't DROP 'dc'; check that column/key exists alter table t3 drop foreign key dc; -ERROR HY000: Error on rename of './test/t3' to '#sql2-temporary' (errno: 152 "Cannot delete a parent row") +ERROR 42000: Can't DROP 'dc'; check that column/key exists alter table t4 drop foreign key dc; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 select * from t2; -a b c d e +alpha beta c d e 1 1 1 1 1 delete from t1; select * from t2; -a b c d e +alpha beta c d e +1 NULL 1 1 1 drop table t2,t4,t3,t1; create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb default charset=utf8; insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe'); @@ -759,6 +728,8 @@ drop table t1; create table t1(a int not null, b int not null, c int, primary key (a), key(c)) engine=innodb; insert into t1 values (5,1,5),(4,2,4),(3,3,3),(2,4,2),(1,5,1); alter table t1 add unique index (b); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 insert into t1 values (10,20,20),(11,19,19),(12,18,18),(13,17,17); show create table t1; Table Create Table @@ -773,6 +744,7 @@ t1 CREATE TABLE `t1` ( check table t1; Table Op Msg_type Msg_text test.t1 check status OK +analyze table t1; explain select * from t1 force index(c) order by c; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL c 5 NULL 9 @@ -819,6 +791,8 @@ drop table t1; create table t1(a int not null, b int not null) engine=innodb; insert into t1 values (1,1); alter table t1 add primary key(b); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 insert into t1 values (2,2); show create table t1; Table Create Table @@ -834,6 +808,9 @@ select * from t1; a b 1 1 2 2 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK explain select * from t1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 @@ -850,6 +827,8 @@ drop table t1; create table t1(a int not null) engine=innodb; insert into t1 values (1); alter table t1 add primary key(a); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 insert into t1 values (2); show create table t1; Table Create Table @@ -865,6 +844,9 @@ select * from t1; a 1 2 +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK explain select * from t1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index @@ -872,188 +854,11 @@ explain select * from t1 order by a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index drop table t1; -create table t2(d varchar(17) primary key) engine=innodb default charset=utf8; -create table t3(a int primary key) engine=innodb; -insert into t3 values(22),(44),(33),(55),(66); -insert into t2 values ('jejdkrun87'),('adfd72nh9k'), -('adfdpplkeock'),('adfdijnmnb78k'),('adfdijn0loKNHJik'); -create table t1(a int, b blob, c text, d text not null) -engine=innodb default charset = utf8; -insert into t1 -select a,left(repeat(d,100*a),65535),repeat(d,20*a),d from t2,t3; -drop table t2, t3; -select count(*) from t1 where a=44; -count(*) -5 -select a, -length(b),b=left(repeat(d,100*a),65535),length(c),c=repeat(d,20*a),d from t1; -a length(b) b=left(repeat(d,100*a),65535) length(c) c=repeat(d,20*a) d -22 22000 1 4400 1 adfd72nh9k -22 35200 1 7040 1 adfdijn0loKNHJik -22 28600 1 5720 1 adfdijnmnb78k -22 26400 1 5280 1 adfdpplkeock -22 22000 1 4400 1 jejdkrun87 -33 33000 1 6600 1 adfd72nh9k -33 52800 1 10560 1 adfdijn0loKNHJik -33 42900 1 8580 1 adfdijnmnb78k -33 39600 1 7920 1 adfdpplkeock -33 33000 1 6600 1 jejdkrun87 -44 44000 1 8800 1 adfd72nh9k -44 65535 1 14080 1 adfdijn0loKNHJik -44 57200 1 11440 1 adfdijnmnb78k -44 52800 1 10560 1 adfdpplkeock -44 44000 1 8800 1 jejdkrun87 -55 55000 1 11000 1 adfd72nh9k -55 65535 1 17600 1 adfdijn0loKNHJik -55 65535 1 14300 1 adfdijnmnb78k -55 65535 1 13200 1 adfdpplkeock -55 55000 1 11000 1 jejdkrun87 -66 65535 1 13200 1 adfd72nh9k -66 65535 1 21120 1 adfdijn0loKNHJik -66 65535 1 17160 1 adfdijnmnb78k -66 65535 1 15840 1 adfdpplkeock -66 65535 1 13200 1 jejdkrun87 -alter table t1 add primary key (a), add key (b(20)); -ERROR 23000: Duplicate entry '22' for key 'PRIMARY' -delete from t1 where a%2; -check table t1; -Table Op Msg_type Msg_text -test.t1 check status OK -alter table t1 add primary key (a,b(255),c(255)), add key (b(767)); -select count(*) from t1 where a=44; -count(*) -5 -select a, -length(b),b=left(repeat(d,100*a),65535),length(c),c=repeat(d,20*a),d from t1; -a length(b) b=left(repeat(d,100*a),65535) length(c) c=repeat(d,20*a) d -22 22000 1 4400 1 adfd72nh9k -22 35200 1 7040 1 adfdijn0loKNHJik -22 28600 1 5720 1 adfdijnmnb78k -22 26400 1 5280 1 adfdpplkeock -22 22000 1 4400 1 jejdkrun87 -44 44000 1 8800 1 adfd72nh9k -44 65535 1 14080 1 adfdijn0loKNHJik -44 57200 1 11440 1 adfdijnmnb78k -44 52800 1 10560 1 adfdpplkeock -44 44000 1 8800 1 jejdkrun87 -66 65535 1 13200 1 adfd72nh9k -66 65535 1 21120 1 adfdijn0loKNHJik -66 65535 1 17160 1 adfdijnmnb78k -66 65535 1 15840 1 adfdpplkeock -66 65535 1 13200 1 jejdkrun87 -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) NOT NULL DEFAULT '0', - `b` blob NOT NULL, - `c` text NOT NULL, - `d` text NOT NULL, - PRIMARY KEY (`a`,`b`(255),`c`(255)), - KEY `b` (`b`(767)) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 -check table t1; -Table Op Msg_type Msg_text -test.t1 check status OK -explain select * from t1 where b like 'adfd%'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL b NULL NULL NULL 15 Using where -drop table t1; -set global innodb_file_per_table=on; -set global innodb_file_format='Barracuda'; -create table t1(a blob,b blob,c blob,d blob,e blob,f blob,g blob,h blob, -i blob,j blob,k blob,l blob,m blob,n blob,o blob,p blob, -q blob,r blob,s blob,t blob,u blob) -engine=innodb row_format=dynamic; -create index t1a on t1 (a(767)); -create index t1b on t1 (b(767)); -create index t1c on t1 (c(767)); -create index t1d on t1 (d(767)); -create index t1e on t1 (e(767)); -create index t1f on t1 (f(767)); -create index t1g on t1 (g(767)); -create index t1h on t1 (h(767)); -create index t1i on t1 (i(767)); -create index t1j on t1 (j(767)); -create index t1k on t1 (k(767)); -create index t1l on t1 (l(767)); -create index t1m on t1 (m(767)); -create index t1n on t1 (n(767)); -create index t1o on t1 (o(767)); -create index t1p on t1 (p(767)); -create index t1q on t1 (q(767)); -create index t1r on t1 (r(767)); -create index t1s on t1 (s(767)); -create index t1t on t1 (t(767)); -create index t1u on t1 (u(767)); -ERROR HY000: Too big row -create index t1ut on t1 (u(767), t(767)); -ERROR HY000: Too big row -create index t1st on t1 (s(767), t(767)); -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` blob, - `b` blob, - `c` blob, - `d` blob, - `e` blob, - `f` blob, - `g` blob, - `h` blob, - `i` blob, - `j` blob, - `k` blob, - `l` blob, - `m` blob, - `n` blob, - `o` blob, - `p` blob, - `q` blob, - `r` blob, - `s` blob, - `t` blob, - `u` blob, - KEY `t1a` (`a`(767)), - KEY `t1b` (`b`(767)), - KEY `t1c` (`c`(767)), - KEY `t1d` (`d`(767)), - KEY `t1e` (`e`(767)), - KEY `t1f` (`f`(767)), - KEY `t1g` (`g`(767)), - KEY `t1h` (`h`(767)), - KEY `t1i` (`i`(767)), - KEY `t1j` (`j`(767)), - KEY `t1k` (`k`(767)), - KEY `t1l` (`l`(767)), - KEY `t1m` (`m`(767)), - KEY `t1n` (`n`(767)), - KEY `t1o` (`o`(767)), - KEY `t1p` (`p`(767)), - KEY `t1q` (`q`(767)), - KEY `t1r` (`r`(767)), - KEY `t1s` (`s`(767)), - KEY `t1t` (`t`(767)), - KEY `t1st` (`s`(767),`t`(767)) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC -create index t1u on t1 (u(767)); -ERROR HY000: Too big row -alter table t1 row_format=compact; -create index t1u on t1 (u(767)); -drop table t1; -CREATE TABLE bug12547647( -a INT NOT NULL, b BLOB NOT NULL, c TEXT, -PRIMARY KEY (b(10), a), INDEX (c(767)), INDEX(b(767)) -) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; -INSERT INTO bug12547647 VALUES (5,repeat('khdfo5AlOq',1900),repeat('g',7751)); -COMMIT; -UPDATE bug12547647 SET c = REPEAT('b',16928); -ERROR HY000: Undo log record is too big. -DROP TABLE bug12547647; -set global innodb_file_per_table=0; +set global innodb_file_per_table=1; set global innodb_file_format=Antelope; set global innodb_file_format_max=Antelope; SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; -SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; +SET FOREIGN_KEY_CHECKS=0; CREATE TABLE t1( c1 BIGINT(12) NOT NULL, PRIMARY KEY (c1) @@ -1102,8 +907,10 @@ c2 BIGINT(12) NOT NULL, c3 BIGINT(12) NOT NULL, PRIMARY KEY (c1,c2,c3) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +SET FOREIGN_KEY_CHECKS=0; ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca FOREIGN KEY (c3) REFERENCES t1(c1); +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( @@ -1144,21 +951,44 @@ c2 BIGINT(12) NOT NULL, c3 BIGINT(12) NOT NULL, PRIMARY KEY (c1) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +SET FOREIGN_KEY_CHECKS=0; +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c1,c1), ALGORITHM=COPY; +ERROR HY000: Can't create table 'test.#sql-temporary' (errno: 150 "Foreign key constraint is incorrectly formed") ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca FOREIGN KEY (c3,c2) REFERENCES t1(c1,c1); -ERROR HY000: Can't create table '#sql-temporary' (errno: 150 "Foreign key constraint is incorrectly formed") +ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_t2_ca' in the referenced table 't1' +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2), ALGORITHM=COPY; +ERROR HY000: Can't create table 'test.#sql-temporary' (errno: 150 "Foreign key constraint is incorrectly formed") ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2); -ERROR HY000: Can't create table '#sql-temporary' (errno: 150 "Foreign key constraint is incorrectly formed") +ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_t2_ca' in the referenced table 't1' ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1); -ERROR HY000: Can't create table '#sql-temporary' (errno: 150 "Foreign key constraint is incorrectly formed") +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ALTER TABLE t2 DROP FOREIGN KEY fk_t2_ca; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1), ALGORITHM=COPY; +ERROR HY000: Can't create table 'test.#sql-temporary' (errno: 150 "Foreign key constraint is incorrectly formed") ALTER TABLE t1 MODIFY COLUMN c2 BIGINT(12) NOT NULL; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca +FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2), ALGORITHM=COPY; +ERROR HY000: Can't create table 'test.#sql-temporary' (errno: 150 "Foreign key constraint is incorrectly formed") ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2); -ERROR HY000: Can't create table '#sql-temporary' (errno: 150 "Foreign key constraint is incorrectly formed") +ERROR HY000: Failed to add the foreign key constaint. Missing index for constraint 'fk_t2_ca' in the referenced table 't1' ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +affected rows: 0 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -1166,6 +996,7 @@ t1 CREATE TABLE `t1` ( `c2` bigint(12) NOT NULL, PRIMARY KEY (`c2`,`c1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( @@ -1176,7 +1007,10 @@ t2 CREATE TABLE `t2` ( KEY `fk_t2_ca` (`c3`,`c2`), CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`, `c2`) REFERENCES `t1` (`c2`, `c1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 CREATE INDEX i_t2_c2_c1 ON t2(c2, c1); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( @@ -1188,7 +1022,10 @@ t2 CREATE TABLE `t2` ( KEY `i_t2_c2_c1` (`c2`,`c1`), CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`, `c2`) REFERENCES `t1` (`c2`, `c1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 CREATE INDEX i_t2_c3_c1_c2 ON t2(c3, c1, c2); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( @@ -1201,7 +1038,10 @@ t2 CREATE TABLE `t2` ( KEY `i_t2_c3_c1_c2` (`c3`,`c1`,`c2`), CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`, `c2`) REFERENCES `t1` (`c2`, `c1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 CREATE INDEX i_t2_c3_c2 ON t2(c3, c2); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( @@ -1214,11 +1054,131 @@ t2 CREATE TABLE `t2` ( KEY `i_t2_c3_c2` (`c3`,`c2`), CONSTRAINT `fk_t2_ca` FOREIGN KEY (`c3`, `c2`) REFERENCES `t1` (`c2`, `c1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 +affected rows: 1 DROP TABLE t2; DROP TABLE t1; -SELECT SLEEP(10); -SLEEP(10) -0 -DROP TABLE t1_purge, t2_purge, t3_purge, t4_purge; -DROP TABLE t12637786; -DROP TABLE t12963823; +CREATE TABLE t1 (a INT, b CHAR(1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (3,'a'),(3,'b'),(1,'c'),(0,'d'),(1,'e'); +CREATE TABLE t2 (a INT, b CHAR(1)) ENGINE=InnoDB; +CREATE TABLE t2i (a INT, b CHAR(1) NOT NULL) ENGINE=InnoDB; +CREATE TABLE t2c (a INT, b CHAR(1) NOT NULL) ENGINE=InnoDB; +INSERT INTO t2 SELECT * FROM t1; +INSERT INTO t2i SELECT * FROM t1; +INSERT INTO t2c SELECT * FROM t1; +BEGIN; +SELECT * FROM t1; +a b +3 a +3 b +1 c +0 d +1 e +SET lock_wait_timeout=1; +CREATE INDEX t1a ON t1(a); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +CREATE INDEX t2a ON t2(a); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +set @old_sql_mode = @@sql_mode; +set @@sql_mode = 'STRICT_TRANS_TABLES'; +ALTER TABLE t2i ADD PRIMARY KEY(a,b), ADD INDEX t2a(a), ALGORITHM=INPLACE; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +set @@sql_mode = @old_sql_mode; +ALTER TABLE t2c ADD PRIMARY KEY(a,b), ADD INDEX t2a(a), ALGORITHM=COPY; +affected rows: 5 +info: Records: 5 Duplicates: 0 Warnings: 0 +SELECT * FROM t2i; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t2i FORCE INDEX(t2a) ORDER BY a; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t2c; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t2c FORCE INDEX(t2a) ORDER BY a; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t2; +a b +3 a +3 b +1 c +0 d +1 e +SELECT * FROM t2 FORCE INDEX(t2a) ORDER BY a; +ERROR HY000: Table definition has changed, please retry transaction +SELECT * FROM t2; +a b +3 a +3 b +1 c +0 d +1 e +COMMIT; +SELECT * FROM t2; +a b +3 a +3 b +1 c +0 d +1 e +SELECT * FROM t2 FORCE INDEX(t2a) ORDER BY a; +a b +0 d +1 c +1 e +3 a +3 b +SELECT * FROM t2i; +a b +0 d +1 c +1 e +3 a +3 b +SELECT * FROM t2i FORCE INDEX(t2a) ORDER BY a; +a b +0 d +1 c +1 e +3 a +3 b +SELECT * FROM t2c; +a b +0 d +1 c +1 e +3 a +3 b +SELECT * FROM t2c FORCE INDEX(t2a) ORDER BY a; +a b +0 d +1 c +1 e +3 a +3 b +alter table t2 add index t2a(b); +ERROR 42000: Duplicate key name 't2a' +alter table t2 drop index t2a, add index t2a(b); +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `b` char(1) DEFAULT NULL, + KEY `t2a` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +show create table t2i; +Table Create Table +t2i CREATE TABLE `t2i` ( + `a` int(11) NOT NULL DEFAULT '0', + `b` char(1) NOT NULL, + PRIMARY KEY (`a`,`b`), + KEY `t2a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +show create table t2c; +Table Create Table +t2c CREATE TABLE `t2c` ( + `a` int(11) NOT NULL DEFAULT '0', + `b` char(1) NOT NULL, + PRIMARY KEY (`a`,`b`), + KEY `t2a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1,t2,t2c,t2i; diff --git a/mysql-test/suite/innodb/r/innodb_bug21704.result b/mysql-test/suite/innodb/r/innodb_bug21704.result index 3a6b38d50da..239aeaa354d 100644 --- a/mysql-test/suite/innodb/r/innodb_bug21704.result +++ b/mysql-test/suite/innodb/r/innodb_bug21704.result @@ -5,9 +5,6 @@ # Test that it's not possible to rename columns participating in a # foreign key (either in the referencing or referenced table). -DROP TABLE IF EXISTS t1; -DROP TABLE IF EXISTS t2; -DROP TABLE IF EXISTS t3; CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT ENGINE=INNODB; CREATE TABLE t2 (a INT PRIMARY KEY, b INT, CONSTRAINT fk1 FOREIGN KEY (a) REFERENCES t1(a)) @@ -21,35 +18,72 @@ INSERT INTO t3 VALUES (1,1,1),(2,2,2),(3,3,3); # Test renaming the column in the referenced table. -ALTER TABLE t1 CHANGE a c INT; -ERROR HY000: Error on rename of '#sql-temporary' to './test/t1' (errno: 150 "Foreign key constraint is incorrectly formed") +ALTER TABLE t1 CHANGE a e INT; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 # Ensure that online column rename works. ALTER TABLE t1 CHANGE b c INT; -affected rows: 3 -info: Records: 3 Duplicates: 0 Warnings: 0 +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 # Test renaming the column in the referencing table -ALTER TABLE t2 CHANGE a c INT; -ERROR HY000: Error on rename of '#sql-temporary' to './test/t2' (errno: 150 "Foreign key constraint is incorrectly formed") +ALTER TABLE t2 CHANGE a z INT; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 # Ensure that online column rename works. ALTER TABLE t2 CHANGE b c INT; -affected rows: 3 -info: Records: 3 Duplicates: 0 Warnings: 0 +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 # Test with self-referential constraints -ALTER TABLE t3 CHANGE a d INT; -ERROR HY000: Error on rename of '#sql-temporary' to './test/t3' (errno: 150 "Foreign key constraint is incorrectly formed") -ALTER TABLE t3 CHANGE b d INT; -ERROR HY000: Error on rename of '#sql-temporary' to './test/t3' (errno: 150 "Foreign key constraint is incorrectly formed") +ALTER TABLE t3 CHANGE a f INT; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ALTER TABLE t3 CHANGE b g INT; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 # Ensure that online column rename works. ALTER TABLE t3 CHANGE c d INT; -affected rows: 3 -info: Records: 3 Duplicates: 0 Warnings: 0 +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 # Cleanup. +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `e` int(11) NOT NULL DEFAULT '0', + `c` int(11) DEFAULT NULL, + PRIMARY KEY (`e`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `z` int(11) NOT NULL DEFAULT '0', + `c` int(11) DEFAULT NULL, + PRIMARY KEY (`z`), + CONSTRAINT `fk1` FOREIGN KEY (`z`) REFERENCES `t1` (`e`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `f` int(11) NOT NULL DEFAULT '0', + `g` int(11) DEFAULT NULL, + `d` int(11) DEFAULT NULL, + PRIMARY KEY (`f`), + KEY `b` (`g`), + CONSTRAINT `fk2` FOREIGN KEY (`g`) REFERENCES `t3` (`f`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT +SELECT f.*, c.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS c +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FOREIGN f +ON c.ID=f.ID +WHERE FOR_NAME LIKE 'test/t%'; +ID FOR_NAME REF_NAME N_COLS TYPE ID FOR_COL_NAME REF_COL_NAME POS +test/fk1 test/t2 test/t1 1 0 test/fk1 z e 0 +test/fk2 test/t3 test/t3 1 0 test/fk2 g f 0 DROP TABLE t3; DROP TABLE t2; DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb_bug54044.result b/mysql-test/suite/innodb/r/innodb_bug54044.result index 47aa8805834..4935febcbfb 100644 --- a/mysql-test/suite/innodb/r/innodb_bug54044.result +++ b/mysql-test/suite/innodb/r/innodb_bug54044.result @@ -5,5 +5,13 @@ Table Create Table table_54044 CREATE TEMPORARY TABLE `table_54044` ( `IF(NULL IS NOT NULL, NULL, NULL)` binary(0) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -CREATE TEMPORARY TABLE tmp1 ENGINE = INNODB AS SELECT COALESCE(NULL, NULL, NULL); -CREATE TEMPORARY TABLE tmp2 ENGINE = INNODB AS SELECT GREATEST(NULL, NULL); +DROP TABLE table_54044; +CREATE TABLE tmp ENGINE = INNODB AS SELECT COALESCE(NULL, NULL, NULL), GREATEST(NULL, NULL), NULL; +SHOW CREATE TABLE tmp; +Table Create Table +tmp CREATE TABLE `tmp` ( + `COALESCE(NULL, NULL, NULL)` binary(0) DEFAULT NULL, + `GREATEST(NULL, NULL)` binary(0) DEFAULT NULL, + `NULL` binary(0) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE tmp; diff --git a/mysql-test/suite/innodb/r/innodb_bug56947.result b/mysql-test/suite/innodb/r/innodb_bug56947.result index 8b864b62e81..0b436ce2656 100644 --- a/mysql-test/suite/innodb/r/innodb_bug56947.result +++ b/mysql-test/suite/innodb/r/innodb_bug56947.result @@ -1,8 +1,11 @@ -SET @old_innodb_file_per_table=@@innodb_file_per_table; SET GLOBAL innodb_file_per_table=0; create table bug56947(a int not null) engine = innodb; -CREATE TABLE `bug56947#1`(a int) ENGINE=InnoDB; +SET DEBUG_DBUG='+d,ib_rebuild_cannot_rename'; alter table bug56947 add unique index (a); -ERROR 42S01: Table 'test.bug56947#1' already exists -drop table `bug56947#1`; +ERROR HY000: Got error 11 "Resource temporarily unavailable" from storage engine +SET DEBUG_DBUG='-d,ib_rebuild_cannot_rename'; +check table bug56947; +Table Op Msg_type Msg_text +test.bug56947 check status OK drop table bug56947; +SET @@global.innodb_file_per_table=DEFAULT; diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result index 712eafe9a12..ddc84851cf3 100644 --- a/mysql-test/suite/innodb/r/innodb_mysql.result +++ b/mysql-test/suite/innodb/r/innodb_mysql.result @@ -1,6 +1,7 @@ set global innodb_support_xa=default; set session innodb_support_xa=default; -SET SESSION STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB; +SET SESSION DEFAULT_TMP_STORAGE_ENGINE = InnoDB; drop table if exists t1,t2,t3,t1m,t1i,t2m,t2i,t4; drop procedure if exists p1; create table t1 ( @@ -186,8 +187,8 @@ min(7) 7 explain select min(7) from t2i join t1i; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2i ALL NULL NULL NULL NULL 1 -1 SIMPLE t1i ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join) +1 SIMPLE t2i ALL NULL NULL NULL NULL 1 NULL +1 SIMPLE t1i ALL NULL NULL NULL NULL 1 Using join buffer (Block Nested Loop) select min(7) from t2i join t1i; min(7) NULL @@ -202,8 +203,8 @@ max(7) 7 explain select max(7) from t2i join t1i; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2i ALL NULL NULL NULL NULL 1 -1 SIMPLE t1i ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join) +1 SIMPLE t2i ALL NULL NULL NULL NULL 1 NULL +1 SIMPLE t1i ALL NULL NULL NULL NULL 1 Using join buffer (Block Nested Loop) select max(7) from t2i join t1i; max(7) NULL @@ -234,21 +235,21 @@ select 1, max(1) from t1i where 1=99; explain select count(*), min(7), max(7) from t1m, t1i; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found -1 SIMPLE t1i ALL NULL NULL NULL NULL 1 +1 SIMPLE t1i ALL NULL NULL NULL NULL 1 NULL select count(*), min(7), max(7) from t1m, t1i; count(*) min(7) max(7) 0 NULL NULL explain select count(*), min(7), max(7) from t1m, t2i; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found -1 SIMPLE t2i ALL NULL NULL NULL NULL 1 +1 SIMPLE t2i ALL NULL NULL NULL NULL 1 NULL select count(*), min(7), max(7) from t1m, t2i; count(*) min(7) max(7) 0 NULL NULL explain select count(*), min(7), max(7) from t2m, t1i; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2m system NULL NULL NULL NULL 1 -1 SIMPLE t1i ALL NULL NULL NULL NULL 1 +1 SIMPLE t2m system NULL NULL NULL NULL 1 NULL +1 SIMPLE t1i ALL NULL NULL NULL NULL 1 NULL select count(*), min(7), max(7) from t2m, t1i; count(*) min(7) max(7) 0 NULL NULL @@ -316,7 +317,7 @@ INSERT INTO t1 VALUES (1); INSERT INTO t2 VALUES (1); DELETE IGNORE FROM t1 WHERE i = 1; Warnings: -Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`) ON DELETE NO ACTION) +Error 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`) ON DELETE NO ACTION) SELECT * FROM t1, t2; i i 1 1 @@ -335,7 +336,7 @@ a count(a) 1 1 NULL 1 drop table t1; -create table t1 (f1 int, f2 char(1), primary key(f1,f2)); +create table t1 (f1 int, f2 char(1), primary key(f1,f2)) stats_persistent=0; insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d"); alter table t1 drop primary key, add primary key (f2, f1); explain select distinct f1 a, f1 b from t1; @@ -371,7 +372,7 @@ dept varchar(20) NOT NULL, age tinyint(3) unsigned NOT NULL, PRIMARY KEY (id), INDEX (name,dept) -) ENGINE=InnoDB; +) ENGINE=InnoDB STATS_PERSISTENT=0; INSERT INTO t1(id, dept, age, name) VALUES (3987, 'cs1', 10, 'rs1'), (3988, 'cs2', 20, 'rs1'), (3995, 'cs3', 10, 'rs2'), (3996, 'cs4', 20, 'rs2'), (4003, 'cs5', 10, 'rs3'), (4004, 'cs6', 20, 'rs3'), @@ -544,7 +545,7 @@ stat_id int NOT NULL, acct_id int DEFAULT NULL, INDEX idx1 (stat_id, acct_id), INDEX idx2 (acct_id) -) ENGINE=InnoDB; +) ENGINE=InnoDB STATS_PERSISTENT=0; INSERT INTO t1(stat_id,acct_id) VALUES (1,759), (2,831), (3,785), (4,854), (1,921), (1,553), (2,589), (3,743), (2,827), (2,545), @@ -679,6 +680,8 @@ INSERT INTO t1(b,c) SELECT b,c FROM t2; UPDATE t2 SET c='2007-01-03'; INSERT INTO t1(b,c) SELECT b,c FROM t2; set @@sort_buffer_size=8192; +Warnings: +Warning 1292 Truncated incorrect sort_buffer_size value: '8192' SELECT COUNT(*) FROM t1; COUNT(*) 3072 @@ -695,7 +698,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 FORCE INDEX(idx_b, idx_c) WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge idx_b,idx_c idx_c,idx_b 8,4 NULL # Using sort_union(idx_c,idx_b); Using where +1 SIMPLE t1 index_merge idx_b,idx_c idx_c,idx_b 5,4 NULL # Using sort_union(idx_c,idx_b); Using where SELECT COUNT(*) FROM t1 FORCE INDEX(idx_b, idx_c) WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1; COUNT(*) @@ -779,7 +782,7 @@ INSERT INTO t1 SELECT a + 32, MOD(a + 32, 20), 1 FROM t1; INSERT INTO t1 SELECT a + 64, MOD(a + 64, 20), 1 FROM t1; EXPLAIN SELECT b, SUM(c) FROM t1 GROUP BY b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL b 5 NULL 128 +1 SIMPLE t1 index NULL b 5 NULL 128 NULL EXPLAIN SELECT SQL_BIG_RESULT b, SUM(c) FROM t1 GROUP BY b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using filesort @@ -1171,7 +1174,7 @@ c b d 3 2 40 EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 3 +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 NULL SELECT c,b,d FROM t1 GROUP BY c,b,d ORDER BY NULL; c b d 1 1 50 @@ -1187,7 +1190,7 @@ c b d 3 2 40 EXPLAIN SELECT c,b,d FROM t1 GROUP BY c,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL c 8 NULL 3 +1 SIMPLE t1 index NULL c 8 NULL 3 NULL SELECT c,b,d FROM t1 GROUP BY c,b; c b d 1 1 50 @@ -1428,15 +1431,11 @@ DROP TABLE t1; # create table t1 (a bit(1) not null,b int) engine=myisam; create table t2 (c int) engine=innodb; -set @save_optimizer_switch=@@optimizer_switch; -set @@optimizer_switch='in_to_exists=on,materialization=off'; explain -select b from t1 where a not in (select max(b) from t1,t2 group by a) group by a; +select b from t1 where a not in (select b from t1,t2 group by a) group by a; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables -2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found -2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 1 -set optimizer_switch=@save_optimizer_switch; +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables DROP TABLE t1,t2; End of 5.0 tests CREATE TABLE `t2` ( @@ -1479,15 +1478,10 @@ k a c 1 6 2 2 7 NULL insert ignore into t2 values (null,6,1),(10,8,1); -Warnings: -Warning 1062 Duplicate entry '6' for key 'idx_1' select last_insert_id(); last_insert_id() 0 insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1); -Warnings: -Warning 1062 Duplicate entry '6' for key 'idx_1' -Warning 1062 Duplicate entry '8' for key 'idx_1' select last_insert_id(); last_insert_id() 11 @@ -1607,17 +1601,7 @@ TRUNCATE t1; INSERT INTO t1 VALUES (1,'init'); CREATE PROCEDURE p1() BEGIN -# retry the UPDATE in case it times out the lock before con1 has time -# to COMMIT. -DECLARE do_retry INT DEFAULT 0; -DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET do_retry = 1; -retry_loop:LOOP UPDATE t1 SET b = CONCAT(b, '+con2') WHERE a = 1; -IF do_retry = 0 THEN -LEAVE retry_loop; -END IF; -SET do_retry = 0; -END LOOP; INSERT INTO t2 VALUES (); END| BEGIN; @@ -1752,7 +1736,7 @@ EXPLAIN SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 NULL 2 DERIVED t1 ref c3,c2 c3 5 const 2 Using where; Using filesort DROP TABLE t1; CREATE TABLE t1 (c1 REAL, c2 REAL, c3 REAL, KEY (c3), KEY (c2, c3)) @@ -1766,7 +1750,7 @@ EXPLAIN SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 NULL 2 DERIVED t1 ref c3,c2 c3 9 const 2 Using where; Using filesort DROP TABLE t1; CREATE TABLE t1 (c1 DECIMAL(12,2), c2 DECIMAL(12,2), c3 DECIMAL(12,2), @@ -1781,11 +1765,38 @@ EXPLAIN SELECT 1 FROM (SELECT COUNT(DISTINCT c1) FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 NULL 2 DERIVED t1 ref c3,c2 c3 7 const 2 Using where; Using filesort DROP TABLE t1; End of 5.1 tests # +# Bug#43600: Incorrect type conversion caused wrong result. +# +CREATE TABLE t1 ( +a int NOT NULL +) engine= innodb; +CREATE TABLE t2 ( +a int NOT NULL, +b int NOT NULL, +filler char(100) DEFAULT NULL, +KEY a (a,b) +) engine= innodb; +insert into t1 values (0),(1),(2),(3),(4); +insert into t2 select A.a + 10 *B.a, 1, 'filler' from t1 A, t1 B; +explain select * from t1, t2 where t2.a=t1.a and t2.b + 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 NULL +1 SIMPLE t2 ref a a 4 test.t1.a 1 Using index condition +select * from t1, t2 where t2.a=t1.a and t2.b + 1; +a a b filler +0 0 1 filler +1 1 1 filler +2 2 1 filler +3 3 1 filler +4 4 1 filler +drop table t1,t2; +# End of test case for the bug#43600 +# # Bug#42643: InnoDB does not support replication of TRUNCATE TABLE # # Check that a TRUNCATE TABLE statement, needing an exclusive meta @@ -1817,15 +1828,21 @@ a # Connection default DROP TABLE t1; drop table if exists t1, t2, t3; +# +# BUG#35850: Performance regression in 5.1.23/5.1.24 +# create table t1(a int); insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t2 (a int, b int, pk int, key(a,b), primary key(pk)) engine=innodb; insert into t2 select @a:=A.a+10*(B.a + 10*C.a),@a, @a from t1 A, t1 B, t1 C; -this must use key 'a', not PRIMARY: +# this must use key 'a', not PRIMARY: explain select a from t2 where a=b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index NULL a 10 NULL # Using where; Using index drop table t1, t2; +# +# Bug #40360: Binlog related errors with binlog off +# SET SESSION BINLOG_FORMAT=STATEMENT; SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; select @@session.sql_log_bin, @@session.binlog_format, @@session.tx_isolation; @@ -1835,12 +1852,19 @@ select @@session.sql_log_bin, @@session.binlog_format, @@session.tx_isolation; CREATE TABLE t1 ( a INT ) ENGINE=InnoDB; INSERT INTO t1 VALUES(1); DROP TABLE t1; +# +# Bug#37284 Crash in Field_string::type() +# DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a char(50)) ENGINE=InnoDB; CREATE INDEX i1 on t1 (a(3)); SELECT * FROM t1 WHERE a = 'abcde'; a DROP TABLE t1; +# +# Bug #37742: HA_EXTRA_KEYREAD flag is set when key contains only prefix of +# requested column +# CREATE TABLE foo (a int, b int, c char(10), PRIMARY KEY (c(3)), KEY b (b) @@ -1858,6 +1882,9 @@ INSERT INTO foo VALUES (4,5,'uvwxyz'), (5,6,'meotnsyglt'), (4,5,'asfdewe'); INSERT INTO bar SELECT * FROM foo; INSERT INTO foo2 SELECT * FROM foo; +ANALYZE TABLE bar; +ANALYZE TABLE foo; +ANALYZE TABLE foo2; EXPLAIN SELECT c FROM bar WHERE b>2;; id 1 select_type SIMPLE @@ -1925,6 +1952,9 @@ ref NULL rows 6 Extra Using where; Using index DROP TABLE foo, bar, foo2; +# +# Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table +# DROP TABLE IF EXISTS t1,t3,t2; DROP FUNCTION IF EXISTS f1; CREATE FUNCTION f1() RETURNS VARCHAR(250) @@ -1946,6 +1976,9 @@ DEALLOCATE PREPARE stmt1; DEALLOCATE PREPARE stmt3; DROP TABLE t1,t3,t2; DROP FUNCTION f1; +# +# Bug#37016: TRUNCATE TABLE removes some rows but not all +# DROP TABLE IF EXISTS t1,t2; CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; CREATE TABLE t2 (id INT PRIMARY KEY, @@ -2152,6 +2185,9 @@ DROP TABLE t4; DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; +# +# Bug#43580: Issue with Innodb on multi-table update +# CREATE TABLE t1 (a INT, b INT, KEY (a)) ENGINE = INNODB; CREATE TABLE t2 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB; CREATE TABLE t3 (a INT, b INT KEY, KEY (a)) ENGINE = INNODB; @@ -2257,6 +2293,7 @@ INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +ANALYZE TABLE t1; EXPLAIN SELECT * FROM t1 WHERE b=1 AND c=1 ORDER BY a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref i2 i2 8 const,const 1 Using where; Using filesort @@ -2265,7 +2302,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref i2 i2 8 const,const 1 Using where; Using filesort EXPLAIN SELECT * FROM t1 FORCE INDEX(PRIMARY) WHERE b=1 AND c=1 ORDER BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL 128 Using where +1 SIMPLE t1 index NULL PRIMARY 4 NULL {checked} Using where DROP TABLE t1; # # Bug #47963: Wrong results when index is used @@ -2335,7 +2372,7 @@ DROP TABLE t1,t2; # Bug #49324: more valgrind errors in test_if_skip_sort_order # CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ; -#should not cause valgrind warnings +# should not cause valgrind warnings SELECT 1 FROM t1 JOIN t1 a USING(a) GROUP BY t1.a,t1.a; 1 DROP TABLE t1; @@ -2347,9 +2384,11 @@ create table t1(f1 int not null primary key, f2 int) engine=innodb; create table t2(f1 int not null, key (f1)) engine=innodb; insert into t1 values (1,1),(2,2),(3,3); insert into t2 values (1),(2),(3); +analyze table t1; +analyze table t2; explain select t1.* from t1 left join t2 using(f1) group by t1.f1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 +1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 NULL 1 SIMPLE t2 ref f1 f1 4 test.t1.f1 1 Using index drop table t1,t2; # @@ -2363,6 +2402,9 @@ INSERT INTO t1 VALUES (1,1,1,1,1,1), (2,2,2,2,2,2), (3,3,3,3,3,3), (4,4,4,4,4,4), (5,5,5,5,5,5), (6,6,6,6,6,6), (7,7,7,7,7,7), (8,8,8,8,8,8), (9,9,9,9,9,9), (11,11,11,11,11,11); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK EXPLAIN SELECT COUNT(*) FROM t1; id 1 select_type SIMPLE @@ -2411,36 +2453,6 @@ Comment Index_comment DROP TABLE t1; # -# Bug #53334: wrong result for outer join with impossible ON condition -# (see the same test case for MyISAM in join.test) -# -create table t1 (id int primary key); -create table t2 (id int); -insert into t1 values (75); -insert into t1 values (79); -insert into t1 values (78); -insert into t1 values (77); -replace into t1 values (76); -replace into t1 values (76); -insert into t1 values (104); -insert into t1 values (103); -insert into t1 values (102); -insert into t1 values (101); -insert into t1 values (105); -insert into t1 values (106); -insert into t1 values (107); -insert into t2 values (107),(75),(1000); -select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 -where t2.id=75 and t1.id is null; -id id -NULL 75 -explain select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 -where t2.id=75 and t1.id is null; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 const PRIMARY NULL NULL NULL 1 Impossible ON condition -1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where -drop table t1,t2; -# # Bug #47453: InnoDB incorrectly changes TIMESTAMP columns when # JOINed during an UPDATE # @@ -2448,7 +2460,7 @@ CREATE TABLE t1 (d INT) ENGINE=InnoDB; CREATE TABLE t2 (a INT, b INT, c TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP) ENGINE=InnoDB; -set up our data elements +# set up our data elements INSERT INTO t1 (d) VALUES (1); INSERT INTO t2 (a,b) VALUES (1,1); SELECT SECOND(c) INTO @bug47453 FROM t2; @@ -2463,7 +2475,7 @@ SELECT SLEEP(1); SLEEP(1) 0 UPDATE t1 JOIN t2 ON d=a SET b=1 WHERE a=1; -#should be 0 +# should be 0 SELECT SECOND(c)-@bug47453 FROM t1 JOIN t2 ON d=a; SECOND(c)-@bug47453 0 @@ -2533,6 +2545,7 @@ KEY idx1 (f2,f5,f4), KEY idx2 (f2,f4) ) ENGINE=InnoDB; LOAD DATA INFILE '../../std_data/intersect-bug50389.tsv' INTO TABLE t1; +ANALYZE TABLE t1; SELECT * FROM t1 WHERE f1 IN (3305028,3353871,3772880,3346860,4228206,3336022, 3470988,3305175,3329875,3817277,3856380,3796193, @@ -2555,7 +2568,7 @@ EXPLAIN SELECT * FROM t1 WHERE f1 IN 3784744,4180925,4559596,3963734,3856391,4494153) AND f5 = 'abcdefghijklmnopwrst' AND f2 = 1221457 AND f4 = 0 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge PRIMARY,idx1,idx2 idx2,idx1,PRIMARY 7,60,4 NULL 1 Using intersect(idx2,idx1,PRIMARY); Using where +1 SIMPLE t1 ref PRIMARY,idx1,idx2 idx1 60 const,const,const 18 Using index condition DROP TABLE t1; # # Bug#51431 Wrong sort order after import of dump file @@ -2568,7 +2581,7 @@ f4 tinyint(1) NOT NULL, PRIMARY KEY (f1), UNIQUE KEY (f2, f3), KEY (f4) -) ENGINE=InnoDB; +) ENGINE=InnoDB STATS_PERSISTENT=0; INSERT INTO t1 VALUES (1,1,991,1), (2,1,992,1), (3,1,993,1), (4,1,994,1), (5,1,995,1), (6,1,996,1), (7,1,997,1), (8,1,998,1), (10,1,999,1), (11,1,9910,1), @@ -2598,44 +2611,10 @@ ALTER TABLE t1 COMMENT 'test'; UNLOCK TABLES; DROP TABLE t1; # -# Bug#55826: create table .. select crashes with when KILL_BAD_DATA -# is returned -# -CREATE TABLE t1(a INT) ENGINE=innodb; -INSERT INTO t1 VALUES (0); -SET SQL_MODE='STRICT_ALL_TABLES'; -CREATE TABLE t2 -SELECT LEAST((SELECT '' FROM t1),NOW()) FROM `t1`; -ERROR 22007: Incorrect datetime value: '' -DROP TABLE t1; -SET SQL_MODE=DEFAULT; -# -# Bug#55580: segfault in read_view_sees_trx_id -# -CREATE TABLE t1 (a INT) ENGINE=Innodb; -CREATE TABLE t2 (a INT) ENGINE=Innodb; -INSERT INTO t1 VALUES (1),(2); -INSERT INTO t2 VALUES (1),(2); -START TRANSACTION; -SELECT * FROM t2 LOCK IN SHARE MODE; -a -1 -2 -START TRANSACTION; -SELECT * FROM t1 LOCK IN SHARE MODE; -a -1 -2 -SELECT * FROM t1 FOR UPDATE; -# should not crash -SELECT * FROM t1 GROUP BY (SELECT a FROM t2 LIMIT 1 FOR UPDATE) + t1.a; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction -DROP TABLE t1,t2; -# # Bug#55656: mysqldump can be slower after bug #39653 fix # CREATE TABLE t1 (a INT , b INT, c INT, d INT, -KEY (b), PRIMARY KEY (a,b)) ENGINE=INNODB; +KEY (b), PRIMARY KEY (a,b)) ENGINE=INNODB STATS_PERSISTENT=0; INSERT INTO t1 VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3); EXPLAIN SELECT COUNT(*) FROM t1; id 1 @@ -2669,8 +2648,8 @@ select_type SIMPLE table t1 type index possible_keys NULL -key PRIMARY -key_len 8 +key b +key_len 13 ref NULL rows 3 Extra Using index @@ -2689,58 +2668,6 @@ rows 3 Extra Using index DROP TABLE t1; # -# Bug#56862 Execution of a query that uses index merge returns a wrong result -# -CREATE TABLE t1 ( -pk int NOT NULL AUTO_INCREMENT PRIMARY KEY, -a int, -b int, -INDEX idx(a)) -ENGINE=INNODB; -INSERT INTO t1(a,b) VALUES -(11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500), -(3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800), -(6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700), -(13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000); -INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1; -INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1; -INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1 VALUES (1000000, 0, 0); -SET SESSION sort_buffer_size = 1024*36; -EXPLAIN -SELECT COUNT(*) FROM -(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY) -WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge PRIMARY,idx idx,PRIMARY 5,4 NULL 1536 Using sort_union(idx,PRIMARY); Using where -SELECT COUNT(*) FROM -(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY) -WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; -COUNT(*) -1537 -SET SESSION sort_buffer_size = DEFAULT; -DROP TABLE t1; -# -# ALTER TABLE IGNORE didn't ignore duplicates for unique add index -# -create table t1 (a int primary key, b int) engine = innodb; -insert into t1 values (1,1),(2,1); -alter ignore table t1 add unique `main` (b); -select * from t1; -a b -1 1 -drop table t1; -End of 5.1 tests -# -# # Bug#55826: create table .. select crashes with when KILL_BAD_DATA # is returned # @@ -2749,59 +2676,18 @@ INSERT INTO t1 VALUES (0); SET SQL_MODE='STRICT_ALL_TABLES'; CREATE TABLE t2 SELECT LEAST((SELECT '' FROM t1),NOW()) FROM `t1`; -ERROR 22007: Incorrect datetime value: '' +ERROR 22007: Incorrect datetime value: '' for column 'NOW()' at row 2 DROP TABLE t1; SET SQL_MODE=DEFAULT; # -# Bug#56862 Execution of a query that uses index merge returns a wrong result +# Bug#56862 Moved to innodb_16k.test # -CREATE TABLE t1 ( -pk int NOT NULL AUTO_INCREMENT PRIMARY KEY, -a int, -b int, -INDEX idx(a)) -ENGINE=INNODB; -INSERT INTO t1(a,b) VALUES -(11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500), -(3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800), -(6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700), -(13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000); -INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1; -INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1; -INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1 VALUES (1000000, 0, 0); -SET SESSION sort_buffer_size = 1024*36; -EXPLAIN -SELECT COUNT(*) FROM -(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY) -WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index_merge PRIMARY,idx idx,PRIMARY 5,4 NULL 1536 Using sort_union(idx,PRIMARY); Using where -SELECT COUNT(*) FROM -(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY) -WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; -COUNT(*) -1537 -SET SESSION sort_buffer_size = DEFAULT; -DROP TABLE t1; # # Test for bug #39932 "create table fails if column for FK is in different # case than in corr index". # drop tables if exists t1, t2; create table t1 (pk int primary key) engine=InnoDB; -# Even although the below statement uses uppercased field names in -# foreign key definition it still should be able to find explicitly -# created supporting index. So it should succeed and should not -# create any additional supporting indexes. create table t2 (fk int, key x (fk), constraint x foreign key (FK) references t1 (PK)) engine=InnoDB; show create table t2; @@ -2813,130 +2699,6 @@ t2 CREATE TABLE `t2` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t2, t1; # -# Bug #663818: wrong result when BNLH is used -# -CREATE TABLE t1(pk int NOT NULL PRIMARY KEY) ENGINE=InnoDB; -INSERT INTO t1 VALUES -(1), (2), (11), (12), (13), (14), -(15), (16), (17), (18), (19); -CREATE TABLE t2(pk int NOT NULL PRIMARY KEY) ENGINE=InnoDB; -INSERT INTO t2 VALUES -(1), (10), (11), (12), (13), (14), -(15), (16), (17), (18), (19), (20), (21); -SET SESSION join_buffer_size=10000; -Warnings: -Warning 1292 Truncated incorrect join_buffer_size value: '10000' -SET SESSION join_cache_level=3; -EXPLAIN -SELECT t1.pk FROM t1,t2 -WHERE t1.pk = t2.pk AND t2.pk <> 8; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 11 Using where; Using index -1 SIMPLE t2 hash_index PRIMARY #hash#PRIMARY:PRIMARY 4:4 test.t1.pk 13 Using join buffer (flat, BNLH join) -SELECT t1.pk FROM t1,t2 -WHERE t1.pk = t2.pk AND t2.pk <> 8; -pk -1 -11 -12 -13 -14 -15 -16 -17 -18 -19 -SET SESSION join_cache_level=1; -EXPLAIN -SELECT t1.pk FROM t1,t2 -WHERE t1.pk = t2.pk AND t2.pk <> 8; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 11 Using where; Using index -1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 Using index -SELECT t1.pk FROM t1,t2 -WHERE t1.pk = t2.pk AND t2.pk <> 8; -pk -1 -11 -12 -13 -14 -15 -16 -17 -18 -19 -DROP TABLE t1,t2; -SET SESSION join_cache_level=DEFAULT; -SET SESSION join_buffer_size=DEFAULT; -# -# Bug#668644: HAVING + ORDER BY -# -CREATE TABLE t1 ( -pk int NOT NULL PRIMARY KEY, i int DEFAULT NULL, -INDEX idx (i) -) ENGINE=INNODB; -INSERT INTO t1 VALUES -(6,-1636630528),(2,-1097924608),(1,6),(3,6),(4,1148715008),(5,1541734400); -CREATE TABLE t2 ( -i int DEFAULT NULL, -pk int NOT NULL PRIMARY KEY, -INDEX idx (i) -) ENGINE= INNODB; -INSERT INTO t2 VALUES -(-1993998336,20),(-1036582912,1),(-733413376,5),(-538247168,16), -(-514260992,4),(-249561088,9),(1,2),(1,6),(2,10),(2,19),(4,17), -(5,14),(5,15),(6,8),(7,13),(8,18),(9,11),(9,12),(257425408,7), -(576061440,3); -EXPLAIN -SELECT t1 .i AS f FROM t1, t2 -WHERE t2.i = t1.pk AND t1.pk BETWEEN 0 AND 224 -HAVING f > 7 -ORDER BY f; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY idx 5 NULL 6 Using where; Using index -1 SIMPLE t2 ref idx idx 5 test.t1.pk 1 Using index -SELECT t1 .i AS f FROM t1, t2 -WHERE t2.i = t1.pk AND t1.pk BETWEEN 0 AND 224 -HAVING f > 7 -ORDER BY f; -f -1148715008 -1541734400 -1541734400 -DROP TABLE t1, t2; -# -# Test for bug #56619 - Assertion failed during -# ALTER TABLE RENAME, DISABLE KEYS -# -DROP TABLE IF EXISTS t1, t2; -CREATE TABLE t1 (a INT, INDEX(a)) engine=innodb; -ALTER TABLE t1 RENAME TO t2, DISABLE KEYS; -DROP TABLE IF EXISTS t1, t2; -# -# Bug#702322: HAVING with two ANDed predicates + ORDER BY -# -CREATE TABLE t1 (pk int PRIMARY KEY, a int, KEY (a)) ENGINE=InnoDB; -CREATE TABLE t2 (a int, KEY (a)) ENGINE=InnoDB; -INSERT INTO t1 VALUES -(18,0),(9,10),(8,11),(2,15),(7,19),(1,20); -SET SESSION join_cache_level = 0; -EXPLAIN -SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.pk = t2.a -WHERE t1.pk >= 6 HAVING t1.a<> 0 AND t1.a <> 11 -ORDER BY t1.a; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using index condition; Using filesort -1 SIMPLE t2 ref a a 5 test.t1.pk 1 Using index -SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.pk = t2.a -WHERE t1.pk >= 6 HAVING t1.a<> 0 AND t1.a <> 11 -ORDER BY t1.a; -a -10 -19 -DROP TABLE t1,t2; -End of 5.3 tests -# # Test for bug #11762012 - "54553: INNODB ASSERTS IN HA_INNOBASE:: # UPDATE_ROW, TEMPORARY TABLE, TABLE LOCK". # @@ -2952,7 +2714,39 @@ LOCK TABLES t1 READ; UPDATE t1 SET c = 5; UNLOCK TABLES; DROP TEMPORARY TABLE t1; -End of 5.1 tests +# End of 5.1 tests +# +# Bug#49604 "6.0 processing compound WHERE clause incorrectly +# with Innodb - extra rows" +# +CREATE TABLE t1 ( +c1 INT NOT NULL, +c2 INT, +PRIMARY KEY (c1), +KEY k1 (c2) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES (12,1); +INSERT INTO t1 VALUES (15,1); +INSERT INTO t1 VALUES (16,1); +INSERT INTO t1 VALUES (22,1); +INSERT INTO t1 VALUES (20,2); +CREATE TABLE t2 ( +c1 INT NOT NULL, +c2 INT, +PRIMARY KEY (c1) +) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1,2); +INSERT INTO t2 VALUES (2,9); +SELECT STRAIGHT_JOIN t2.c2, t1.c2, t2.c1 +FROM t1 JOIN t2 ON t1.c2 = t2.c1 +WHERE t2.c1 IN (2, 1, 6) OR t2.c1 NOT IN (1); +c2 c2 c1 +2 1 1 +2 1 1 +2 1 1 +2 1 1 +9 2 2 +DROP TABLE t1, t2; # # Bug#44613 SELECT statement inside FUNCTION takes a shared lock # @@ -2979,13 +2773,86 @@ COMMIT; DROP TABLE t1; DROP FUNCTION f1; # +# Bug#42744: Crash when using a join buffer to join a table with a blob +# column and an additional column used for duplicate elimination. +# +CREATE TABLE t1 (a tinyblob) ENGINE=InnoDB; +CREATE TABLE t2 (a int PRIMARY KEY, b tinyblob) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('1'), (NULL); +INSERT INTO t2 VALUES (1, '1'); +EXPLAIN +SELECT t2.b FROM t1,t2 WHERE t1.a IN (SELECT 1 FROM t2); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Start temporary +1 SIMPLE t2 index NULL PRIMARY 4 NULL 1 Using index; Using join buffer (Block Nested Loop) +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) +SELECT t2.b FROM t1,t2 WHERE t1.a IN (SELECT 1 FROM t2); +b +1 +DROP TABLE t1,t2; +# +# Bug#48093: 6.0 Server not processing equivalent IN clauses properly +# with Innodb tables +# +CREATE TABLE t1 ( +i int(11) DEFAULT NULL, +v1 varchar(1) DEFAULT NULL, +v2 varchar(20) DEFAULT NULL, +KEY i (i), +KEY v (v1,i) +) ENGINE=innodb; +INSERT INTO t1 VALUES (1,'f','no'); +INSERT INTO t1 VALUES (2,'u','yes-u'); +INSERT INTO t1 VALUES (2,'h','yes-h'); +INSERT INTO t1 VALUES (3,'d','no'); + +SELECT v2 +FROM t1 +WHERE v1 IN ('f', 'd', 'h', 'u' ) AND i = 2; +v2 +yes-u +yes-h + +# Should not use index_merge +EXPLAIN +SELECT v2 +FROM t1 +WHERE v1 IN ('f', 'd', 'h', 'u' ) AND i = 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref i,v i 5 const 2 Using where +DROP TABLE t1; +# # Bug#54606 innodb fast alter table + pack_keys=0 # prevents adding new indexes # +DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT, b CHAR(9), c INT, key(b)) ENGINE=InnoDB PACK_KEYS=0; CREATE INDEX a ON t1 (a); CREATE INDEX c on t1 (c); DROP TABLE t1; -End of 5.1 tests +# +# Additional coverage for refactoring which is made as part +# of fix for Bug#27480 "Extend CREATE TEMPORARY TABLES privilege +# to allow temp table operations". +# +# Check that OPTIMIZE table works for temporary InnoDB tables. +DROP TABLE IF EXISTS t1; +CREATE TEMPORARY TABLE t1 (a INT) ENGINE=InnoDB; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +DROP TABLE t1; +# +# Bug#11762345 54927: DROPPING AND ADDING AN INDEX IN ONE +# COMMAND CAN FAIL IN INNODB PLUGIN 1.0 +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (id int, a int, b int, PRIMARY KEY (id), +INDEX a (a)) ENGINE=innodb; +ALTER TABLE t1 DROP INDEX a, ADD INDEX a (b, a); +ALTER TABLE t1 DROP INDEX a, ADD INDEX (a, b); +DROP TABLE t1; +End of 6.0 tests diff --git a/mysql-test/suite/innodb/t/innodb-autoinc-44030.test b/mysql-test/suite/innodb/t/innodb-autoinc-44030.test index 07e9ca30fd6..fd90d5d92de 100644 --- a/mysql-test/suite/innodb/t/innodb-autoinc-44030.test +++ b/mysql-test/suite/innodb/t/innodb-autoinc-44030.test @@ -1,4 +1,4 @@ ---source include/have_innodb.inc +-- source include/have_innodb.inc # embedded server ignores 'delayed', so skip this -- source include/not_embedded.inc @@ -27,8 +27,14 @@ SELECT * FROM t1; # to be enabled. Also, see http://bugs.mysql.com/bug.php?id=47621. #-- error ER_AUTOINC_READ_FAILED,1467 INSERT INTO t1 VALUES(null); +# Before WL#5534, the following statement would copy the table, +# and effectively set AUTO_INCREMENT to 4, because while copying +# it would write values 1,2,3 to the column. +# WL#5534 makes this an in-place ALTER, setting AUTO_INCREMENT=3 for real. ALTER TABLE t1 AUTO_INCREMENT = 3; SHOW CREATE TABLE t1; +-- error ER_DUP_ENTRY +INSERT INTO t1 VALUES(null); INSERT INTO t1 VALUES(null); SELECT * FROM t1; DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb-index.test b/mysql-test/suite/innodb/t/innodb-index.test index cea9055b873..b6fd2529ada 100644 --- a/mysql-test/suite/innodb/t/innodb-index.test +++ b/mysql-test/suite/innodb/t/innodb-index.test @@ -7,127 +7,16 @@ let $format=`select @@innodb_file_format`; set global innodb_file_per_table=on; set global innodb_file_format='Barracuda'; -# Bug #12429576 - Test an assertion failure on purge. -CREATE TABLE t1_purge ( -A INT, -B BLOB, C BLOB, D BLOB, E BLOB, -F BLOB, G BLOB, H BLOB, -PRIMARY KEY (B(767), C(767), D(767), E(767), A), -INDEX (A) -) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; - -INSERT INTO t1_purge VALUES (1, -REPEAT('b', 766), REPEAT('c', 766), REPEAT('d', 766), REPEAT('e', 766), -REPEAT('f', 766), REPEAT('g', 766), REPEAT('h', 766)); - -CREATE TABLE t2_purge ( -A INT PRIMARY KEY, -B BLOB, C BLOB, D BLOB, E BLOB, -F BLOB, G BLOB, H BLOB, I BLOB, -J BLOB, K BLOB, L BLOB, -INDEX (B(767))) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; - -INSERT INTO t2_purge VALUES (1, -REPEAT('b', 766), REPEAT('c', 766), REPEAT('d', 766), REPEAT('e', 766), -REPEAT('f', 766), REPEAT('g', 766), REPEAT('h', 766), REPEAT('i', 766), -REPEAT('j', 766), REPEAT('k', 766), REPEAT('l', 766)); - -CREATE TABLE t3_purge ( -A INT, -B VARCHAR(800), C VARCHAR(800), D VARCHAR(800), E VARCHAR(800), -F VARCHAR(800), G VARCHAR(800), H VARCHAR(800), -PRIMARY KEY (B(767), C(767), D(767), E(767), A), -INDEX (A) -) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; - -INSERT INTO t3_purge SELECT * FROM t1_purge; - -CREATE TABLE t4_purge ( -A INT PRIMARY KEY, -B VARCHAR(800), C VARCHAR(800), D VARCHAR(800), E VARCHAR(800), -F VARCHAR(800), G VARCHAR(800), H VARCHAR(800), I VARCHAR(800), -J VARCHAR(800), K VARCHAR(800), L VARCHAR(800), -INDEX (B(767))) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; - -INSERT INTO t4_purge SELECT * FROM t2_purge; - -# This would trigger the failure (Bug #12429576) -# if purge gets a chance to run before DROP TABLE t1_purge, .... -DELETE FROM t1_purge; -DELETE FROM t2_purge; -DELETE FROM t3_purge; -DELETE FROM t4_purge; -# Instead of doing a --sleep 10, wait until the rest of the tests in -# this file complete before dropping the tables. By then, the purge thread -# will have delt with the updates above. - -# Bug#12637786 - Bad assert by purge thread for records with external data -# used in secondary indexes. -SET @r=REPEAT('a',500); -CREATE TABLE t12637786(a INT, - v1 VARCHAR(500), v2 VARCHAR(500), v3 VARCHAR(500), - v4 VARCHAR(500), v5 VARCHAR(500), v6 VARCHAR(500), - v7 VARCHAR(500), v8 VARCHAR(500), v9 VARCHAR(500), - v10 VARCHAR(500), v11 VARCHAR(500), v12 VARCHAR(500), - v13 VARCHAR(500), v14 VARCHAR(500), v15 VARCHAR(500), - v16 VARCHAR(500), v17 VARCHAR(500), v18 VARCHAR(500) -) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; -CREATE INDEX idx1 ON t12637786(a,v1); -INSERT INTO t12637786 VALUES(9,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r); -UPDATE t12637786 SET a=1000; -DELETE FROM t12637786; -# We need to activate the purge thread at this point to make sure it does not -# assert and is able to clean up the old versions of secondary index entries. -# But instead of doing a --sleep 10, wait until the rest of the tests in -# this file complete before dropping the table. By then, the purge thread -# will have delt with the updates above. - -# Bug#12963823 - Test that the purge thread does not crash when -# the number of indexes has changed since the UNDO record was logged. -create table t12963823(a blob,b blob,c blob,d blob,e blob,f blob,g blob,h blob, - i blob,j blob,k blob,l blob,m blob,n blob,o blob,p blob) - engine=innodb row_format=dynamic; -SET @r = repeat('a', 767); -insert into t12963823 values (@r,@r,@r,@r, @r,@r,@r,@r, @r,@r,@r,@r, @r,@r,@r,@r); -create index ndx_a on t12963823 (a(500)); -create index ndx_b on t12963823 (b(500)); -create index ndx_c on t12963823 (c(500)); -create index ndx_d on t12963823 (d(500)); -create index ndx_e on t12963823 (e(500)); -create index ndx_f on t12963823 (f(500)); -create index ndx_k on t12963823 (k(500)); -create index ndx_l on t12963823 (l(500)); - -SET @r = repeat('b', 500); -update t12963823 set a=@r,b=@r,c=@r,d=@r; -update t12963823 set e=@r,f=@r,g=@r,h=@r; -update t12963823 set i=@r,j=@r,k=@r,l=@r; -update t12963823 set m=@r,n=@r,o=@r,p=@r; -alter table t12963823 drop index ndx_a; -alter table t12963823 drop index ndx_b; -create index ndx_g on t12963823 (g(500)); -create index ndx_h on t12963823 (h(500)); -create index ndx_i on t12963823 (i(500)); -create index ndx_j on t12963823 (j(500)); -create index ndx_m on t12963823 (m(500)); -create index ndx_n on t12963823 (n(500)); -create index ndx_o on t12963823 (o(500)); -create index ndx_p on t12963823 (p(500)); -show create table t12963823; -# We need to activate the purge thread at this point to see if it crashes -# but instead of doing a --sleep 10, wait until the rest of the tests in -# this file complete before dropping the table. By then, the purge thread -# will have delt with the updates above. +SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS; # Bug#13654923 BOGUS DEBUG ASSERTION IN INDEX CREATION FOR ZERO-LENGTH RECORD create table t1(a varchar(2) primary key) engine=innodb; insert into t1 values(''); +--enable_info create index t1a1 on t1(a(1)); +--disable_info drop table t1; -eval set global innodb_file_per_table=$per_table; -eval set global innodb_file_format=$format; - create table t1(a int not null, b int, c char(10) not null, d varchar(20)) engine = innodb; insert into t1 values (5,5,'oo','oo'),(4,4,'tr','tr'),(3,4,'ad','ad'),(2,3,'ak','ak'); commit; @@ -135,19 +24,30 @@ commit; alter table t1 add index b (b), add index b (b); --error ER_DUP_FIELDNAME alter table t1 add index (b,b); +--enable_info alter table t1 add index d2 (d); +--disable_info show create table t1; +-- disable_result_log +analyze table t1; +-- enable_result_log explain select * from t1 force index(d2) order by d; select * from t1 force index (d2) order by d; --error ER_DUP_ENTRY alter table t1 add unique index (b); show create table t1; +--enable_info alter table t1 add index (b); +--disable_info show create table t1; +--enable_info alter table t1 add unique index (c), add index (d); +--disable_info show create table t1; +analyze table t1; explain select * from t1 force index(c) order by c; +--enable_info alter table t1 add primary key (a), drop index c; show create table t1; --error ER_MULTIPLE_PRI_KEY @@ -155,16 +55,23 @@ alter table t1 add primary key (c); --error ER_DUP_ENTRY alter table t1 drop primary key, add primary key (b); create unique index c on t1 (c); +--disable_info show create table t1; +analyze table t1; explain select * from t1 force index(c) order by c; select * from t1 force index(c) order by c; +--enable_info alter table t1 drop index b, add index (b); +--disable_info show create table t1; insert into t1 values(6,1,'ggg','ggg'); select * from t1; select * from t1 force index(b) order by b; select * from t1 force index(c) order by c; select * from t1 force index(d) order by d; +-- disable_result_log +analyze table t1; +-- enable_result_log explain select * from t1 force index(b) order by b; explain select * from t1 force index(c) order by c; explain select * from t1 force index(d) order by d; @@ -174,11 +81,16 @@ drop table t1; create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb; insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,3,'ad','ad'),(4,4,'afe','afe'); commit; +--enable_info alter table t1 add index (c(2)); show create table t1; alter table t1 add unique index (d(10)); show create table t1; +--disable_info insert into t1 values(5,1,'ggg','ggg'); +-- disable_result_log +analyze table t1; +-- enable_result_log select * from t1; select * from t1 force index(c) order by c; select * from t1 force index(d) order by d; @@ -186,10 +98,15 @@ explain select * from t1 order by b; explain select * from t1 force index(c) order by c; explain select * from t1 force index(d) order by d; show create table t1; +--enable_info alter table t1 drop index d; +--disable_info insert into t1 values(8,9,'fff','fff'); select * from t1; select * from t1 force index(c) order by c; +-- disable_result_log +analyze table t1; +-- enable_result_log explain select * from t1 order by b; explain select * from t1 force index(c) order by c; explain select * from t1 order by d; @@ -199,23 +116,38 @@ drop table t1; create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb; insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe'); commit; +--enable_info alter table t1 add unique index (b,c); +--disable_info insert into t1 values(8,9,'fff','fff'); select * from t1; select * from t1 force index(b) order by b; +-- disable_result_log +analyze table t1; +-- enable_result_log explain select * from t1 force index(b) order by b; show create table t1; +--enable_info alter table t1 add index (b,c); +--disable_info insert into t1 values(11,11,'kkk','kkk'); select * from t1; select * from t1 force index(b) order by b; +-- disable_result_log +analyze table t1; +-- enable_result_log explain select * from t1 force index(b) order by b; show create table t1; +--enable_info alter table t1 add unique index (c,d); +--disable_info insert into t1 values(13,13,'yyy','aaa'); select * from t1; select * from t1 force index(b) order by b; select * from t1 force index(c) order by c; +-- disable_result_log +analyze table t1; +-- enable_result_log explain select * from t1 force index(b) order by b; explain select * from t1 force index(c) order by c; show create table t1; @@ -224,9 +156,9 @@ drop table t1; create table t1(a int not null, b int not null, c int, primary key (a), key (b)) engine = innodb; create table t3(a int not null, c int not null, d int, primary key (a), key (c)) engine = innodb; create table t4(a int not null, d int not null, e int, primary key (a), key (d)) engine = innodb; -create table t2(a int not null, b int not null, c int not null, d int not null, e int, -foreign key (b) references t1(b) on delete cascade, -foreign key (c) references t3(c), foreign key (d) references t4(d)) +create table t2(a int not null, b int, c int, d int, e int, +foreign key (b) references t1(b) on delete set null, +foreign key (c) references t3(c), foreign key (d) references t4(d) on update set null) engine = innodb; --error ER_DROP_INDEX_FK alter table t1 drop index b; @@ -238,38 +170,80 @@ alter table t4 drop index d; alter table t2 drop index b; --error ER_DROP_INDEX_FK alter table t2 drop index b, drop index c, drop index d; +--error ER_FK_COLUMN_CANNOT_CHANGE +alter table t2 MODIFY b INT NOT NULL, ALGORITHM=COPY; +# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. +set @old_sql_mode = @@sql_mode; +set @@sql_mode = 'STRICT_TRANS_TABLES'; +--error ER_FK_COLUMN_NOT_NULL +alter table t2 MODIFY b INT NOT NULL, ALGORITHM=INPLACE; +set @@sql_mode = @old_sql_mode; + +SET FOREIGN_KEY_CHECKS=0; +--error ER_FK_COLUMN_CANNOT_DROP +alter table t2 DROP COLUMN b, ALGORITHM=COPY; +--error ER_FK_COLUMN_CANNOT_DROP +alter table t2 DROP COLUMN b; +--error ER_FK_COLUMN_CANNOT_DROP_CHILD +alter table t1 DROP COLUMN b, ALGORITHM=COPY; +--error ER_FK_COLUMN_CANNOT_DROP_CHILD +alter table t1 DROP COLUMN b; +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; + +--enable_info # Apparently, the following makes mysql_alter_table() drop index d. create unique index dc on t2 (d,c); create index dc on t1 (b,c); # This should preserve the foreign key constraints. -alter table t2 add primary key (a); +--disable_info +# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. +# And adding a PRIMARY KEY will also add NOT NULL implicitly! +set @@sql_mode = 'STRICT_TRANS_TABLES'; +--enable_info +--error ER_FK_COLUMN_NOT_NULL +alter table t2 add primary key (alpha), change a alpha int, +change b beta int not null, change c charlie int not null; +--error ER_FK_COLUMN_NOT_NULL +alter table t2 add primary key (alpha), change a alpha int, +change c charlie int not null, change d delta int not null; +alter table t2 add primary key (alpha), change a alpha int, +change b beta int, modify c int not null; +--disable_info +set @@sql_mode = @old_sql_mode; insert into t1 values (1,1,1); insert into t3 values (1,1,1); insert into t4 values (1,1,1); insert into t2 values (1,1,1,1,1); commit; +--enable_info alter table t4 add constraint dc foreign key (a) references t1(a); +--disable_info show create table t4; ---replace_regex /'test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ +# mysqltest first does replace_regex, then replace_result +--replace_regex /#sql-[0-9a-f_]*'/#sql-temporary'/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLD_DATADIR ./ master-data/ '' # a foreign key 'test/dc' already exists --error ER_CANT_CREATE_TABLE alter table t3 add constraint dc foreign key (a) references t1(a); +SET FOREIGN_KEY_CHECKS=0; +--error ER_FK_FAIL_ADD_SYSTEM +alter table t3 add constraint dc foreign key (a) references t1(a); +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; show create table t3; -# this should be fixed by MySQL (see Bug #51451) ---error ER_WRONG_NAME_FOR_INDEX -alter table t2 drop index b, add index (b); +--enable_info +alter table t2 drop index b, add index (beta); +--disable_info show create table t2; --error ER_ROW_IS_REFERENCED_2 delete from t1; --error ER_CANT_DROP_FIELD_OR_KEY drop index dc on t4; -# there is no foreign key dc on t3 ---replace_regex /'[^']*test\/#sql2-[0-9a-f-]*'/'#sql2-temporary'/ -# Embedded server doesn't chdir to data directory ---replace_result $MYSQLD_DATADIR ./ master-data/ '' ---error ER_ERROR_ON_RENAME +--enable_info +--error ER_CANT_DROP_FIELD_OR_KEY alter table t3 drop foreign key dc; alter table t4 drop foreign key dc; +--disable_info select * from t2; delete from t1; select * from t2; @@ -311,10 +285,15 @@ drop table t1; create table t1(a int not null, b int not null, c int, primary key (a), key(c)) engine=innodb; insert into t1 values (5,1,5),(4,2,4),(3,3,3),(2,4,2),(1,5,1); +--enable_info alter table t1 add unique index (b); +--disable_info insert into t1 values (10,20,20),(11,19,19),(12,18,18),(13,17,17); show create table t1; check table t1; +-- disable_result_log +analyze table t1; +-- enable_result_log explain select * from t1 force index(c) order by c; explain select * from t1 order by a; explain select * from t1 force index(b) order by b; @@ -325,11 +304,14 @@ drop table t1; create table t1(a int not null, b int not null) engine=innodb; insert into t1 values (1,1); +--enable_info alter table t1 add primary key(b); +--disable_info insert into t1 values (2,2); show create table t1; check table t1; select * from t1; +analyze table t1; explain select * from t1; explain select * from t1 order by a; explain select * from t1 order by b; @@ -338,205 +320,19 @@ drop table t1; create table t1(a int not null) engine=innodb; insert into t1 values (1); +--enable_info alter table t1 add primary key(a); +--disable_info insert into t1 values (2); show create table t1; check table t1; commit; select * from t1; +analyze table t1; explain select * from t1; explain select * from t1 order by a; drop table t1; -create table t2(d varchar(17) primary key) engine=innodb default charset=utf8; -create table t3(a int primary key) engine=innodb; - -insert into t3 values(22),(44),(33),(55),(66); - -insert into t2 values ('jejdkrun87'),('adfd72nh9k'), -('adfdpplkeock'),('adfdijnmnb78k'),('adfdijn0loKNHJik'); - -create table t1(a int, b blob, c text, d text not null) -engine=innodb default charset = utf8; - -# r2667 The following test is disabled because MySQL behavior changed. -# r2667 The test was added with this comment: -# r2667 -# r2667 ------------------------------------------------------------------------ -# r2667 r1699 | marko | 2007-08-10 19:53:19 +0300 (Fri, 10 Aug 2007) | 5 lines -# r2667 -# r2667 branches/zip: Add changes that accidentally omitted from r1698: -# r2667 -# r2667 innodb-index.test, innodb-index.result: Add a test for creating -# r2667 a PRIMARY KEY on a column that contains a NULL value. -# r2667 ------------------------------------------------------------------------ -# r2667 -# r2667 but in BZR-r2667: -# r2667 http://bazaar.launchpad.net/~mysql/mysql-server/mysql-5.1/revision/davi%40mysql.com-20080617141221-8yre8ys9j4uw3xx5?start_revid=joerg%40mysql.com-20080630105418-7qoe5ehomgrcdb89 -# r2667 MySQL changed the behavior to do full table copy when creating PRIMARY INDEX -# r2667 on a non-NULL column instead of calling ::add_index() which would fail (and -# r2667 this is what we were testing here). Before r2667 the code execution path was -# r2667 like this (when adding PRIMARY INDEX on a non-NULL column with ALTER TABLE): -# r2667 -# r2667 mysql_alter_table() -# r2667 compare_tables() // would return ALTER_TABLE_INDEX_CHANGED -# r2667 ::add_index() // would fail with "primary index cannot contain NULL" -# r2667 -# r2667 after r2667 the code execution path is the following: -# r2667 -# r2667 mysql_alter_table() -# r2667 compare_tables() // returns ALTER_TABLE_DATA_CHANGED -# r2667 full copy is done, without calling ::add_index() -# r2667 -# r2667 To enable, remove "# r2667: " below. -# r2667 -# r2667: insert into t1 values (null,null,null,'null'); -insert into t1 -select a,left(repeat(d,100*a),65535),repeat(d,20*a),d from t2,t3; -drop table t2, t3; -select count(*) from t1 where a=44; -select a, -length(b),b=left(repeat(d,100*a),65535),length(c),c=repeat(d,20*a),d from t1; -# r2667: --error ER_PRIMARY_CANT_HAVE_NULL -# r2667: alter table t1 add primary key (a), add key (b(20)); -# r2667: delete from t1 where d='null'; ---error ER_DUP_ENTRY -alter table t1 add primary key (a), add key (b(20)); -delete from t1 where a%2; -check table t1; -alter table t1 add primary key (a,b(255),c(255)), add key (b(767)); -select count(*) from t1 where a=44; -select a, -length(b),b=left(repeat(d,100*a),65535),length(c),c=repeat(d,20*a),d from t1; -show create table t1; -check table t1; -explain select * from t1 where b like 'adfd%'; - -# The following tests are disabled because of the introduced timeouts for -# metadata locks at the MySQL level as part of the fix for -# Bug#45225 Locking: hang if drop table with no timeout -# The following commands now play with MySQL metadata locks instead of -# InnoDB locks -# start disabled45225_1 -## -## Test locking -## -# -#create table t2(a int, b varchar(255), primary key(a,b)) engine=innodb; -#insert into t2 select a,left(b,255) from t1; -#drop table t1; -#rename table t2 to t1; -# -#connect (a,localhost,root,,); -#connect (b,localhost,root,,); -#connection a; -#set innodb_lock_wait_timeout=1; -#begin; -## Obtain an IX lock on the table -#select a from t1 limit 1 for update; -#connection b; -#set innodb_lock_wait_timeout=1; -## This would require an S lock on the table, conflicting with the IX lock. -#--error ER_LOCK_WAIT_TIMEOUT -#create index t1ba on t1 (b,a); -#connection a; -#commit; -#begin; -## Obtain an IS lock on the table -#select a from t1 limit 1 lock in share mode; -#connection b; -## This will require an S lock on the table. No conflict with the IS lock. -#create index t1ba on t1 (b,a); -## This would require an X lock on the table, conflicting with the IS lock. -#--error ER_LOCK_WAIT_TIMEOUT -#drop index t1ba on t1; -#connection a; -#commit; -#explain select a from t1 order by b; -#--send -#select a,sleep(2+a/100) from t1 order by b limit 3; -# -## The following DROP INDEX will succeed, altough the SELECT above has -## opened a read view. However, during the execution of the SELECT, -## MySQL should hold a table lock that should block the execution -## of the DROP INDEX below. -# -#connection b; -#select sleep(1); -#drop index t1ba on t1; -# -## After the index was dropped, subsequent SELECTs will use the same -## read view, but they should not be accessing the dropped index any more. -# -#connection a; -#reap; -#explain select a from t1 order by b; -#select a from t1 order by b limit 3; -#commit; -# -#connection default; -#disconnect a; -#disconnect b; -# -# end disabled45225_1 -drop table t1; - -set global innodb_file_per_table=on; -set global innodb_file_format='Barracuda'; -# Test creating a table that could lead to undo log overflow. -# In the undo log, we write a 768-byte prefix (REC_MAX_INDEX_COL_LEN) -# of each externally stored column that appears as a column prefix in an index. -# For this test case, it would suffice to write 1 byte, though. -create table t1(a blob,b blob,c blob,d blob,e blob,f blob,g blob,h blob, - i blob,j blob,k blob,l blob,m blob,n blob,o blob,p blob, - q blob,r blob,s blob,t blob,u blob) - engine=innodb row_format=dynamic; -create index t1a on t1 (a(767)); -create index t1b on t1 (b(767)); -create index t1c on t1 (c(767)); -create index t1d on t1 (d(767)); -create index t1e on t1 (e(767)); -create index t1f on t1 (f(767)); -create index t1g on t1 (g(767)); -create index t1h on t1 (h(767)); -create index t1i on t1 (i(767)); -create index t1j on t1 (j(767)); -create index t1k on t1 (k(767)); -create index t1l on t1 (l(767)); -create index t1m on t1 (m(767)); -create index t1n on t1 (n(767)); -create index t1o on t1 (o(767)); -create index t1p on t1 (p(767)); -create index t1q on t1 (q(767)); -create index t1r on t1 (r(767)); -create index t1s on t1 (s(767)); -create index t1t on t1 (t(767)); ---error 139 -create index t1u on t1 (u(767)); ---error 139 -create index t1ut on t1 (u(767), t(767)); -create index t1st on t1 (s(767), t(767)); -show create table t1; ---error 139 -create index t1u on t1 (u(767)); -alter table t1 row_format=compact; -create index t1u on t1 (u(767)); - -drop table t1; - -# Bug#12547647 UPDATE LOGGING COULD EXCEED LOG PAGE SIZE -CREATE TABLE bug12547647( -a INT NOT NULL, b BLOB NOT NULL, c TEXT, -PRIMARY KEY (b(10), a), INDEX (c(767)), INDEX(b(767)) -) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; - -INSERT INTO bug12547647 VALUES (5,repeat('khdfo5AlOq',1900),repeat('g',7751)); -COMMIT; -# The following used to cause infinite undo log allocation. ---error ER_UNDO_RECORD_TOO_BIG -UPDATE bug12547647 SET c = REPEAT('b',16928); -DROP TABLE bug12547647; - eval set global innodb_file_per_table=$per_table; eval set global innodb_file_format=$format; eval set global innodb_file_format_max=$format; @@ -546,7 +342,7 @@ eval set global innodb_file_format_max=$format; # constraint modifications (Issue #70, Bug #38786) # SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; -SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; +SET FOREIGN_KEY_CHECKS=0; CREATE TABLE t1( c1 BIGINT(12) NOT NULL, @@ -589,8 +385,10 @@ CREATE TABLE t2( PRIMARY KEY (c1,c2,c3) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +SET FOREIGN_KEY_CHECKS=0; ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca FOREIGN KEY (c3) REFERENCES t1(c1); +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SHOW CREATE TABLE t2; @@ -620,26 +418,60 @@ CREATE TABLE t2( PRIMARY KEY (c1) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ---replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/ +SET FOREIGN_KEY_CHECKS=0; +--enable_info + +# mysqltest first does replace_regex, then replace_result +--replace_regex /#sql-[0-9a-f_]*'/#sql-temporary'/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLD_DATADIR ./ master-data/ '' --error ER_CANT_CREATE_TABLE ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca + FOREIGN KEY (c3,c2) REFERENCES t1(c1,c1), ALGORITHM=COPY; +--error ER_FK_NO_INDEX_PARENT +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca FOREIGN KEY (c3,c2) REFERENCES t1(c1,c1); ---replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/ +# mysqltest first does replace_regex, then replace_result +--replace_regex /#sql-[0-9a-f_]*'/#sql-temporary'/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLD_DATADIR ./ master-data/ '' --error ER_CANT_CREATE_TABLE ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca + FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2), ALGORITHM=COPY; +--error ER_FK_NO_INDEX_PARENT +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2); ---replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/ ---error ER_CANT_CREATE_TABLE + +# FIXME (WL#6251 problem): this should fail, like the ALGORITHM=COPY below ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1); +ALTER TABLE t2 DROP FOREIGN KEY fk_t2_ca; + +# mysqltest first does replace_regex, then replace_result +--replace_regex /#sql-[0-9a-f_]*'/#sql-temporary'/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLD_DATADIR ./ master-data/ '' +--error ER_CANT_CREATE_TABLE +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca + FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1), ALGORITHM=COPY; + ALTER TABLE t1 MODIFY COLUMN c2 BIGINT(12) NOT NULL; ---replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/ +# mysqltest first does replace_regex, then replace_result +--replace_regex /#sql-[0-9a-f_]*'/#sql-temporary'/ +# Embedded server doesn't chdir to data directory +--replace_result $MYSQLD_DATADIR ./ master-data/ '' --error ER_CANT_CREATE_TABLE ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca + FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2), ALGORITHM=COPY; +--error ER_FK_NO_INDEX_PARENT +ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca FOREIGN KEY (c3,c2) REFERENCES t1(c1,c2); ALTER TABLE t2 ADD CONSTRAINT fk_t2_ca FOREIGN KEY (c3,c2) REFERENCES t1(c2,c1); + +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; + SHOW CREATE TABLE t1; SHOW CREATE TABLE t2; CREATE INDEX i_t2_c2_c1 ON t2(c2, c1); @@ -648,40 +480,79 @@ CREATE INDEX i_t2_c3_c1_c2 ON t2(c3, c1, c2); SHOW CREATE TABLE t2; CREATE INDEX i_t2_c3_c2 ON t2(c3, c2); SHOW CREATE TABLE t2; +--disable_info DROP TABLE t2; DROP TABLE t1; -# The following tests are disabled because of the introduced timeouts for -# metadata locks at the MySQL level as part of the fix for -# Bug#45225 Locking: hang if drop table with no timeout -# The following CREATE INDEX t1a ON t1(a); causes a lock wait timeout -# start disabled45225_2 -#connect (a,localhost,root,,); -#connect (b,localhost,root,,); -#connection a; -#CREATE TABLE t1 (a INT, b CHAR(1)) ENGINE=InnoDB; -#INSERT INTO t1 VALUES (3,'a'),(3,'b'),(1,'c'),(0,'d'),(1,'e'); -#connection b; -#BEGIN; -#SELECT * FROM t1; -#connection a; -#CREATE INDEX t1a ON t1(a); -#connection b; -#SELECT * FROM t1; -#--error ER_TABLE_DEF_CHANGED -#SELECT * FROM t1 FORCE INDEX(t1a) ORDER BY a; -#SELECT * FROM t1; -#COMMIT; -#SELECT * FROM t1 FORCE INDEX(t1a) ORDER BY a; -#connection default; -#disconnect a; -#disconnect b; -# -#DROP TABLE t1; -# end disabled45225_2 -#this delay is needed because 45225_2 is disabled, to allow the purge to run -SELECT SLEEP(10); -DROP TABLE t1_purge, t2_purge, t3_purge, t4_purge; -DROP TABLE t12637786; -DROP TABLE t12963823; +connect (a,localhost,root,,); +connect (b,localhost,root,,); +connection a; +CREATE TABLE t1 (a INT, b CHAR(1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (3,'a'),(3,'b'),(1,'c'),(0,'d'),(1,'e'); +CREATE TABLE t2 (a INT, b CHAR(1)) ENGINE=InnoDB; +CREATE TABLE t2i (a INT, b CHAR(1) NOT NULL) ENGINE=InnoDB; +CREATE TABLE t2c (a INT, b CHAR(1) NOT NULL) ENGINE=InnoDB; +INSERT INTO t2 SELECT * FROM t1; +INSERT INTO t2i SELECT * FROM t1; +INSERT INTO t2c SELECT * FROM t1; +connection b; +BEGIN; +# This acquires a MDL lock on t1 until commit. +SELECT * FROM t1; +connection a; +# This times out before of the MDL lock held by connection b. +SET lock_wait_timeout=1; +--error ER_LOCK_WAIT_TIMEOUT +CREATE INDEX t1a ON t1(a); +--enable_info +CREATE INDEX t2a ON t2(a); +--disable_info +set @old_sql_mode = @@sql_mode; +# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. +# And adding a PRIMARY KEY will also add NOT NULL implicitly! +set @@sql_mode = 'STRICT_TRANS_TABLES'; +--enable_info +ALTER TABLE t2i ADD PRIMARY KEY(a,b), ADD INDEX t2a(a), ALGORITHM=INPLACE; +--disable_info +set @@sql_mode = @old_sql_mode; +--enable_info +ALTER TABLE t2c ADD PRIMARY KEY(a,b), ADD INDEX t2a(a), ALGORITHM=COPY; +--disable_info +connection b; +# t2i and t2c are too new for this transaction, because they were rebuilt +--error ER_TABLE_DEF_CHANGED +SELECT * FROM t2i; +--error ER_TABLE_DEF_CHANGED +SELECT * FROM t2i FORCE INDEX(t2a) ORDER BY a; +--error ER_TABLE_DEF_CHANGED +SELECT * FROM t2c; +--error ER_TABLE_DEF_CHANGED +SELECT * FROM t2c FORCE INDEX(t2a) ORDER BY a; +# In t2, only the new index t2a is too new for this transaction. +SELECT * FROM t2; +--error ER_TABLE_DEF_CHANGED +SELECT * FROM t2 FORCE INDEX(t2a) ORDER BY a; +SELECT * FROM t2; +COMMIT; +# For a new transaction, all of t2, t2i, t2c are accessible. +SELECT * FROM t2; +SELECT * FROM t2 FORCE INDEX(t2a) ORDER BY a; +SELECT * FROM t2i; +SELECT * FROM t2i FORCE INDEX(t2a) ORDER BY a; +SELECT * FROM t2c; +SELECT * FROM t2c FORCE INDEX(t2a) ORDER BY a; +connection default; +disconnect a; +disconnect b; + +--error ER_DUP_KEYNAME +alter table t2 add index t2a(b); +alter table t2 drop index t2a, add index t2a(b); +show create table t2; +show create table t2i; +show create table t2c; + +--disable_info + +DROP TABLE t1,t2,t2c,t2i; diff --git a/mysql-test/suite/innodb/t/innodb_bug21704.test b/mysql-test/suite/innodb/t/innodb_bug21704.test index 67d76587819..82e7c81d0e4 100644 --- a/mysql-test/suite/innodb/t/innodb_bug21704.test +++ b/mysql-test/suite/innodb/t/innodb_bug21704.test @@ -1,4 +1,5 @@ ---source include/have_innodb.inc +-- source include/have_innodb.inc + --echo # --echo # Bug#21704: Renaming column does not update FK definition. --echo # @@ -8,12 +9,6 @@ --echo # foreign key (either in the referencing or referenced table). --echo ---disable_warnings -DROP TABLE IF EXISTS t1; -DROP TABLE IF EXISTS t2; -DROP TABLE IF EXISTS t3; ---enable_warnings - CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT ENGINE=INNODB; CREATE TABLE t2 (a INT PRIMARY KEY, b INT, @@ -32,64 +27,50 @@ INSERT INTO t3 VALUES (1,1,1),(2,2,2),(3,3,3); --echo # Test renaming the column in the referenced table. --echo -# mysqltest first does replace_regex, then replace_result ---replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ -# Embedded server doesn't chdir to data directory ---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' ---error ER_ERROR_ON_RENAME -ALTER TABLE t1 CHANGE a c INT; +--enable_info +ALTER TABLE t1 CHANGE a e INT; --echo # Ensure that online column rename works. ---enable_info ALTER TABLE t1 CHANGE b c INT; ---disable_info --echo --echo # Test renaming the column in the referencing table --echo -# mysqltest first does replace_regex, then replace_result ---replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ -# Embedded server doesn't chdir to data directory ---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' ---error ER_ERROR_ON_RENAME -ALTER TABLE t2 CHANGE a c INT; +ALTER TABLE t2 CHANGE a z INT; --echo # Ensure that online column rename works. ---enable_info ALTER TABLE t2 CHANGE b c INT; ---disable_info --echo --echo # Test with self-referential constraints --echo -# mysqltest first does replace_regex, then replace_result ---replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ -# Embedded server doesn't chdir to data directory ---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' ---error ER_ERROR_ON_RENAME -ALTER TABLE t3 CHANGE a d INT; +ALTER TABLE t3 CHANGE a f INT; -# mysqltest first does replace_regex, then replace_result ---replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/ -# Embedded server doesn't chdir to data directory ---replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' ---error ER_ERROR_ON_RENAME -ALTER TABLE t3 CHANGE b d INT; +ALTER TABLE t3 CHANGE b g INT; --echo # Ensure that online column rename works. ---enable_info ALTER TABLE t3 CHANGE c d INT; ---disable_info --echo --echo # Cleanup. --echo +--disable_info +SHOW CREATE TABLE t1; +SHOW CREATE TABLE t2; +SHOW CREATE TABLE t3; + +SELECT f.*, c.* +FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS c +INNER JOIN INFORMATION_SCHEMA.INNODB_SYS_FOREIGN f +ON c.ID=f.ID +WHERE FOR_NAME LIKE 'test/t%'; + DROP TABLE t3; DROP TABLE t2; DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb_bug53592.test b/mysql-test/suite/innodb/t/innodb_bug53592.test index 9bf8578eafa..6c0f5a8422d 100644 --- a/mysql-test/suite/innodb/t/innodb_bug53592.test +++ b/mysql-test/suite/innodb/t/innodb_bug53592.test @@ -1,8 +1,8 @@ ---source include/have_innodb.inc # Testcase for Bug #53592 - "crash replacing duplicates into # table after fast alter table added unique key". The fix is to make # sure index number lookup should go through "index translation table". +--source include/have_innodb.inc # Use FIC for index creation set old_alter_table=0; diff --git a/mysql-test/suite/innodb/t/innodb_bug54044.test b/mysql-test/suite/innodb/t/innodb_bug54044.test index 013a7ff1e93..13c37d9c841 100644 --- a/mysql-test/suite/innodb/t/innodb_bug54044.test +++ b/mysql-test/suite/innodb/t/innodb_bug54044.test @@ -1,12 +1,19 @@ ---source include/have_innodb.inc # This is the test for bug #54044. Special handle MYSQL_TYPE_NULL type # during create table, so it will not trigger assertion failure. +--source include/have_innodb.inc # This 'create table' operation no longer uses the NULL datatype. CREATE TEMPORARY TABLE table_54044 ENGINE = INNODB AS SELECT IF(NULL IS NOT NULL, NULL, NULL); SHOW CREATE TABLE table_54044; -CREATE TEMPORARY TABLE tmp1 ENGINE = INNODB AS SELECT COALESCE(NULL, NULL, NULL); -CREATE TEMPORARY TABLE tmp2 ENGINE = INNODB AS SELECT GREATEST(NULL, NULL); +DROP TABLE table_54044; + +# These 'create table' operations should fail because of +# using NULL datatype + +CREATE TABLE tmp ENGINE = INNODB AS SELECT COALESCE(NULL, NULL, NULL), GREATEST(NULL, NULL), NULL; +SHOW CREATE TABLE tmp; +DROP TABLE tmp; + diff --git a/mysql-test/suite/innodb/t/innodb_bug56947.test b/mysql-test/suite/innodb/t/innodb_bug56947.test index b6feb239314..4cefeb391cf 100644 --- a/mysql-test/suite/innodb/t/innodb_bug56947.test +++ b/mysql-test/suite/innodb/t/innodb_bug56947.test @@ -1,15 +1,17 @@ ---source include/have_innodb.inc # # Bug #56947 valgrind reports a memory leak in innodb-plugin.innodb-index # -SET @old_innodb_file_per_table=@@innodb_file_per_table; -# avoid a message about filed *.ibd file creation in the error log +-- source include/have_innodb.inc +-- source include/have_debug.inc + SET GLOBAL innodb_file_per_table=0; create table bug56947(a int not null) engine = innodb; -CREATE TABLE `bug56947#1`(a int) ENGINE=InnoDB; ---error 156 + +SET DEBUG_DBUG='+d,ib_rebuild_cannot_rename'; +--error ER_GET_ERRNO alter table bug56947 add unique index (a); -drop table `bug56947#1`; +SET DEBUG_DBUG='-d,ib_rebuild_cannot_rename'; +check table bug56947; + drop table bug56947; ---disable_query_log -SET GLOBAL innodb_file_per_table=@old_innodb_file_per_table; +SET @@global.innodb_file_per_table=DEFAULT; diff --git a/mysql-test/suite/innodb/t/innodb_mysql.test b/mysql-test/suite/innodb/t/innodb_mysql.test index 3ae5be3aa30..44e2e8b2342 100644 --- a/mysql-test/suite/innodb/t/innodb_mysql.test +++ b/mysql-test/suite/innodb/t/innodb_mysql.test @@ -5,11 +5,12 @@ # main testing code t/innodb_mysql.test -> include/mix1.inc # -# Slow test, don't run during staging part --- source include/not_staging.inc --- source include/have_innodb.inc --- source include/have_query_cache.inc +#Want to skip this test from daily Valgrind execution. +--source include/no_valgrind_without_big.inc +# Adding big test option for this test. +--source include/big_test.inc +-- source include/have_innodb.inc let $engine_type= InnoDB; let $other_engine_type= MEMORY; # InnoDB does support FOREIGN KEYFOREIGN KEYs @@ -21,21 +22,21 @@ set session innodb_support_xa=default; --disable_warnings drop table if exists t1, t2, t3; --enable_warnings -# -# BUG#35850: Performance regression in 5.1.23/5.1.24 -# +--echo # +--echo # BUG#35850: Performance regression in 5.1.23/5.1.24 +--echo # create table t1(a int); insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t2 (a int, b int, pk int, key(a,b), primary key(pk)) engine=innodb; insert into t2 select @a:=A.a+10*(B.a + 10*C.a),@a, @a from t1 A, t1 B, t1 C; ---echo this must use key 'a', not PRIMARY: +--echo # this must use key 'a', not PRIMARY: --replace_column 9 # explain select a from t2 where a=b; drop table t1, t2; -# -# Bug #40360: Binlog related errors with binlog off -# +--echo # +--echo # Bug #40360: Binlog related errors with binlog off +--echo # # This bug is triggered when the binlog format is STATEMENT and the # binary log is turned off. In this case, no error should be shown for # the statement since there are no replication issues. @@ -47,9 +48,9 @@ CREATE TABLE t1 ( a INT ) ENGINE=InnoDB; INSERT INTO t1 VALUES(1); DROP TABLE t1; -# -# Bug#37284 Crash in Field_string::type() -# +--echo # +--echo # Bug#37284 Crash in Field_string::type() +--echo # --disable_warnings DROP TABLE IF EXISTS t1; --enable_warnings @@ -58,10 +59,10 @@ CREATE INDEX i1 on t1 (a(3)); SELECT * FROM t1 WHERE a = 'abcde'; DROP TABLE t1; -# -# Bug #37742: HA_EXTRA_KEYREAD flag is set when key contains only prefix of -# requested column -# +--echo # +--echo # Bug #37742: HA_EXTRA_KEYREAD flag is set when key contains only prefix of +--echo # requested column +--echo # CREATE TABLE foo (a int, b int, c char(10), PRIMARY KEY (c(3)), @@ -85,6 +86,12 @@ INSERT INTO foo VALUES INSERT INTO bar SELECT * FROM foo; INSERT INTO foo2 SELECT * FROM foo; +-- disable_result_log +ANALYZE TABLE bar; +ANALYZE TABLE foo; +ANALYZE TABLE foo2; +-- enable_result_log + --query_vertical EXPLAIN SELECT c FROM bar WHERE b>2; --query_vertical EXPLAIN SELECT c FROM foo WHERE b>2; --query_vertical EXPLAIN SELECT c FROM foo2 WHERE b>2; @@ -96,9 +103,9 @@ INSERT INTO foo2 SELECT * FROM foo; DROP TABLE foo, bar, foo2; -# -# Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table -# +--echo # +--echo # Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table +--echo # --disable_warnings DROP TABLE IF EXISTS t1,t3,t2; @@ -137,9 +144,9 @@ DEALLOCATE PREPARE stmt3; DROP TABLE t1,t3,t2; DROP FUNCTION f1; -# -# Bug#37016: TRUNCATE TABLE removes some rows but not all -# +--echo # +--echo # Bug#37016: TRUNCATE TABLE removes some rows but not all +--echo # --disable_warnings DROP TABLE IF EXISTS t1,t2; @@ -337,9 +344,9 @@ DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; -# -# Bug#43580: Issue with Innodb on multi-table update -# +--echo # +--echo # Bug#43580: Issue with Innodb on multi-table update +--echo # CREATE TABLE t1 (a INT, b INT, KEY (a)) ENGINE = INNODB; CREATE TABLE t2 (a INT KEY, b INT, KEY (b)) ENGINE = INNODB; @@ -460,8 +467,14 @@ INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; INSERT INTO t1 (b,c,d,e) SELECT RAND()*10000, RAND()*10000, d, e FROM t1; +-- disable_result_log +ANALYZE TABLE t1; +-- enable_result_log EXPLAIN SELECT * FROM t1 WHERE b=1 AND c=1 ORDER BY a; EXPLAIN SELECT * FROM t1 FORCE INDEX(i2) WHERE b=1 and c=1 ORDER BY a; +# With 4k pages, the 'rows' column in the output below is either 120 or 138, +# not 128 as it is with 8k and 16k. Bug#12602606 +--replace_result 128 {checked} 120 {checked} 138 {checked} EXPLAIN SELECT * FROM t1 FORCE INDEX(PRIMARY) WHERE b=1 AND c=1 ORDER BY a; DROP TABLE t1; @@ -505,11 +518,7 @@ INSERT INTO t2 VALUES (),(); CREATE OR REPLACE VIEW v1 AS SELECT 1 FROM t2 WHERE b =(SELECT a FROM t1 LIMIT 1); ---disable_query_log ---disable_result_log CONNECT (con1, localhost, root,,); ---enable_query_log ---enable_result_log CONNECTION default; DELIMITER |; @@ -546,7 +555,7 @@ DROP TABLE t1,t2; --echo # Bug #49324: more valgrind errors in test_if_skip_sort_order --echo # CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb ; ---echo #should not cause valgrind warnings +--echo # should not cause valgrind warnings SELECT 1 FROM t1 JOIN t1 a USING(a) GROUP BY t1.a,t1.a; DROP TABLE t1; @@ -558,6 +567,10 @@ create table t1(f1 int not null primary key, f2 int) engine=innodb; create table t2(f1 int not null, key (f1)) engine=innodb; insert into t1 values (1,1),(2,2),(3,3); insert into t2 values (1),(2),(3); +-- disable_result_log +analyze table t1; +analyze table t2; +-- enable_result_log explain select t1.* from t1 left join t2 using(f1) group by t1.f1; drop table t1,t2; --echo # @@ -576,6 +589,8 @@ INSERT INTO t1 VALUES (1,1,1,1,1,1), (2,2,2,2,2,2), (3,3,3,3,3,3), (7,7,7,7,7,7), (8,8,8,8,8,8), (9,9,9,9,9,9), (11,11,11,11,11,11); +ANALYZE TABLE t1; + --query_vertical EXPLAIN SELECT COUNT(*) FROM t1 DROP TABLE t1; @@ -594,36 +609,6 @@ ALTER TABLE t1 DROP INDEX k, ADD UNIQUE INDEX k (a,b); DROP TABLE t1; ---echo # ---echo # Bug #53334: wrong result for outer join with impossible ON condition ---echo # (see the same test case for MyISAM in join.test) ---echo # - -create table t1 (id int primary key); -create table t2 (id int); - -insert into t1 values (75); -insert into t1 values (79); -insert into t1 values (78); -insert into t1 values (77); -replace into t1 values (76); -replace into t1 values (76); -insert into t1 values (104); -insert into t1 values (103); -insert into t1 values (102); -insert into t1 values (101); -insert into t1 values (105); -insert into t1 values (106); -insert into t1 values (107); - -insert into t2 values (107),(75),(1000); - -select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 - where t2.id=75 and t1.id is null; -explain select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 - where t2.id=75 and t1.id is null; - -drop table t1,t2; --echo # --echo # Bug #47453: InnoDB incorrectly changes TIMESTAMP columns when @@ -635,7 +620,7 @@ CREATE TABLE t2 (a INT, b INT, c TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP) ENGINE=InnoDB; ---echo set up our data elements +--echo # set up our data elements INSERT INTO t1 (d) VALUES (1); INSERT INTO t2 (a,b) VALUES (1,1); SELECT SECOND(c) INTO @bug47453 FROM t2; @@ -648,7 +633,7 @@ SELECT SLEEP(1); UPDATE t1 JOIN t2 ON d=a SET b=1 WHERE a=1; ---echo #should be 0 +--echo # should be 0 SELECT SECOND(c)-@bug47453 FROM t1 JOIN t2 ON d=a; DROP TABLE t1, t2; @@ -728,6 +713,10 @@ CREATE TABLE t1 ( LOAD DATA INFILE '../../std_data/intersect-bug50389.tsv' INTO TABLE t1; +-- disable_result_log +ANALYZE TABLE t1; +-- enable_result_log + SELECT * FROM t1 WHERE f1 IN (3305028,3353871,3772880,3346860,4228206,3336022, 3470988,3305175,3329875,3817277,3856380,3796193, @@ -754,7 +743,7 @@ CREATE TABLE t1 ( PRIMARY KEY (f1), UNIQUE KEY (f2, f3), KEY (f4) -) ENGINE=InnoDB; +) ENGINE=InnoDB STATS_PERSISTENT=0; INSERT INTO t1 VALUES (1,1,991,1), (2,1,992,1), (3,1,993,1), (4,1,994,1), (5,1,995,1), @@ -786,64 +775,11 @@ UNLOCK TABLES; DROP TABLE t1; --echo # ---echo # Bug#55826: create table .. select crashes with when KILL_BAD_DATA ---echo # is returned ---echo # -CREATE TABLE t1(a INT) ENGINE=innodb; -INSERT INTO t1 VALUES (0); -SET SQL_MODE='STRICT_ALL_TABLES'; ---error ER_TRUNCATED_WRONG_VALUE -CREATE TABLE t2 - SELECT LEAST((SELECT '' FROM t1),NOW()) FROM `t1`; -DROP TABLE t1; -SET SQL_MODE=DEFAULT; - - - ---echo # ---echo # Bug#55580: segfault in read_view_sees_trx_id ---echo # -CREATE TABLE t1 (a INT) ENGINE=Innodb; -CREATE TABLE t2 (a INT) ENGINE=Innodb; -INSERT INTO t1 VALUES (1),(2); -INSERT INTO t2 VALUES (1),(2); - -connect (con1,localhost,root,,test); -connect (con2,localhost,root,,test); - -connection con1; -START TRANSACTION; -SELECT * FROM t2 LOCK IN SHARE MODE; - -connection con2; -START TRANSACTION; -SELECT * FROM t1 LOCK IN SHARE MODE; - -connection con1; -let $conn_id= `SELECT CONNECTION_ID()`; ---send SELECT * FROM t1 FOR UPDATE - -connection con2; -let $wait_timeout= 2; -let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST -WHERE ID=$conn_id AND STATE='Sending data'; ---source include/wait_condition.inc ---echo # should not crash ---error ER_LOCK_DEADLOCK -SELECT * FROM t1 GROUP BY (SELECT a FROM t2 LIMIT 1 FOR UPDATE) + t1.a; - -connection default; -disconnect con1; -disconnect con2; - -DROP TABLE t1,t2; - ---echo # --echo # Bug#55656: mysqldump can be slower after bug #39653 fix --echo # CREATE TABLE t1 (a INT , b INT, c INT, d INT, - KEY (b), PRIMARY KEY (a,b)) ENGINE=INNODB; + KEY (b), PRIMARY KEY (a,b)) ENGINE=INNODB STATS_PERSISTENT=0; INSERT INTO t1 VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3); --query_vertical EXPLAIN SELECT COUNT(*) FROM t1 @@ -862,63 +798,6 @@ CREATE INDEX b ON t1(a,b,c,d); DROP TABLE t1; --echo # ---echo # Bug#56862 Execution of a query that uses index merge returns a wrong result ---echo # - -CREATE TABLE t1 ( - pk int NOT NULL AUTO_INCREMENT PRIMARY KEY, - a int, - b int, - INDEX idx(a)) -ENGINE=INNODB; - -INSERT INTO t1(a,b) VALUES - (11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500), - (3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800), - (6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700), - (13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000); -INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1; -INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1; -INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1 VALUES (1000000, 0, 0); - -SET SESSION sort_buffer_size = 1024*36; - -EXPLAIN -SELECT COUNT(*) FROM - (SELECT * FROM t1 FORCE INDEX (idx,PRIMARY) - WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; - -SELECT COUNT(*) FROM - (SELECT * FROM t1 FORCE INDEX (idx,PRIMARY) - WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; - -SET SESSION sort_buffer_size = DEFAULT; - -DROP TABLE t1; - ---echo # ---echo # ALTER TABLE IGNORE didn't ignore duplicates for unique add index ---echo # - -create table t1 (a int primary key, b int) engine = innodb; -insert into t1 values (1,1),(2,1); -alter ignore table t1 add unique `main` (b); -select * from t1; -drop table t1; - ---echo End of 5.1 tests ---echo # - ---echo # --echo # Bug#55826: create table .. select crashes with when KILL_BAD_DATA --echo # is returned --echo # @@ -933,49 +812,8 @@ DROP TABLE t1; SET SQL_MODE=DEFAULT; --echo # ---echo # Bug#56862 Execution of a query that uses index merge returns a wrong result +--echo # Bug#56862 Moved to innodb_16k.test --echo # - -CREATE TABLE t1 ( - pk int NOT NULL AUTO_INCREMENT PRIMARY KEY, - a int, - b int, - INDEX idx(a)) -ENGINE=INNODB; - -INSERT INTO t1(a,b) VALUES - (11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500), - (3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800), - (6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700), - (13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000); -INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1; -INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1; -INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1 VALUES (1000000, 0, 0); - -SET SESSION sort_buffer_size = 1024*36; - -EXPLAIN -SELECT COUNT(*) FROM - (SELECT * FROM t1 FORCE INDEX (idx,PRIMARY) - WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; - -SELECT COUNT(*) FROM - (SELECT * FROM t1 FORCE INDEX (idx,PRIMARY) - WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; - -SET SESSION sort_buffer_size = DEFAULT; - -DROP TABLE t1; - --echo # --echo # Test for bug #39932 "create table fails if column for FK is in different --echo # case than in corr index". @@ -984,122 +822,15 @@ DROP TABLE t1; drop tables if exists t1, t2; --enable_warnings create table t1 (pk int primary key) engine=InnoDB; ---echo # Even although the below statement uses uppercased field names in ---echo # foreign key definition it still should be able to find explicitly ---echo # created supporting index. So it should succeed and should not ---echo # create any additional supporting indexes. +# Even although the below statement uses uppercased field names in +# foreign key definition it still should be able to find explicitly +# created supporting index. So it should succeed and should not +# create any additional supporting indexes. create table t2 (fk int, key x (fk), constraint x foreign key (FK) references t1 (PK)) engine=InnoDB; show create table t2; drop table t2, t1; ---echo # ---echo # Bug #663818: wrong result when BNLH is used ---echo # - -CREATE TABLE t1(pk int NOT NULL PRIMARY KEY) ENGINE=InnoDB; -INSERT INTO t1 VALUES - (1), (2), (11), (12), (13), (14), - (15), (16), (17), (18), (19); -CREATE TABLE t2(pk int NOT NULL PRIMARY KEY) ENGINE=InnoDB; -INSERT INTO t2 VALUES - (1), (10), (11), (12), (13), (14), - (15), (16), (17), (18), (19), (20), (21); - -SET SESSION join_buffer_size=10000; - -SET SESSION join_cache_level=3; -EXPLAIN -SELECT t1.pk FROM t1,t2 - WHERE t1.pk = t2.pk AND t2.pk <> 8; -SELECT t1.pk FROM t1,t2 - WHERE t1.pk = t2.pk AND t2.pk <> 8; - -SET SESSION join_cache_level=1; -EXPLAIN -SELECT t1.pk FROM t1,t2 - WHERE t1.pk = t2.pk AND t2.pk <> 8; -SELECT t1.pk FROM t1,t2 - WHERE t1.pk = t2.pk AND t2.pk <> 8; - -DROP TABLE t1,t2; - -SET SESSION join_cache_level=DEFAULT; -SET SESSION join_buffer_size=DEFAULT; - ---echo # ---echo # Bug#668644: HAVING + ORDER BY ---echo # - -CREATE TABLE t1 ( - pk int NOT NULL PRIMARY KEY, i int DEFAULT NULL, - INDEX idx (i) -) ENGINE=INNODB; -INSERT INTO t1 VALUES - (6,-1636630528),(2,-1097924608),(1,6),(3,6),(4,1148715008),(5,1541734400); - -CREATE TABLE t2 ( - i int DEFAULT NULL, - pk int NOT NULL PRIMARY KEY, - INDEX idx (i) -) ENGINE= INNODB; -INSERT INTO t2 VALUES - (-1993998336,20),(-1036582912,1),(-733413376,5),(-538247168,16), - (-514260992,4),(-249561088,9),(1,2),(1,6),(2,10),(2,19),(4,17), - (5,14),(5,15),(6,8),(7,13),(8,18),(9,11),(9,12),(257425408,7), - (576061440,3); - -EXPLAIN -SELECT t1 .i AS f FROM t1, t2 - WHERE t2.i = t1.pk AND t1.pk BETWEEN 0 AND 224 - HAVING f > 7 - ORDER BY f; -SELECT t1 .i AS f FROM t1, t2 - WHERE t2.i = t1.pk AND t1.pk BETWEEN 0 AND 224 - HAVING f > 7 - ORDER BY f; - -DROP TABLE t1, t2; - ---echo # ---echo # Test for bug #56619 - Assertion failed during ---echo # ALTER TABLE RENAME, DISABLE KEYS ---echo # - ---disable_warnings -DROP TABLE IF EXISTS t1, t2; ---enable_warnings -CREATE TABLE t1 (a INT, INDEX(a)) engine=innodb; ---disable_warnings -ALTER TABLE t1 RENAME TO t2, DISABLE KEYS; -DROP TABLE IF EXISTS t1, t2; ---enable_warnings - ---echo # ---echo # Bug#702322: HAVING with two ANDed predicates + ORDER BY ---echo # - -CREATE TABLE t1 (pk int PRIMARY KEY, a int, KEY (a)) ENGINE=InnoDB; -CREATE TABLE t2 (a int, KEY (a)) ENGINE=InnoDB; - -INSERT INTO t1 VALUES - (18,0),(9,10),(8,11),(2,15),(7,19),(1,20); - -SET SESSION join_cache_level = 0; - -# vanilla InnoDB doesn't do ICP ---replace_result "Using where" "Using index condition" -EXPLAIN -SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.pk = t2.a - WHERE t1.pk >= 6 HAVING t1.a<> 0 AND t1.a <> 11 - ORDER BY t1.a; -SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.pk = t2.a - WHERE t1.pk >= 6 HAVING t1.a<> 0 AND t1.a <> 11 - ORDER BY t1.a; - -DROP TABLE t1,t2; - ---echo End of 5.3 tests --echo # --echo # Test for bug #11762012 - "54553: INNODB ASSERTS IN HA_INNOBASE:: @@ -1120,7 +851,41 @@ UPDATE t1 SET c = 5; UNLOCK TABLES; DROP TEMPORARY TABLE t1; ---echo End of 5.1 tests +--echo # End of 5.1 tests + + +--echo # +--echo # Bug#49604 "6.0 processing compound WHERE clause incorrectly +--echo # with Innodb - extra rows" +--echo # + +CREATE TABLE t1 ( + c1 INT NOT NULL, + c2 INT, + PRIMARY KEY (c1), + KEY k1 (c2) +) ENGINE=InnoDB; + +INSERT INTO t1 VALUES (12,1); +INSERT INTO t1 VALUES (15,1); +INSERT INTO t1 VALUES (16,1); +INSERT INTO t1 VALUES (22,1); +INSERT INTO t1 VALUES (20,2); + +CREATE TABLE t2 ( + c1 INT NOT NULL, + c2 INT, + PRIMARY KEY (c1) +) ENGINE=InnoDB; + +INSERT INTO t2 VALUES (1,2); +INSERT INTO t2 VALUES (2,9); + +SELECT STRAIGHT_JOIN t2.c2, t1.c2, t2.c1 +FROM t1 JOIN t2 ON t1.c2 = t2.c1 +WHERE t2.c1 IN (2, 1, 6) OR t2.c1 NOT IN (1); + +DROP TABLE t1, t2; --echo # @@ -1160,12 +925,64 @@ connection default; COMMIT; DROP TABLE t1; DROP FUNCTION f1; +--echo # +--echo # Bug#42744: Crash when using a join buffer to join a table with a blob +--echo # column and an additional column used for duplicate elimination. +--echo # + +CREATE TABLE t1 (a tinyblob) ENGINE=InnoDB; +CREATE TABLE t2 (a int PRIMARY KEY, b tinyblob) ENGINE=InnoDB; +INSERT INTO t1 VALUES ('1'), (NULL); +INSERT INTO t2 VALUES (1, '1'); + +EXPLAIN +SELECT t2.b FROM t1,t2 WHERE t1.a IN (SELECT 1 FROM t2); + +SELECT t2.b FROM t1,t2 WHERE t1.a IN (SELECT 1 FROM t2); + +DROP TABLE t1,t2; + +--echo # +--echo # Bug#48093: 6.0 Server not processing equivalent IN clauses properly +--echo # with Innodb tables +--echo # + +CREATE TABLE t1 ( + i int(11) DEFAULT NULL, + v1 varchar(1) DEFAULT NULL, + v2 varchar(20) DEFAULT NULL, + KEY i (i), + KEY v (v1,i) +) ENGINE=innodb; + +INSERT INTO t1 VALUES (1,'f','no'); +INSERT INTO t1 VALUES (2,'u','yes-u'); +INSERT INTO t1 VALUES (2,'h','yes-h'); +INSERT INTO t1 VALUES (3,'d','no'); + +--echo +SELECT v2 +FROM t1 +WHERE v1 IN ('f', 'd', 'h', 'u' ) AND i = 2; + +--echo +--echo # Should not use index_merge +EXPLAIN +SELECT v2 +FROM t1 +WHERE v1 IN ('f', 'd', 'h', 'u' ) AND i = 2; + +DROP TABLE t1; --echo # --echo # Bug#54606 innodb fast alter table + pack_keys=0 --echo # prevents adding new indexes --echo # +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + CREATE TABLE t1 (a INT, b CHAR(9), c INT, key(b)) ENGINE=InnoDB PACK_KEYS=0; @@ -1174,4 +991,38 @@ CREATE INDEX c on t1 (c); DROP TABLE t1; ---echo End of 5.1 tests + +--echo # +--echo # Additional coverage for refactoring which is made as part +--echo # of fix for Bug#27480 "Extend CREATE TEMPORARY TABLES privilege +--echo # to allow temp table operations". +--echo # +--echo # Check that OPTIMIZE table works for temporary InnoDB tables. +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +CREATE TEMPORARY TABLE t1 (a INT) ENGINE=InnoDB; +OPTIMIZE TABLE t1; +DROP TABLE t1; + + +--echo # +--echo # Bug#11762345 54927: DROPPING AND ADDING AN INDEX IN ONE +--echo # COMMAND CAN FAIL IN INNODB PLUGIN 1.0 +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (id int, a int, b int, PRIMARY KEY (id), + INDEX a (a)) ENGINE=innodb; + +ALTER TABLE t1 DROP INDEX a, ADD INDEX a (b, a); +# This used to fail +ALTER TABLE t1 DROP INDEX a, ADD INDEX (a, b); + +DROP TABLE t1; + + +--echo End of 6.0 tests diff --git a/mysql-test/t/sp-bugs.test b/mysql-test/t/sp-bugs.test index 3ab1689e8b2..1ec154f1c69 100644 --- a/mysql-test/t/sp-bugs.test +++ b/mysql-test/t/sp-bugs.test @@ -167,6 +167,15 @@ USE test; --echo End of 5.1 tests --echo # +--echo # BUG#13489996 valgrind:conditional jump or move depends on +--echo # uninitialised values-field_blob +--echo # + +CREATE FUNCTION sf() RETURNS BLOB RETURN ""; +SELECT sf(); +DROP FUNCTION sf; + +--echo # --echo # Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE --echo # SET @@SQL_MODE = ''; @@ -228,3 +237,4 @@ DROP PROCEDURE testp_bug11763507; DROP FUNCTION testf_bug11763507; --echo #END OF BUG#11763507 test. + diff --git a/sql/field.cc b/sql/field.cc index a70bbe08469..d84baac41f5 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1759,7 +1759,7 @@ uint Field::fill_cache_field(CACHE_FIELD *copy) if (flags & BLOB_FLAG) { copy->type= CACHE_BLOB; - copy->length-= table->s->blob_ptr_size; + copy->length-= portable_sizeof_char_ptr; return copy->length; } else if (!zero_pack() && @@ -9572,11 +9572,6 @@ Create_field::Create_field(Field *old_field,Field *orig_field) option_list= old_field->option_list; option_struct= old_field->option_struct; - /* Fix if the original table had 4 byte pointer blobs */ - if (flags & BLOB_FLAG) - pack_length= (pack_length- old_field->table->s->blob_ptr_size + - portable_sizeof_char_ptr); - switch (sql_type) { case MYSQL_TYPE_BLOB: switch (pack_length - portable_sizeof_char_ptr) { diff --git a/sql/field.h b/sql/field.h index f58833629b2..3b4285c9cc9 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1986,6 +1986,7 @@ public: Field_blob(uint32 packlength_arg) :Field_longstr((uchar*) 0, 0, (uchar*) "", 0, NONE, "temp", system_charset_info), packlength(packlength_arg) {} + /* Note that the default copy constructor is used, in clone() */ enum_field_types type() const { return MYSQL_TYPE_BLOB;} bool match_collation_to_optimize_range() const { return TRUE; } enum ha_base_keytype key_type() const @@ -2011,7 +2012,7 @@ public: uint32 key_length() const { return 0; } void sort_string(uchar *buff,uint length); uint32 pack_length() const - { return (uint32) (packlength+table->s->blob_ptr_size); } + { return (uint32) (packlength + portable_sizeof_char_ptr); } /** Return the packed length without the pointer size added. @@ -2486,9 +2487,6 @@ public: { return 255 - FRM_VCOL_HEADER_SIZE(interval != NULL); } - -private: - const String empty_set_string; }; diff --git a/sql/field_conv.cc b/sql/field_conv.cc index c652ee12c93..c4cc8d53ae4 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -712,8 +712,8 @@ Copy_field::get_copy_func(Field *to,Field *from) if (from_length != to_length) { // Correct pointer to point at char pointer - to_ptr+= to_length - to->table->s->blob_ptr_size; - from_ptr+= from_length- from->table->s->blob_ptr_size; + to_ptr+= to_length - portable_sizeof_char_ptr; + from_ptr+= from_length - portable_sizeof_char_ptr; return do_copy_blob; } } diff --git a/sql/item.cc b/sql/item.cc index f004f25b18c..ab7806cfd0e 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5673,10 +5673,6 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length) field= new Field_double((uchar*) 0, max_length, null_ptr, 0, Field::NONE, name, decimals, 0, unsigned_flag); break; - case MYSQL_TYPE_NULL: - field= new Field_null((uchar*) 0, max_length, Field::NONE, - name, &my_charset_bin); - break; case MYSQL_TYPE_INT24: field= new Field_medium((uchar*) 0, max_length, null_ptr, 0, Field::NONE, name, 0, unsigned_flag); @@ -5709,6 +5705,7 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length) /* This case should never be chosen */ DBUG_ASSERT(0); /* If something goes awfully wrong, it's better to get a string than die */ + case MYSQL_TYPE_NULL: case MYSQL_TYPE_STRING: if (fixed_length && !too_big_for_varchar()) { diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index c3ddf3831c4..aa31c44a385 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -3919,7 +3919,6 @@ SJ_TMP_TABLE::create_sj_weedout_tmp_table(THD *thd) table->s= share; init_tmp_table_share(thd, share, "", 0, tmpname, tmpname); share->blob_field= blob_field; - share->blob_ptr_size= portable_sizeof_char_ptr; share->table_charset= NULL; share->primary_key= MAX_KEY; // Indicate no primary key share->keys_for_keyread.init(); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index f7b6fc529b2..bd8f72d408d 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -129,6 +129,7 @@ Key::Key(const Key &rhs, MEM_ROOT *mem_root) Foreign_key::Foreign_key(const Foreign_key &rhs, MEM_ROOT *mem_root) :Key(rhs,mem_root), + ref_db(rhs.ref_db), ref_table(rhs.ref_table), ref_columns(rhs.ref_columns,mem_root), delete_opt(rhs.delete_opt), diff --git a/sql/sql_const.h b/sql/sql_const.h index 9849f10b6ac..ec91fd02289 100644 --- a/sql/sql_const.h +++ b/sql/sql_const.h @@ -76,7 +76,6 @@ /* Some portable defines */ -#define portable_sizeof_char_ptr 8 #define STRING_BUFFER_USUAL_SIZE 80 /* Memory allocated when parsing a statement / saving a statement */ diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 12222fddca9..37b355f1d66 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3839,7 +3839,6 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, init_tmp_table_share(thd, &share, "", 0, "", ""); tmp_table.s->db_create_options=0; - tmp_table.s->blob_ptr_size= portable_sizeof_char_ptr; tmp_table.null_row= 0; tmp_table.maybe_null= 0; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f865be44ea3..cf01cd330f9 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -14436,7 +14436,6 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, table->s= share; init_tmp_table_share(thd, share, "", 0, tmpname, tmpname); share->blob_field= blob_field; - share->blob_ptr_size= portable_sizeof_char_ptr; share->table_charset= param->table_charset; share->primary_key= MAX_KEY; // Indicate no primary key share->keys_for_keyread.init(); @@ -15163,7 +15162,6 @@ TABLE *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list) table->temp_pool_slot= MY_BIT_NONE; share->blob_field= blob_field; share->fields= field_count; - share->blob_ptr_size= portable_sizeof_char_ptr; setup_tmp_table_column_bitmaps(table, bitmaps); /* Create all fields and calculate the total length of record */ @@ -15371,7 +15369,8 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo, seg->type= ((keyinfo->key_part[i].key_type & FIELDFLAG_BINARY) ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2); - seg->bit_start= (uint8)(field->pack_length() - share->blob_ptr_size); + seg->bit_start= (uint8)(field->pack_length() - + portable_sizeof_char_ptr); seg->flag= HA_BLOB_PART; seg->length=0; // Whole blob in unique constraint } @@ -15533,7 +15532,7 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo, seg->type= ((keyinfo->key_part[i].key_type & FIELDFLAG_BINARY) ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2); - seg->bit_start= (uint8)(field->pack_length() - share->blob_ptr_size); + seg->bit_start= (uint8)(field->pack_length() - portable_sizeof_char_ptr); seg->flag= HA_BLOB_PART; seg->length=0; // Whole blob in unique constraint } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index ef8115f8407..f0ad42fe6b2 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5410,6 +5410,10 @@ static bool fill_alter_inplace_info(THD *thd, */ for (f_ptr= table->field; (field= *f_ptr); f_ptr++) { + /* Clear marker for renamed or dropped field + which we are going to set later. */ + field->flags&= ~(FIELD_IS_RENAMED | FIELD_IS_DROPPED); + /* Use transformed info to evaluate flags for storage engine. */ uint new_field_index= 0; new_field_it.init(alter_info->create_list); @@ -5498,6 +5502,7 @@ static bool fill_alter_inplace_info(THD *thd, if (my_strcasecmp(system_charset_info, field->field_name, new_field->field_name)) { + field->flags|= FIELD_IS_RENAMED; ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_NAME; rename_column_in_stat_tables(thd, table, field, new_field->field_name); @@ -5543,6 +5548,7 @@ static bool fill_alter_inplace_info(THD *thd, Corresponding storage engine flag should be already set. */ DBUG_ASSERT(ha_alter_info->handler_flags & Alter_inplace_info::DROP_COLUMN); + field->flags|= FIELD_IS_DROPPED; } } @@ -6895,8 +6901,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, if (key->type == Key::FOREIGN_KEY && ((Foreign_key *)key)->validate(new_create_list)) goto err; - if (key->type != Key::FOREIGN_KEY) - new_key_list.push_back(key); + new_key_list.push_back(key); if (key->name.str && !my_strcasecmp(system_charset_info, key->name.str, primary_key_name)) { diff --git a/sql/table.cc b/sql/table.cc index a7d330636c9..a386510f180 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -868,8 +868,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, share->table_charset= default_charset_info; } share->db_record_offset= 1; - if (db_create_options & HA_OPTION_LONG_BLOB_PTR) - share->blob_ptr_size= portable_sizeof_char_ptr; error=4; share->max_rows= uint4korr(head+18); share->min_rows= uint4korr(head+22); diff --git a/sql/table.h b/sql/table.h index 2508c5f76da..1e4774e021e 100644 --- a/sql/table.h +++ b/sql/table.h @@ -655,7 +655,6 @@ struct TABLE_SHARE enum ha_choice page_checksum; uint ref_count; /* How many TABLE objects uses this */ - uint blob_ptr_size; /* 4 or 8 */ uint key_block_size; /* create key_block_size, if used */ uint stats_sample_pages; /* number of pages to sample during stats estimation, if used, otherwise 0. */ diff --git a/sql/unireg.cc b/sql/unireg.cc index a546fb769b3..fca4dc200c3 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -1122,7 +1122,6 @@ static bool make_empty_rec(THD *thd, File file,enum legacy_db_type table_type, } table.in_use= thd; - table.s->blob_ptr_size= portable_sizeof_char_ptr; null_count=0; if (!(table_options & HA_OPTION_PACK_RECORD)) diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 1c37c4f811d..6b74140a828 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -564,7 +564,7 @@ static int table2maria(TABLE *table_arg, data_file_type row_type, keydef[i].seg[j].flag|= HA_BLOB_PART; /* save number of bytes used to pack length */ keydef[i].seg[j].bit_start= (uint) (field->pack_length() - - share->blob_ptr_size); + portable_sizeof_char_ptr); } else if (field->type() == MYSQL_TYPE_BIT) { diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 9d53372d467..dc0a0317fdb 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -300,7 +300,7 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out, keydef[i].seg[j].flag|= HA_BLOB_PART; /* save number of bytes used to pack length */ keydef[i].seg[j].bit_start= (uint) (field->pack_length() - - share->blob_ptr_size); + portable_sizeof_char_ptr); } else if (field->type() == MYSQL_TYPE_BIT) { |