1# WL#6404 - Add rewrite-db option to mysqlbinlog on RBR 2# 3# The test aims to check that the use of rewrite-db option of 4# mysqlbinlog suppresses the USE DATABASE command logged in 5# binlog file. 6# 7 8--source include/have_binlog_format_row.inc 9RESET MASTER; 10CREATE DATABASE db1; 11USE db1; 12CREATE TABLE t1 (i INT); 13 14# Get some INSERT, UPDATE and DELETE ROW events. 15INSERT INTO t1 VALUES(1); 16INSERT INTO t1 VALUES(2); 17UPDATE t1 SET i= i+1; 18DELETE FROM t1 WHERE i=2; 19 20--let $MYSQLD_DATADIR= `select @@datadir` 21 22# Checking for the suppression of the USE DATABASE command on using the new option. 23# Reading binlog file without the rewrite-db option. 24--echo [The use <db_name> is not suppressed in the general use of mysqlbinlog] 25--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/row_event.sql 26--let GREP_FILE=$MYSQLTEST_VARDIR/tmp/row_event.sql 27--let GREP_PATTERN=use `db1` 28--source extra/rpl_tests/grep_pattern.inc 29 30# Reading binlog file with the rewrite-db option. 31--echo [The use <db_name> is suppressed on using rewrite-db option of mysqlbinlog] 32--exec $MYSQL_BINLOG --force-if-open --rewrite-db="db1->db2" $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/row_event_rewrite.sql 33--let GREP_FILE=$MYSQLTEST_VARDIR/tmp/row_event_rewrite.sql 34--let GREP_PATTERN=use `db1` 35--source extra/rpl_tests/grep_pattern.inc 36 37CREATE DATABASE db2; 38DROP DATABASE db1; 39# With gtid-mode=on we need purge gtid_executed, if not transactions 40# replayed through mysqlbinlog will be skipped. 41RESET MASTER; 42--exec $MYSQL --database=db2 --local-infile=1 < $MYSQLTEST_VARDIR/tmp/row_event.sql 43--error ER_NO_SUCH_TABLE 44SELECT * FROM db2.t1; 45 46DROP DATABASE db1; 47# With gtid-mode=on we need purge gtid_executed, if not transactions 48# replayed through mysqlbinlog will be skipped. 49RESET MASTER; 50--echo [The event of table db1.t1 has been successfully applied to db2.t1] 51--exec $MYSQL --database=db2 --local-infile=1 < $MYSQLTEST_VARDIR/tmp/row_event_rewrite.sql 52--let $assert_text= Assert that table db2.t1 has no rows after applying the sql file. 53--let $assert_cond= `SELECT COUNT(*)=1 from db2.t1` 54--source include/assert.inc 55 56--echo [CLEANUP] 57--remove_file $MYSQLTEST_VARDIR/tmp/row_event.sql 58--remove_file $MYSQLTEST_VARDIR/tmp/row_event_rewrite.sql 59 60DROP DATABASE db1; 61DROP DATABASE db2; 62