Debian Codegraph @

mysql-test/suite/rpl/t/rpl_row_find_row.test

raw
1 # BUG#47312: RBR: Disabling key on slave breaks replication:
2 # HA_ERR_WRONG_INDEX
3 #
4 # Description
5 # ===========
6 #
7 # This test case checks whether disabling a key on a slave breaks
8 # replication or not.
9 #
10 # Case #1, shows that while not using ALTER TABLE... DISABLE KEYS and
11 # the slave has no key defined while the master has one, replication
12 # won't break.
13 #
14 # Case #2, shows that before patch for BUG#47312, if defining key on
15 # slave table, and later disable it, replication would break. This
16 # has been fixed.
17 #
18
19 -- source include/have_binlog_format_row.inc
20 -- source include/master-slave.inc
21
22 #
23 # Case #1: master has key, but slave has not.
24 # Replication does not break.
25 #
26
27 SET SQL_LOG_BIN=0;
28 CREATE TABLE t (a int, b int, c int, key(b));
29 SET SQL_LOG_BIN=1;
30
31 -- connection slave
32
33 CREATE TABLE t (a int, b int, c int);
34
35 -- connection master
36
37 INSERT INTO t VALUES (1,2,4);
38 INSERT INTO t VALUES (4,3,4);
39 DELETE FROM t;
40
41 -- sync_slave_with_master
42
43 -- connection master
44 DROP TABLE t;
45
46 -- sync_slave_with_master
47
48 #
49 # Case #2: master has key, slave also has one,
50 # but it gets disabled sometime.
51 # Replication does not break anymore.
52 #
53 --source include/rpl_reset.inc
54 -- connection master
55
56 CREATE TABLE t (a int, b int, c int, key(b));
57
58 -- sync_slave_with_master
59
60 ALTER TABLE t DISABLE KEYS;
61
62 -- connection master
63
64 INSERT INTO t VALUES (1,2,4);
65 INSERT INTO t VALUES (4,3,4);
66 DELETE FROM t;
67
68 -- sync_slave_with_master
69
70 -- connection master
71 DROP TABLE t;
72
73 -- sync_slave_with_master
74
75 #
76 # BUG#53893: RBR: nullable unique key can lead to out-of-sync slave
77 #
78
79 #
80 # We insert two rows. Both with part of UNIQUE KEY set to null.
81 # Then we update the last row inserted. On master the correct
82 # row is updated. On the slave the wrong row would be updated
83 # because the engine would look it up by the NULL Unique KEY.
84 # As a consquence, the wrong row would be updated.
85 #
86
87 -- source include/rpl_reset.inc
88 -- connection master
89
90 CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, c3 INT, UNIQUE KEY(c1,c3), KEY(c2));
91 INSERT INTO t1(c1,c2) VALUES(1,1);
92 INSERT INTO t1(c1,c2) VALUES(1,2);
93 UPDATE t1 SET c1=1000 WHERE c2=2;
94 -- sync_slave_with_master
95
96 -- let $diff_tables= master:t1, slave:t1
97 -- source include/diff_tables.inc
98
99 -- connection master
100 DROP TABLE t1;
101 -- sync_slave_with_master
102
103 --source include/rpl_end.inc