diff options
Diffstat (limited to 'mysql-test/suite/innodb/r/foreign_key.result')
-rw-r--r-- | mysql-test/suite/innodb/r/foreign_key.result | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb/r/foreign_key.result b/mysql-test/suite/innodb/r/foreign_key.result index 7098faca0c9..378fe74e14b 100644 --- a/mysql-test/suite/innodb/r/foreign_key.result +++ b/mysql-test/suite/innodb/r/foreign_key.result @@ -130,3 +130,106 @@ ALTER TABLE t1 DROP f3; ALTER TABLE t1 CHANGE f f3 INT; DROP TABLE t1; SET FOREIGN_KEY_CHECKS=1; +# +# Bug #19471516 SERVER CRASHES WHEN EXECUTING ALTER TABLE +# ADD FOREIGN KEY +# +CREATE TABLE `department` (`department_id` INT, `department_people_fk` INT, +PRIMARY KEY (`department_id`)) engine=innodb; +CREATE TABLE `title` (`title_id` INT, `title_manager_fk` INT, +`title_reporter_fk` INT, PRIMARY KEY (`title_id`)) engine=innodb; +CREATE TABLE `people` (`people_id` INT, PRIMARY KEY (`people_id`)) engine=innodb; +ALTER TABLE `department` ADD FOREIGN KEY (`department_people_fk`) REFERENCES +`people` (`people_id`); +ALTER TABLE `title` ADD FOREIGN KEY (`title_manager_fk`) REFERENCES `people` +(`people_id`); +ALTER TABLE `title` ADD FOREIGN KEY (`title_reporter_fk`) REFERENCES `people` +(`people_id`); +drop table title, department, people; +create table t1 (a int primary key, b int) engine=innodb; +create table t2 (c int primary key, d int, +foreign key (d) references t1 (a) on update cascade) engine=innodb; +insert t1 values (1,1),(2,2),(3,3); +insert t2 values (4,1),(5,2),(6,3); +flush table t2 with read lock; +delete from t1 where a=2; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`d`) REFERENCES `t1` (`a`) ON UPDATE CASCADE) +update t1 set a=10 where a=1; +unlock tables; +lock table t2 write; +delete from t1 where a=2; +unlock tables; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`d`) REFERENCES `t1` (`a`) ON UPDATE CASCADE) +unlock tables; +create user foo; +grant select,update on test.t1 to foo; +update t1 set a=30 where a=3; +select * from t2; +c d +5 2 +4 10 +6 30 +drop table t2, t1; +drop user foo; +# +# MDEV-17595 - Server crashes in copy_data_between_tables or +# Assertion `thd->transaction.stmt.is_empty() || +# (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)' +# fails in close_tables_for_reopen upon concurrent +# ALTER TABLE and FLUSH +# +CREATE TABLE t1 (a INT, KEY(a)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1),(2); +CREATE TABLE t2 (b INT, KEY(b)) ENGINE=InnoDB; +INSERT INTO t2 VALUES(2); +ALTER TABLE t2 ADD FOREIGN KEY(b) REFERENCES t1(a), LOCK=EXCLUSIVE; +DROP TABLE t2, t1; +create table t1 (pk int primary key, data int) engine=innodb; +insert t1 values (1,1),(2,2),(3,3); +create table t2 (t1_pk int, foreign key (t1_pk) references t1 (pk)) engine=innodb; +insert t2 values (1),(2); +insert t2 values (10); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`t1_pk`) REFERENCES `t1` (`pk`)) +flush tables; +flush status; +update t1 set data=10 where pk+1>10; +show status like '%opened_tab%'; +Variable_name Value +Opened_table_definitions 1 +Opened_tables 1 +flush tables; +flush status; +update t2 set t1_pk=11 where t1_pk+1>10; +show status like '%opened_tab%'; +Variable_name Value +Opened_table_definitions 1 +Opened_tables 1 +flush tables; +flush status; +lock tables t1 write; +show status like '%opened_tab%'; +Variable_name Value +Opened_table_definitions 2 +Opened_tables 2 +insert t1 values (4,4); +show status like '%opened_tab%'; +Variable_name Value +Opened_table_definitions 2 +Opened_tables 2 +unlock tables; +create function foo() returns int +begin +insert t1 values (5,5); +return 5; +end| +flush tables; +flush status; +select foo(); +foo() +5 +show status like '%opened_tab%'; +Variable_name Value +Opened_table_definitions 2 +Opened_tables 2 +drop function foo; +drop table t2, t1; |