############################### # Test Setup ############################### 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 @@session.server_id= 2; CREATE TABLE t2 (a int); INSERT INTO t2 values (3); SET @@session.gtid_domain_id= 1; SET @@session.server_id= 1; CREATE TABLE t3 (a int); INSERT INTO t3 values (4); SET @@session.server_id= 3; SET timestamp=@a+1; CREATE TABLE t4 (a int); SET timestamp=@a+2; INSERT INTO t4 values (5); SET @@session.gtid_domain_id= 0; SET @@session.server_id= 1; INSERT INTO t1 values (1); SET @@session.gtid_domain_id= 2; SET @@session.server_id= 1; CREATE TABLE t5 (a int); INSERT INTO t5 values (6); SET @@session.gtid_domain_id= 0; SET @@session.server_id= 1; INSERT INTO t1 values (2); FLUSH LOGS; SET @@session.gtid_domain_id= 0; SET @@session.server_id= 2; CREATE TABLE t6 (a int); INSERT INTO t6 values (1); FLUSH LOGS; DROP TABLE t1; DROP TABLE t2; DROP TABLE t3; DROP TABLE t4; DROP TABLE t5; DROP TABLE t6; RESET MASTER; ############################### # Test Cases ############################### # # Test Case 1) --do-server-ids with a single server id limits output # to that single server # MYSQL_BINLOG BINLOG_FILE_PARAM --do-server-ids=2 | MYSQL DROP TABLE t2; # # Test Case 2) --do-server-ids with multiple server ids limits output # to the provided servers # MYSQL_BINLOG BINLOG_FILE_PARAM --do-server-ids=2,3 | MYSQL DROP TABLE t2; DROP TABLE t4; # # Test Case 3) --do-server-ids when combined with --do-domain-ids should # intersect the results # MYSQL_BINLOG BINLOG_FILE_PARAM --do-server-ids=1 --do-domain-ids=0 | MYSQL DROP TABLE t1; # # Test Case 4) --do-server-ids when combined with --ignore-domain-ids should # intersect the results # MYSQL_BINLOG BINLOG_FILE_PARAM --do-server-ids=1 --ignore-domain-ids=0 | MYSQL DROP TABLE t3; DROP TABLE t5; # # Test Case 5) --do-server-ids when combined with a GTID range should # intersect the results # MYSQL_BINLOG BINLOG_FILE_PARAM --do-server-ids=1 --stop-position=0-1-4 | MYSQL DROP TABLE t1; # # Test Case 6) --do-server-ids when combined with both --ignore-domain-ids # and a GTID range should intersect all results # MYSQL_BINLOG BINLOG_FILE_PARAM --do-server-ids=1 --ignore-domain-ids=0 --start-position=1-1-0 | MYSQL DROP TABLE t3; DROP TABLE t5; # # Test Case 7) --do-server-ids when combined with both --do-domain-ids and # a GTID range should intersect all results # MYSQL_BINLOG BINLOG_FILE_PARAM --do-server-ids=2 --do-domain-ids=0 --start-position=0-1-0 | MYSQL DROP TABLE t2; # # Test Case 8) --do-server-ids and --offset= skips n events after the # first GTID is found CREATE TABLE t4 (a int); # MYSQL_BINLOG BINLOG_FILE_PARAM --offset=5 --do-server-ids=3 --do-domain-ids=1 | MYSQL DROP TABLE t4; # # Test Case 9) --do-server-ids with --start-datetime= where T occurs # after the first GTID is found results in no events before T CREATE TABLE t4 (a int); # MYSQL_BINLOG BINLOG_FILE_PARAM --start-datetime="1970-01-21 15:32:24" --do-server-ids=3 --do-domain-ids=1 | MYSQL DROP TABLE t4; # # Test Case 10) --do-server-ids works with --read-from-remote-server # Setup test specific data RESET MASTER; SET @@session.gtid_domain_id= 0; SET @@session.server_id= 1; CREATE TABLE t1 (a int); INSERT INTO t1 VALUES (1); SET @@session.server_id= 2; CREATE TABLE t2 (a int); INSERT INTO t2 VALUES (1); SET @@session.server_id= 1; DROP TABLE t1; DROP TABLE t2; # MYSQL_BINLOG BINLOG_FILENAME --read-from-remote-server --do-server-ids=2 | MYSQL DROP TABLE t2; # # Test Case 11) --do-server-ids works over multiple binary log input # files # MYSQL_BINLOG BINLOG_FILE_PARAM BINLOG_FILE_PARAM2 --do-server-ids=2 | MYSQL DROP TABLE t2; DROP TABLE t6; # # Test Case 12) --do-server-ids re-specifications should override # previous ones # MYSQL_BINLOG BINLOG_FILE_PARAM --do-server-ids=1 --do-server-ids=2 | MYSQL DROP TABLE t2; # # Test Case 13) --do-server-ids and --server-id should be aliases and # a re-specification of one should override the former # MYSQL_BINLOG BINLOG_FILE_PARAM --do-server-ids=1 --server-id=2 | MYSQL DROP TABLE t2; # # Test Case 14) --ignore-server-ids re-specifications should override # previous ones # MYSQL_BINLOG BINLOG_FILE_PARAM --ignore-server-ids=2 --ignore-server-ids=1,3 | MYSQL DROP TABLE t2; # # Test Case 15) --do-domain-ids re-specifications should override # previous ones # MYSQL_BINLOG BINLOG_FILE_PARAM --do-domain-ids=1 --do-domain-ids=0 | MYSQL DROP TABLE t1,t2; # # Test Case 16) --ignore-domain-ids re-specifications should override # previous ones # MYSQL_BINLOG BINLOG_FILE_PARAM --ignore-domain-ids=0 --ignore-domain-ids=1,2 | MYSQL DROP TABLE t1,t2; ############################## # Error Cases ############################## # # Error Case 1: # --ignore-server-ids and --do-server-ids both specified # MYSQL_BINLOG BINLOG_FILE_PARAM --do-server-ids=1 --ignore-server-ids=2 # # Error Case 2: # Invalid server ID number provided # MYSQL_BINLOG BINLOG_FILE_PARAM --do-server-ids=-1 ############################## # Cleanup ############################## SET @@global.gtid_domain_id= 0; SET @@global.server_id= 1; # End of tests