Current Path : /home/usr.opt/mysql57/mysql-test/suite/binlog/t/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //home/usr.opt/mysql57/mysql-test/suite/binlog/t/binlog_mysqlbinlog_rewrite_db.test |
# WL#6404 - Add rewrite-db option to mysqlbinlog on RBR # # The test checks the new rewrite-db option for the mysqlbinlog. # # The test checks the following aspects of the new option: # 1. The valid syntax for the use of the new option and the errors in # case the usage is not correct. # 2. Apply the new binlog file ( with database rewritten ) to a new database # and check if it works. # # Bug26117735: MYSQLBINLOG READ-FROM-REMOTE-SERVER NOT HONORING REWRITE_DB # FILTERING # # Problem: # When running mysqlbinlog with the --read-from-remote-server option, # the processing of the binlog entries accepts rewrite_db as an argument, but # ignores the rewrite rule. Therefore no filtering is done on the binlog # entries, resulting in failures to write data in the target DB. # # Test case1: # Verify that rewrite_db filter works fine when reading binary log from remote # server. # # Test case2: # Verify that error scenario is handled properly in a case where rewrite_db # filter fails to rewrite the databases. # # mysqlbinlog should be debug compiled. --source include/mysqlbinlog_have_debug.inc --source include/have_binlog_format_row.inc RESET MASTER; CREATE DATABASE db1; USE db1; CREATE TABLE t1 (i INT); # Get some INSERT, UPDATE and DELETE ROW events. INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); UPDATE t1 SET i= i+1; DELETE FROM t1 WHERE i=2; --let $MYSQLD_DATADIR= `select @@datadir` --exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/row_event.sql # Using the new option to apply the row event on some other database (from db1 -> new_db1 in the current case) --echo [Syntax error in the use of the new option: The from database name is missing] --error 1 --exec $MYSQL_BINLOG --force-if-open --rewrite-db="->new_db1" $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/row_event_rewrite.sql --echo [Syntax error in the use of the new option: The '->' is missing] --error 1 --exec $MYSQL_BINLOG --force-if-open --rewrite-db="db1 new_db1" $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/row_event_rewrite.sql --echo [Syntax error in the use of the new option: The to database name is missing] --error 1 --exec $MYSQL_BINLOG --force-if-open --rewrite-db="db1->" $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/row_event_rewrite.sql --echo [VALID SYNTAX,The from->to database names is correctly mentioned] --exec $MYSQL_BINLOG --force-if-open --rewrite-db="db1->new_db1" $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/row_event_rewrite.sql --let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) # Bug26117735: MYSQLBINLOG READ-FROM-REMOTE-SERVER NOT HONORING REWRITE_DB FILTERING --echo [VALID SYNTAX read from remote server ,The from->to database names are correctly mentioned] --exec $MYSQL_BINLOG --force-if-open --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --rewrite-db="db1->new_db1" $binlog_file > $MYSQLTEST_VARDIR/tmp/row_event_from_remote_server_rewrite.sql # BUG26878022: MYSQLBINLOG: ASSERTION `(OLD_MH->M_KEY == KEY) || (OLD_MH->M_KEY == 0)' FAILED --echo [VALID SYNTAX read from remote server in raw mode, the from->to database names are correctly mentioned] --exec $MYSQL_BINLOG --raw --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --rewrite-db="db1->new_db1" $binlog_file --result-file=$MYSQLTEST_VARDIR/tmp/ --exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/tmp/$binlog_file > $MYSQLTEST_VARDIR/tmp/row_event_from_remote_server_rewrite_raw.sql --echo [VALID SYNTAX, but during the application of rewrite_db filter an invalid event is found. Hence mysqlbinlog tool should exit with an appropriate error] --echo [ERROR: Got fatal error while applying rewrite db filter.] --error 1 --exec $MYSQL_BINLOG --force-if-open -#d,'simulate_corrupt_event_len' --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --rewrite-db="db1->new_db1" $binlog_file > $MYSQLTEST_VARDIR/tmp/tmp.sql --echo #Dropping the database db1 and creating the table in the new database new_db1. CREATE DATABASE new_db1; DROP DATABASE db1; # The SQL file will be applied but nothing is applied on Database new_db1 since the row event was # generated for database db1 and table t1. # With gtid-mode=on we need purge gtid_executed, if not transactions # replayed through mysqlbinlog will be skipped. RESET MASTER; --exec $MYSQL --database=new_db1 --local-infile=1 < $MYSQLTEST_VARDIR/tmp/row_event.sql --error ER_NO_SUCH_TABLE SELECT * FROM new_db1.t1; # The SQL file should be applied since the row event was extracted using the new mysqlbinlog option. DROP DATABASE db1; # With gtid-mode=on we need purge gtid_executed, if not transactions # replayed through mysqlbinlog will be skipped. RESET MASTER; --echo [The event of table db1.t1 has been successfully applied to new_db1.t1] --exec $MYSQL --database=new_db1 --local-infile=1 < $MYSQLTEST_VARDIR/tmp/row_event_rewrite.sql --let $assert_text= Assert that table new_db1.t1 has one row after applying the sql file. --let $assert_cond= `SELECT COUNT(*)=1 from new_db1.t1` --source include/assert.inc DROP DATABASE db1; DROP DATABASE new_db1; CREATE DATABASE new_db1; # With gtid-mode=on we need purge gtid_executed, if not transactions # replayed through mysqlbinlog will be skipped. RESET MASTER; --echo [The event of table db1.t1 has been successfully applied to new_db1.t1] --exec $MYSQL --database=new_db1 --local-infile=1 < $MYSQLTEST_VARDIR/tmp/row_event_from_remote_server_rewrite.sql --let $assert_text= Assert that table new_db1.t1 has one row after applying the sql file. --let $assert_cond= `SELECT COUNT(*)=1 from new_db1.t1` --source include/assert.inc DROP DATABASE db1; DROP DATABASE new_db1; CREATE DATABASE new_db1; # With gtid-mode=on we need purge gtid_executed, if not transactions # replayed through mysqlbinlog will be skipped. RESET MASTER; --echo [The event of table db1.t1 has been successfully applied to new_db1.t1 from raw mode] --exec $MYSQL --database=new_db1 --local-infile=1 < $MYSQLTEST_VARDIR/tmp/row_event_from_remote_server_rewrite_raw.sql --let $assert_text= Assert that table new_db1.t1 has one row after applying the sql file from raw binlog dump. --let $assert_cond= `SELECT COUNT(*)=1 from new_db1.t1` --source include/assert.inc --echo CLEANUP --remove_file $MYSQLTEST_VARDIR/tmp/row_event.sql --remove_file $MYSQLTEST_VARDIR/tmp/row_event_rewrite.sql --remove_file $MYSQLTEST_VARDIR/tmp/row_event_from_remote_server_rewrite.sql --remove_file $MYSQLTEST_VARDIR/tmp/row_event_from_remote_server_rewrite_raw.sql --remove_file $MYSQLTEST_VARDIR/tmp/tmp.sql --remove_file $MYSQLTEST_VARDIR/tmp/$binlog_file DROP DATABASE db1; DROP DATABASE new_db1;