mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge the test innodb.innodb_misc1 into innodb.innodb.
This commit is contained in:
@ -2455,17 +2455,30 @@ drop table t1,t2;
|
|||||||
CREATE TABLE t1 (
|
CREATE TABLE t1 (
|
||||||
id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)
|
id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
CREATE TABLE t2 (
|
||||||
|
id INTEGER NOT NULL,
|
||||||
|
FOREIGN KEY (id) REFERENCES t1 (id)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
INSERT INTO t1 (id) VALUES (NULL);
|
INSERT INTO t1 (id) VALUES (NULL);
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
id
|
id
|
||||||
1
|
1
|
||||||
TRUNCATE t1;
|
TRUNCATE t1;
|
||||||
|
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`id`) REFERENCES `test`.`t1` (`id`))
|
||||||
INSERT INTO t1 (id) VALUES (NULL);
|
INSERT INTO t1 (id) VALUES (NULL);
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
id
|
id
|
||||||
1
|
1
|
||||||
|
2
|
||||||
DELETE FROM t1;
|
DELETE FROM t1;
|
||||||
TRUNCATE t1;
|
TRUNCATE t1;
|
||||||
|
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`id`) REFERENCES `test`.`t1` (`id`))
|
||||||
|
INSERT INTO t1 (id) VALUES (NULL);
|
||||||
|
SELECT * FROM t1;
|
||||||
|
id
|
||||||
|
3
|
||||||
|
DROP TABLE t2;
|
||||||
|
TRUNCATE t1;
|
||||||
INSERT INTO t1 (id) VALUES (NULL);
|
INSERT INTO t1 (id) VALUES (NULL);
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
id
|
id
|
||||||
@ -2481,7 +2494,7 @@ id INT NOT NULL PRIMARY KEY,
|
|||||||
b INT,
|
b INT,
|
||||||
FOREIGN KEY (b) REFERENCES test.t1(id)
|
FOREIGN KEY (b) REFERENCES test.t1(id)
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
Got one of the listed errors
|
ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
create table t1 (col1 varchar(2000), index (col1(767)))
|
create table t1 (col1 varchar(2000), index (col1(767)))
|
||||||
character set = latin1 engine = innodb;
|
character set = latin1 engine = innodb;
|
||||||
@ -2574,7 +2587,7 @@ INSERT INTO t2 VALUES(1);
|
|||||||
DELETE FROM t1 WHERE id = 1;
|
DELETE FROM t1 WHERE id = 1;
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
Got one of the listed errors
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
|
||||||
SET FOREIGN_KEY_CHECKS=0;
|
SET FOREIGN_KEY_CHECKS=0;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
SET FOREIGN_KEY_CHECKS=1;
|
SET FOREIGN_KEY_CHECKS=1;
|
||||||
@ -3089,8 +3102,8 @@ a BIGINT(20) NOT NULL,
|
|||||||
b VARCHAR(128) NOT NULL,
|
b VARCHAR(128) NOT NULL,
|
||||||
c TEXT NOT NULL,
|
c TEXT NOT NULL,
|
||||||
PRIMARY KEY (a,b),
|
PRIMARY KEY (a,b),
|
||||||
KEY idx_t2_b_c (b,c(200)),
|
KEY idx_t2_b_c (b,c(100)),
|
||||||
CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a)
|
CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a)
|
||||||
ON DELETE CASCADE
|
ON DELETE CASCADE
|
||||||
) ENGINE=INNODB DEFAULT CHARSET=UTF8;
|
) ENGINE=INNODB DEFAULT CHARSET=UTF8;
|
||||||
INSERT INTO t1 VALUES (1);
|
INSERT INTO t1 VALUES (1);
|
||||||
|
@ -1,922 +0,0 @@
|
|||||||
drop table if exists t1,t2,t3,t4;
|
|
||||||
drop database if exists mysqltest;
|
|
||||||
create table t1 (v varchar(16384)) engine=innodb;
|
|
||||||
drop table t1;
|
|
||||||
create table t1 (a char(1), b char(1), key(a, b)) engine=innodb;
|
|
||||||
insert into t1 values ('8', '6'), ('4', '7');
|
|
||||||
select min(a) from t1;
|
|
||||||
min(a)
|
|
||||||
4
|
|
||||||
select min(b) from t1 where a='8';
|
|
||||||
min(b)
|
|
||||||
6
|
|
||||||
drop table t1;
|
|
||||||
CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`)) ENGINE=innodb;
|
|
||||||
insert into t1 (b) values (1);
|
|
||||||
replace into t1 (b) values (2), (1), (3);
|
|
||||||
select * from t1;
|
|
||||||
a b
|
|
||||||
3 1
|
|
||||||
2 2
|
|
||||||
4 3
|
|
||||||
truncate table t1;
|
|
||||||
insert into t1 (b) values (1);
|
|
||||||
replace into t1 (b) values (2);
|
|
||||||
replace into t1 (b) values (1);
|
|
||||||
replace into t1 (b) values (3);
|
|
||||||
select * from t1;
|
|
||||||
a b
|
|
||||||
3 1
|
|
||||||
2 2
|
|
||||||
4 3
|
|
||||||
drop table t1;
|
|
||||||
create table t1 (rowid int not null auto_increment, val int not null,primary
|
|
||||||
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 'val'
|
|
||||||
select * from t1;
|
|
||||||
rowid val
|
|
||||||
3 1
|
|
||||||
4 2
|
|
||||||
drop table t1;
|
|
||||||
create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
|
|
||||||
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 'PRIMARY'
|
|
||||||
select * from t1;
|
|
||||||
a val
|
|
||||||
2 1
|
|
||||||
drop table t1;
|
|
||||||
CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB;
|
|
||||||
INSERT INTO t1 (GRADE) VALUES (151),(252),(343);
|
|
||||||
SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300;
|
|
||||||
GRADE
|
|
||||||
252
|
|
||||||
SELECT GRADE FROM t1 WHERE GRADE= 151;
|
|
||||||
GRADE
|
|
||||||
151
|
|
||||||
DROP TABLE t1;
|
|
||||||
create table t1 (f1 varchar(10), f2 varchar(10), primary key (f1,f2)) engine=innodb;
|
|
||||||
create table t2 (f3 varchar(10), f4 varchar(10), key (f4)) engine=innodb;
|
|
||||||
insert into t2 values ('aa','cc');
|
|
||||||
insert into t1 values ('aa','bb'),('aa','cc');
|
|
||||||
delete t1 from t1,t2 where f1=f3 and f4='cc';
|
|
||||||
select * from t1;
|
|
||||||
f1 f2
|
|
||||||
drop table t1,t2;
|
|
||||||
CREATE TABLE t1 (
|
|
||||||
id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)
|
|
||||||
) ENGINE=InnoDB;
|
|
||||||
CREATE TABLE t2 (
|
|
||||||
id INTEGER NOT NULL,
|
|
||||||
FOREIGN KEY (id) REFERENCES t1 (id)
|
|
||||||
) ENGINE=InnoDB;
|
|
||||||
INSERT INTO t1 (id) VALUES (NULL);
|
|
||||||
SELECT * FROM t1;
|
|
||||||
id
|
|
||||||
1
|
|
||||||
TRUNCATE t1;
|
|
||||||
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`id`) REFERENCES `test`.`t1` (`id`))
|
|
||||||
INSERT INTO t1 (id) VALUES (NULL);
|
|
||||||
SELECT * FROM t1;
|
|
||||||
id
|
|
||||||
1
|
|
||||||
2
|
|
||||||
DELETE FROM t1;
|
|
||||||
TRUNCATE t1;
|
|
||||||
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`id`) REFERENCES `test`.`t1` (`id`))
|
|
||||||
INSERT INTO t1 (id) VALUES (NULL);
|
|
||||||
SELECT * FROM t1;
|
|
||||||
id
|
|
||||||
3
|
|
||||||
DROP TABLE t2, t1;
|
|
||||||
CREATE TABLE t1
|
|
||||||
(
|
|
||||||
id INT PRIMARY KEY
|
|
||||||
) ENGINE=InnoDB;
|
|
||||||
CREATE TEMPORARY TABLE t2
|
|
||||||
(
|
|
||||||
id INT NOT NULL PRIMARY KEY,
|
|
||||||
b INT,
|
|
||||||
FOREIGN KEY (b) REFERENCES test.t1(id)
|
|
||||||
) ENGINE=InnoDB;
|
|
||||||
ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
|
|
||||||
DROP TABLE t1;
|
|
||||||
create table t1 (col1 varchar(2000), index (col1(767)))
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
create table t2 (col1 char(255), index (col1))
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
create table t3 (col1 binary(255), index (col1))
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
create table t4 (col1 varchar(767), index (col1))
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
create table t5 (col1 varchar(767) primary key)
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
create table t6 (col1 varbinary(767) primary key)
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
create table t7 (col1 text, index(col1(767)))
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
create table t8 (col1 blob, index(col1(767)))
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
drop table t1, t2, t3, t4, t5, t6, t7, t8;
|
|
||||||
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
|
|
||||||
SET GLOBAL innodb_default_row_format=compact;
|
|
||||||
create table t1 (col1 varchar(768) primary key)
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
ERROR HY000: Index column size too large. The maximum column size is 767 bytes
|
|
||||||
create table t2 (col1 varbinary(768) primary key)
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
ERROR HY000: Index column size too large. The maximum column size is 767 bytes
|
|
||||||
create table t3 (col1 text, primary key(col1(768)))
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
ERROR HY000: Index column size too large. The maximum column size is 767 bytes
|
|
||||||
create table t4 (col1 blob, primary key(col1(768)))
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
ERROR HY000: Index column size too large. The maximum column size is 767 bytes
|
|
||||||
SET GLOBAL innodb_default_row_format=dynamic;
|
|
||||||
create table t1 (col1 varchar(768) primary key)
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
drop table t1;
|
|
||||||
create table t2 (col1 varbinary(768) primary key)
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
drop table t2;
|
|
||||||
create table t3 (col1 text, primary key(col1(768)))
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
drop table t3;
|
|
||||||
create table t4 (col1 blob, primary key(col1(768)))
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
drop table t4;
|
|
||||||
SET GLOBAL innodb_default_row_format=default;
|
|
||||||
SET sql_mode = default;
|
|
||||||
SET GLOBAL innodb_default_row_format=compact;
|
|
||||||
create table t1 (col1 varchar(768) primary key)
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
ERROR HY000: Index column size too large. The maximum column size is 767 bytes
|
|
||||||
create table t2 (col1 varbinary(768) primary key)
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
ERROR HY000: Index column size too large. The maximum column size is 767 bytes
|
|
||||||
create table t3 (col1 text, primary key(col1(768)))
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
ERROR HY000: Index column size too large. The maximum column size is 767 bytes
|
|
||||||
create table t4 (col1 blob, primary key(col1(768)))
|
|
||||||
character set = latin1 engine = innodb;
|
|
||||||
ERROR HY000: Index column size too large. The maximum column size is 767 bytes
|
|
||||||
SET GLOBAL innodb_default_row_format=default;
|
|
||||||
CREATE TABLE t1
|
|
||||||
(
|
|
||||||
id INT PRIMARY KEY
|
|
||||||
) ENGINE=InnoDB;
|
|
||||||
CREATE TABLE t2
|
|
||||||
(
|
|
||||||
v INT,
|
|
||||||
CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
|
|
||||||
) ENGINE=InnoDB;
|
|
||||||
INSERT INTO t2 VALUES(2);
|
|
||||||
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
|
|
||||||
INSERT INTO t1 VALUES(1);
|
|
||||||
INSERT INTO t2 VALUES(1);
|
|
||||||
DELETE FROM t1 WHERE id = 1;
|
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
|
|
||||||
DROP TABLE t1;
|
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
|
|
||||||
SET FOREIGN_KEY_CHECKS=0;
|
|
||||||
DROP TABLE t1;
|
|
||||||
SET FOREIGN_KEY_CHECKS=1;
|
|
||||||
INSERT INTO t2 VALUES(3);
|
|
||||||
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
|
|
||||||
DROP TABLE t2;
|
|
||||||
connect a,localhost,root,,;
|
|
||||||
connect b,localhost,root,,;
|
|
||||||
connection a;
|
|
||||||
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
|
|
||||||
insert into t1 values (1),(2);
|
|
||||||
set autocommit=0;
|
|
||||||
checksum table t1;
|
|
||||||
Table Checksum
|
|
||||||
test.t1 1531596814
|
|
||||||
connection b;
|
|
||||||
insert into t1 values(3);
|
|
||||||
connection a;
|
|
||||||
checksum table t1;
|
|
||||||
Table Checksum
|
|
||||||
test.t1 1531596814
|
|
||||||
connection a;
|
|
||||||
commit;
|
|
||||||
checksum table t1;
|
|
||||||
Table Checksum
|
|
||||||
test.t1 2050879373
|
|
||||||
commit;
|
|
||||||
drop table t1;
|
|
||||||
connection a;
|
|
||||||
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
|
|
||||||
insert into t1 values (1),(2);
|
|
||||||
set autocommit=1;
|
|
||||||
checksum table t1;
|
|
||||||
Table Checksum
|
|
||||||
test.t1 1531596814
|
|
||||||
connection b;
|
|
||||||
set autocommit=1;
|
|
||||||
insert into t1 values(3);
|
|
||||||
connection a;
|
|
||||||
checksum table t1;
|
|
||||||
Table Checksum
|
|
||||||
test.t1 2050879373
|
|
||||||
drop table t1;
|
|
||||||
connection default;
|
|
||||||
disconnect a;
|
|
||||||
disconnect b;
|
|
||||||
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` (errno: 150 "Foreign key constraint is incorrectly formed")
|
|
||||||
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` (errno: 150 "Foreign key constraint is incorrectly formed")
|
|
||||||
set foreign_key_checks=1;
|
|
||||||
drop table t1;
|
|
||||||
set foreign_key_checks=0;
|
|
||||||
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb;
|
|
||||||
create table t1(a varchar(10) primary key) engine = innodb;
|
|
||||||
alter table t1 modify column a int;
|
|
||||||
Got one of the listed errors
|
|
||||||
set foreign_key_checks=1;
|
|
||||||
drop table t2,t1;
|
|
||||||
set foreign_key_checks=0;
|
|
||||||
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
|
|
||||||
create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
|
|
||||||
alter table t1 convert to character set utf8;
|
|
||||||
set foreign_key_checks=1;
|
|
||||||
drop table t2,t1;
|
|
||||||
set foreign_key_checks=0;
|
|
||||||
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
|
|
||||||
create table t3(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=utf8;
|
|
||||||
rename table t3 to t1;
|
|
||||||
ERROR HY000: Error on rename of './test/t3' to './test/t1' (errno: 150 "Foreign key constraint is incorrectly formed")
|
|
||||||
set foreign_key_checks=1;
|
|
||||||
drop table t2,t3;
|
|
||||||
create table t1(a int primary key) row_format=redundant engine=innodb;
|
|
||||||
create table t2(a int primary key,constraint foreign key(a)references t1(a)) row_format=compact engine=innodb;
|
|
||||||
create table t3(a int primary key) row_format=compact engine=innodb;
|
|
||||||
create table t4(a int primary key,constraint foreign key(a)references t3(a)) row_format=redundant engine=innodb;
|
|
||||||
insert into t1 values(1);
|
|
||||||
insert into t3 values(1);
|
|
||||||
insert into t2 values(2);
|
|
||||||
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
|
|
||||||
insert into t4 values(2);
|
|
||||||
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
|
|
||||||
insert into t2 values(1);
|
|
||||||
insert into t4 values(1);
|
|
||||||
update t1 set a=2;
|
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
|
|
||||||
update t2 set a=2;
|
|
||||||
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
|
|
||||||
update t3 set a=2;
|
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
|
|
||||||
update t4 set a=2;
|
|
||||||
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
|
|
||||||
truncate t1;
|
|
||||||
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `test`.`t1` (`a`))
|
|
||||||
truncate t3;
|
|
||||||
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `test`.`t3` (`a`))
|
|
||||||
truncate t2;
|
|
||||||
truncate t4;
|
|
||||||
truncate t1;
|
|
||||||
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `test`.`t1` (`a`))
|
|
||||||
truncate t3;
|
|
||||||
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `test`.`t3` (`a`))
|
|
||||||
drop table t4,t3,t2,t1;
|
|
||||||
create table t1 (s1 varbinary(2),primary key (s1)) engine=innodb;
|
|
||||||
create table t2 (s1 binary(2),primary key (s1)) engine=innodb;
|
|
||||||
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 'PRIMARY'
|
|
||||||
insert into t2 values (0x41),(0x4120);
|
|
||||||
insert into t3 values (0x41),(0x4120),(0x4100);
|
|
||||||
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 'PRIMARY'
|
|
||||||
insert into t4 values (0x41),(0x4100);
|
|
||||||
select hex(s1) from t1;
|
|
||||||
hex(s1)
|
|
||||||
41
|
|
||||||
4100
|
|
||||||
4120
|
|
||||||
select hex(s1) from t2;
|
|
||||||
hex(s1)
|
|
||||||
4100
|
|
||||||
4120
|
|
||||||
select hex(s1) from t3;
|
|
||||||
hex(s1)
|
|
||||||
4100
|
|
||||||
41
|
|
||||||
select hex(s1) from t4;
|
|
||||||
hex(s1)
|
|
||||||
4100
|
|
||||||
41
|
|
||||||
drop table t1,t2,t3,t4;
|
|
||||||
create table t1 (a int primary key,s1 varbinary(3) not null unique) engine=innodb;
|
|
||||||
create table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
|
|
||||||
insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42);
|
|
||||||
insert into t2 values(0x42);
|
|
||||||
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
|
|
||||||
insert into t2 values(0x41);
|
|
||||||
select hex(s1) from t2;
|
|
||||||
hex(s1)
|
|
||||||
4100
|
|
||||||
update t1 set s1=0x123456 where a=2;
|
|
||||||
select hex(s1) from t2;
|
|
||||||
hex(s1)
|
|
||||||
4100
|
|
||||||
update t1 set s1=0x12 where a=1;
|
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
|
|
||||||
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
|
|
||||||
update t1 set s1=0x12345678 where a=1;
|
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
|
|
||||||
SET sql_mode = default;
|
|
||||||
update t1 set s1=0x123457 where a=1;
|
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
|
|
||||||
update t1 set s1=0x1220 where a=1;
|
|
||||||
select hex(s1) from t2;
|
|
||||||
hex(s1)
|
|
||||||
1220
|
|
||||||
update t1 set s1=0x1200 where a=1;
|
|
||||||
select hex(s1) from t2;
|
|
||||||
hex(s1)
|
|
||||||
1200
|
|
||||||
update t1 set s1=0x4200 where a=1;
|
|
||||||
select hex(s1) from t2;
|
|
||||||
hex(s1)
|
|
||||||
4200
|
|
||||||
delete from t1 where a=1;
|
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
|
|
||||||
delete from t1 where a=2;
|
|
||||||
update t2 set s1=0x4120;
|
|
||||||
delete from t1;
|
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
|
|
||||||
delete from t1 where a!=3;
|
|
||||||
select a,hex(s1) from t1;
|
|
||||||
a hex(s1)
|
|
||||||
3 4120
|
|
||||||
select hex(s1) from t2;
|
|
||||||
hex(s1)
|
|
||||||
4120
|
|
||||||
drop table t2,t1;
|
|
||||||
create table t1 (a int primary key,s1 varchar(2) binary not null unique) engine=innodb;
|
|
||||||
create table t2 (s1 char(2) binary not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
|
|
||||||
insert into t1 values(1,0x4100),(2,0x41);
|
|
||||||
insert into t2 values(0x41);
|
|
||||||
select hex(s1) from t2;
|
|
||||||
hex(s1)
|
|
||||||
41
|
|
||||||
update t1 set s1=0x1234 where a=1;
|
|
||||||
select hex(s1) from t2;
|
|
||||||
hex(s1)
|
|
||||||
41
|
|
||||||
update t1 set s1=0x12 where a=2;
|
|
||||||
select hex(s1) from t2;
|
|
||||||
hex(s1)
|
|
||||||
12
|
|
||||||
delete from t1 where a=1;
|
|
||||||
delete from t1 where a=2;
|
|
||||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
|
|
||||||
select a,hex(s1) from t1;
|
|
||||||
a hex(s1)
|
|
||||||
2 12
|
|
||||||
select hex(s1) from t2;
|
|
||||||
hex(s1)
|
|
||||||
12
|
|
||||||
drop table t2,t1;
|
|
||||||
CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB;
|
|
||||||
CREATE TABLE t2(a INT) ENGINE=InnoDB;
|
|
||||||
ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a);
|
|
||||||
ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1;
|
|
||||||
ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a);
|
|
||||||
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,
|
|
||||||
KEY `t2_ibfk_0` (`a`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
||||||
DROP TABLE t2,t1;
|
|
||||||
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: Foreign key constraint for table 't1', record 'other-somevalu' would lead to a duplicate entry in table 't2', key 'PRIMARY'
|
|
||||||
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');
|
|
||||||
insert into t2 values('2005-10-01');
|
|
||||||
select * from t1, t2
|
|
||||||
where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
|
|
||||||
a a
|
|
||||||
2005-10-01 2005-10-01
|
|
||||||
drop table t1, t2;
|
|
||||||
create table t1 (id int not null, f_id int not null, f int not null,
|
|
||||||
primary key(f_id, id)) engine=innodb;
|
|
||||||
create table t2 (id int not null,s_id int not null,s varchar(200),
|
|
||||||
primary key(id)) engine=innodb;
|
|
||||||
INSERT INTO t1 VALUES (8, 1, 3);
|
|
||||||
INSERT INTO t1 VALUES (1, 2, 1);
|
|
||||||
INSERT INTO t2 VALUES (1, 0, '');
|
|
||||||
INSERT INTO t2 VALUES (8, 1, '');
|
|
||||||
commit;
|
|
||||||
DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id)
|
|
||||||
WHERE mm.id IS NULL;
|
|
||||||
select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
|
|
||||||
where mm.id is null lock in share mode;
|
|
||||||
id f_id f
|
|
||||||
drop table t1,t2;
|
|
||||||
connect a,localhost,root,,;
|
|
||||||
connect b,localhost,root,,;
|
|
||||||
connection a;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
|
|
||||||
commit;
|
|
||||||
SET binlog_format='MIXED';
|
|
||||||
set autocommit = 0;
|
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
|
||||||
update t1 set b = 5 where b = 1;
|
|
||||||
connection b;
|
|
||||||
SET binlog_format='MIXED';
|
|
||||||
set autocommit = 0;
|
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
|
||||||
select * from t1 where a = 7 and b = 3 for update;
|
|
||||||
a b
|
|
||||||
7 3
|
|
||||||
connection a;
|
|
||||||
commit;
|
|
||||||
connection b;
|
|
||||||
commit;
|
|
||||||
drop table t1;
|
|
||||||
connection default;
|
|
||||||
disconnect a;
|
|
||||||
disconnect b;
|
|
||||||
connect a,localhost,root,,;
|
|
||||||
connect b,localhost,root,,;
|
|
||||||
connection a;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t1 lock in share mode;
|
|
||||||
a b
|
|
||||||
1 1
|
|
||||||
2 2
|
|
||||||
3 1
|
|
||||||
4 2
|
|
||||||
5 1
|
|
||||||
6 2
|
|
||||||
update t1 set b = 5 where b = 1;
|
|
||||||
connection b;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t1 where a = 2 and b = 2 for update;
|
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
connection a;
|
|
||||||
commit;
|
|
||||||
connection b;
|
|
||||||
commit;
|
|
||||||
connection default;
|
|
||||||
disconnect a;
|
|
||||||
disconnect b;
|
|
||||||
drop table t1;
|
|
||||||
connect a,localhost,root,,;
|
|
||||||
connect b,localhost,root,,;
|
|
||||||
connection a;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
|
||||||
create table t2(d int not null, e int, primary key(d)) engine=innodb;
|
|
||||||
insert into t2 values (8,6),(12,1),(3,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
d e
|
|
||||||
3 1
|
|
||||||
8 6
|
|
||||||
12 1
|
|
||||||
connection b;
|
|
||||||
SET binlog_format='MIXED';
|
|
||||||
set autocommit = 0;
|
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
|
||||||
insert into t1 select * from t2;
|
|
||||||
update t1 set b = (select e from t2 where a = d);
|
|
||||||
create table t3(d int not null, e int, primary key(d)) engine=innodb
|
|
||||||
select * from t2;
|
|
||||||
commit;
|
|
||||||
connection a;
|
|
||||||
commit;
|
|
||||||
connection default;
|
|
||||||
disconnect a;
|
|
||||||
disconnect b;
|
|
||||||
drop table t1, t2, t3;
|
|
||||||
connect a,localhost,root,,;
|
|
||||||
connect b,localhost,root,,;
|
|
||||||
connect c,localhost,root,,;
|
|
||||||
connect d,localhost,root,,;
|
|
||||||
connect e,localhost,root,,;
|
|
||||||
connect f,localhost,root,,;
|
|
||||||
connect g,localhost,root,,;
|
|
||||||
connect h,localhost,root,,;
|
|
||||||
connect i,localhost,root,,;
|
|
||||||
connect j,localhost,root,,;
|
|
||||||
connection a;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
|
||||||
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t2 values (8,6),(12,1),(3,1);
|
|
||||||
create table t3(d int not null, b int, primary key(d)) engine=innodb;
|
|
||||||
insert into t3 values (8,6),(12,1),(3,1);
|
|
||||||
create table t5(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t5 values (1,2),(5,3),(4,2);
|
|
||||||
create table t6(d int not null, e int, primary key(d)) engine=innodb;
|
|
||||||
insert into t6 values (8,6),(12,1),(3,1);
|
|
||||||
create table t8(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t8 values (1,2),(5,3),(4,2);
|
|
||||||
create table t9(d int not null, e int, primary key(d)) engine=innodb;
|
|
||||||
insert into t9 values (8,6),(12,1),(3,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
a b
|
|
||||||
3 1
|
|
||||||
8 6
|
|
||||||
12 1
|
|
||||||
connection b;
|
|
||||||
SET binlog_format='MIXED';
|
|
||||||
set autocommit = 0;
|
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
|
||||||
insert into t1 select * from t2;
|
|
||||||
connection c;
|
|
||||||
SET binlog_format='MIXED';
|
|
||||||
set autocommit = 0;
|
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
|
||||||
update t3 set b = (select b from t2 where a = d);
|
|
||||||
connection d;
|
|
||||||
SET binlog_format='MIXED';
|
|
||||||
set autocommit = 0;
|
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
|
||||||
create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2;
|
|
||||||
connection e;
|
|
||||||
SET binlog_format='MIXED';
|
|
||||||
set autocommit = 0;
|
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
|
||||||
insert into t5 (select * from t2 lock in share mode);
|
|
||||||
connection f;
|
|
||||||
SET binlog_format='MIXED';
|
|
||||||
set autocommit = 0;
|
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
|
||||||
update t6 set e = (select b from t2 where a = d lock in share mode);
|
|
||||||
connection g;
|
|
||||||
SET binlog_format='MIXED';
|
|
||||||
set autocommit = 0;
|
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
|
||||||
create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
|
|
||||||
connection h;
|
|
||||||
SET binlog_format='MIXED';
|
|
||||||
set autocommit = 0;
|
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
|
||||||
insert into t8 (select * from t2 for update);
|
|
||||||
connection i;
|
|
||||||
SET binlog_format='MIXED';
|
|
||||||
set autocommit = 0;
|
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
|
||||||
update t9 set e = (select b from t2 where a = d for update);
|
|
||||||
connection j;
|
|
||||||
SET binlog_format='MIXED';
|
|
||||||
set autocommit = 0;
|
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
|
||||||
create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
|
|
||||||
connection b;
|
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
connection c;
|
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
connection d;
|
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
connection e;
|
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
connection f;
|
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
connection g;
|
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
connection h;
|
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
connection i;
|
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
connection j;
|
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
connection a;
|
|
||||||
commit;
|
|
||||||
connection default;
|
|
||||||
disconnect a;
|
|
||||||
disconnect b;
|
|
||||||
disconnect c;
|
|
||||||
disconnect d;
|
|
||||||
disconnect e;
|
|
||||||
disconnect f;
|
|
||||||
disconnect g;
|
|
||||||
disconnect h;
|
|
||||||
disconnect i;
|
|
||||||
disconnect j;
|
|
||||||
drop table t1, t2, t3, t5, t6, t8, t9;
|
|
||||||
CREATE TABLE t1 (DB_ROW_ID int) engine=innodb;
|
|
||||||
ERROR 42000: Incorrect column name 'DB_ROW_ID'
|
|
||||||
CREATE TABLE t1 (
|
|
||||||
a BIGINT(20) NOT NULL,
|
|
||||||
PRIMARY KEY (a)
|
|
||||||
) ENGINE=INNODB DEFAULT CHARSET=UTF8;
|
|
||||||
CREATE TABLE t2 (
|
|
||||||
a BIGINT(20) NOT NULL,
|
|
||||||
b VARCHAR(128) NOT NULL,
|
|
||||||
c TEXT NOT NULL,
|
|
||||||
PRIMARY KEY (a,b),
|
|
||||||
KEY idx_t2_b_c (b,c(100)),
|
|
||||||
CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a)
|
|
||||||
ON DELETE CASCADE
|
|
||||||
) ENGINE=INNODB DEFAULT CHARSET=UTF8;
|
|
||||||
INSERT INTO t1 VALUES (1);
|
|
||||||
INSERT INTO t2 VALUES (1, 'bar', 'vbar');
|
|
||||||
INSERT INTO t2 VALUES (1, 'BAR2', 'VBAR');
|
|
||||||
INSERT INTO t2 VALUES (1, 'bar_bar', 'bibi');
|
|
||||||
INSERT INTO t2 VALUES (1, 'customer_over', '1');
|
|
||||||
SELECT * FROM t2 WHERE b = 'customer_over';
|
|
||||||
a b c
|
|
||||||
1 customer_over 1
|
|
||||||
SELECT * FROM t2 WHERE BINARY b = 'customer_over';
|
|
||||||
a b c
|
|
||||||
1 customer_over 1
|
|
||||||
SELECT DISTINCT p0.a FROM t2 p0 WHERE p0.b = 'customer_over';
|
|
||||||
a
|
|
||||||
1
|
|
||||||
/* Bang: Empty result set, above was expected: */
|
|
||||||
SELECT DISTINCT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
|
|
||||||
a
|
|
||||||
1
|
|
||||||
SELECT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over';
|
|
||||||
a
|
|
||||||
1
|
|
||||||
drop table t2, t1;
|
|
||||||
CREATE TABLE t1 ( a int ) ENGINE=innodb;
|
|
||||||
BEGIN;
|
|
||||||
INSERT INTO t1 VALUES (1);
|
|
||||||
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;
|
|
||||||
CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB;
|
|
||||||
CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL,
|
|
||||||
CONSTRAINT t2_t1 FOREIGN KEY (id) REFERENCES t1 (id)
|
|
||||||
ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB;
|
|
||||||
ALTER TABLE t2 ADD FOREIGN KEY (f) REFERENCES t1 (f) ON
|
|
||||||
DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
SHOW CREATE TABLE t2;
|
|
||||||
Table Create Table
|
|
||||||
t2 CREATE TABLE `t2` (
|
|
||||||
`id` int(11) NOT NULL,
|
|
||||||
`f` int(11) NOT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `f` (`f`),
|
|
||||||
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f`) REFERENCES `t1` (`f`) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
||||||
CONSTRAINT `t2_t1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
||||||
DROP TABLE t2, t1;
|
|
||||||
CREATE TABLE t1 (a INT, INDEX(a)) ENGINE=InnoDB;
|
|
||||||
CREATE TABLE t2 (a INT, INDEX(a)) ENGINE=InnoDB;
|
|
||||||
INSERT INTO t1 VALUES (1);
|
|
||||||
INSERT INTO t2 VALUES (1);
|
|
||||||
ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1 (a) ON DELETE SET NULL;
|
|
||||||
ALTER TABLE t2 MODIFY a INT NOT NULL;
|
|
||||||
ERROR HY000: Cannot change column 'a': used in a foreign key constraint 't2_ibfk_1'
|
|
||||||
DELETE FROM t1;
|
|
||||||
DROP TABLE t2,t1;
|
|
||||||
CREATE TABLE t1 (a VARCHAR(5) COLLATE utf8_unicode_ci PRIMARY KEY)
|
|
||||||
ENGINE=InnoDB;
|
|
||||||
INSERT INTO t1 VALUES (0xEFBCA4EFBCA4EFBCA4);
|
|
||||||
DELETE FROM t1;
|
|
||||||
INSERT INTO t1 VALUES ('DDD');
|
|
||||||
SELECT * FROM t1;
|
|
||||||
a
|
|
||||||
DDD
|
|
||||||
DROP TABLE t1;
|
|
||||||
CREATE TABLE t1 (id int PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB
|
|
||||||
AUTO_INCREMENT=42;
|
|
||||||
INSERT INTO t1 VALUES (0),(347),(0);
|
|
||||||
SELECT * FROM t1;
|
|
||||||
id
|
|
||||||
42
|
|
||||||
347
|
|
||||||
348
|
|
||||||
SHOW CREATE TABLE t1;
|
|
||||||
Table Create Table
|
|
||||||
t1 CREATE TABLE `t1` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=349 DEFAULT CHARSET=latin1
|
|
||||||
CREATE TABLE t2 (id int PRIMARY KEY) ENGINE=InnoDB;
|
|
||||||
INSERT INTO t2 VALUES(42),(347),(348);
|
|
||||||
ALTER TABLE t1 ADD CONSTRAINT t1_t2 FOREIGN KEY (id) REFERENCES t2(id);
|
|
||||||
SHOW CREATE TABLE t1;
|
|
||||||
Table Create Table
|
|
||||||
t1 CREATE TABLE `t1` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
CONSTRAINT `t1_t2` FOREIGN KEY (`id`) REFERENCES `t2` (`id`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=349 DEFAULT CHARSET=latin1
|
|
||||||
DROP TABLE t1,t2;
|
|
||||||
SET innodb_strict_mode=ON;
|
|
||||||
CREATE TABLE t1 (
|
|
||||||
c01 CHAR(255), c02 CHAR(255), c03 CHAR(255), c04 CHAR(255),
|
|
||||||
c05 CHAR(255), c06 CHAR(255), c07 CHAR(255), c08 CHAR(255),
|
|
||||||
c09 CHAR(255), c10 CHAR(255), c11 CHAR(255), c12 CHAR(255),
|
|
||||||
c13 CHAR(255), c14 CHAR(255), c15 CHAR(255), c16 CHAR(255),
|
|
||||||
c17 CHAR(255), c18 CHAR(255), c19 CHAR(255), c20 CHAR(255),
|
|
||||||
c21 CHAR(255), c22 CHAR(255), c23 CHAR(255), c24 CHAR(255),
|
|
||||||
c25 CHAR(255), c26 CHAR(255), c27 CHAR(255), c28 CHAR(255),
|
|
||||||
c29 CHAR(255), c30 CHAR(255), c31 CHAR(255), c32 CHAR(255)
|
|
||||||
) ENGINE = InnoDB;
|
|
||||||
ERROR 42000: Row size too large (> {checked_valid}). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline.
|
|
||||||
SET innodb_strict_mode=OFF;
|
|
||||||
DROP TABLE IF EXISTS t1;
|
|
||||||
Warnings:
|
|
||||||
Note 1051 Unknown table 'test.t1'
|
|
||||||
CREATE TABLE t1(
|
|
||||||
id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY
|
|
||||||
) ENGINE=InnoDB;
|
|
||||||
INSERT INTO t1 VALUES(-10);
|
|
||||||
SELECT * FROM t1;
|
|
||||||
id
|
|
||||||
-10
|
|
||||||
INSERT INTO t1 VALUES(NULL);
|
|
||||||
SELECT * FROM t1;
|
|
||||||
id
|
|
||||||
-10
|
|
||||||
1
|
|
||||||
DROP TABLE t1;
|
|
||||||
CONNECT c1,localhost,root,,;
|
|
||||||
CONNECT c2,localhost,root,,;
|
|
||||||
connection c1;
|
|
||||||
SET binlog_format='MIXED';
|
|
||||||
SET TX_ISOLATION='read-committed';
|
|
||||||
SET AUTOCOMMIT=0;
|
|
||||||
DROP TABLE IF EXISTS t1, t2;
|
|
||||||
Warnings:
|
|
||||||
Note 1051 Unknown table 'test.t1'
|
|
||||||
Note 1051 Unknown table 'test.t2'
|
|
||||||
CREATE TABLE t1 ( a int ) ENGINE=InnoDB;
|
|
||||||
CREATE TABLE t2 LIKE t1;
|
|
||||||
SELECT * FROM t2;
|
|
||||||
a
|
|
||||||
connection c2;
|
|
||||||
SET binlog_format='MIXED';
|
|
||||||
SET TX_ISOLATION='read-committed';
|
|
||||||
SET AUTOCOMMIT=0;
|
|
||||||
INSERT INTO t1 VALUES (1);
|
|
||||||
COMMIT;
|
|
||||||
connection c1;
|
|
||||||
SELECT * FROM t1 WHERE a=1;
|
|
||||||
a
|
|
||||||
1
|
|
||||||
disconnect c1;
|
|
||||||
disconnect c2;
|
|
||||||
CONNECT c1,localhost,root,,;
|
|
||||||
CONNECT c2,localhost,root,,;
|
|
||||||
connection c1;
|
|
||||||
SET binlog_format='MIXED';
|
|
||||||
SET TX_ISOLATION='read-committed';
|
|
||||||
SET AUTOCOMMIT=0;
|
|
||||||
SELECT * FROM t2;
|
|
||||||
a
|
|
||||||
connection c2;
|
|
||||||
SET binlog_format='MIXED';
|
|
||||||
SET TX_ISOLATION='read-committed';
|
|
||||||
SET AUTOCOMMIT=0;
|
|
||||||
INSERT INTO t1 VALUES (2);
|
|
||||||
COMMIT;
|
|
||||||
connection c1;
|
|
||||||
SELECT * FROM t1 WHERE a=2;
|
|
||||||
a
|
|
||||||
2
|
|
||||||
SELECT * FROM t1 WHERE a=2;
|
|
||||||
a
|
|
||||||
2
|
|
||||||
DROP TABLE t1;
|
|
||||||
DROP TABLE t2;
|
|
||||||
disconnect c1;
|
|
||||||
disconnect c2;
|
|
||||||
connection default;
|
|
||||||
create table t1 (i int, j int) engine=innodb;
|
|
||||||
insert into t1 (i, j) values (1, 1), (2, 2);
|
|
||||||
update t1 set j = 2;
|
|
||||||
affected rows: 1
|
|
||||||
info: Rows matched: 2 Changed: 1 Warnings: 0
|
|
||||||
drop table t1;
|
|
||||||
set @save_innodb_file_per_table= @@global.innodb_file_per_table;
|
|
||||||
set @@global.innodb_file_per_table=0;
|
|
||||||
create table t1 (id int) comment='this is a comment' engine=innodb;
|
|
||||||
ANALYZE TABLE t1;
|
|
||||||
Table Op Msg_type Msg_text
|
|
||||||
test.t1 analyze status OK
|
|
||||||
select table_comment, data_free > 0 as data_free_is_set
|
|
||||||
from information_schema.tables
|
|
||||||
where table_schema='test' and table_name = 't1';
|
|
||||||
table_comment data_free_is_set
|
|
||||||
this is a comment 1
|
|
||||||
drop table t1;
|
|
||||||
set @@global.innodb_file_per_table= @save_innodb_file_per_table;
|
|
||||||
connection default;
|
|
||||||
CREATE TABLE t1 (
|
|
||||||
c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
||||||
c2 VARCHAR(128) NOT NULL,
|
|
||||||
PRIMARY KEY(c1)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=100;
|
|
||||||
CREATE TABLE t2 (
|
|
||||||
c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
||||||
c2 INT(10) UNSIGNED DEFAULT NULL,
|
|
||||||
PRIMARY KEY(c1)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=200;
|
|
||||||
ANALYZE TABLE t2;
|
|
||||||
Table Op Msg_type Msg_text
|
|
||||||
test.t2 analyze status OK
|
|
||||||
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
|
|
||||||
AUTO_INCREMENT
|
|
||||||
200
|
|
||||||
ALTER TABLE t2 ADD CONSTRAINT t1_t2_1 FOREIGN KEY(c1) REFERENCES t1(c1);
|
|
||||||
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't2';
|
|
||||||
AUTO_INCREMENT
|
|
||||||
200
|
|
||||||
DROP TABLE t2;
|
|
||||||
DROP TABLE t1;
|
|
||||||
connection default;
|
|
||||||
CREATE TABLE t1 (c1 int default NULL,
|
|
||||||
c2 int default NULL
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
|
||||||
TRUNCATE TABLE t1;
|
|
||||||
affected rows: 0
|
|
||||||
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
|
|
||||||
affected rows: 5
|
|
||||||
info: Records: 5 Duplicates: 0 Warnings: 0
|
|
||||||
TRUNCATE TABLE t1;
|
|
||||||
affected rows: 0
|
|
||||||
DROP TABLE t1;
|
|
||||||
Variable_name Value
|
|
||||||
Handler_update 0
|
|
||||||
Variable_name Value
|
|
||||||
Handler_delete 0
|
|
||||||
Variable_name Value
|
|
||||||
Handler_update 1
|
|
||||||
Variable_name Value
|
|
||||||
Handler_delete 1
|
|
@ -1,18 +1,3 @@
|
|||||||
#######################################################################
|
|
||||||
# #
|
|
||||||
# Please, DO NOT TOUCH this file as well as the innodb.result file. #
|
|
||||||
# These files are to be modified ONLY BY INNOBASE guys. #
|
|
||||||
# #
|
|
||||||
# Use innodb_mysql.[test|result] files instead. #
|
|
||||||
# #
|
|
||||||
# If nevertheless you need to make some changes here, please, forward #
|
|
||||||
# your commit message #
|
|
||||||
# To: innodb_dev_ww@oracle.com #
|
|
||||||
# Cc: dev-innodb@mysql.com #
|
|
||||||
# (otherwise your changes may be erased). #
|
|
||||||
# #
|
|
||||||
#######################################################################
|
|
||||||
|
|
||||||
-- source include/have_innodb.inc
|
-- source include/have_innodb.inc
|
||||||
-- source include/have_innodb_16k.inc
|
-- source include/have_innodb_16k.inc
|
||||||
|
|
||||||
@ -1521,15 +1506,25 @@ CREATE TABLE t1 (
|
|||||||
id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)
|
id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
CREATE TABLE t2 (
|
||||||
|
id INTEGER NOT NULL,
|
||||||
|
FOREIGN KEY (id) REFERENCES t1 (id)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
INSERT INTO t1 (id) VALUES (NULL);
|
INSERT INTO t1 (id) VALUES (NULL);
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
|
--error ER_TRUNCATE_ILLEGAL_FK
|
||||||
TRUNCATE t1;
|
TRUNCATE t1;
|
||||||
INSERT INTO t1 (id) VALUES (NULL);
|
INSERT INTO t1 (id) VALUES (NULL);
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
|
|
||||||
# continued from above; test that doing a slow TRUNCATE on a table with 0
|
# continued from above; test that doing a TRUNCATE resets AUTO_INCREMENT
|
||||||
# rows resets autoincrement columns
|
|
||||||
DELETE FROM t1;
|
DELETE FROM t1;
|
||||||
|
--error ER_TRUNCATE_ILLEGAL_FK
|
||||||
|
TRUNCATE t1;
|
||||||
|
INSERT INTO t1 (id) VALUES (NULL);
|
||||||
|
SELECT * FROM t1;
|
||||||
|
DROP TABLE t2;
|
||||||
TRUNCATE t1;
|
TRUNCATE t1;
|
||||||
INSERT INTO t1 (id) VALUES (NULL);
|
INSERT INTO t1 (id) VALUES (NULL);
|
||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
@ -1541,7 +1536,7 @@ CREATE TABLE t1
|
|||||||
id INT PRIMARY KEY
|
id INT PRIMARY KEY
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
--error ER_CANNOT_ADD_FOREIGN,1005
|
--error ER_CANT_CREATE_TABLE
|
||||||
CREATE TEMPORARY TABLE t2
|
CREATE TEMPORARY TABLE t2
|
||||||
(
|
(
|
||||||
id INT NOT NULL PRIMARY KEY,
|
id INT NOT NULL PRIMARY KEY,
|
||||||
@ -1630,7 +1625,7 @@ CREATE TABLE t2
|
|||||||
CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
|
CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
--error 1452
|
--error ER_NO_REFERENCED_ROW_2
|
||||||
INSERT INTO t2 VALUES(2);
|
INSERT INTO t2 VALUES(2);
|
||||||
|
|
||||||
INSERT INTO t1 VALUES(1);
|
INSERT INTO t1 VALUES(1);
|
||||||
@ -1639,14 +1634,14 @@ INSERT INTO t2 VALUES(1);
|
|||||||
--error ER_ROW_IS_REFERENCED_2
|
--error ER_ROW_IS_REFERENCED_2
|
||||||
DELETE FROM t1 WHERE id = 1;
|
DELETE FROM t1 WHERE id = 1;
|
||||||
|
|
||||||
--error ER_ROW_IS_REFERENCED_2, 1217
|
--error ER_ROW_IS_REFERENCED_2
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS=0;
|
SET FOREIGN_KEY_CHECKS=0;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
SET FOREIGN_KEY_CHECKS=1;
|
SET FOREIGN_KEY_CHECKS=1;
|
||||||
|
|
||||||
--error 1452
|
--error ER_NO_REFERENCED_ROW_2
|
||||||
INSERT INTO t2 VALUES(3);
|
INSERT INTO t2 VALUES(3);
|
||||||
|
|
||||||
DROP TABLE t2;
|
DROP TABLE t2;
|
||||||
@ -1702,7 +1697,7 @@ set foreign_key_checks=0;
|
|||||||
create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
|
create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
|
||||||
# Embedded server doesn't chdir to data directory
|
# Embedded server doesn't chdir to data directory
|
||||||
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
|
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
|
||||||
-- error 1005
|
--error ER_CANT_CREATE_TABLE
|
||||||
create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
|
create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
|
||||||
set foreign_key_checks=1;
|
set foreign_key_checks=1;
|
||||||
drop table t2;
|
drop table t2;
|
||||||
@ -1714,7 +1709,7 @@ set foreign_key_checks=0;
|
|||||||
create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
|
create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
|
||||||
# Embedded server doesn't chdir to data directory
|
# Embedded server doesn't chdir to data directory
|
||||||
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
|
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
|
||||||
-- error 1005
|
--error ER_CANT_CREATE_TABLE
|
||||||
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8;
|
create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8;
|
||||||
set foreign_key_checks=1;
|
set foreign_key_checks=1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
@ -1946,7 +1941,7 @@ SET sql_mode = default;
|
|||||||
#insert into t5(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12);
|
#insert into t5(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12);
|
||||||
#
|
#
|
||||||
#delimiter |;
|
#delimiter |;
|
||||||
#create trigger t1t before insert on t1 for each row begin
|
#create trigger t1t before insert on t1 for each row begin
|
||||||
# INSERT INTO t2 SET a = NEW.a;
|
# INSERT INTO t2 SET a = NEW.a;
|
||||||
#end |
|
#end |
|
||||||
#
|
#
|
||||||
@ -1954,7 +1949,7 @@ SET sql_mode = default;
|
|||||||
# DELETE FROM t3 WHERE a = NEW.a;
|
# DELETE FROM t3 WHERE a = NEW.a;
|
||||||
#end |
|
#end |
|
||||||
#
|
#
|
||||||
#create trigger t3t before delete on t3 for each row begin
|
#create trigger t3t before delete on t3 for each row begin
|
||||||
# UPDATE t4 SET b = b + 1 WHERE a = OLD.a;
|
# UPDATE t4 SET b = b + 1 WHERE a = OLD.a;
|
||||||
#end |
|
#end |
|
||||||
#
|
#
|
||||||
@ -2078,7 +2073,7 @@ create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
|||||||
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
|
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
|
||||||
commit;
|
commit;
|
||||||
SET binlog_format='MIXED';
|
SET binlog_format='MIXED';
|
||||||
set autocommit = 0;
|
set autocommit = 0;
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
||||||
update t1 set b = 5 where b = 1;
|
update t1 set b = 5 where b = 1;
|
||||||
connection b;
|
connection b;
|
||||||
@ -2086,7 +2081,7 @@ SET binlog_format='MIXED';
|
|||||||
set autocommit = 0;
|
set autocommit = 0;
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
||||||
#
|
#
|
||||||
# X-lock to record (7,3) should be released in a update
|
# X-lock to record (7,3) should be released in a update
|
||||||
#
|
#
|
||||||
select * from t1 where a = 7 and b = 3 for update;
|
select * from t1 where a = 7 and b = 3 for update;
|
||||||
connection a;
|
connection a;
|
||||||
@ -2109,7 +2104,7 @@ connection a;
|
|||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
||||||
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2);
|
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2);
|
||||||
commit;
|
commit;
|
||||||
set autocommit = 0;
|
set autocommit = 0;
|
||||||
select * from t1 lock in share mode;
|
select * from t1 lock in share mode;
|
||||||
update t1 set b = 5 where b = 1;
|
update t1 set b = 5 where b = 1;
|
||||||
connection b;
|
connection b;
|
||||||
@ -2117,12 +2112,12 @@ set autocommit = 0;
|
|||||||
#
|
#
|
||||||
# S-lock to records (2,2),(4,2), and (6,2) should not be released in a update
|
# S-lock to records (2,2),(4,2), and (6,2) should not be released in a update
|
||||||
#
|
#
|
||||||
--error 1205
|
--error ER_LOCK_WAIT_TIMEOUT
|
||||||
select * from t1 where a = 2 and b = 2 for update;
|
select * from t1 where a = 2 and b = 2 for update;
|
||||||
#
|
#
|
||||||
# X-lock to record (1,1),(3,1),(5,1) should not be released in a update
|
# X-lock to record (1,1),(3,1),(5,1) should not be released in a update
|
||||||
#
|
#
|
||||||
--error 1205
|
--error ER_LOCK_WAIT_TIMEOUT
|
||||||
connection a;
|
connection a;
|
||||||
commit;
|
commit;
|
||||||
connection b;
|
connection b;
|
||||||
@ -2166,7 +2161,7 @@ disconnect b;
|
|||||||
drop table t1, t2, t3;
|
drop table t1, t2, t3;
|
||||||
|
|
||||||
#
|
#
|
||||||
# Consistent read should not be used if
|
# Consistent read should not be used if
|
||||||
#
|
#
|
||||||
# (a) isolation level is serializable OR
|
# (a) isolation level is serializable OR
|
||||||
# (b) select ... lock in share mode OR
|
# (b) select ... lock in share mode OR
|
||||||
@ -2262,39 +2257,39 @@ SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
|||||||
create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
|
create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
|
||||||
|
|
||||||
connection b;
|
connection b;
|
||||||
--error 1205
|
--error ER_LOCK_WAIT_TIMEOUT
|
||||||
reap;
|
reap;
|
||||||
|
|
||||||
connection c;
|
connection c;
|
||||||
--error 1205
|
--error ER_LOCK_WAIT_TIMEOUT
|
||||||
reap;
|
reap;
|
||||||
|
|
||||||
connection d;
|
connection d;
|
||||||
--error 1205
|
--error ER_LOCK_WAIT_TIMEOUT
|
||||||
reap;
|
reap;
|
||||||
|
|
||||||
connection e;
|
connection e;
|
||||||
--error 1205
|
--error ER_LOCK_WAIT_TIMEOUT
|
||||||
reap;
|
reap;
|
||||||
|
|
||||||
connection f;
|
connection f;
|
||||||
--error 1205
|
--error ER_LOCK_WAIT_TIMEOUT
|
||||||
reap;
|
reap;
|
||||||
|
|
||||||
connection g;
|
connection g;
|
||||||
--error 1205
|
--error ER_LOCK_WAIT_TIMEOUT
|
||||||
reap;
|
reap;
|
||||||
|
|
||||||
connection h;
|
connection h;
|
||||||
--error 1205
|
--error ER_LOCK_WAIT_TIMEOUT
|
||||||
reap;
|
reap;
|
||||||
|
|
||||||
connection i;
|
connection i;
|
||||||
--error 1205
|
--error ER_LOCK_WAIT_TIMEOUT
|
||||||
reap;
|
reap;
|
||||||
|
|
||||||
connection j;
|
connection j;
|
||||||
--error 1205
|
--error ER_LOCK_WAIT_TIMEOUT
|
||||||
reap;
|
reap;
|
||||||
|
|
||||||
connection a;
|
connection a;
|
||||||
@ -2331,8 +2326,8 @@ CREATE TABLE t2 (
|
|||||||
b VARCHAR(128) NOT NULL,
|
b VARCHAR(128) NOT NULL,
|
||||||
c TEXT NOT NULL,
|
c TEXT NOT NULL,
|
||||||
PRIMARY KEY (a,b),
|
PRIMARY KEY (a,b),
|
||||||
KEY idx_t2_b_c (b,c(200)),
|
KEY idx_t2_b_c (b,c(100)),
|
||||||
CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a)
|
CONSTRAINT t_fk FOREIGN KEY (a) REFERENCES t1 (a)
|
||||||
ON DELETE CASCADE
|
ON DELETE CASCADE
|
||||||
) ENGINE=INNODB DEFAULT CHARSET=UTF8;
|
) ENGINE=INNODB DEFAULT CHARSET=UTF8;
|
||||||
|
|
||||||
@ -2457,7 +2452,7 @@ INSERT INTO t1 VALUES(-10);
|
|||||||
SELECT * FROM t1;
|
SELECT * FROM t1;
|
||||||
#
|
#
|
||||||
# NOTE: The server really needs to be restarted at this point
|
# NOTE: The server really needs to be restarted at this point
|
||||||
# for the test to be useful.
|
# for the test to be useful.
|
||||||
#
|
#
|
||||||
# Without the fix InnoDB would trip over an assertion here.
|
# Without the fix InnoDB would trip over an assertion here.
|
||||||
INSERT INTO t1 VALUES(NULL);
|
INSERT INTO t1 VALUES(NULL);
|
||||||
|
@ -1 +0,0 @@
|
|||||||
--binlog_cache_size=32768 --innodb_lock_wait_timeout=1
|
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user