| 1 |
# |
| 2 |
# This file runs test cases for providing GTIDs to --start-position and |
| 3 |
# --stop-position arguments in mariadb-binlog |
| 4 |
# |
| 5 |
# param $is_remote boolean (0 for false, 1 for true) to perform a local file |
| 6 |
# or remote host analysis |
| 7 |
# |
| 8 |
|
| 9 |
--let MYSQLD_DATADIR=`select @@datadir` |
| 10 |
--let data_inconsistent_err= "table data is inconsistent after replaying binlog using GTID start/stop positions"; |
| 11 |
--let $tmp_out_ = $MYSQLTEST_VARDIR/tmp/null.log |
| 12 |
|
| 13 |
## Initialize test data |
| 14 |
# |
| 15 |
set @a=UNIX_TIMESTAMP("1970-01-21 15:32:22"); |
| 16 |
SET timestamp=@a; |
| 17 |
RESET MASTER; |
| 18 |
SET @@session.gtid_domain_id= 0; |
| 19 |
SET @@session.server_id= 1; |
| 20 |
--let $empty_binlog_pos= query_get_value(SHOW MASTER STATUS,Position, 1) |
| 21 |
CREATE TABLE t1 (a int); |
| 22 |
SET timestamp=@a+1; |
| 23 |
INSERT INTO t1 values (1), (2); |
| 24 |
--let test2_t1_mid_checksum= `CHECKSUM TABLE t1` |
| 25 |
|
| 26 |
SET @@session.gtid_domain_id= 1; |
| 27 |
SET @@session.server_id= 2; |
| 28 |
SET timestamp=@a+2; |
| 29 |
CREATE TABLE t2 (a int); |
| 30 |
SET timestamp=@a+3; |
| 31 |
INSERT INTO t2 values (1); |
| 32 |
--let t2_mid_checksum= `CHECKSUM TABLE t2` |
| 33 |
|
| 34 |
SET @@session.gtid_domain_id= 0; |
| 35 |
SET @@session.server_id= 1; |
| 36 |
SET timestamp=@a+4; |
| 37 |
INSERT INTO t1 values (3), (4); |
| 38 |
--let t1_final_checksum_pos= query_get_value(SHOW MASTER STATUS,Position, 1) |
| 39 |
--let t1_final_checksum= `CHECKSUM TABLE t1` |
| 40 |
|
| 41 |
SET @@session.gtid_domain_id= 1; |
| 42 |
SET @@session.server_id= 2; |
| 43 |
INSERT INTO t2 values (2); |
| 44 |
--let test4_t2_good_checksum= `CHECKSUM TABLE t2` |
| 45 |
|
| 46 |
SET @@session.server_id= 3; |
| 47 |
INSERT INTO t2 values (3); |
| 48 |
--let test3_t2_good_checksum= `CHECKSUM TABLE t2` |
| 49 |
|
| 50 |
SET @@session.server_id= 2; |
| 51 |
INSERT INTO t2 values (4); |
| 52 |
--let t2_final_checksum= `CHECKSUM TABLE t2` |
| 53 |
|
| 54 |
FLUSH LOGS; |
| 55 |
|
| 56 |
# Multiple binlog file case, used by test 18 |
| 57 |
SET @@session.gtid_domain_id= 0; |
| 58 |
SET @@session.server_id= 1; |
| 59 |
CREATE TABLE t3 (a int); |
| 60 |
INSERT INTO t3 VALUES (1); |
| 61 |
--let t3_final_checksum= `CHECKSUM TABLE t3` |
| 62 |
|
| 63 |
FLUSH LOGS; |
| 64 |
|
| 65 |
--echo # Gtid list event of the 2nd binlog file whose content is |
| 66 |
--echo # matched against --start-position in the following tests: |
| 67 |
--let $binlog_file= query_get_value(SHOW BINARY LOGS, Log_name, 2) |
| 68 |
--source include/show_gtid_list.inc |
| 69 |
--let $binlog_file= |
| 70 |
|
| 71 |
--let BINLOG_FILE= query_get_value(SHOW BINARY LOGS, Log_name, 1) |
| 72 |
--let BINLOG_FILE2= query_get_value(SHOW BINARY LOGS, Log_name, 2) |
| 73 |
|
| 74 |
if ($is_remote == 0) |
| 75 |
{ |
| 76 |
--let BINLOG_FILE_PARAM=$MYSQLD_DATADIR/$BINLOG_FILE.orig |
| 77 |
--let BINLOG_FILE_PARAM2=$MYSQLD_DATADIR/$BINLOG_FILE2.orig |
| 78 |
} |
| 79 |
if ($is_remote == 1) |
| 80 |
{ |
| 81 |
--let BINLOG_FILE_PARAM= --read-from-remote-server $BINLOG_FILE |
| 82 |
--let BINLOG_FILE_PARAM2= --read-from-remote-server $BINLOG_FILE2 |
| 83 |
} |
| 84 |
|
| 85 |
--copy_file $MYSQLD_DATADIR/$BINLOG_FILE $MYSQLD_DATADIR/$BINLOG_FILE.orig |
| 86 |
--copy_file $MYSQLD_DATADIR/$BINLOG_FILE2 $MYSQLD_DATADIR/$BINLOG_FILE2.orig |
| 87 |
|
| 88 |
DROP TABLE t1; |
| 89 |
DROP TABLE t2; |
| 90 |
DROP TABLE t3; |
| 91 |
|
| 92 |
|
| 93 |
--echo # |
| 94 |
--echo # Test Case 1: |
| 95 |
--echo # The end of the binlog file resets the server and domain id of the |
| 96 |
--echo # session |
| 97 |
|
| 98 |
# As gtid_domain_id and server_id should not change after reading binlog in GTID |
| 99 |
# mode, change variables to otherwise-unused values to ensure they remain |
| 100 |
--let $reset_gtid_domain_id = `select @@session.gtid_domain_id` |
| 101 |
--let $reset_server_id = `select @@session.server_id` |
| 102 |
SET @@session.gtid_domain_id= 10; |
| 103 |
SET @@session.server_id= 20; |
| 104 |
|
| 105 |
# Replay the binlog |
| 106 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | MYSQL |
| 107 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | $MYSQL |
| 108 |
--let $test_gtid_domain_id = `select @@session.gtid_domain_id` |
| 109 |
|
| 110 |
# Ensure variables haven't changed |
| 111 |
--let $assert_text = session gtid_domain_id should not change when reading binlog in GTID mode |
| 112 |
--let $assert_cond = @@session.gtid_domain_id = 10 |
| 113 |
--source include/assert.inc |
| 114 |
--let $assert_text = session server_id should not change when reading binlog in GTID mode |
| 115 |
--let $assert_cond = @@session.server_id = 20 |
| 116 |
--source include/assert.inc |
| 117 |
|
| 118 |
# Reset back to previous state |
| 119 |
--eval SET @@session.gtid_domain_id= $reset_gtid_domain_id |
| 120 |
--eval SET @@session.server_id= $reset_server_id |
| 121 |
DROP TABLE t1; |
| 122 |
|
| 123 |
|
| 124 |
--echo # |
| 125 |
--echo # Test Case 2: |
| 126 |
--echo # Single GTID range specified |
| 127 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | MYSQL |
| 128 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 | $MYSQL |
| 129 |
|
| 130 |
if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`) |
| 131 |
{ |
| 132 |
die $data_inconsistent_err; |
| 133 |
} |
| 134 |
DROP TABLE t1; |
| 135 |
|
| 136 |
|
| 137 |
--echo # |
| 138 |
--echo # Test Case 3: |
| 139 |
--echo # Single GTID range with different server_ids |
| 140 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=1-2-0 --stop-position=1-3-4 | MYSQL |
| 141 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=1-2-0 --stop-position=1-3-4 | $MYSQL |
| 142 |
|
| 143 |
if ($test3_t2_good_checksum != `CHECKSUM TABLE t2`) |
| 144 |
{ |
| 145 |
die $data_inconsistent_err; |
| 146 |
} |
| 147 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`) |
| 148 |
{ |
| 149 |
die "t1 should not exist as binlog replay should exclude domain 0 from stop position"; |
| 150 |
} |
| 151 |
DROP TABLE t2; |
| 152 |
|
| 153 |
|
| 154 |
--echo # |
| 155 |
--echo # Test Case 4: |
| 156 |
--echo # Multiple GTID ranges specified |
| 157 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 --stop-position=0-1-3,1-2-3 | MYSQL |
| 158 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 --stop-position=0-1-3,1-2-3 | $MYSQL |
| 159 |
|
| 160 |
# Reuse checksum spot from test 4 |
| 161 |
if ($t1_final_checksum != `CHECKSUM TABLE t1`) |
| 162 |
{ |
| 163 |
die $data_inconsistent_err; |
| 164 |
} |
| 165 |
if ($test4_t2_good_checksum != `CHECKSUM TABLE t2`) |
| 166 |
{ |
| 167 |
die $data_inconsistent_err; |
| 168 |
} |
| 169 |
DROP TABLE t1; |
| 170 |
DROP TABLE t2; |
| 171 |
|
| 172 |
|
| 173 |
--echo # |
| 174 |
--echo # Test Case 5: |
| 175 |
--echo # Multiple GTID ranges specified where the domain ids are listed in |
| 176 |
--echo # different orders between start/stop position |
| 177 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-3,1-2-3 --start-position=1-2-0,0-1-0 | MYSQL |
| 178 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=0-1-3,1-2-3 --start-position=1-2-0,0-1-0 | $MYSQL |
| 179 |
|
| 180 |
# Reuse checksum spot from test 4 |
| 181 |
if ($t1_final_checksum != `CHECKSUM TABLE t1`) |
| 182 |
{ |
| 183 |
die $data_inconsistent_err; |
| 184 |
} |
| 185 |
if ($test4_t2_good_checksum != `CHECKSUM TABLE t2`) |
| 186 |
{ |
| 187 |
die $data_inconsistent_err; |
| 188 |
} |
| 189 |
DROP TABLE t1; |
| 190 |
DROP TABLE t2; |
| 191 |
|
| 192 |
|
| 193 |
--echo # |
| 194 |
--echo # Test Case 6: |
| 195 |
--echo # Only start position specified |
| 196 |
CREATE TABLE t1 (a int); |
| 197 |
INSERT INTO t1 values (3), (4); |
| 198 |
--let test6_t1_mid_checksum= `CHECKSUM TABLE t1` |
| 199 |
DROP TABLE t1; |
| 200 |
CREATE TABLE t1 (a int); |
| 201 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-2 | MYSQL |
| 202 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-2 | $MYSQL |
| 203 |
if ($test6_t1_mid_checksum != `CHECKSUM TABLE t1`) |
| 204 |
{ |
| 205 |
die $data_inconsistent_err; |
| 206 |
} |
| 207 |
if ($t2_final_checksum != `CHECKSUM TABLE t2`) |
| 208 |
{ |
| 209 |
die $data_inconsistent_err; |
| 210 |
} |
| 211 |
DROP TABLE t1; |
| 212 |
DROP TABLE t2; |
| 213 |
|
| 214 |
|
| 215 |
--echo # |
| 216 |
--echo # Test Case 7: |
| 217 |
--echo # Only stop position specified |
| 218 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-2 | MYSQL |
| 219 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=0-1-2 | $MYSQL |
| 220 |
|
| 221 |
# Reuse checksum spot from test 2 |
| 222 |
if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`) |
| 223 |
{ |
| 224 |
die $data_inconsistent_err; |
| 225 |
} |
| 226 |
DROP TABLE t1; |
| 227 |
|
| 228 |
|
| 229 |
--echo # |
| 230 |
--echo # Test Case 8: |
| 231 |
--echo # Seq_no=0 in --start-position includes all events for a domain |
| 232 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 | MYSQL |
| 233 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0,1-2-0 | $MYSQL |
| 234 |
if ($t1_final_checksum != `CHECKSUM TABLE t1`) |
| 235 |
{ |
| 236 |
die "t1 data should be complete as binlog replay should include domain 0 entirely in results"; |
| 237 |
} |
| 238 |
if ($t2_final_checksum != `CHECKSUM TABLE t2`) |
| 239 |
{ |
| 240 |
die "t2 data should be complete as binlog replay should include domain 1 entirely in results"; |
| 241 |
} |
| 242 |
DROP TABLE t1; |
| 243 |
DROP TABLE t2; |
| 244 |
|
| 245 |
--echo # |
| 246 |
--echo # Test Case 9: |
| 247 |
--echo # Seq_no=0 in --stop-position excludes all events for a domain |
| 248 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-0,1-2-0 | MYSQL |
| 249 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=0-1-0,1-2-0 | $MYSQL |
| 250 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`) |
| 251 |
{ |
| 252 |
die "t1 should not exist as binlog replay should exclude domain 0 from results"; |
| 253 |
} |
| 254 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) |
| 255 |
{ |
| 256 |
die "t2 should not exist as binlog replay should exclude domain 1 from results"; |
| 257 |
} |
| 258 |
|
| 259 |
--echo # |
| 260 |
--echo # Test Case 10: |
| 261 |
--echo # Output stops for all domain ids when all --stop-position GTID values |
| 262 |
--echo # have been hit. |
| 263 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=0-1-2 | MYSQL |
| 264 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=0-1-2 | $MYSQL |
| 265 |
if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`) |
| 266 |
{ |
| 267 |
die $data_inconsistent_err; |
| 268 |
} |
| 269 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) |
| 270 |
{ |
| 271 |
die "t2 should not exist as binlog replay should exclude domain 1 from results"; |
| 272 |
} |
| 273 |
DROP TABLE t1; |
| 274 |
|
| 275 |
--echo # |
| 276 |
--echo # Test Case 11: |
| 277 |
--echo # All GTID events from other domains are printed until the |
| 278 |
--echo # --stop-position values are hit |
| 279 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=1-3-4 | MYSQL |
| 280 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=1-3-4 | $MYSQL |
| 281 |
if ($test3_t2_good_checksum != `CHECKSUM TABLE t2`) |
| 282 |
{ |
| 283 |
die $data_inconsistent_err; |
| 284 |
} |
| 285 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`) |
| 286 |
{ |
| 287 |
die "t1 should not exist as binlog replay should exclude domain 0 from stop position"; |
| 288 |
} |
| 289 |
DROP TABLE t2; |
| 290 |
|
| 291 |
--echo # |
| 292 |
--echo # Test Case 12: |
| 293 |
--echo # Scalar and GTID values can be used together for stop or start |
| 294 |
--echo # position |
| 295 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=empty_binlog_pos --stop-position=0-1-2 | MYSQL |
| 296 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=$empty_binlog_pos --stop-position=0-1-2 | $MYSQL |
| 297 |
if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`) |
| 298 |
{ |
| 299 |
die $data_inconsistent_err; |
| 300 |
} |
| 301 |
DROP TABLE t1; |
| 302 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=t1_final_checksum_pos | MYSQL |
| 303 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=$t1_final_checksum_pos | $MYSQL |
| 304 |
if ($t1_final_checksum != `CHECKSUM TABLE t1`) |
| 305 |
{ |
| 306 |
die $data_inconsistent_err; |
| 307 |
} |
| 308 |
if ($t2_mid_checksum != `CHECKSUM TABLE t2`) |
| 309 |
{ |
| 310 |
die $data_inconsistent_err; |
| 311 |
} |
| 312 |
DROP TABLE t1; |
| 313 |
DROP TABLE t2; |
| 314 |
|
| 315 |
--echo # |
| 316 |
--echo # Test Case 13: |
| 317 |
--echo # If the start position is delayed within the binlog, events occurring |
| 318 |
--echo # before that position are ignored |
| 319 |
CREATE TABLE t1 (a int); |
| 320 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-1 --stop-position=0-1-2 | MYSQL |
| 321 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-1 --stop-position=0-1-2 | $MYSQL |
| 322 |
if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`) |
| 323 |
{ |
| 324 |
die $data_inconsistent_err; |
| 325 |
} |
| 326 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) |
| 327 |
{ |
| 328 |
die "t2 should not exist as binlog replay should exclude domain 1 from results"; |
| 329 |
} |
| 330 |
DROP TABLE t1; |
| 331 |
|
| 332 |
--echo # |
| 333 |
--echo # Test Case 14: |
| 334 |
--echo # If start position is repeated, the last specification overrides all |
| 335 |
--echo # previous ones |
| 336 |
CREATE TABLE t1 (a int); |
| 337 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --start-position=0-1-1 --stop-position=0-1-2 | MYSQL |
| 338 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --start-position=0-1-1 --stop-position=0-1-2 | $MYSQL |
| 339 |
if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`) |
| 340 |
{ |
| 341 |
die $data_inconsistent_err; |
| 342 |
} |
| 343 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) |
| 344 |
{ |
| 345 |
die "t2 should not exist as binlog replay should exclude domain 1 from results"; |
| 346 |
} |
| 347 |
DROP TABLE t1; |
| 348 |
|
| 349 |
--echo # |
| 350 |
--echo # Test Case 15: |
| 351 |
--echo # If stop position is repeated, the last specification overrides all |
| 352 |
--echo # previous ones |
| 353 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-1 --stop-position=0-1-2 | MYSQL |
| 354 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-1 --stop-position=0-1-2 | $MYSQL |
| 355 |
if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`) |
| 356 |
{ |
| 357 |
die $data_inconsistent_err; |
| 358 |
} |
| 359 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) |
| 360 |
{ |
| 361 |
die "t2 should not exist as binlog replay should exclude domain 1 from results"; |
| 362 |
} |
| 363 |
DROP TABLE t1; |
| 364 |
|
| 365 |
--echo # |
| 366 |
--echo # Test Case 16: |
| 367 |
--echo # Start position with --offset=<n> skips n events after the first |
| 368 |
--echo # GTID is found |
| 369 |
|
| 370 |
# t1 needs to be specified because its creation should be skipped from |
| 371 |
# --offset specification |
| 372 |
CREATE TABLE t1 (a int); |
| 373 |
|
| 374 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 --offset=5 | MYSQL |
| 375 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=0-1-2 --offset=5 | $MYSQL |
| 376 |
if ($test2_t1_mid_checksum != `CHECKSUM TABLE t1`) |
| 377 |
{ |
| 378 |
die $data_inconsistent_err; |
| 379 |
} |
| 380 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) |
| 381 |
{ |
| 382 |
die "t2 should not exist as binlog replay should exclude events after GTID 0-1-2"; |
| 383 |
} |
| 384 |
DROP TABLE t1; |
| 385 |
|
| 386 |
--echo # |
| 387 |
--echo # Test Case 17: |
| 388 |
--echo # Start position with --start-datetime=<T> where T occurs after the |
| 389 |
--echo # specified GTID results in no events before T |
| 390 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=1-2-2 --start-datetime="1970-01-21 15:32:24" | MYSQL |
| 391 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-0 --stop-position=1-2-2 --start-datetime="1970-01-21 15:32:24" | $MYSQL |
| 392 |
if ($t2_mid_checksum != `CHECKSUM TABLE t2`) |
| 393 |
{ |
| 394 |
die $data_inconsistent_err; |
| 395 |
} |
| 396 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`) |
| 397 |
{ |
| 398 |
die "t1 should not exist as binlog replay should exclude events before the given start-datetime"; |
| 399 |
} |
| 400 |
DROP TABLE t2; |
| 401 |
|
| 402 |
--echo # |
| 403 |
--echo # Test Case 18: |
| 404 |
--echo # If --stop-position is specified, domains which are not present |
| 405 |
--echo # in its list should be excluded from output |
| 406 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --stop-position=1-3-4 | MYSQL |
| 407 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --stop-position=1-3-4 | $MYSQL |
| 408 |
|
| 409 |
if ($test3_t2_good_checksum != `CHECKSUM TABLE t2`) |
| 410 |
{ |
| 411 |
die $data_inconsistent_err; |
| 412 |
} |
| 413 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`) |
| 414 |
{ |
| 415 |
die "t1 should not exist as binlog replay should exclude domain 0 from stop position"; |
| 416 |
} |
| 417 |
DROP TABLE t2; |
| 418 |
|
| 419 |
--echo # |
| 420 |
--echo # Test Case 19: |
| 421 |
--echo # If the start and stop GTIDs in any domain are equal, the domain |
| 422 |
--echo # should not have any output |
| 423 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=0-1-2 --stop-position=0-1-2 | MYSQL |
| 424 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=0-1-2 --stop-position=0-1-2 | $MYSQL |
| 425 |
|
| 426 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`) |
| 427 |
{ |
| 428 |
die "t1 should not exist as binlog replay should exclude domain 0 from stop position"; |
| 429 |
} |
| 430 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) |
| 431 |
{ |
| 432 |
die "t2 should not exist as binlog replay should exclude domain 1 from stop position"; |
| 433 |
} |
| 434 |
|
| 435 |
--echo # |
| 436 |
--echo # Test Case 20: |
| 437 |
--echo # If --start-position and --stop-position have different domain ids, |
| 438 |
--echo # only events from GTIDs in the --stop-position list are output |
| 439 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM --start-position=1-2-2 --stop-position=0-1-3 | MYSQL |
| 440 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM --start-position=1-2-2 --stop-position=0-1-3 | $MYSQL |
| 441 |
if ($t1_final_checksum != `CHECKSUM TABLE t1`) |
| 442 |
{ |
| 443 |
die $data_inconsistent_err; |
| 444 |
} |
| 445 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) |
| 446 |
{ |
| 447 |
die "t2 should not exist as binlog replay should exclude domain 1 from stop position"; |
| 448 |
} |
| 449 |
DROP TABLE t1; |
| 450 |
|
| 451 |
--echo # |
| 452 |
--echo # Test Case 21: |
| 453 |
--echo # Successive binary logs (e.g. logs with previous logs that have been |
| 454 |
--echo # purged) will write events when the --start-position matches their |
| 455 |
--echo # Gtid_list_log_event state |
| 456 |
if ($is_remote == 1) |
| 457 |
{ |
| 458 |
--echo # |
| 459 |
--echo # Reset server state |
| 460 |
RESET MASTER; |
| 461 |
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE.orig | $MYSQL |
| 462 |
FLUSH LOGS; |
| 463 |
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE2.orig | $MYSQL |
| 464 |
FLUSH LOGS; |
| 465 |
--eval PURGE BINARY LOGS TO "$BINLOG_FILE2" |
| 466 |
DROP TABLE t1; |
| 467 |
DROP TABLE t2; |
| 468 |
DROP TABLE t3; |
| 469 |
} |
| 470 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-3,1-2-5 | MYSQL |
| 471 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM2 --start-position=0-1-3,1-2-5 | $MYSQL |
| 472 |
if ($t3_final_checksum != `CHECKSUM TABLE t3`) |
| 473 |
{ |
| 474 |
die $data_inconsistent_err; |
| 475 |
} |
| 476 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`) |
| 477 |
{ |
| 478 |
die "t1 should not exist as binlog replay should not have any events from unspecified binlog file"; |
| 479 |
} |
| 480 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) |
| 481 |
{ |
| 482 |
die "t2 should not exist as binlog replay should not have any events from unspecified binlog file"; |
| 483 |
} |
| 484 |
DROP TABLE t3; |
| 485 |
|
| 486 |
--echo # |
| 487 |
--echo # Test Case 22: |
| 488 |
--echo # Successive binary logs can be called with --stop-position and |
| 489 |
--echo # without --start-position |
| 490 |
if ($is_remote == 1) |
| 491 |
{ |
| 492 |
--echo # |
| 493 |
--echo # Reset server state |
| 494 |
RESET MASTER; |
| 495 |
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE.orig | $MYSQL |
| 496 |
FLUSH LOGS; |
| 497 |
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE2.orig | $MYSQL |
| 498 |
FLUSH LOGS; |
| 499 |
--eval PURGE BINARY LOGS TO "$BINLOG_FILE2" |
| 500 |
DROP TABLE t1; |
| 501 |
DROP TABLE t2; |
| 502 |
DROP TABLE t3; |
| 503 |
} |
| 504 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM2 --stop-position=0-1-4 | MYSQL |
| 505 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM2 --stop-position=0-1-4 | $MYSQL |
| 506 |
if (`SELECT COUNT(*) FROM test.t3`) |
| 507 |
{ |
| 508 |
die $data_inconsistent_err; |
| 509 |
} |
| 510 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't1'`) |
| 511 |
{ |
| 512 |
die "t1 should not exist as binlog replay should not have any events from unspecified binlog file"; |
| 513 |
} |
| 514 |
if (`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) |
| 515 |
{ |
| 516 |
die "t2 should not exist as binlog replay should not have any events from unspecified binlog file"; |
| 517 |
} |
| 518 |
DROP TABLE t3; |
| 519 |
|
| 520 |
|
| 521 |
if ($is_remote == 1) |
| 522 |
{ |
| 523 |
--echo # |
| 524 |
--echo # Remote-only setup for error cases |
| 525 |
RESET MASTER; |
| 526 |
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE.orig | $MYSQL |
| 527 |
FLUSH LOGS; |
| 528 |
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/$BINLOG_FILE2.orig | $MYSQL |
| 529 |
FLUSH LOGS; |
| 530 |
--eval PURGE BINARY LOGS TO "$BINLOG_FILE2" |
| 531 |
} |
| 532 |
|
| 533 |
--echo # At the following error cases analysis |
| 534 |
--echo # note incompatible --start-position with the value of |
| 535 |
--echo # Gtid list event of the 2nd binlog file printed above. |
| 536 |
|
| 537 |
--let err_out_= $MYSQLTEST_VARDIR/tmp/err.out |
| 538 |
--let SEARCH_FILE=$err_out_ |
| 539 |
|
| 540 |
--echo # |
| 541 |
--echo # Error Case 1: |
| 542 |
--echo # A GTID --start-position that does not mention all domains that make |
| 543 |
--echo # up the binary log state should error |
| 544 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-3 > tmp_out_ 2> err_out_ |
| 545 |
--error 1 |
| 546 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM2 --start-position=0-1-3 > $tmp_out_ 2> $err_out_ |
| 547 |
if ($is_remote == 1) |
| 548 |
{ |
| 549 |
--let SEARCH_PATTERN=ERROR: Got error reading packet from server |
| 550 |
} |
| 551 |
if ($is_remote == 0) |
| 552 |
{ |
| 553 |
--let SEARCH_PATTERN=ERROR: Starting GTID position list does not specify an initial value |
| 554 |
} |
| 555 |
--source include/search_pattern_in_file.inc |
| 556 |
--remove_file $err_out_ |
| 557 |
|
| 558 |
--echo # |
| 559 |
--echo # Error Case 2: |
| 560 |
--echo # A GTID --start-position with any sequence numbers which occur before |
| 561 |
--echo # the binary log state should result in error |
| 562 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-2,1-2-5 > tmp_out_ 2> err_out_ |
| 563 |
--error 1 |
| 564 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM2 --start-position=0-1-2,1-2-5 > $tmp_out_ 2> $err_out_ |
| 565 |
if ($is_remote == 1) |
| 566 |
{ |
| 567 |
--let SEARCH_PATTERN=ERROR: Got error reading packet from server |
| 568 |
} |
| 569 |
if ($is_remote == 0) |
| 570 |
{ |
| 571 |
--let SEARCH_PATTERN=ERROR: Binary logs are missing data for domain 0 |
| 572 |
} |
| 573 |
--source include/search_pattern_in_file.inc |
| 574 |
--remove_file $err_out_ |
| 575 |
|
| 576 |
--echo # |
| 577 |
--echo # Error Case 3: |
| 578 |
--echo # A GTID --start-position with any sequence numbers that are not |
| 579 |
--echo # eventually processed results in error |
| 580 |
--echo # MYSQL_BINLOG BINLOG_FILE_PARAM2 --start-position=0-1-8,1-2-6 > tmp_out_ 2> err_out_ |
| 581 |
--error 1 |
| 582 |
--exec $MYSQL_BINLOG $BINLOG_FILE_PARAM2 --start-position=0-1-8,1-2-6 > $tmp_out_ 2> $err_out_ |
| 583 |
if ($is_remote == 1) |
| 584 |
{ |
| 585 |
--let SEARCH_PATTERN=ERROR: Got error reading packet from server |
| 586 |
} |
| 587 |
if ($is_remote == 0) |
| 588 |
{ |
| 589 |
--let SEARCH_PATTERN=ERROR: Binary logs never reached expected GTID state |
| 590 |
} |
| 591 |
--source include/search_pattern_in_file.inc |
| 592 |
--remove_file $err_out_ |
| 593 |
|
| 594 |
if ($is_remote == 1) |
| 595 |
{ |
| 596 |
--echo # |
| 597 |
--echo # Remote-only cleanup from error cases |
| 598 |
DROP TABLE t1; |
| 599 |
DROP TABLE t2; |
| 600 |
DROP TABLE t3; |
| 601 |
RESET MASTER; |
| 602 |
} |
| 603 |
|
| 604 |
--remove_file $MYSQLD_DATADIR/$BINLOG_FILE.orig |
| 605 |
--remove_file $MYSQLD_DATADIR/$BINLOG_FILE2.orig |
| 606 |
--remove_file $tmp_out_ |