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