Loading mysql-test/r/innodb.result +115 −66 Original line number Diff line number Diff line Loading @@ -234,7 +234,7 @@ n after commit commit; insert into t1 values (5); insert into t1 values (4); ERROR 23000: Duplicate entry '4' for key 1 ERROR 23000: Duplicate entry '4' for key 'PRIMARY' commit; select n, "after commit" from t1; n after commit Loading @@ -243,7 +243,7 @@ n after commit set autocommit=1; insert into t1 values (6); insert into t1 values (4); ERROR 23000: Duplicate entry '4' for key 1 ERROR 23000: Duplicate entry '4' for key 'PRIMARY' select n from t1; n 4 Loading Loading @@ -318,7 +318,7 @@ drop table t1; CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=innodb; insert into t1 values ('pippo', 12); insert into t1 values ('pippo', 12); ERROR 23000: Duplicate entry 'pippo' for key 1 ERROR 23000: Duplicate entry 'pippo' for key 'PRIMARY' delete from t1; delete from t1 where id = 'pippo'; select * from t1; Loading Loading @@ -482,9 +482,9 @@ UNIQUE ggid (ggid) insert into t1 (ggid,passwd) values ('test1','xxx'); insert into t1 (ggid,passwd) values ('test2','yyy'); insert into t1 (ggid,passwd) values ('test2','this will fail'); ERROR 23000: Duplicate entry 'test2' for key 2 ERROR 23000: Duplicate entry 'test2' for key 'ggid' insert into t1 (ggid,id) values ('this will fail',1); ERROR 23000: Duplicate entry '1' for key 1 ERROR 23000: Duplicate entry '1' for key 'PRIMARY' select * from t1 where ggid='test1'; id ggid email passwd 1 test1 xxx Loading @@ -497,7 +497,7 @@ id ggid email passwd replace into t1 (ggid,id) values ('this will work',1); replace into t1 (ggid,passwd) values ('test2','this will work'); update t1 set id=100,ggid='test2' where id=1; ERROR 23000: Duplicate entry 'test2' for key 2 ERROR 23000: Duplicate entry 'test2' for key 'ggid' select * from t1; id ggid email passwd 1 this will work Loading Loading @@ -816,7 +816,7 @@ create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(3 insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); LOCK TABLES t1 WRITE; insert into t1 values (99,1,2,'D'),(1,1,2,'D'); ERROR 23000: Duplicate entry '1-1' for key 1 ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY' select id from t1; id 0 Loading @@ -834,7 +834,7 @@ insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJ LOCK TABLES t1 WRITE; begin; insert into t1 values (99,1,2,'D'),(1,1,2,'D'); ERROR 23000: Duplicate entry '1-1' for key 1 ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY' select id from t1; id 0 Loading @@ -856,7 +856,7 @@ create table t1 (a char(20), index (a(5))) engine=innodb; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` char(20) default NULL, `a` char(20) DEFAULT NULL, KEY `a` (`a`(5)) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t1; Loading Loading @@ -1587,7 +1587,7 @@ create table t2 (id int(11) not null auto_increment, id2 int(11) not null, const show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `id` int(11) NOT NULL auto_increment, `id` int(11) NOT NULL AUTO_INCREMENT, `id2` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `id` (`id`,`id2`), Loading @@ -1598,7 +1598,7 @@ create table t2 (id int(11) not null auto_increment, id2 int(11) not null, const show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `id` int(11) NOT NULL auto_increment, `id` int(11) NOT NULL AUTO_INCREMENT, `id2` int(11) NOT NULL, KEY `t1_id_fk` (`id`), CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) Loading @@ -1607,7 +1607,7 @@ alter table t2 add index id_test (id), add index id_test2 (id,id2); show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `id` int(11) NOT NULL auto_increment, `id` int(11) NOT NULL AUTO_INCREMENT, `id2` int(11) NOT NULL, KEY `id_test` (`id`), KEY `id_test2` (`id`,`id2`), Loading @@ -1615,13 +1615,13 @@ t2 CREATE TABLE `t2` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t2; create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb; ERROR HY000: Can't create table './test/t2' (errno: 150) ERROR HY000: Can't create table 'test.t2' (errno: 150) create table t2 (a int auto_increment primary key, b int, index(b), foreign key (b) references t1(id), unique(b)) engine=innodb; show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL, `a` int(11) NOT NULL AUTO_INCREMENT, `b` int(11) DEFAULT NULL, PRIMARY KEY (`a`), UNIQUE KEY `b_2` (`b`), KEY `b` (`b`), Loading @@ -1632,8 +1632,8 @@ create table t2 (a int auto_increment primary key, b int, foreign key (b) refere show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL, `a` int(11) NOT NULL AUTO_INCREMENT, `b` int(11) DEFAULT NULL, PRIMARY KEY (`a`), UNIQUE KEY `b` (`b`), CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`), Loading Loading @@ -1821,7 +1821,7 @@ Variable_name Value innodb_sync_spin_loops 20 show variables like "innodb_thread_concurrency"; Variable_name Value innodb_thread_concurrency 8 innodb_thread_concurrency 20 set global innodb_thread_concurrency=1001; show variables like "innodb_thread_concurrency"; Variable_name Value Loading @@ -1829,7 +1829,7 @@ innodb_thread_concurrency 1000 set global innodb_thread_concurrency=0; show variables like "innodb_thread_concurrency"; Variable_name Value innodb_thread_concurrency 0 innodb_thread_concurrency 1 set global innodb_thread_concurrency=16; show variables like "innodb_thread_concurrency"; Variable_name Value Loading Loading @@ -1881,40 +1881,40 @@ concat('*',v,'*',c,'*',t,'*') show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` varchar(10) default NULL, `c` char(10) default NULL, `v` varchar(10) DEFAULT NULL, `c` char(10) DEFAULT NULL, `t` text ) ENGINE=InnoDB DEFAULT CHARSET=latin1 create table t2 like t1; show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `v` varchar(10) default NULL, `c` char(10) default NULL, `v` varchar(10) DEFAULT NULL, `c` char(10) DEFAULT NULL, `t` text ) ENGINE=InnoDB DEFAULT CHARSET=latin1 create table t3 select * from t1; show create table t3; Table Create Table t3 CREATE TABLE `t3` ( `v` varchar(10) default NULL, `c` char(10) default NULL, `v` varchar(10) DEFAULT NULL, `c` char(10) DEFAULT NULL, `t` text ) ENGINE=InnoDB DEFAULT CHARSET=latin1 alter table t1 modify c varchar(10); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` varchar(10) default NULL, `c` varchar(10) default NULL, `v` varchar(10) DEFAULT NULL, `c` varchar(10) DEFAULT NULL, `t` text ) ENGINE=InnoDB DEFAULT CHARSET=latin1 alter table t1 modify v char(10); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` char(10) default NULL, `c` varchar(10) default NULL, `v` char(10) DEFAULT NULL, `c` varchar(10) DEFAULT NULL, `t` text ) ENGINE=InnoDB DEFAULT CHARSET=latin1 alter table t1 modify t varchar(10); Loading @@ -1923,9 +1923,9 @@ Note 1265 Data truncated for column 't' at row 2 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` char(10) default NULL, `c` varchar(10) default NULL, `t` varchar(10) default NULL `v` char(10) DEFAULT NULL, `c` varchar(10) DEFAULT NULL, `t` varchar(10) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 select concat('*',v,'*',c,'*',t,'*') from t1; concat('*',v,'*',c,'*',t,'*') Loading @@ -1936,8 +1936,8 @@ create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10))); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` varchar(10) default NULL, `c` char(10) default NULL, `v` varchar(10) DEFAULT NULL, `c` char(10) DEFAULT NULL, `t` text, KEY `v` (`v`), KEY `c` (`c`), Loading Loading @@ -2002,7 +2002,7 @@ explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref v v 13 const # Using where; Using index alter table t1 add unique(v); ERROR 23000: Duplicate entry '{ ' for key 1 ERROR 23000: Duplicate entry '{ ' for key 'v_2' alter table t1 add key(v); select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a'; qq Loading Loading @@ -2155,8 +2155,8 @@ alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` varchar(300) default NULL, `c` char(10) default NULL, `v` varchar(300) DEFAULT NULL, `c` char(10) DEFAULT NULL, `t` text, KEY `c` (`c`), KEY `t` (`t`(10)), Loading Loading @@ -2235,8 +2235,8 @@ alter table t1 drop key v, add key v (v(30)); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` varchar(300) default NULL, `c` char(10) default NULL, `v` varchar(300) DEFAULT NULL, `c` char(10) DEFAULT NULL, `t` text, KEY `c` (`c`), KEY `t` (`t`(10)), Loading Loading @@ -2315,8 +2315,8 @@ alter table t1 modify v varchar(600), drop key v, add key v (v); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` varchar(600) default NULL, `c` char(10) default NULL, `v` varchar(600) DEFAULT NULL, `c` char(10) DEFAULT NULL, `t` text, KEY `c` (`c`), KEY `t` (`t`(10)), Loading Loading @@ -2362,16 +2362,16 @@ drop table t1; create table t1 (a char(10), unique (a)); insert into t1 values ('a '); insert into t1 values ('a '); ERROR 23000: Duplicate entry 'a' for key 1 ERROR 23000: Duplicate entry 'a' for key 'a' alter table t1 modify a varchar(10); insert into t1 values ('a '),('a '),('a '),('a '); ERROR 23000: Duplicate entry 'a ' for key 1 ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); ERROR 23000: Duplicate entry 'a ' for key 1 ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); ERROR 23000: Duplicate entry 'a ' for key 1 ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); ERROR 23000: Duplicate entry 'a ' for key 1 ERROR 23000: Duplicate entry 'a ' for key 'a' update t1 set a='a ' where a like 'a%'; select concat(a,'.') from t1; concat(a,'.') Loading @@ -2393,8 +2393,8 @@ create table t1 (v varchar(10), c char(10), t text, key(v(5)), key(c(5)), key(t( show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` varchar(10) default NULL, `c` char(10) default NULL, `v` varchar(10) DEFAULT NULL, `c` char(10) DEFAULT NULL, `t` text, KEY `v` (`v`(5)), KEY `c` (`c`(5)), Loading @@ -2405,15 +2405,15 @@ create table t1 (v char(10) character set utf8); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` char(10) character set utf8 default NULL `v` char(10) CHARACTER SET utf8 DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t1; create table t1 (v varchar(10), c char(10)) row_format=fixed; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` varchar(10) default NULL, `c` char(10) default NULL `v` varchar(10) DEFAULT NULL, `c` char(10) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED insert into t1 values('a','a'),('a ','a '); select concat('*',v,'*',c,'*') from t1; Loading Loading @@ -2455,7 +2455,7 @@ Note 1246 Converting column 'v' from VARCHAR to TEXT show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` mediumtext character set utf8 `v` mediumtext CHARACTER SET utf8 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t1; set storage_engine=MyISAM; Loading Loading @@ -2494,7 +2494,7 @@ key (rowid), unique(val)) engine=innodb; replace into t1 (val) values ('1'),('2'); replace into t1 (val) values ('1'),('2'); insert into t1 (val) values ('1'),('2'); ERROR 23000: Duplicate entry '1' for key 2 ERROR 23000: Duplicate entry '1' for key 'val' select * from t1; rowid val 3 1 Loading @@ -2504,7 +2504,7 @@ create table t1 (a int not null auto_increment primary key, val int) engine=Inno insert into t1 (val) values (1); update t1 set a=2 where a=1; insert into t1 (val) values (1); ERROR 23000: Duplicate entry '2' for key 1 ERROR 23000: Duplicate entry '2' for key 'PRIMARY' select * from t1; a val 2 1 Loading Loading @@ -2582,8 +2582,8 @@ character set = latin1 engine = innodb; show create table t9; Table Create Table t9 CREATE TABLE `t9` ( `col1` varchar(512) default NULL, `col2` varchar(512) default NULL, `col1` varchar(512) DEFAULT NULL, `col2` varchar(512) DEFAULT NULL, KEY `col1` (`col1`,`col2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t1, t2, t3, t4, t5, t6, t7, t8, t9; Loading @@ -2606,7 +2606,7 @@ Warning 1071 Specified key was too long; max key length is 767 bytes show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `col1` varchar(768) default NULL, `col1` varchar(768) DEFAULT NULL, KEY `col1` (`col1`(767)) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t1, t2, t3, t4; Loading Loading @@ -2885,13 +2885,13 @@ commit; set foreign_key_checks=0; create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb; create table t1(a char(10) primary key, b varchar(20)) engine = innodb; ERROR HY000: Can't create table './test/t1.frm' (errno: 150) ERROR HY000: Can't create table 'test.t1' (errno: 150) set foreign_key_checks=1; drop table t2; set foreign_key_checks=0; create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1; create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8; ERROR HY000: Can't create table './test/t2.frm' (errno: 150) ERROR HY000: Can't create table 'test.t2' (errno: 150) set foreign_key_checks=1; drop table t1; set foreign_key_checks=0; Loading Loading @@ -2962,13 +2962,13 @@ create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb; create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb; insert into t1 values (0x41),(0x4120),(0x4100); insert into t2 values (0x41),(0x4120),(0x4100); ERROR 23000: Duplicate entry 'A' for key 1 ERROR 23000: Duplicate entry 'A' for key 'PRIMARY' insert into t2 values (0x41),(0x4120); insert into t3 values (0x41),(0x4120),(0x4100); ERROR 23000: Duplicate entry 'A ' for key 1 ERROR 23000: Duplicate entry 'A ' for key 'PRIMARY' insert into t3 values (0x41),(0x4100); insert into t4 values (0x41),(0x4120),(0x4100); ERROR 23000: Duplicate entry 'A' for key 1 ERROR 23000: Duplicate entry 'A' for key 'PRIMARY' insert into t4 values (0x41),(0x4100); select hex(s1) from t1; hex(s1) Loading Loading @@ -3170,7 +3170,7 @@ ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0; SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( `a` int(11) default NULL, `a` int(11) DEFAULT NULL, KEY `t2_ibfk_0` (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 DROP TABLE t2,t1; Loading Loading @@ -3232,6 +3232,55 @@ drop trigger t2t; drop trigger t3t; drop trigger t4t; drop table t1, t2, t3, t4, t5; CREATE TABLE t1 ( field1 varchar(8) NOT NULL DEFAULT '', field2 varchar(8) NOT NULL DEFAULT '', PRIMARY KEY (field1, field2) ) ENGINE=InnoDB; CREATE TABLE t2 ( field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY, FOREIGN KEY (field1) REFERENCES t1 (field1) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; INSERT INTO t1 VALUES ('old', 'somevalu'); INSERT INTO t1 VALUES ('other', 'anyvalue'); INSERT INTO t2 VALUES ('old'); INSERT INTO t2 VALUES ('other'); UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu'; ERROR 23000: Upholding foreign key constraints for table 't1', entry 'other-somevalu', key 1 would lead to a duplicate entry DROP TABLE t2; DROP TABLE t1; create table t1 ( c1 bigint not null, c2 bigint not null, primary key (c1), unique key (c2) ) engine=innodb; create table t2 ( c1 bigint not null, primary key (c1) ) engine=innodb; alter table t1 add constraint c2_fk foreign key (c2) references t2(c1) on delete cascade; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` bigint(20) NOT NULL, PRIMARY KEY (`c1`), UNIQUE KEY `c2` (`c2`), CONSTRAINT `c2_fk` FOREIGN KEY (`c2`) REFERENCES `t2` (`c1`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1 alter table t1 drop foreign key c2_fk; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` bigint(20) NOT NULL, PRIMARY KEY (`c1`), UNIQUE KEY `c2` (`c2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t1, t2; create table t1(a date) engine=innodb; create table t2(a date, key(a)) engine=innodb; insert into t1 values('2005-10-01'); Loading mysql-test/t/innodb.test +54 −0 Original line number Diff line number Diff line Loading @@ -2128,6 +2128,60 @@ connection default; disconnect a; disconnect b; # # Test that cascading updates leading to duplicate keys give the correct # error message (bug #9680) # CREATE TABLE t1 ( field1 varchar(8) NOT NULL DEFAULT '', field2 varchar(8) NOT NULL DEFAULT '', PRIMARY KEY (field1, field2) ) ENGINE=InnoDB; CREATE TABLE t2 ( field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY, FOREIGN KEY (field1) REFERENCES t1 (field1) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; INSERT INTO t1 VALUES ('old', 'somevalu'); INSERT INTO t1 VALUES ('other', 'anyvalue'); INSERT INTO t2 VALUES ('old'); INSERT INTO t2 VALUES ('other'); --error ER_FOREIGN_DUPLICATE_KEY UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu'; DROP TABLE t2; DROP TABLE t1; # # Bug#18477 - MySQL/InnoDB Ignoring Foreign Keys in ALTER TABLE # create table t1 ( c1 bigint not null, c2 bigint not null, primary key (c1), unique key (c2) ) engine=innodb; # create table t2 ( c1 bigint not null, primary key (c1) ) engine=innodb; # alter table t1 add constraint c2_fk foreign key (c2) references t2(c1) on delete cascade; show create table t1; # alter table t1 drop foreign key c2_fk; show create table t1; # drop table t1, t2; # # Bug #14360: problem with intervals # Loading Loading
mysql-test/r/innodb.result +115 −66 Original line number Diff line number Diff line Loading @@ -234,7 +234,7 @@ n after commit commit; insert into t1 values (5); insert into t1 values (4); ERROR 23000: Duplicate entry '4' for key 1 ERROR 23000: Duplicate entry '4' for key 'PRIMARY' commit; select n, "after commit" from t1; n after commit Loading @@ -243,7 +243,7 @@ n after commit set autocommit=1; insert into t1 values (6); insert into t1 values (4); ERROR 23000: Duplicate entry '4' for key 1 ERROR 23000: Duplicate entry '4' for key 'PRIMARY' select n from t1; n 4 Loading Loading @@ -318,7 +318,7 @@ drop table t1; CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=innodb; insert into t1 values ('pippo', 12); insert into t1 values ('pippo', 12); ERROR 23000: Duplicate entry 'pippo' for key 1 ERROR 23000: Duplicate entry 'pippo' for key 'PRIMARY' delete from t1; delete from t1 where id = 'pippo'; select * from t1; Loading Loading @@ -482,9 +482,9 @@ UNIQUE ggid (ggid) insert into t1 (ggid,passwd) values ('test1','xxx'); insert into t1 (ggid,passwd) values ('test2','yyy'); insert into t1 (ggid,passwd) values ('test2','this will fail'); ERROR 23000: Duplicate entry 'test2' for key 2 ERROR 23000: Duplicate entry 'test2' for key 'ggid' insert into t1 (ggid,id) values ('this will fail',1); ERROR 23000: Duplicate entry '1' for key 1 ERROR 23000: Duplicate entry '1' for key 'PRIMARY' select * from t1 where ggid='test1'; id ggid email passwd 1 test1 xxx Loading @@ -497,7 +497,7 @@ id ggid email passwd replace into t1 (ggid,id) values ('this will work',1); replace into t1 (ggid,passwd) values ('test2','this will work'); update t1 set id=100,ggid='test2' where id=1; ERROR 23000: Duplicate entry 'test2' for key 2 ERROR 23000: Duplicate entry 'test2' for key 'ggid' select * from t1; id ggid email passwd 1 this will work Loading Loading @@ -816,7 +816,7 @@ create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(3 insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); LOCK TABLES t1 WRITE; insert into t1 values (99,1,2,'D'),(1,1,2,'D'); ERROR 23000: Duplicate entry '1-1' for key 1 ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY' select id from t1; id 0 Loading @@ -834,7 +834,7 @@ insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJ LOCK TABLES t1 WRITE; begin; insert into t1 values (99,1,2,'D'),(1,1,2,'D'); ERROR 23000: Duplicate entry '1-1' for key 1 ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY' select id from t1; id 0 Loading @@ -856,7 +856,7 @@ create table t1 (a char(20), index (a(5))) engine=innodb; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` char(20) default NULL, `a` char(20) DEFAULT NULL, KEY `a` (`a`(5)) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t1; Loading Loading @@ -1587,7 +1587,7 @@ create table t2 (id int(11) not null auto_increment, id2 int(11) not null, const show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `id` int(11) NOT NULL auto_increment, `id` int(11) NOT NULL AUTO_INCREMENT, `id2` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `id` (`id`,`id2`), Loading @@ -1598,7 +1598,7 @@ create table t2 (id int(11) not null auto_increment, id2 int(11) not null, const show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `id` int(11) NOT NULL auto_increment, `id` int(11) NOT NULL AUTO_INCREMENT, `id2` int(11) NOT NULL, KEY `t1_id_fk` (`id`), CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) Loading @@ -1607,7 +1607,7 @@ alter table t2 add index id_test (id), add index id_test2 (id,id2); show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `id` int(11) NOT NULL auto_increment, `id` int(11) NOT NULL AUTO_INCREMENT, `id2` int(11) NOT NULL, KEY `id_test` (`id`), KEY `id_test2` (`id`,`id2`), Loading @@ -1615,13 +1615,13 @@ t2 CREATE TABLE `t2` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t2; create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb; ERROR HY000: Can't create table './test/t2' (errno: 150) ERROR HY000: Can't create table 'test.t2' (errno: 150) create table t2 (a int auto_increment primary key, b int, index(b), foreign key (b) references t1(id), unique(b)) engine=innodb; show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL, `a` int(11) NOT NULL AUTO_INCREMENT, `b` int(11) DEFAULT NULL, PRIMARY KEY (`a`), UNIQUE KEY `b_2` (`b`), KEY `b` (`b`), Loading @@ -1632,8 +1632,8 @@ create table t2 (a int auto_increment primary key, b int, foreign key (b) refere show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL, `a` int(11) NOT NULL AUTO_INCREMENT, `b` int(11) DEFAULT NULL, PRIMARY KEY (`a`), UNIQUE KEY `b` (`b`), CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`), Loading Loading @@ -1821,7 +1821,7 @@ Variable_name Value innodb_sync_spin_loops 20 show variables like "innodb_thread_concurrency"; Variable_name Value innodb_thread_concurrency 8 innodb_thread_concurrency 20 set global innodb_thread_concurrency=1001; show variables like "innodb_thread_concurrency"; Variable_name Value Loading @@ -1829,7 +1829,7 @@ innodb_thread_concurrency 1000 set global innodb_thread_concurrency=0; show variables like "innodb_thread_concurrency"; Variable_name Value innodb_thread_concurrency 0 innodb_thread_concurrency 1 set global innodb_thread_concurrency=16; show variables like "innodb_thread_concurrency"; Variable_name Value Loading Loading @@ -1881,40 +1881,40 @@ concat('*',v,'*',c,'*',t,'*') show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` varchar(10) default NULL, `c` char(10) default NULL, `v` varchar(10) DEFAULT NULL, `c` char(10) DEFAULT NULL, `t` text ) ENGINE=InnoDB DEFAULT CHARSET=latin1 create table t2 like t1; show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `v` varchar(10) default NULL, `c` char(10) default NULL, `v` varchar(10) DEFAULT NULL, `c` char(10) DEFAULT NULL, `t` text ) ENGINE=InnoDB DEFAULT CHARSET=latin1 create table t3 select * from t1; show create table t3; Table Create Table t3 CREATE TABLE `t3` ( `v` varchar(10) default NULL, `c` char(10) default NULL, `v` varchar(10) DEFAULT NULL, `c` char(10) DEFAULT NULL, `t` text ) ENGINE=InnoDB DEFAULT CHARSET=latin1 alter table t1 modify c varchar(10); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` varchar(10) default NULL, `c` varchar(10) default NULL, `v` varchar(10) DEFAULT NULL, `c` varchar(10) DEFAULT NULL, `t` text ) ENGINE=InnoDB DEFAULT CHARSET=latin1 alter table t1 modify v char(10); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` char(10) default NULL, `c` varchar(10) default NULL, `v` char(10) DEFAULT NULL, `c` varchar(10) DEFAULT NULL, `t` text ) ENGINE=InnoDB DEFAULT CHARSET=latin1 alter table t1 modify t varchar(10); Loading @@ -1923,9 +1923,9 @@ Note 1265 Data truncated for column 't' at row 2 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` char(10) default NULL, `c` varchar(10) default NULL, `t` varchar(10) default NULL `v` char(10) DEFAULT NULL, `c` varchar(10) DEFAULT NULL, `t` varchar(10) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 select concat('*',v,'*',c,'*',t,'*') from t1; concat('*',v,'*',c,'*',t,'*') Loading @@ -1936,8 +1936,8 @@ create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10))); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` varchar(10) default NULL, `c` char(10) default NULL, `v` varchar(10) DEFAULT NULL, `c` char(10) DEFAULT NULL, `t` text, KEY `v` (`v`), KEY `c` (`c`), Loading Loading @@ -2002,7 +2002,7 @@ explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref v v 13 const # Using where; Using index alter table t1 add unique(v); ERROR 23000: Duplicate entry '{ ' for key 1 ERROR 23000: Duplicate entry '{ ' for key 'v_2' alter table t1 add key(v); select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a'; qq Loading Loading @@ -2155,8 +2155,8 @@ alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` varchar(300) default NULL, `c` char(10) default NULL, `v` varchar(300) DEFAULT NULL, `c` char(10) DEFAULT NULL, `t` text, KEY `c` (`c`), KEY `t` (`t`(10)), Loading Loading @@ -2235,8 +2235,8 @@ alter table t1 drop key v, add key v (v(30)); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` varchar(300) default NULL, `c` char(10) default NULL, `v` varchar(300) DEFAULT NULL, `c` char(10) DEFAULT NULL, `t` text, KEY `c` (`c`), KEY `t` (`t`(10)), Loading Loading @@ -2315,8 +2315,8 @@ alter table t1 modify v varchar(600), drop key v, add key v (v); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` varchar(600) default NULL, `c` char(10) default NULL, `v` varchar(600) DEFAULT NULL, `c` char(10) DEFAULT NULL, `t` text, KEY `c` (`c`), KEY `t` (`t`(10)), Loading Loading @@ -2362,16 +2362,16 @@ drop table t1; create table t1 (a char(10), unique (a)); insert into t1 values ('a '); insert into t1 values ('a '); ERROR 23000: Duplicate entry 'a' for key 1 ERROR 23000: Duplicate entry 'a' for key 'a' alter table t1 modify a varchar(10); insert into t1 values ('a '),('a '),('a '),('a '); ERROR 23000: Duplicate entry 'a ' for key 1 ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); ERROR 23000: Duplicate entry 'a ' for key 1 ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); ERROR 23000: Duplicate entry 'a ' for key 1 ERROR 23000: Duplicate entry 'a ' for key 'a' insert into t1 values ('a '); ERROR 23000: Duplicate entry 'a ' for key 1 ERROR 23000: Duplicate entry 'a ' for key 'a' update t1 set a='a ' where a like 'a%'; select concat(a,'.') from t1; concat(a,'.') Loading @@ -2393,8 +2393,8 @@ create table t1 (v varchar(10), c char(10), t text, key(v(5)), key(c(5)), key(t( show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` varchar(10) default NULL, `c` char(10) default NULL, `v` varchar(10) DEFAULT NULL, `c` char(10) DEFAULT NULL, `t` text, KEY `v` (`v`(5)), KEY `c` (`c`(5)), Loading @@ -2405,15 +2405,15 @@ create table t1 (v char(10) character set utf8); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` char(10) character set utf8 default NULL `v` char(10) CHARACTER SET utf8 DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t1; create table t1 (v varchar(10), c char(10)) row_format=fixed; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` varchar(10) default NULL, `c` char(10) default NULL `v` varchar(10) DEFAULT NULL, `c` char(10) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED insert into t1 values('a','a'),('a ','a '); select concat('*',v,'*',c,'*') from t1; Loading Loading @@ -2455,7 +2455,7 @@ Note 1246 Converting column 'v' from VARCHAR to TEXT show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `v` mediumtext character set utf8 `v` mediumtext CHARACTER SET utf8 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t1; set storage_engine=MyISAM; Loading Loading @@ -2494,7 +2494,7 @@ key (rowid), unique(val)) engine=innodb; replace into t1 (val) values ('1'),('2'); replace into t1 (val) values ('1'),('2'); insert into t1 (val) values ('1'),('2'); ERROR 23000: Duplicate entry '1' for key 2 ERROR 23000: Duplicate entry '1' for key 'val' select * from t1; rowid val 3 1 Loading @@ -2504,7 +2504,7 @@ create table t1 (a int not null auto_increment primary key, val int) engine=Inno insert into t1 (val) values (1); update t1 set a=2 where a=1; insert into t1 (val) values (1); ERROR 23000: Duplicate entry '2' for key 1 ERROR 23000: Duplicate entry '2' for key 'PRIMARY' select * from t1; a val 2 1 Loading Loading @@ -2582,8 +2582,8 @@ character set = latin1 engine = innodb; show create table t9; Table Create Table t9 CREATE TABLE `t9` ( `col1` varchar(512) default NULL, `col2` varchar(512) default NULL, `col1` varchar(512) DEFAULT NULL, `col2` varchar(512) DEFAULT NULL, KEY `col1` (`col1`,`col2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t1, t2, t3, t4, t5, t6, t7, t8, t9; Loading @@ -2606,7 +2606,7 @@ Warning 1071 Specified key was too long; max key length is 767 bytes show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `col1` varchar(768) default NULL, `col1` varchar(768) DEFAULT NULL, KEY `col1` (`col1`(767)) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t1, t2, t3, t4; Loading Loading @@ -2885,13 +2885,13 @@ commit; set foreign_key_checks=0; create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb; create table t1(a char(10) primary key, b varchar(20)) engine = innodb; ERROR HY000: Can't create table './test/t1.frm' (errno: 150) ERROR HY000: Can't create table 'test.t1' (errno: 150) set foreign_key_checks=1; drop table t2; set foreign_key_checks=0; create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1; create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8; ERROR HY000: Can't create table './test/t2.frm' (errno: 150) ERROR HY000: Can't create table 'test.t2' (errno: 150) set foreign_key_checks=1; drop table t1; set foreign_key_checks=0; Loading Loading @@ -2962,13 +2962,13 @@ create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb; create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb; insert into t1 values (0x41),(0x4120),(0x4100); insert into t2 values (0x41),(0x4120),(0x4100); ERROR 23000: Duplicate entry 'A' for key 1 ERROR 23000: Duplicate entry 'A' for key 'PRIMARY' insert into t2 values (0x41),(0x4120); insert into t3 values (0x41),(0x4120),(0x4100); ERROR 23000: Duplicate entry 'A ' for key 1 ERROR 23000: Duplicate entry 'A ' for key 'PRIMARY' insert into t3 values (0x41),(0x4100); insert into t4 values (0x41),(0x4120),(0x4100); ERROR 23000: Duplicate entry 'A' for key 1 ERROR 23000: Duplicate entry 'A' for key 'PRIMARY' insert into t4 values (0x41),(0x4100); select hex(s1) from t1; hex(s1) Loading Loading @@ -3170,7 +3170,7 @@ ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0; SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( `a` int(11) default NULL, `a` int(11) DEFAULT NULL, KEY `t2_ibfk_0` (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 DROP TABLE t2,t1; Loading Loading @@ -3232,6 +3232,55 @@ drop trigger t2t; drop trigger t3t; drop trigger t4t; drop table t1, t2, t3, t4, t5; CREATE TABLE t1 ( field1 varchar(8) NOT NULL DEFAULT '', field2 varchar(8) NOT NULL DEFAULT '', PRIMARY KEY (field1, field2) ) ENGINE=InnoDB; CREATE TABLE t2 ( field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY, FOREIGN KEY (field1) REFERENCES t1 (field1) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; INSERT INTO t1 VALUES ('old', 'somevalu'); INSERT INTO t1 VALUES ('other', 'anyvalue'); INSERT INTO t2 VALUES ('old'); INSERT INTO t2 VALUES ('other'); UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu'; ERROR 23000: Upholding foreign key constraints for table 't1', entry 'other-somevalu', key 1 would lead to a duplicate entry DROP TABLE t2; DROP TABLE t1; create table t1 ( c1 bigint not null, c2 bigint not null, primary key (c1), unique key (c2) ) engine=innodb; create table t2 ( c1 bigint not null, primary key (c1) ) engine=innodb; alter table t1 add constraint c2_fk foreign key (c2) references t2(c1) on delete cascade; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` bigint(20) NOT NULL, PRIMARY KEY (`c1`), UNIQUE KEY `c2` (`c2`), CONSTRAINT `c2_fk` FOREIGN KEY (`c2`) REFERENCES `t2` (`c1`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1 alter table t1 drop foreign key c2_fk; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c1` bigint(20) NOT NULL, `c2` bigint(20) NOT NULL, PRIMARY KEY (`c1`), UNIQUE KEY `c2` (`c2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t1, t2; create table t1(a date) engine=innodb; create table t2(a date, key(a)) engine=innodb; insert into t1 values('2005-10-01'); Loading
mysql-test/t/innodb.test +54 −0 Original line number Diff line number Diff line Loading @@ -2128,6 +2128,60 @@ connection default; disconnect a; disconnect b; # # Test that cascading updates leading to duplicate keys give the correct # error message (bug #9680) # CREATE TABLE t1 ( field1 varchar(8) NOT NULL DEFAULT '', field2 varchar(8) NOT NULL DEFAULT '', PRIMARY KEY (field1, field2) ) ENGINE=InnoDB; CREATE TABLE t2 ( field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY, FOREIGN KEY (field1) REFERENCES t1 (field1) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB; INSERT INTO t1 VALUES ('old', 'somevalu'); INSERT INTO t1 VALUES ('other', 'anyvalue'); INSERT INTO t2 VALUES ('old'); INSERT INTO t2 VALUES ('other'); --error ER_FOREIGN_DUPLICATE_KEY UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu'; DROP TABLE t2; DROP TABLE t1; # # Bug#18477 - MySQL/InnoDB Ignoring Foreign Keys in ALTER TABLE # create table t1 ( c1 bigint not null, c2 bigint not null, primary key (c1), unique key (c2) ) engine=innodb; # create table t2 ( c1 bigint not null, primary key (c1) ) engine=innodb; # alter table t1 add constraint c2_fk foreign key (c2) references t2(c1) on delete cascade; show create table t1; # alter table t1 drop foreign key c2_fk; show create table t1; # drop table t1, t2; # # Bug #14360: problem with intervals # Loading