~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
source include/master-slave.inc;
2
source include/have_innodb.inc;
3
4
--echo **** On Slave ****
5
connection slave;
6
source include/have_innodb.inc;
7
STOP SLAVE;
8
9
--echo **** On Master ****
10
connection master;
11
SET SESSION BINLOG_FORMAT=ROW;
12
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;
19
20
# These tables should be changed
21
SELECT * FROM t1;
22
SELECT * FROM t2;
23
save_master_pos;
24
25
--echo **** On Slave ****
26
connection slave;
27
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;
34
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
37
# changed.
38
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
39
START SLAVE;
40
sync_with_master;
41
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.
46
SELECT * FROM t1;
47
SELECT * FROM t2;
48
49
STOP SLAVE;
50
RESET SLAVE;
51
connection master;
52
RESET MASTER;
53
54
SET SESSION BINLOG_FORMAT=STATEMENT;
55
SET @foo = 12;
56
INSERT INTO t1 VALUES(@foo, 2*@foo);
57
save_master_pos;
58
source include/show_binlog_events.inc;
59
60
connection slave;
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;
64
START SLAVE;
65
sync_with_master;
66
--replace_result $MASTER_MYPORT MASTER_PORT
67
--replace_column 1 # 8 # 9 # 23 # 33 # 35 # 36 #
68
query_vertical SHOW SLAVE STATUS;
69
70
--echo **** On Master ****
71
connection master;
72
DROP TABLE t1, t2;
73
sync_slave_with_master;
74
75
#
76
# More tests for BUG#28618
77
#
78
# Case 1.
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.
82
#  
83
84
connection master;
85
SET SESSION BINLOG_FORMAT=ROW;
86
SET AUTOCOMMIT=0;
87
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;
91
92
INSERT INTO t1 VALUES (1,'master/slave');
93
INSERT INTO t2 VALUES (1,'master/slave');
94
INSERT INTO t3 VALUES (1,'master/slave');
95
96
DELIMITER |;
97
98
CREATE TRIGGER tr1 AFTER UPDATE on t1 FOR EACH ROW
99
BEGIN
100
  INSERT INTO t2 VALUES (NEW.a,NEW.b);
101
  DELETE FROM t2 WHERE a < NEW.a;
102
END|
103
104
CREATE TRIGGER tr2 AFTER INSERT on t2 FOR EACH ROW
105
BEGIN
106
  UPDATE t3 SET a =2, b = 'master only';
107
END|
108
109
DELIMITER ;|
110
111
--echo **** On Slave ****
112
sync_slave_with_master;
113
STOP SLAVE;
114
source include/wait_for_slave_to_stop.inc;
115
116
--echo **** On Master ****
117
connection master;
118
UPDATE t1 SET a = 2, b = 'master only' WHERE a = 1;
119
DROP TRIGGER tr1;
120
DROP TRIGGER tr2;
121
INSERT INTO t1 VALUES (3,'master/slave');
122
INSERT INTO t2 VALUES (3,'master/slave');
123
INSERT INTO t3 VALUES (3,'master/slave');
124
125
SELECT * FROM t1 ORDER BY a;
126
SELECT * FROM t2 ORDER BY a;
127
SELECT * FROM t3 ORDER BY a;
128
129
save_master_pos;
130
131
--echo *** On Slave ***
132
connection slave;
133
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
134
START SLAVE;
135
source include/wait_for_slave_to_start.inc;
136
sync_with_master;
137
138
SELECT * FROM t1 ORDER BY a;
139
SELECT * FROM t2 ORDER BY a;
140
SELECT * FROM t3 ORDER BY a;
141
142
connection master;
143
DROP TABLE t1, t2, t3;
144
sync_slave_with_master;
145
146
--echo **** Case 2: Row binlog format and transactional tables ****
147
148
# Create the transaction and try to skip some
149
# queries from one.
150
151
--echo *** On Master ***
152
connection 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;
156
157
--echo **** On Slave ****
158
sync_slave_with_master;
159
STOP SLAVE;
160
source include/wait_for_slave_to_stop.inc;
161
162
--echo *** On Master ***
163
connection master;
164
BEGIN;
165
INSERT INTO t4 VALUES (2, 'master only');
166
INSERT INTO t5 VALUES (2, 'master only');
167
INSERT INTO t6 VALUES (2, 'master only');
168
COMMIT;
169
170
BEGIN;
171
INSERT INTO t4 VALUES (3, 'master/slave');
172
INSERT INTO t5 VALUES (3, 'master/slave');
173
INSERT INTO t6 VALUES (3, 'master/slave');
174
COMMIT;
175
176
SELECT * FROM t4 ORDER BY a;
177
SELECT * FROM t5 ORDER BY a;
178
SELECT * FROM t6 ORDER BY a;
179
180
save_master_pos;
181
182
--echo *** On Slave ***
183
connection slave;
184
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
185
START SLAVE;
186
source include/wait_for_slave_to_start.inc;
187
sync_with_master;
188
189
SELECT * FROM t4 ORDER BY a;
190
SELECT * FROM t5 ORDER BY a;
191
SELECT * FROM t6 ORDER BY a;
192
193
# Test skipping two groups
194
195
--echo **** On Slave ****
196
connection slave;
197
STOP SLAVE;
198
source include/wait_for_slave_to_stop.inc;
199
200
--echo *** On Master ***
201
connection master;
202
BEGIN;
203
INSERT INTO t4 VALUES (6, 'master only');
204
INSERT INTO t5 VALUES (6, 'master only');
205
INSERT INTO t6 VALUES (6, 'master only');
206
COMMIT;
207
208
BEGIN;
209
INSERT INTO t4 VALUES (7, 'master only');
210
INSERT INTO t5 VALUES (7, 'master only');
211
INSERT INTO t6 VALUES (7, 'master only');
212
COMMIT;
213
214
SELECT * FROM t4 ORDER BY a;
215
SELECT * FROM t5 ORDER BY a;
216
SELECT * FROM t6 ORDER BY a;
217
218
save_master_pos;
219
220
--echo *** On Slave ***
221
connection slave;
222
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=10;
223
START SLAVE;
224
source include/wait_for_slave_to_start.inc;
225
sync_with_master;
226
227
SELECT * FROM t4 ORDER BY a;
228
SELECT * FROM t5 ORDER BY a;
229
SELECT * FROM t6 ORDER BY a;
230
231
#
232
# And the same, but with autocommit = 0
233
#
234
connection slave;
235
STOP SLAVE;
236
source include/wait_for_slave_to_stop.inc;
237
238
connection master;
239
SET AUTOCOMMIT=0;
240
241
INSERT INTO t4 VALUES (4, 'master only');
242
INSERT INTO t5 VALUES (4, 'master only');
243
INSERT INTO t6 VALUES (4, 'master only');
244
COMMIT;
245
246
INSERT INTO t4 VALUES (5, 'master/slave');
247
INSERT INTO t5 VALUES (5, 'master/slave');
248
INSERT INTO t6 VALUES (5, 'master/slave');
249
COMMIT;
250
251
SELECT * FROM t4 ORDER BY a;
252
SELECT * FROM t5 ORDER BY a;
253
SELECT * FROM t6 ORDER BY a;
254
255
save_master_pos;
256
257
--echo *** On Slave ***
258
connection slave;
259
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
260
START SLAVE;
261
source include/wait_for_slave_to_start.inc;
262
sync_with_master;
263
264
SELECT * FROM t4 ORDER BY a;
265
SELECT * FROM t5 ORDER BY a;
266
SELECT * FROM t6 ORDER BY a;
267
268
connection master;
269
DROP TABLE t4, t5, t6;
270
sync_slave_with_master;
271
272
--echo **** Case 3: Statement logging format and LOAD DATA with non-transactional table ****
273
274
# LOAD DATA creates two events in binary log for statement binlog format.
275
# Try to skip the first.
276
277
--echo *** On Master ***
278
connection master;
279
CREATE TABLE t10 (a INT, b VARCHAR(20)) ENGINE=myisam;
280
281
--echo *** On Slave ***
282
sync_slave_with_master;
283
STOP SLAVE;
284
source include/wait_for_slave_to_stop.inc;
285
286
--echo *** On Master ***
287
connection 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;
293
294
SELECT * FROM t10 ORDER BY a;
295
296
save_master_pos;
297
298
--echo *** On Slave ***
299
connection slave;
300
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
301
START SLAVE;
302
source include/wait_for_slave_to_start.inc;
303
sync_with_master;
304
305
SELECT * FROM t10 ORDER BY a;
306
307
connection master;
308
DROP TABLE t10;
309
sync_slave_with_master;
310