1
# BUG#42941: --database parameter to mysqlbinlog fails with RBR
6
# This test aims at checking whether a rows log event is printed or
7
# not when --database parameter is used to filter events from one
13
# The test is implemented as follows:
15
# i) Some operations are done in two different databases:
16
# 'test' and 'b42941';
17
# ii) mysqlbinlog is used to dump the contents of the binlog file
18
# filtering only events from 'b42941'. The result of the dump is
19
# stored in a temporary file. (This is done with and without
20
# --verbose/hexdump flag);
21
# iii) The contents of the dump are loaded into a session variable;
22
# iv) The variable contents are searched for 'test' and 'b42941';
23
# v) Should 'test' be found, an ERROR is reported. Should 'b42941' be
24
# absent, an ERROR is reported.
26
-- source include/have_log_bin.inc
27
-- source include/have_binlog_format_row.inc
28
-- source include/have_innodb.inc
31
-- let $MYSQLD_DATADIR= `select @@datadir`
33
CREATE TABLE t1 (id int);
34
CREATE TABLE t2 (id int);
35
CREATE TABLE t3 (txt TEXT);
36
CREATE TABLE t4 (a int) ENGINE= InnoDB;
37
INSERT INTO t1 VALUES (1);
38
INSERT INTO t1 VALUES (2);
39
INSERT INTO t2 VALUES (1);
40
INSERT INTO t2 VALUES (2);
41
INSERT INTO t1 VALUES (3);
42
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
43
-- eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data/words.dat' INTO TABLE t3
44
INSERT INTO t1 VALUES (4);
46
CREATE DATABASE b42941;
48
CREATE TABLE t1 (id int);
49
CREATE TABLE t2 (id int);
50
CREATE TABLE t3 (txt TEXT);
51
CREATE TABLE t4 (a int) ENGINE= InnoDB;
52
INSERT INTO t1 VALUES (1);
53
INSERT INTO t1 VALUES (2);
54
INSERT INTO t2 VALUES (1);
55
INSERT INTO t2 VALUES (2);
56
INSERT INTO t1 VALUES (3);
57
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
58
-- eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/std_data/words.dat' INTO TABLE t3
59
INSERT INTO t1 VALUES (4);
61
INSERT INTO test.t1 VALUES (5);
65
UPDATE test.t1 t11, b42941.t1 t12 SET t11.id=10, t12.id=100;
68
INSERT INTO test.t4 VALUES (1);
69
INSERT INTO b42941.t4 VALUES (1);
70
UPDATE test.t4 tn4, b42941.t4 tt4 SET tn4.a= 10, tt4.a= 100;
75
-- let $log_file1= $MYSQLD_DATADIR/master-bin.000001
76
-- let $log_file2= $MYSQLD_DATADIR/master-bin.000002
77
-- let $outfile= $MYSQLTEST_VARDIR/tmp/b42941-mysqlbinlog
78
-- let $cmd= $MYSQL_BINLOG
83
-- let $flags=--database=b42941
85
# construct CLI for mysqlbinlog
88
-- let $flags= $flags --verbose --hexdump
93
-- let $flags= $flags --verbose
98
# do nothing $flags is already set as it should be
101
# execute mysqlbinlog on the two available master binlog files
102
-- exec $cmd $flags $log_file1 > $outfile.1
103
-- exec $cmd $flags $log_file2 > $outfile.2
105
# load outputs into a variable
106
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
107
-- eval SET @b42941_output.1= LOAD_FILE('$outfile.1')
109
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
110
-- eval SET @b42941_output.2= LOAD_FILE('$outfile.2')
112
# remove unecessary files
113
-- remove_file $outfile.1
114
-- remove_file $outfile.2
116
# assertion: events for database test are filtered
117
if (`SELECT INSTR(@b42941_output.1, 'test')`)
119
-- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.1).
122
if (`SELECT INSTR(@b42941_output.2, 'test')`)
124
-- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.2).
127
# assertion: events for database b42941 are not filtered
128
if (!`SELECT INSTR(@b42941_output.1, 'b42941')`)
130
-- echo **** ERROR **** Database name 'b42941' NOT FOUND in mysqlbinlog output ($flags $outfile.1).
133
if (!`SELECT INSTR(@b42941_output.2, 'b42941')`)
135
-- echo **** ERROR **** Database name 'b42941' NOT FOUND in mysqlbinlog output ($flags $outfile.2).
141
DROP DATABASE b42941;
143
DROP TABLE t1, t2, t3, t4;