Debian Codegraph @

mysql-test/suite/binlog/t/binlog_rewrite_suppress_use.test

raw
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
9 RESET MASTER;
10 CREATE DATABASE db1;
11 USE db1;
12 CREATE TABLE t1 (i INT);
13
14 # Get some INSERT, UPDATE and DELETE ROW events.
15 INSERT INTO t1 VALUES(1);
16 INSERT INTO t1 VALUES(2);
17 UPDATE t1 SET i= i+1;
18 DELETE 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/binlog.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 include/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/binlog.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 include/grep_pattern.inc
36
37 CREATE DATABASE db2;
38 DROP DATABASE db1;
39 # With gtid-mode=on we need purge gtid_executed, if not transactions
40 # replayed through mysqlbinlog will be skipped.
41 RESET MASTER;
42 --exec $MYSQL --database=db2 --local-infile=1 < $MYSQLTEST_VARDIR/tmp/row_event.sql
43 --error ER_NO_SUCH_TABLE
44 SELECT * FROM db2.t1;
45
46 DROP DATABASE db1;
47 # With gtid-mode=on we need purge gtid_executed, if not transactions
48 # replayed through mysqlbinlog will be skipped.
49 RESET 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
60 DROP DATABASE db1;
61 DROP DATABASE db2;