Debian Codegraph @

mysql-test/suite/rpl/include/rpl_blackhole_basic.test

raw
1 # PURPOSE. Test that blackhole works with replication in all three
2 # modes: STATEMENT, MIXED, and ROW.
3 #
4 # METHOD. We start by creating a table on the master and then change
5 # the engine to use blackhole on the slave.
6 #
7 # After insert/update/delete of one or more rows, the test the
8 # proceeds to check that replication is running after replicating an
9 # change, that the blackhole engine does not contain anything (which
10 # is just a check that the correct engine is used), and that something
11 # is written to the binary log.
12 #
13 # Whe check INSERT, UPDATE, and DELETE statement for tables with no
14 # key (forcing a range search on the slave), primary keys (using a
15 # primary key lookup), and index/key with multiple matches (forcing an
16 # index search).
17
18 # We start with no primary key
19 CREATE TABLE t1 (a INT, b INT, c INT);
20 CREATE TABLE t2 (a INT, b INT, c INT);
21
22 sync_slave_with_master;
23 ALTER TABLE t1 ENGINE=BLACKHOLE;
24
25 connection master;
26 INSERT INTO t2 VALUES (1,9,1), (2,9,2), (3,9,3), (4,9,4);
27 sync_slave_with_master;
28
29 # Test insert, no primary key
30 let $statement = INSERT INTO t1 VALUES (1,1,1),(2,1,2),(3,1,3),(4,1,4);
31 source include/rpl_blackhole.test;
32
33 # Test update, no primary key
34 let $statement = UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 1;
35 source include/rpl_blackhole.test;
36
37 # Test delete, no primary key
38 let $statement = DELETE FROM t1 WHERE a % 2 = 0 AND b = 1;
39 source include/rpl_blackhole.test;
40
41 # Test INSERT-SELECT into Blackhole, no primary key
42 let $statement = INSERT INTO t1 SELECT * FROM t2;
43 source include/rpl_blackhole.test;
44
45 #
46 # The MASTER has MyISAM as the engine for both tables. The SLAVE has Blackhole
47 # on t1 (transactional engine) and MyISAM on t2 (non-transactional engine).
48 #
49 # In MIXED mode, the command "INSERT INTO t2 SELECT * FROM t1" is logged as
50 # statement on the master. On the slave, it is tagged as unsafe because the
51 # statement mixes both transactional and non-transactional engines and as such
52 # its changes are logged as rows. However, due to the nature of the blackhole
53 # engine, no rows are returned and thus any chain replication would make the
54 # next master on the chain diverge.
55 #
56 # Fo this reason, we have disabled the statement.
57 #
58 # Test INSERT-SELECT from Blackhole, no primary key
59 # let $statement = INSERT INTO t2 SELECT * FROM t1;
60 # source include/rpl_blackhole.test;
61 #
62
63 connection master;
64 ALTER TABLE t1 ADD PRIMARY KEY pk_t1 (a,b);
65 sync_slave_with_master;
66
67 # Test insert, primary key
68 let $statement = INSERT INTO t1 VALUES (1,2,1),(2,2,2),(3,2,3),(4,2,4);
69 source include/rpl_blackhole.test;
70
71 # Test update, primary key
72 let $statement = UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 2;
73 source include/rpl_blackhole.test;
74
75 # Test delete, primary key
76 let $statement = DELETE FROM t1 WHERE a % 2 = 0 AND b = 2;
77 source include/rpl_blackhole.test;
78
79 connection master;
80 ALTER TABLE t1 DROP PRIMARY KEY, ADD KEY key_t1 (a);
81 sync_slave_with_master;
82
83 # Test insert, key
84 let $statement = INSERT INTO t1 VALUES (1,3,1),(2,3,2),(3,3,3),(4,3,4);
85 source include/rpl_blackhole.test;
86
87 # Test update, key
88 let $statement = UPDATE t1 SET c = 2*c WHERE a % 2 = 0 AND b = 3;
89 source include/rpl_blackhole.test;
90
91 # Test delete, key
92 let $statement = DELETE FROM t1 WHERE a % 2 = 0 AND b = 3;
93 source include/rpl_blackhole.test;
94
95 connection master;
96 DROP TABLE t1,t2;
97 sync_slave_with_master;