1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
# Every statement in this test is either executing under ROW or
# STATEMENT format, which requires the slave thread to be able to apply
# both statement and row events. Hence, we only need to execute this
# test for MIXED mode.
source include/have_binlog_format_mixed.inc;
source include/have_innodb.inc;
source include/master-slave.inc;
connection slave;
source include/have_innodb.inc;
STOP SLAVE;
--source include/wait_for_slave_to_stop.inc
connection master;
SET SESSION BINLOG_FORMAT=ROW;
CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM;
CREATE TABLE t2 (c INT, d INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,1),(2,4),(3,9);
INSERT INTO t2 VALUES (1,1),(2,8),(3,27);
let $master_log_pos= query_get_value(SHOW MASTER STATUS, Position, 1);
UPDATE t1,t2 SET b = d, d = b * 2 WHERE a = c;
source include/show_binlog_events.inc;
# These tables should be changed
SELECT * FROM t1;
SELECT * FROM t2;
save_master_pos;
connection slave;
# Stop when reaching the the first table map event.
--replace_result $master_log_pos MASTER_LOG_POS
eval START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=$master_log_pos;
source include/wait_for_slave_sql_to_stop.inc;
let $slave_param= Exec_Master_Log_Pos;
let $slave_param_value= $master_log_pos;
source include/check_slave_param.inc;
source include/check_slave_no_error.inc;
# Now we skip *one* table map event. If the execution starts right
# after that table map event, *one* of the involved tables will be
# changed.
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
START SLAVE;
--source include/wait_for_slave_to_start.inc
sync_with_master;
# These values should be what was inserted, not what was
# updated. Since we are skipping the first table map of the group
# representing the UPDATE statement above, we should skip the entire
# group and not start executing at the first table map.
SELECT * FROM t1;
SELECT * FROM t2;
STOP SLAVE;
--source include/wait_for_slave_to_stop.inc
--source include/reset_slave.inc
connection master;
RESET MASTER;
SET SESSION BINLOG_FORMAT=STATEMENT;
SET @foo = 12;
let $master_log_pos= query_get_value(SHOW MASTER STATUS, Position, 1);
INSERT INTO t1 VALUES(@foo, 2*@foo);
save_master_pos;
source include/show_binlog_events.inc;
connection slave;
--replace_result $master_log_pos MASTER_LOG_POS
eval START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=$master_log_pos;
source include/wait_for_slave_sql_to_stop.inc;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
START SLAVE;
--source include/wait_for_slave_to_start.inc
sync_with_master;
connection master;
DROP TABLE t1, t2;
sync_slave_with_master;
#
# More tests for BUG#28618
#
# Case 1.
# ROW binlog format and non-transactional tables.
# Create the group of events via triggers and try to skip
# some items of that group.
#
connection master;
SET SESSION BINLOG_FORMAT=ROW;
SET AUTOCOMMIT=0;
CREATE TABLE t1 (a INT, b VARCHAR(20)) ENGINE=myisam;
CREATE TABLE t2 (a INT, b VARCHAR(20)) ENGINE=myisam;
CREATE TABLE t3 (a INT, b VARCHAR(20)) ENGINE=myisam;
INSERT INTO t1 VALUES (1,'master/slave');
INSERT INTO t2 VALUES (1,'master/slave');
INSERT INTO t3 VALUES (1,'master/slave');
DELIMITER |;
CREATE TRIGGER tr1 AFTER UPDATE on t1 FOR EACH ROW
BEGIN
INSERT INTO t2 VALUES (NEW.a,NEW.b);
DELETE FROM t2 WHERE a < NEW.a;
END|
CREATE TRIGGER tr2 AFTER INSERT on t2 FOR EACH ROW
BEGIN
UPDATE t3 SET a =2, b = 'master only';
END|
DELIMITER ;|
sync_slave_with_master;
source include/stop_slave.inc;
connection master;
UPDATE t1 SET a = 2, b = 'master only' WHERE a = 1;
DROP TRIGGER tr1;
DROP TRIGGER tr2;
INSERT INTO t1 VALUES (3,'master/slave');
INSERT INTO t2 VALUES (3,'master/slave');
INSERT INTO t3 VALUES (3,'master/slave');
COMMIT;
SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;
SELECT * FROM t3 ORDER BY a;
save_master_pos;
connection slave;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
source include/start_slave.inc;
sync_with_master;
SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a;
SELECT * FROM t3 ORDER BY a;
connection master;
DROP TABLE t1, t2, t3;
sync_slave_with_master;
--echo **** Case 2: Row binlog format and transactional tables ****
# Create the transaction and try to skip some
# queries from one.
connection master;
CREATE TABLE t4 (a INT, b VARCHAR(20)) ENGINE=innodb;
CREATE TABLE t5 (a INT, b VARCHAR(20)) ENGINE=innodb;
CREATE TABLE t6 (a INT, b VARCHAR(20)) ENGINE=innodb;
sync_slave_with_master;
source include/stop_slave.inc;
connection master;
BEGIN;
INSERT INTO t4 VALUES (2, 'master only');
INSERT INTO t5 VALUES (2, 'master only');
INSERT INTO t6 VALUES (2, 'master only');
COMMIT;
BEGIN;
INSERT INTO t4 VALUES (3, 'master/slave');
INSERT INTO t5 VALUES (3, 'master/slave');
INSERT INTO t6 VALUES (3, 'master/slave');
COMMIT;
SELECT * FROM t4 ORDER BY a;
SELECT * FROM t5 ORDER BY a;
SELECT * FROM t6 ORDER BY a;
save_master_pos;
connection slave;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
source include/start_slave.inc;
sync_with_master;
SELECT * FROM t4 ORDER BY a;
SELECT * FROM t5 ORDER BY a;
SELECT * FROM t6 ORDER BY a;
# Test skipping two groups
connection slave;
source include/stop_slave.inc;
connection master;
BEGIN;
INSERT INTO t4 VALUES (6, 'master only');
INSERT INTO t5 VALUES (6, 'master only');
INSERT INTO t6 VALUES (6, 'master only');
COMMIT;
BEGIN;
INSERT INTO t4 VALUES (7, 'master only');
INSERT INTO t5 VALUES (7, 'master only');
INSERT INTO t6 VALUES (7, 'master only');
COMMIT;
SELECT * FROM t4 ORDER BY a;
SELECT * FROM t5 ORDER BY a;
SELECT * FROM t6 ORDER BY a;
save_master_pos;
connection slave;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=12;
source include/start_slave.inc;
sync_with_master;
SELECT * FROM t4 ORDER BY a;
SELECT * FROM t5 ORDER BY a;
SELECT * FROM t6 ORDER BY a;
#
# And the same, but with autocommit = 0
#
connection slave;
source include/stop_slave.inc;
connection master;
SET AUTOCOMMIT=0;
INSERT INTO t4 VALUES (4, 'master only');
INSERT INTO t5 VALUES (4, 'master only');
INSERT INTO t6 VALUES (4, 'master only');
COMMIT;
INSERT INTO t4 VALUES (5, 'master/slave');
INSERT INTO t5 VALUES (5, 'master/slave');
INSERT INTO t6 VALUES (5, 'master/slave');
COMMIT;
SELECT * FROM t4 ORDER BY a;
SELECT * FROM t5 ORDER BY a;
SELECT * FROM t6 ORDER BY a;
save_master_pos;
connection slave;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
source include/start_slave.inc;
sync_with_master;
SELECT * FROM t4 ORDER BY a;
SELECT * FROM t5 ORDER BY a;
SELECT * FROM t6 ORDER BY a;
connection master;
DROP TABLE t4, t5, t6;
sync_slave_with_master;
--echo **** Case 3: Statement logging format and LOAD DATA with non-transactional table ****
# LOAD DATA creates two events in binary log for statement binlog format.
# Try to skip the first.
connection master;
CREATE TABLE t10 (a INT, b VARCHAR(20)) ENGINE=myisam;
sync_slave_with_master;
source include/stop_slave.inc;
connection master;
SET SESSION BINLOG_FORMAT=STATEMENT;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data/rpl_bug28618.dat' INTO TABLE t10 FIELDS TERMINATED BY '|';
SELECT * FROM t10 ORDER BY a;
save_master_pos;
connection slave;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
source include/start_slave.inc;
sync_with_master;
SELECT * FROM t10 ORDER BY a;
connection master;
DROP TABLE t10;
sync_slave_with_master;
--source include/rpl_end.inc
|