Debian Codegraph @

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

raw
1 # BUG#42829: binlogging enabled for all schemas regardless of
2 # binlog-db-db / binlog-ignore-db
3 #
4 # WHAT
5 # ====
6 #
7 # We want to test whether filtered events from binlog will cause
8 # raising an error mentioning that statement is unable to be logged or
9 # not, when:
10 #
11 # 1. isolation level READ-COMMITTED; AND
12 #
13 # 2. using InnoDB engine; AND
14 #
15 # 3. using SBL (in which case InnoDB will only allow RBL).
16 #
17 # HOW
18 # ===
19 #
20 # The test is implemented as follows:
21 #
22 # i) set transaction_isolation to read-committed.
23 #
24 # ii) create two databases (one filtered other not - using
25 # binlog-do-db)
26 #
27 # iii) Create statements that are to be filtered on filtered db
28 #
29 # - At this point, before fix, an error would be raised
30 #
31 # iv) do the same thing for not the filtered database and check
32 # that events throw an error:
33 #
34 # - Error: ER_BINLOG_STMT_MODE_AND_ROW_ENGINE
35 #
36
37 -- source include/have_log_bin.inc
38 -- source include/have_binlog_format_statement.inc
39
40 SET @old_isolation_level= @@session.transaction_isolation;
41 SET @@session.transaction_isolation= 'READ-COMMITTED';
42
43 -- let $engine= InnoDB
44 -- let $filtered= b42829_filtered
45 -- let $not_filtered= b42829
46
47 -- eval CREATE DATABASE $not_filtered
48 -- eval use $not_filtered
49 -- eval CREATE TABLE t1 (x int, y int) engine=$engine
50 -- eval CREATE TABLE t2 (x int, y int) engine=$engine
51
52 -- eval CREATE DATABASE $filtered
53 -- eval use $filtered
54 -- eval CREATE TABLE t1 (x int, y int) engine=$engine
55 -- eval CREATE TABLE t2 (x int, y int) engine=$engine
56
57 SET @@session.sql_log_bin= 0;
58 -- eval INSERT INTO $filtered.t1 VALUES (100,100)
59 -- eval INSERT INTO $not_filtered.t1 VALUES (100,100)
60 SET @@session.sql_log_bin= 1;
61
62 -- echo ### assertion: the inserts will not raise log error because
63 -- echo ### binlog-do-db is filtering used database
64 INSERT INTO t2 VALUES (1,2), (1,3), (1,4);
65 INSERT INTO t1 SELECT * FROM t2;
66
67 -- echo ### assertion: assert that despite updating a not filtered
68 -- echo ### database this wont trigger an error as the
69 -- echo ### used database is the filtered one.
70 -- eval UPDATE $filtered.t1 ft1, $not_filtered.t1 nft1 SET ft1.x=1, nft1.x=2
71
72 -- eval use $not_filtered
73 -- echo ### assertion: the statements *will* raise log error because
74 -- echo ### binlog-do-db is not filtering used database
75 BEGIN;
76 -- error ER_BINLOG_STMT_MODE_AND_ROW_ENGINE
77 INSERT INTO t2 VALUES (1,2), (1,3), (1,4);
78 -- error ER_BINLOG_STMT_MODE_AND_ROW_ENGINE
79 -- eval UPDATE $filtered.t1 ft1, $not_filtered.t1 nft1 SET ft1.x=1, nft1.x=2
80 -- error ER_BINLOG_STMT_MODE_AND_ROW_ENGINE
81 INSERT INTO t1 SELECT * FROM t2;
82 COMMIT;
83
84 -- echo ### assertion: filtered events did not make into the binlog
85 source include/show_binlog_events.inc;
86
87 -- eval DROP DATABASE $not_filtered
88 -- eval DROP DATABASE $filtered
89 SET @@session.transaction_isolation= @old_isolation_level;