File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
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;
Original file line number Diff line number Diff line change
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;
You can’t perform that action at this time.
0 commit comments