Debian Codegraph @

mysql-test/suite/rpl/r/rpl_foreign_key_innodb.result

raw
1 include/master-slave.inc
2 [connection master]
3 CREATE TABLE t1 (a INT AUTO_INCREMENT KEY) ENGINE=INNODB;
4 CREATE TABLE t2 (b INT AUTO_INCREMENT KEY, c INT, FOREIGN KEY(b) REFERENCES t1(a)) ENGINE=INNODB;
5 SET FOREIGN_KEY_CHECKS=0;
6 INSERT INTO t1 VALUES (10);
7 INSERT INTO t1 VALUES (NULL),(NULL),(NULL);
8 INSERT INTO t2 VALUES (5,0);
9 INSERT INTO t2 VALUES (NULL,LAST_INSERT_ID());
10 SET FOREIGN_KEY_CHECKS=1;
11 SELECT * FROM t1 ORDER BY a;
12 a
13 10
14 11
15 12
16 13
17 SELECT * FROM t2 ORDER BY b;
18 b c
19 5 0
20 6 11
21 connection slave;
22 SELECT * FROM t1 ORDER BY a;
23 a
24 10
25 11
26 12
27 13
28 SELECT * FROM t2 ORDER BY b;
29 b c
30 5 0
31 6 11
32 connection master;
33 SET TIMESTAMP=1000000000;
34 CREATE TABLE t3 ( a INT UNIQUE );
35 SET FOREIGN_KEY_CHECKS=0;
36 INSERT INTO t3 VALUES (1),(1);
37 ERROR 23000: Duplicate entry '1' for key 'a'
38 connection slave;
39 connection master;
40 SET FOREIGN_KEY_CHECKS=0;
41 DROP TABLE IF EXISTS t1,t2,t3;
42 SET FOREIGN_KEY_CHECKS=1;
43 connection slave;
44 connection master;
45 create table t1 (b int primary key) engine = INNODB;
46 create table t2 (a int primary key, b int, foreign key (b) references t1(b)) engine = INNODB;
47 insert into t1 set b=1;
48 insert into t2 set a=1, b=1;
49 set foreign_key_checks=0;
50 delete from t1;
51 must sync w/o a problem (could not with the buggy code)
52 connection slave;
53 select count(*) from t1 /* must be zero */;
54 count(*)
55 0
56 connection master;
57 drop table t2,t1;
58 set foreign_key_checks=1;
59 #
60 # MDEV-25530 Error 1451 on slave: Cannot delete or update a parent row: a foreign key constraint fails
61 #
62 create table t1 (id int primary key)engine=innodb;
63 create table t2 (id int not null primary key auto_increment,
64 id2 int default null, key f1 (id2),
65 constraint f1 foreign key (id2) references t1 (id) on delete cascade) engine=innodb;
66 drop table t1,t2;
67 ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
68 connection slave;
69 show tables;
70 Tables_in_test
71 t1
72 connection master;
73 drop table t1;
74 connection slave;
75 include/rpl_end.inc