MINI MINI MANI MO

Path : /opt/mysql/mysql-test/suite/binlog/t/
File Upload :
Current File : //opt/mysql/mysql-test/suite/binlog/t/binlog_foreign_key_parent_table_deleted.test

################################################################################
# Validate that when a DELETE operation is done on a child table, after the
# parent table was dropped using foreign_key_checks= 0, the server does not crash.
#
# Test:
# 0. Create a parent and child tables.
# 1. Drop parent table with foreign_key_checks= 0.
# 2. Delete a row from the child table with foreign_key_checks= 1.
################################################################################
--source include/have_binlog_format_row.inc

call mtr.add_suppression("InnoDB: Foreign Key referenced table test.t1 not found for foreign table test.t2");

SET @saved_foreign_key_checks= @@session.foreign_key_checks;
SET @@session.foreign_key_checks= 1;

CREATE TABLE t1 (c1 INT PRIMARY KEY);
CREATE TABLE t2 (c1 INT PRIMARY KEY, FOREIGN KEY (c1) REFERENCES t1(c1));

INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1);

SET @@session.foreign_key_checks= 0;
DROP TABLE t1;
SET @@session.foreign_key_checks= 1;

DELETE FROM t2 WHERE c1=1;

DROP TABLE t2;

SET @@session.foreign_key_checks= @saved_foreign_key_checks;

OHA YOOOO