1
# WL#6404 - Add rewrite-db option to mysqlbinlog on RBR
3
# The test checks that there is no leak of the global variables used
4
# to decide whether rewrite-db option is ON or OFF.
6
# The test checks this by creating two tables in two different databases.
7
# insert rows in both of them.
9
# Read the binlog file using the new option --rewrite-db="db1->db3" and
10
# writing in the .sql file.
12
# On applying the .sql file on database db3, we get an error since not
13
# all events are converted for database db3. Only DB1 is converted to db3.
14
# The db2 event cause the error.
17
--source include/have_binlog_format_row.inc
21
CREATE TABLE t1 (i INT);
23
# Get some INSERT, UPDATE and DELETE ROW events.
24
INSERT INTO db1.t1 VALUES(1);
25
INSERT INTO db1.t1 VALUES(2);
27
DELETE FROM t1 WHERE i=2;
30
CREATE TABLE db2.t1 (i INT);
32
# Get some INSERT, UPDATE and DELETE ROW events.
33
INSERT INTO db2.t1 VALUES(3);
34
INSERT INTO db2.t1 VALUES(4);
35
INSERT INTO db2.t1 VALUES(5);
36
UPDATE db2.t1 SET i= i+1;
37
DELETE FROM db2.t1 WHERE i=4;
39
--let $MYSQLD_DATADIR= `select @@datadir`
41
# Using the new option to apply the row event on some other database (from db1 -> db3 in the current case)
43
--exec $MYSQL_BINLOG --force-if-open --rewrite-db="db1->db3" $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/rewrite_noleak.sql
44
call mtr.add_suppression("Slave SQL: Error executing row event:*");
46
--echo Dropping the database db1 creating the new database db3.
50
# The SQL file will be applied but only db1 events will be replayed on db3.
51
# Database db2 will not be applied on db3 confirming there is no leak.
54
# With gtid-mode=on we need purge gtid_executed, if not transactions
55
# replayed through mysqlbinlog will be skipped.
57
--echo [The sql file will be applied on the current database]
58
--exec $MYSQL --database=db3 --local-infile=1 < $MYSQLTEST_VARDIR/tmp/rewrite_noleak.sql
60
--echo [The content of table db3.t1 and db2.t1 will be different confirming no leak]
62
--let $db3_max= `SELECT MAX(i) FROM db3.t1`
63
--let $db2_max= `SELECT MAX(i) FROM db2.t1`
64
--let $assert_text= The content of the table t1 in database db3 and db2 is different
65
--let $assert_cond= $db3_max <> $db2_max
66
--source include/assert.inc
68
--let $db3_count= `SELECT COUNT(*) FROM db3.t1`
69
--let $db2_count= `SELECT COUNT(*) FROM db2.t1`
70
--let $assert_text= Table t1 in db3 have different row count than t1 in db2
71
--let $assert_cond= $db3_count=1 AND $db2_count<>1
72
--source include/assert.inc
76
#--remove_file $MYSQLTEST_VARDIR/tmp/rewrite_noleak.sql