~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# BUG#42941: --database parameter to mysqlbinlog fails with RBR
 
2
#
 
3
# WHAT
 
4
# ====
 
5
#
 
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
 
8
#  given database.
 
9
#
 
10
# HOW
 
11
# ===
 
12
#
 
13
#  The test is implemented as follows: 
 
14
#
 
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.
 
25
 
 
26
-- source include/have_log_bin.inc
 
27
-- source include/have_binlog_format_row.inc
 
28
-- source include/have_innodb.inc
 
29
 
 
30
RESET MASTER;
 
31
-- let $MYSQLD_DATADIR= `select @@datadir`
 
32
 
 
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);
 
45
 
 
46
CREATE DATABASE b42941;
 
47
use 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);
 
60
 
 
61
INSERT INTO test.t1 VALUES (5);
 
62
 
 
63
FLUSH LOGS;
 
64
 
 
65
UPDATE test.t1 t11, b42941.t1 t12 SET t11.id=10, t12.id=100;
 
66
 
 
67
BEGIN;
 
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;
 
71
COMMIT;
 
72
 
 
73
FLUSH LOGS;
 
74
 
 
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
 
79
 
 
80
let $i= 3;
 
81
while($i)
 
82
{
 
83
  -- let $flags=--database=b42941
 
84
 
 
85
  # construct CLI for mysqlbinlog
 
86
  if(`SELECT $i=3`)
 
87
  {
 
88
    -- let $flags= $flags --verbose --hexdump
 
89
  }
 
90
 
 
91
  if(`SELECT $i=2`)
 
92
  {
 
93
    -- let $flags= $flags --verbose
 
94
  }
 
95
 
 
96
#  if(`SELECT $i=1`)
 
97
#  {
 
98
    # do nothing $flags is already set as it should be
 
99
#  }
 
100
 
 
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
 
104
 
 
105
  # load outputs into a variable
 
106
  -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 
107
  -- eval SET @b42941_output.1= LOAD_FILE('$outfile.1')
 
108
 
 
109
  -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 
110
  -- eval SET @b42941_output.2= LOAD_FILE('$outfile.2')
 
111
 
 
112
  # remove unecessary files
 
113
  -- remove_file $outfile.1
 
114
  -- remove_file $outfile.2
 
115
  
 
116
  #
 
117
  # The two tests are canceled since we introduced the patch of bug#46998,  
 
118
  # which will make mydsqlbinlog output the 'BEGIN', 'COMMIT' and 'ROLLBACK' 
 
119
  # in regardless of database filtering
 
120
  #
 
121
  # assertion: events for database test are filtered
 
122
  #if (`SELECT INSTR(@b42941_output.1, 'test')`)
 
123
  #{
 
124
    #-- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.1).
 
125
  #}
 
126
 
 
127
  #if (`SELECT INSTR(@b42941_output.2, 'test')`)
 
128
  #{
 
129
    #-- echo **** ERROR **** Database name 'test' FOUND in mysqlbinlog output ($flags $outfile.2).
 
130
  #}
 
131
 
 
132
  # assertion: events for database b42941 are not filtered
 
133
  if (!`SELECT INSTR(@b42941_output.1, 'b42941')`)
 
134
  {
 
135
    -- echo **** ERROR **** Database name 'b42941' NOT FOUND in mysqlbinlog output ($flags $outfile.1).
 
136
  }
 
137
 
 
138
  if (!`SELECT INSTR(@b42941_output.2, 'b42941')`)
 
139
  {
 
140
    -- echo **** ERROR **** Database name 'b42941' NOT FOUND in mysqlbinlog output ($flags $outfile.2).
 
141
  }
 
142
 
 
143
  dec $i;
 
144
}
 
145
 
 
146
DROP DATABASE b42941;
 
147
use test;
 
148
DROP TABLE t1, t2, t3, t4;