summaryrefslogtreecommitdiff
path: root/mysql-test/suite/binlog/r/binlog_mysqlbinlog_gtid_window.result
blob: 63af0d20cc66aa3fa122dcd84cfb763fae176adf (plain)
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
###############################
#      Test Setup
###############################
RESET MASTER;
######################################
#      Test Group 1
#      Run test cases on local log file
######################################
set @a=UNIX_TIMESTAMP("1970-01-21 15:32:22");
SET timestamp=@a;
RESET MASTER;
SET @@session.gtid_domain_id= 0;
SET @@session.server_id= 1;
CREATE TABLE t1 (a int);
SET timestamp=@a+1;
INSERT INTO t1 values (1), (2);
SET @@session.gtid_domain_id= 1;
SET @@session.server_id= 2;
SET timestamp=@a+2;
CREATE TABLE t2 (a int);
SET timestamp=@a+3;
INSERT INTO t2 values (1);
SET @@session.gtid_domain_id= 0;
SET @@session.server_id= 1;
SET timestamp=@a+4;
INSERT INTO t1 values (3), (4);
SET @@session.gtid_domain_id= 1;
SET @@session.server_id= 2;
INSERT INTO t2 values (2);
SET @@session.server_id= 3;
INSERT INTO t2 values (3);
SET @@session.server_id= 2;
INSERT INTO t2 values (4);
FLUSH LOGS;
SET @@session.gtid_domain_id= 0;
SET @@session.server_id= 1;
CREATE TABLE t3 (a int);
INSERT INTO t3 VALUES (1);
FLUSH LOGS;
# Gtid list event of the 2nd binlog file whose content is
# matched against --start-position in the following tests:
show binlog events in 'master-bin.000002' limit 1,1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000002	#	Gtid_list	1	#	[1-3-4,1-2-5,0-1-3]
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
#
#   Test Case 1:
#   The end of the binlog file resets the server and domain id of the
# session
SET @@session.gtid_domain_id= 10;
SET @@session.server_id= 20;
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | MYSQL
include/assert.inc [session gtid_domain_id should not change when reading binlog in GTID mode]
include/assert.inc [session server_id should not change when reading binlog in GTID mode]
SET @@session.gtid_domain_id= 0;
SET @@session.server_id= 1;
DROP TABLE t1;
#
#   Test Case 2:
#   Single GTID range specified
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | MYSQL
DROP TABLE t1;
#
#   Test Case 3:
#   Single GTID range with different server_ids
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=1-2-0 --stop-position=1-3-4 | MYSQL
DROP TABLE t2;
#
#   Test Case 4:
#   Multiple GTID ranges specified
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 --stop-position=0-1-3,1-2-3 | MYSQL
DROP TABLE t1;
DROP TABLE t2;
#
#   Test Case 5:
#   Multiple GTID ranges specified where the domain ids are listed in
# different orders between start/stop position
# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-3,1-2-3 --start-position=1-2-0,0-1-0 | MYSQL
DROP TABLE t1;
DROP TABLE t2;
#
#   Test Case 6:
#   Only start position specified
CREATE TABLE t1 (a int);
INSERT INTO t1 values (3), (4);
DROP TABLE t1;
CREATE TABLE t1 (a int);
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-2 | MYSQL
DROP TABLE t1;
DROP TABLE t2;
#
#   Test Case 7:
#   Only stop position specified
# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-2 | MYSQL
DROP TABLE t1;
#
#   Test Case 8:
#   Seq_no=0 in --start-position includes all events for a domain
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 | MYSQL
DROP TABLE t1;
DROP TABLE t2;
#
#   Test Case 9:
#   Seq_no=0 in --stop-position excludes all events for a domain
# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-0,1-2-0 | MYSQL
#
#   Test Case 10:
#   Output stops for all domain ids when all --stop-position GTID values
# have been hit.
# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-2 | MYSQL
DROP TABLE t1;
#
#   Test Case 11:
#   All GTID events from other domains are printed until the
# --stop-position values are hit
# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=1-3-4 | MYSQL
DROP TABLE t2;
#
#   Test Case 12:
#   Scalar and GTID values can be used together for stop or start
# position
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=empty_binlog_pos --stop-position=0-1-2 | MYSQL
DROP TABLE t1;
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=t1_final_checksum_pos | MYSQL
DROP TABLE t1;
DROP TABLE t2;
#
#   Test Case 13:
#   If the start position is delayed within the binlog, events occurring
# before that position are ignored
CREATE TABLE t1 (a int);
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-1 --stop-position=0-1-2 | MYSQL
DROP TABLE t1;
#
#   Test Case 14:
#   If start position is repeated, the last specification overrides all
# previous ones
CREATE TABLE t1 (a int);
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --start-position=0-1-1 --stop-position=0-1-2 | MYSQL
DROP TABLE t1;
#
#   Test Case 15:
#   If stop position is repeated, the last specification overrides all
# previous ones
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-1 --stop-position=0-1-2 | MYSQL
DROP TABLE t1;
#
#   Test Case 16:
#   Start position with --offset=<n> skips n events after the first
# GTID is found
CREATE TABLE t1 (a int);
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 --offset=5 | MYSQL
DROP TABLE t1;
#
#   Test Case 17:
#   Start position with --start-datetime=<T> where T occurs after the
# specified GTID results in no events before T
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=1-2-2 --start-datetime="1970-01-21 15:32:24" | MYSQL
DROP TABLE t2;
#
#   Test Case 18:
#   If --stop-position is specified, domains which are not present
# in its list should be excluded from output
# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=1-3-4 | MYSQL
DROP TABLE t2;
#
#   Test Case 19:
#   If the start and stop GTIDs in any domain are equal, the domain
# should not have any output
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-2 --stop-position=0-1-2 | MYSQL
#
#   Test Case 20:
#   If --start-position and --stop-position have different domain ids,
# only events from GTIDs in the --stop-position list are output
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=1-2-2 --stop-position=0-1-3 | MYSQL
DROP TABLE t1;
#
#   Test Case 21:
#   Successive binary logs (e.g. logs with previous logs that have been
# purged) will write events when the --start-position matches their
# Gtid_list_log_event state
# MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-3,1-2-5 | MYSQL
DROP TABLE t3;
#
#   Test Case 22:
#   Successive binary logs can be called with --stop-position and
# without --start-position
# MYSQL_BINLOG BINLOG_FILE_PARAM2 --stop-position=0-1-4 | MYSQL
DROP TABLE t3;
# At the following error cases analysis
# note incompatible --start-position with the value of
# Gtid list event of the 2nd binlog file printed above.
#
#   Error Case 1:
#    A GTID --start-position that does not mention all domains that make
# up the binary log state should error
# MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-3 > tmp_out_ 2> err_out_
FOUND 2 /ERROR: Starting GTID position list does not specify an initial value/ in err.out
#
#   Error Case 2:
#   A GTID --start-position with any sequence numbers which occur before
# the binary log state should result in error
# MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-2,1-2-5 > tmp_out_ 2> err_out_
FOUND 1 /ERROR: Binary logs are missing data for domain 0/ in err.out
#
#   Error Case 3:
#   A GTID --start-position with any sequence numbers that are not
# eventually processed results in error
# MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-8,1-2-6 > tmp_out_ 2> err_out_
FOUND 2 /ERROR: Binary logs never reached expected GTID state/ in err.out
######################################
#      Test Group 2
#      Run test cases on remote host
######################################
set @a=UNIX_TIMESTAMP("1970-01-21 15:32:22");
SET timestamp=@a;
RESET MASTER;
SET @@session.gtid_domain_id= 0;
SET @@session.server_id= 1;
CREATE TABLE t1 (a int);
SET timestamp=@a+1;
INSERT INTO t1 values (1), (2);
SET @@session.gtid_domain_id= 1;
SET @@session.server_id= 2;
SET timestamp=@a+2;
CREATE TABLE t2 (a int);
SET timestamp=@a+3;
INSERT INTO t2 values (1);
SET @@session.gtid_domain_id= 0;
SET @@session.server_id= 1;
SET timestamp=@a+4;
INSERT INTO t1 values (3), (4);
SET @@session.gtid_domain_id= 1;
SET @@session.server_id= 2;
INSERT INTO t2 values (2);
SET @@session.server_id= 3;
INSERT INTO t2 values (3);
SET @@session.server_id= 2;
INSERT INTO t2 values (4);
FLUSH LOGS;
SET @@session.gtid_domain_id= 0;
SET @@session.server_id= 1;
CREATE TABLE t3 (a int);
INSERT INTO t3 VALUES (1);
FLUSH LOGS;
# Gtid list event of the 2nd binlog file whose content is
# matched against --start-position in the following tests:
show binlog events in 'master-bin.000002' limit 1,1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000002	#	Gtid_list	1	#	[1-3-4,1-2-5,0-1-3]
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
#
#   Test Case 1:
#   The end of the binlog file resets the server and domain id of the
# session
SET @@session.gtid_domain_id= 10;
SET @@session.server_id= 20;
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | MYSQL
include/assert.inc [session gtid_domain_id should not change when reading binlog in GTID mode]
include/assert.inc [session server_id should not change when reading binlog in GTID mode]
SET @@session.gtid_domain_id= 0;
SET @@session.server_id= 1;
DROP TABLE t1;
#
#   Test Case 2:
#   Single GTID range specified
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | MYSQL
DROP TABLE t1;
#
#   Test Case 3:
#   Single GTID range with different server_ids
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=1-2-0 --stop-position=1-3-4 | MYSQL
DROP TABLE t2;
#
#   Test Case 4:
#   Multiple GTID ranges specified
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 --stop-position=0-1-3,1-2-3 | MYSQL
DROP TABLE t1;
DROP TABLE t2;
#
#   Test Case 5:
#   Multiple GTID ranges specified where the domain ids are listed in
# different orders between start/stop position
# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-3,1-2-3 --start-position=1-2-0,0-1-0 | MYSQL
DROP TABLE t1;
DROP TABLE t2;
#
#   Test Case 6:
#   Only start position specified
CREATE TABLE t1 (a int);
INSERT INTO t1 values (3), (4);
DROP TABLE t1;
CREATE TABLE t1 (a int);
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-2 | MYSQL
DROP TABLE t1;
DROP TABLE t2;
#
#   Test Case 7:
#   Only stop position specified
# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-2 | MYSQL
DROP TABLE t1;
#
#   Test Case 8:
#   Seq_no=0 in --start-position includes all events for a domain
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 | MYSQL
DROP TABLE t1;
DROP TABLE t2;
#
#   Test Case 9:
#   Seq_no=0 in --stop-position excludes all events for a domain
# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-0,1-2-0 | MYSQL
#
#   Test Case 10:
#   Output stops for all domain ids when all --stop-position GTID values
# have been hit.
# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-2 | MYSQL
DROP TABLE t1;
#
#   Test Case 11:
#   All GTID events from other domains are printed until the
# --stop-position values are hit
# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=1-3-4 | MYSQL
DROP TABLE t2;
#
#   Test Case 12:
#   Scalar and GTID values can be used together for stop or start
# position
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=empty_binlog_pos --stop-position=0-1-2 | MYSQL
DROP TABLE t1;
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=t1_final_checksum_pos | MYSQL
DROP TABLE t1;
DROP TABLE t2;
#
#   Test Case 13:
#   If the start position is delayed within the binlog, events occurring
# before that position are ignored
CREATE TABLE t1 (a int);
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-1 --stop-position=0-1-2 | MYSQL
DROP TABLE t1;
#
#   Test Case 14:
#   If start position is repeated, the last specification overrides all
# previous ones
CREATE TABLE t1 (a int);
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --start-position=0-1-1 --stop-position=0-1-2 | MYSQL
DROP TABLE t1;
#
#   Test Case 15:
#   If stop position is repeated, the last specification overrides all
# previous ones
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-1 --stop-position=0-1-2 | MYSQL
DROP TABLE t1;
#
#   Test Case 16:
#   Start position with --offset=<n> skips n events after the first
# GTID is found
CREATE TABLE t1 (a int);
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 --offset=5 | MYSQL
DROP TABLE t1;
#
#   Test Case 17:
#   Start position with --start-datetime=<T> where T occurs after the
# specified GTID results in no events before T
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=1-2-2 --start-datetime="1970-01-21 15:32:24" | MYSQL
DROP TABLE t2;
#
#   Test Case 18:
#   If --stop-position is specified, domains which are not present
# in its list should be excluded from output
# MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=1-3-4 | MYSQL
DROP TABLE t2;
#
#   Test Case 19:
#   If the start and stop GTIDs in any domain are equal, the domain
# should not have any output
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-2 --stop-position=0-1-2 | MYSQL
#
#   Test Case 20:
#   If --start-position and --stop-position have different domain ids,
# only events from GTIDs in the --stop-position list are output
# MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=1-2-2 --stop-position=0-1-3 | MYSQL
DROP TABLE t1;
#
#   Test Case 21:
#   Successive binary logs (e.g. logs with previous logs that have been
# purged) will write events when the --start-position matches their
# Gtid_list_log_event state
#
# Reset server state
RESET MASTER;
FLUSH LOGS;
FLUSH LOGS;
PURGE BINARY LOGS TO "master-bin.000002";
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
# MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-3,1-2-5 | MYSQL
DROP TABLE t3;
#
#   Test Case 22:
#   Successive binary logs can be called with --stop-position and
# without --start-position
#
# Reset server state
RESET MASTER;
FLUSH LOGS;
FLUSH LOGS;
PURGE BINARY LOGS TO "master-bin.000002";
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
# MYSQL_BINLOG BINLOG_FILE_PARAM2 --stop-position=0-1-4 | MYSQL
DROP TABLE t3;
#
# Remote-only setup for error cases
RESET MASTER;
FLUSH LOGS;
FLUSH LOGS;
PURGE BINARY LOGS TO "master-bin.000002";
# At the following error cases analysis
# note incompatible --start-position with the value of
# Gtid list event of the 2nd binlog file printed above.
#
#   Error Case 1:
#    A GTID --start-position that does not mention all domains that make
# up the binary log state should error
# MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-3 > tmp_out_ 2> err_out_
FOUND 1 /ERROR: Got error reading packet from server/ in err.out
#
#   Error Case 2:
#   A GTID --start-position with any sequence numbers which occur before
# the binary log state should result in error
# MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-2,1-2-5 > tmp_out_ 2> err_out_
FOUND 1 /ERROR: Got error reading packet from server/ in err.out
#
#   Error Case 3:
#   A GTID --start-position with any sequence numbers that are not
# eventually processed results in error
# MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-8,1-2-6 > tmp_out_ 2> err_out_
FOUND 1 /ERROR: Got error reading packet from server/ in err.out
#
# Remote-only cleanup from error cases
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
RESET MASTER;
#
#   Error Case 4:
#   User provides invalid positions
# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=z
# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=1-
# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=1-2
# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=1-2-
# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=-1
#
#   Error Case 5:
#   User provides GTID ranges with repeated domain ids
# MYSQL_BINLOG MYSQLD_DATADIR/master-bin.000001 --start-position=0-1-1,0-1-8 --stop-position=0-1-4,0-1-12
##############################
#      Cleanup
##############################
SET @@global.gtid_domain_id= 0;
SET @@global.server_id= 1;
# End of the tests