1
source include/master-slave.inc;
2
source include/have_innodb.inc;
4
--echo **** On Slave ****
6
source include/have_innodb.inc;
9
--echo **** On Master ****
11
SET SESSION BINLOG_FORMAT=ROW;
13
CREATE TABLE t1 (a INT, b INT);
14
CREATE TABLE t2 (c INT, d INT);
15
INSERT INTO t1 VALUES (1,1),(2,4),(3,9);
16
INSERT INTO t2 VALUES (1,1),(2,8),(3,27);
17
UPDATE t1,t2 SET b = d, d = b * 2 WHERE a = c;
18
source include/show_binlog_events.inc;
20
# These tables should be changed
25
--echo **** On Slave ****
28
# Stop when reaching the the first table map event.
29
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=762;
30
wait_for_slave_to_stop;
31
--replace_result $MASTER_MYPORT MASTER_PORT
32
--replace_column 1 # 8 # 9 # 23 # 33 # 35 # 36 #
33
query_vertical SHOW SLAVE STATUS;
35
# Now we skip *one* table map event. If the execution starts right
36
# after that table map event, *one* of the involved tables will be
38
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
42
# These values should be what was inserted, not what was
43
# updated. Since we are skipping the first table map of the group
44
# representing the UPDATE statement above, we should skip the entire
45
# group and not start executing at the first table map.
54
SET SESSION BINLOG_FORMAT=STATEMENT;
56
INSERT INTO t1 VALUES(@foo, 2*@foo);
58
source include/show_binlog_events.inc;
61
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=106;
62
wait_for_slave_to_stop;
63
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
66
--replace_result $MASTER_MYPORT MASTER_PORT
67
--replace_column 1 # 8 # 9 # 23 # 33 # 35 # 36 #
68
query_vertical SHOW SLAVE STATUS;
70
--echo **** On Master ****
73
sync_slave_with_master;
76
# More tests for BUG#28618
79
# ROW binlog format and non-transactional tables.
80
# Create the group of events via triggers and try to skip
81
# some items of that group.
85
SET SESSION BINLOG_FORMAT=ROW;
88
CREATE TABLE t1 (a INT, b VARCHAR(20)) ENGINE=myisam;
89
CREATE TABLE t2 (a INT, b VARCHAR(20)) ENGINE=myisam;
90
CREATE TABLE t3 (a INT, b VARCHAR(20)) ENGINE=myisam;
92
INSERT INTO t1 VALUES (1,'master/slave');
93
INSERT INTO t2 VALUES (1,'master/slave');
94
INSERT INTO t3 VALUES (1,'master/slave');
98
CREATE TRIGGER tr1 AFTER UPDATE on t1 FOR EACH ROW
100
INSERT INTO t2 VALUES (NEW.a,NEW.b);
101
DELETE FROM t2 WHERE a < NEW.a;
104
CREATE TRIGGER tr2 AFTER INSERT on t2 FOR EACH ROW
106
UPDATE t3 SET a =2, b = 'master only';
111
--echo **** On Slave ****
112
sync_slave_with_master;
114
source include/wait_for_slave_to_stop.inc;
116
--echo **** On Master ****
118
UPDATE t1 SET a = 2, b = 'master only' WHERE a = 1;
121
INSERT INTO t1 VALUES (3,'master/slave');
122
INSERT INTO t2 VALUES (3,'master/slave');
123
INSERT INTO t3 VALUES (3,'master/slave');
125
SELECT * FROM t1 ORDER BY a;
126
SELECT * FROM t2 ORDER BY a;
127
SELECT * FROM t3 ORDER BY a;
131
--echo *** On Slave ***
133
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
135
source include/wait_for_slave_to_start.inc;
138
SELECT * FROM t1 ORDER BY a;
139
SELECT * FROM t2 ORDER BY a;
140
SELECT * FROM t3 ORDER BY a;
143
DROP TABLE t1, t2, t3;
144
sync_slave_with_master;
146
--echo **** Case 2: Row binlog format and transactional tables ****
148
# Create the transaction and try to skip some
151
--echo *** On Master ***
153
CREATE TABLE t4 (a INT, b VARCHAR(20)) ENGINE=innodb;
154
CREATE TABLE t5 (a INT, b VARCHAR(20)) ENGINE=innodb;
155
CREATE TABLE t6 (a INT, b VARCHAR(20)) ENGINE=innodb;
157
--echo **** On Slave ****
158
sync_slave_with_master;
160
source include/wait_for_slave_to_stop.inc;
162
--echo *** On Master ***
165
INSERT INTO t4 VALUES (2, 'master only');
166
INSERT INTO t5 VALUES (2, 'master only');
167
INSERT INTO t6 VALUES (2, 'master only');
171
INSERT INTO t4 VALUES (3, 'master/slave');
172
INSERT INTO t5 VALUES (3, 'master/slave');
173
INSERT INTO t6 VALUES (3, 'master/slave');
176
SELECT * FROM t4 ORDER BY a;
177
SELECT * FROM t5 ORDER BY a;
178
SELECT * FROM t6 ORDER BY a;
182
--echo *** On Slave ***
184
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
186
source include/wait_for_slave_to_start.inc;
189
SELECT * FROM t4 ORDER BY a;
190
SELECT * FROM t5 ORDER BY a;
191
SELECT * FROM t6 ORDER BY a;
193
# Test skipping two groups
195
--echo **** On Slave ****
198
source include/wait_for_slave_to_stop.inc;
200
--echo *** On Master ***
203
INSERT INTO t4 VALUES (6, 'master only');
204
INSERT INTO t5 VALUES (6, 'master only');
205
INSERT INTO t6 VALUES (6, 'master only');
209
INSERT INTO t4 VALUES (7, 'master only');
210
INSERT INTO t5 VALUES (7, 'master only');
211
INSERT INTO t6 VALUES (7, 'master only');
214
SELECT * FROM t4 ORDER BY a;
215
SELECT * FROM t5 ORDER BY a;
216
SELECT * FROM t6 ORDER BY a;
220
--echo *** On Slave ***
222
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=10;
224
source include/wait_for_slave_to_start.inc;
227
SELECT * FROM t4 ORDER BY a;
228
SELECT * FROM t5 ORDER BY a;
229
SELECT * FROM t6 ORDER BY a;
232
# And the same, but with autocommit = 0
236
source include/wait_for_slave_to_stop.inc;
241
INSERT INTO t4 VALUES (4, 'master only');
242
INSERT INTO t5 VALUES (4, 'master only');
243
INSERT INTO t6 VALUES (4, 'master only');
246
INSERT INTO t4 VALUES (5, 'master/slave');
247
INSERT INTO t5 VALUES (5, 'master/slave');
248
INSERT INTO t6 VALUES (5, 'master/slave');
251
SELECT * FROM t4 ORDER BY a;
252
SELECT * FROM t5 ORDER BY a;
253
SELECT * FROM t6 ORDER BY a;
257
--echo *** On Slave ***
259
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
261
source include/wait_for_slave_to_start.inc;
264
SELECT * FROM t4 ORDER BY a;
265
SELECT * FROM t5 ORDER BY a;
266
SELECT * FROM t6 ORDER BY a;
269
DROP TABLE t4, t5, t6;
270
sync_slave_with_master;
272
--echo **** Case 3: Statement logging format and LOAD DATA with non-transactional table ****
274
# LOAD DATA creates two events in binary log for statement binlog format.
275
# Try to skip the first.
277
--echo *** On Master ***
279
CREATE TABLE t10 (a INT, b VARCHAR(20)) ENGINE=myisam;
281
--echo *** On Slave ***
282
sync_slave_with_master;
284
source include/wait_for_slave_to_stop.inc;
286
--echo *** On Master ***
288
SET SESSION BINLOG_FORMAT=STATEMENT;
289
exec cp ./suite/rpl/data/rpl_bug28618.dat $MYSQLTEST_VARDIR/tmp/;
290
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
291
eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/rpl_bug28618.dat' INTO TABLE t10 FIELDS TERMINATED BY '|';
292
remove_file $MYSQLTEST_VARDIR/tmp/rpl_bug28618.dat;
294
SELECT * FROM t10 ORDER BY a;
298
--echo *** On Slave ***
300
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
302
source include/wait_for_slave_to_start.inc;
305
SELECT * FROM t10 ORDER BY a;
309
sync_slave_with_master;