|
1 |
| --- source include/not_ndb_default.inc |
2 | 1 | -- source include/have_innodb.inc
|
3 |
| -let $engine_type=INNODB; |
4 |
| --- source extra/rpl_tests/rpl_foreign_key.test |
| 2 | + |
| 3 | +# Check the replication of the FOREIGN_KEY_CHECKS variable. |
| 4 | + |
| 5 | +-- source include/master-slave.inc |
| 6 | + |
| 7 | +CREATE TABLE t1 (a INT AUTO_INCREMENT KEY) ENGINE=INNODB; |
| 8 | +CREATE TABLE t2 (b INT AUTO_INCREMENT KEY, c INT, FOREIGN KEY(b) REFERENCES t1(a)) ENGINE=INNODB; |
| 9 | + |
| 10 | +SET FOREIGN_KEY_CHECKS=0; |
| 11 | +INSERT INTO t1 VALUES (10); |
| 12 | +INSERT INTO t1 VALUES (NULL),(NULL),(NULL); |
| 13 | +INSERT INTO t2 VALUES (5,0); |
| 14 | +INSERT INTO t2 VALUES (NULL,LAST_INSERT_ID()); |
| 15 | +SET FOREIGN_KEY_CHECKS=1; |
| 16 | +SELECT * FROM t1 ORDER BY a; |
| 17 | +SELECT * FROM t2 ORDER BY b; |
| 18 | +sync_slave_with_master; |
| 19 | +SELECT * FROM t1 ORDER BY a; |
| 20 | +SELECT * FROM t2 ORDER BY b; |
| 21 | + |
| 22 | +connection master; |
| 23 | +SET TIMESTAMP=1000000000; |
| 24 | +CREATE TABLE t3 ( a INT UNIQUE ); |
| 25 | +SET FOREIGN_KEY_CHECKS=0; |
| 26 | +--error ER_DUP_ENTRY |
| 27 | +INSERT INTO t3 VALUES (1),(1); |
| 28 | +sync_slave_with_master; |
| 29 | + |
| 30 | +connection master; |
| 31 | +SET FOREIGN_KEY_CHECKS=0; |
| 32 | +DROP TABLE IF EXISTS t1,t2,t3; |
| 33 | +SET FOREIGN_KEY_CHECKS=1; |
| 34 | +sync_slave_with_master; |
| 35 | + |
| 36 | +# |
| 37 | +# Bug #32468 delete rows event on a table with foreign key constraint fails |
| 38 | +# |
| 39 | + |
| 40 | +connection master; |
| 41 | + |
| 42 | +create table t1 (b int primary key) engine = INNODB; |
| 43 | +create table t2 (a int primary key, b int, foreign key (b) references t1(b)) engine = INNODB; |
| 44 | + |
| 45 | +insert into t1 set b=1; |
| 46 | +insert into t2 set a=1, b=1; |
| 47 | + |
| 48 | +set foreign_key_checks=0; |
| 49 | +delete from t1; |
| 50 | + |
| 51 | +--echo must sync w/o a problem (could not with the buggy code) |
| 52 | +sync_slave_with_master; |
| 53 | +select count(*) from t1 /* must be zero */; |
| 54 | + |
| 55 | + |
| 56 | +# cleanup for bug#32468 |
| 57 | + |
| 58 | +connection master; |
| 59 | +drop table t2,t1; |
| 60 | + |
| 61 | +--source include/rpl_end.inc |
0 commit comments