| 1 |
create table t1 (f1 int primary key) engine=innodb; |
| 2 |
create table t2 (f2 int primary key) engine=innodb; |
| 3 |
create table t3 (f3 int primary key, foreign key (f3) references t2(f2)) engine=innodb; |
| 4 |
insert into t1 values (1),(2),(3),(4),(5); |
| 5 |
insert into t2 values (1),(2),(3),(4),(5); |
| 6 |
insert into t3 values (1),(2),(3),(4),(5); |
| 7 |
connect con1,localhost,root; |
| 8 |
set debug_sync='alter_table_before_rename_result_table signal g1 wait_for g2'; |
| 9 |
alter table t2 add constraint foreign key (f2) references t1(f1) on delete cascade on update cascade; |
| 10 |
connection default; |
| 11 |
set debug_sync='before_execute_sql_command wait_for g1'; |
| 12 |
update t1 set f1 = f1 + 100000 limit 2; |
| 13 |
connect con2,localhost,root; |
| 14 |
kill query UPDATE; |
| 15 |
disconnect con2; |
| 16 |
connection default; |
| 17 |
ERROR 70100: Query execution was interrupted |
| 18 |
set debug_sync='now signal g2'; |
| 19 |
connection con1; |
| 20 |
show create table t2; |
| 21 |
Table Create Table |
| 22 |
t2 CREATE TABLE `t2` ( |
| 23 |
`f2` int(11) NOT NULL, |
| 24 |
PRIMARY KEY (`f2`), |
| 25 |
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`) ON DELETE CASCADE ON UPDATE CASCADE |
| 26 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 27 |
disconnect con1; |
| 28 |
connection default; |
| 29 |
select * from t2 where f2 not in (select f1 from t1); |
| 30 |
f2 |
| 31 |
select * from t3 where f3 not in (select f2 from t2); |
| 32 |
f3 |
| 33 |
drop table t3; |
| 34 |
drop table t2; |
| 35 |
drop table t1; |
| 36 |
set debug_sync='reset'; |
| 37 |
# |
| 38 |
# MDEV-16060 - InnoDB: Failing assertion: ut_strcmp(index->name, key->name) |
| 39 |
# |
| 40 |
CREATE TABLE t1 (`pk` INT PRIMARY KEY) ENGINE=InnoDB; |
| 41 |
CREATE TABLE t2 LIKE t1; |
| 42 |
FLUSH TABLES; |
| 43 |
SET debug_sync='alter_table_intermediate_table_created SIGNAL ready WAIT_FOR go'; |
| 44 |
ALTER TABLE t1 ADD FOREIGN KEY(pk) REFERENCES t2(pk) ON UPDATE CASCADE; |
| 45 |
connect con1, localhost, root; |
| 46 |
SET debug_sync='now WAIT_FOR ready'; |
| 47 |
SET lock_wait_timeout=0; |
| 48 |
UPDATE t2 SET pk=10 WHERE pk=1; |
| 49 |
ERROR HY000: Lock wait timeout exceeded; try restarting transaction |
| 50 |
PREPARE stmt FROM 'UPDATE t2 SET pk=10 WHERE pk=1'; |
| 51 |
DEALLOCATE PREPARE stmt; |
| 52 |
SET debug_sync='now SIGNAL go'; |
| 53 |
connection default; |
| 54 |
disconnect con1; |
| 55 |
connection default; |
| 56 |
SET debug_sync='reset'; |
| 57 |
SHOW OPEN TABLES FROM test; |
| 58 |
Database Table In_use Name_locked |
| 59 |
test t2 0 0 |
| 60 |
DROP TABLE t1, t2; |