| 1 |
# |
| 2 |
# Test for bug #26654685 "INDEX->ID == BTR_PAGE_GET_INDEX_ID(PAGE) AT |
| 3 |
# BTR_CUR_SEARCH_TO_NTH_LEVEL IN BTR/B". |
| 4 |
# |
| 5 |
CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; |
| 6 |
INSERT INTO parent VALUES(1,2),(2,2); |
| 7 |
CREATE TABLE child (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; |
| 8 |
INSERT INTO child VALUES (10, 2); |
| 9 |
SET DEBUG_SYNC = 'innodb_inplace_alter_table_enter SIGNAL start_create WAIT_FOR go_ahead'; |
| 10 |
CREATE UNIQUE INDEX idx ON parent(b);; |
| 11 |
connect con1,localhost,root,,; |
| 12 |
connection con1; |
| 13 |
SET DEBUG_SYNC = 'now WAIT_FOR start_create'; |
| 14 |
INSERT INTO parent VALUES(4, 2); |
| 15 |
SET DEBUG_SYNC = 'now SIGNAL go_ahead'; |
| 16 |
connection default; |
| 17 |
ERROR 23000: Duplicate entry '2' for key 'parent.idx' |
| 18 |
SET DEBUG_SYNC = 'now SIGNAL conn_add_fk'; |
| 19 |
connection con1; |
| 20 |
SET DEBUG_SYNC = 'now WAIT_FOR conn_add_fk'; |
| 21 |
ALTER TABLE child ADD CONSTRAINT cfx FOREIGN KEY (b) REFERENCES parent(b); |
| 22 |
ERROR HY000: Failed to add the foreign key constraint. Missing index for constraint 'cfx' in the referenced table 'parent' |
| 23 |
SET DEBUG_SYNC = 'RESET'; |
| 24 |
connection default; |
| 25 |
DROP TABLE child; |
| 26 |
DROP TABLE parent; |
| 27 |
connection con1; |
| 28 |
disconnect con1; |
| 29 |
connection default; |
| 30 |
# |
| 31 |
# Test case for bug#26655360 "ASSERTION FAILURE: DICT0DICT.CC:2045 |
| 32 |
# :TABLE->N_REC_LOCKS == 0". |
| 33 |
CREATE TABLE parent (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; |
| 34 |
CREATE INDEX idx on parent(b); |
| 35 |
INSERT INTO parent VALUES(1,2),(2,2); |
| 36 |
CREATE TABLE child (a INT PRIMARY KEY, b INT NOT NULL) ENGINE = InnoDB; |
| 37 |
INSERT INTO child VALUES (10, 3); |
| 38 |
SET DEBUG_SYNC = "innodb_ddl_log_before_enter SIGNAL start_create WAIT_FOR go_ahead"; |
| 39 |
ALTER TABLE child ADD CONSTRAINT idx17 FOREIGN KEY (b) REFERENCES parent(a); |
| 40 |
# Make table lock _count > 1 |
| 41 |
connect con1,localhost,root,,; |
| 42 |
connection con1; |
| 43 |
SET DEBUG_SYNC = 'now WAIT_FOR start_create'; |
| 44 |
START TRANSACTION; |
| 45 |
DELETE FROM parent WHERE a=1;; |
| 46 |
connect con2,localhost,root,,; |
| 47 |
# Wait until DELETE is blocked due to MDL on the parent. |
| 48 |
SET DEBUG_SYNC = 'now SIGNAL go_ahead'; |
| 49 |
disconnect con2; |
| 50 |
connection default; |
| 51 |
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`#sql-xxxxx |
| 52 |
connection con1; |
| 53 |
COMMIT; |
| 54 |
disconnect con1; |
| 55 |
connection default; |
| 56 |
SET DEBUG_SYNC = 'RESET'; |
| 57 |
DROP TABLE child; |
| 58 |
DROP TABLE parent; |