| 1 |
################################################################################ |
| 2 |
# Validate that when a DELETE operation is done on a child table, after the |
| 3 |
# parent table was dropped using foreign_key_checks= 0, the server does not crash. |
| 4 |
# |
| 5 |
# Test: |
| 6 |
# 0. Create a parent and child tables. |
| 7 |
# 1. Drop parent table with foreign_key_checks= 0. |
| 8 |
# 2. Delete a row from the child table with foreign_key_checks= 1. |
| 9 |
################################################################################ |
| 10 |
--source include/have_binlog_format_row.inc |
| 11 |
|
| 12 |
call mtr.add_suppression("Foreign Key referenced table test.t1 not found for foreign table test.t2"); |
| 13 |
|
| 14 |
SET @saved_foreign_key_checks= @@session.foreign_key_checks; |
| 15 |
SET @@session.foreign_key_checks= 1; |
| 16 |
|
| 17 |
CREATE TABLE t1 (c1 INT PRIMARY KEY); |
| 18 |
CREATE TABLE t2 (c1 INT PRIMARY KEY, FOREIGN KEY (c1) REFERENCES t1(c1)); |
| 19 |
|
| 20 |
INSERT INTO t1 VALUES (1); |
| 21 |
INSERT INTO t2 VALUES (1); |
| 22 |
|
| 23 |
SET @@session.foreign_key_checks= 0; |
| 24 |
DROP TABLE t1; |
| 25 |
SET @@session.foreign_key_checks= 1; |
| 26 |
|
| 27 |
DELETE FROM t2 WHERE c1=1; |
| 28 |
|
| 29 |
DROP TABLE t2; |
| 30 |
|
| 31 |
SET @@session.foreign_key_checks= @saved_foreign_key_checks; |