Skip to content

Commit dfa9012

Browse files
Daniele SciasciaNirbhay Choubey
authored andcommitted
MW-285 MTR test case for broken foreign key constraints
1 parent c9ac48f commit dfa9012

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CREATE TABLE parent1 ( id INT PRIMARY KEY, KEY (id) ) ENGINE=InnoDB;
2+
CREATE TABLE parent2 ( id INT PRIMARY KEY, KEY (id) ) ENGINE=InnoDB;
3+
CREATE TABLE child (
4+
id INT PRIMARY KEY,
5+
parent1_id INT,
6+
parent2_id INT,
7+
FOREIGN KEY (parent1_id) REFERENCES parent1(id),
8+
FOREIGN KEY (parent1_id) REFERENCES parent2(id)
9+
) ENGINE=InnoDB;
10+
INSERT INTO parent1 VALUES (1);
11+
INSERT INTO parent2 VALUES (1);
12+
INSERT INTO child VALUES (1,1,1);
13+
INSERT INTO child VALUES (2,1,1);
14+
SET foreign_key_checks=OFF;
15+
DROP TABLE parent1;
16+
UPDATE child SET parent1_id=2 WHERE id=1;
17+
DROP TABLE child;
18+
DROP TABLE parent2;
19+
SET foreign_key_checks=ON;

mysql-test/suite/galera/t/MW-285.test

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# Broken FK constraints cause assertions
3+
#
4+
5+
--source include/galera_cluster.inc
6+
--source include/have_innodb.inc
7+
8+
CREATE TABLE parent1 ( id INT PRIMARY KEY, KEY (id) ) ENGINE=InnoDB;
9+
CREATE TABLE parent2 ( id INT PRIMARY KEY, KEY (id) ) ENGINE=InnoDB;
10+
11+
CREATE TABLE child (
12+
id INT PRIMARY KEY,
13+
parent1_id INT,
14+
parent2_id INT,
15+
FOREIGN KEY (parent1_id) REFERENCES parent1(id),
16+
FOREIGN KEY (parent1_id) REFERENCES parent2(id)
17+
) ENGINE=InnoDB;
18+
19+
INSERT INTO parent1 VALUES (1);
20+
INSERT INTO parent2 VALUES (1);
21+
INSERT INTO child VALUES (1,1,1);
22+
INSERT INTO child VALUES (2,1,1);
23+
24+
SET foreign_key_checks=OFF;
25+
DROP TABLE parent1;
26+
27+
UPDATE child SET parent1_id=2 WHERE id=1;
28+
29+
DROP TABLE child;
30+
DROP TABLE parent2;
31+
SET foreign_key_checks=ON;

0 commit comments

Comments
 (0)