1
CREATE TABLE Bug_60196_FK1 (Primary_Key INT PRIMARY KEY) ENGINE=InnoDB;
2
CREATE TABLE Bug_60196_FK2 (Primary_Key INT PRIMARY KEY) ENGINE=InnoDB;
3
CREATE TABLE Bug_60196 (
6
PRIMARY KEY (FK2_Key, FK1_Key),
9
CONSTRAINT FK_FK1 FOREIGN KEY (FK1_Key)
10
REFERENCES Bug_60196_FK1 (Primary_Key)
13
CONSTRAINT FK_FK2 FOREIGN KEY (FK2_Key)
14
REFERENCES Bug_60196_FK2 (Primary_Key)
18
INSERT INTO Bug_60196_FK1 VALUES (1), (2), (3), (4), (5);
19
INSERT INTO Bug_60196_FK2 VALUES (1), (2), (3), (4), (5);
20
INSERT INTO Bug_60196 VALUES (1, 1);
21
INSERT INTO Bug_60196 VALUES (1, 2);
22
INSERT INTO Bug_60196 VALUES (1, 3);
23
INSERT INTO Bug_60196 VALUES (1, 99);
24
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`bug_60196`, CONSTRAINT `FK_FK2` FOREIGN KEY (`FK2_Key`) REFERENCES `Bug_60196_FK2` (`Primary_Key`) ON DELETE CASCADE ON UPDATE CASCADE)
25
INSERT INTO Bug_60196 VALUES (99, 1);
26
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`bug_60196`, CONSTRAINT `FK_FK1` FOREIGN KEY (`FK1_Key`) REFERENCES `Bug_60196_FK1` (`Primary_Key`) ON DELETE CASCADE ON UPDATE CASCADE)
27
SELECT * FROM bug_60196_FK1;
34
SELECT * FROM bug_60196_FK2;
41
SELECT * FROM bug_60196;
49
# Try to insert more to the example table with foreign keys.
50
# Bug60196 causes the foreign key file not to be found after
53
SELECT * FROM Bug_60196;
58
INSERT INTO Bug_60196 VALUES (2, 1);
59
INSERT INTO Bug_60196 VALUES (2, 2);
60
INSERT INTO Bug_60196 VALUES (2, 3);
61
SELECT * FROM Bug_60196;
72
DROP TABLE Bug_60196_FK1;
73
DROP TABLE Bug_60196_FK2;
74
CREATE TABLE Bug_60309_FK (
79
CREATE TABLE Bug_60309 (
83
CONSTRAINT FK FOREIGN KEY (FK_ID) REFERENCES Bug_60309_FK (ID)
85
INSERT INTO Bug_60309_FK (ID, ID2) VALUES (1, 1), (2, 2), (3, 3);
86
INSERT INTO Bug_60309 VALUES (1, 1);
87
INSERT INTO Bug_60309 VALUES (2, 99);
88
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`bug_60309`, CONSTRAINT `FK` FOREIGN KEY (`FK_ID`) REFERENCES `Bug_60309_FK` (`ID`))
89
SELECT * FROM Bug_60309_FK;
94
SELECT * FROM Bug_60309;
100
# Try to insert more to the example table with foreign keys.
101
# Bug60309 causes the foreign key file not to be found after
102
# the resstart above.
104
SELECT * FROM Bug_60309;
107
INSERT INTO Bug_60309 VALUES (2, 2);
108
INSERT INTO Bug_60309 VALUES (3, 3);
109
SELECT * FROM Bug_60309;
116
DROP TABLE Bug_60309;
117
DROP TABLE Bug_60309_FK;