Debian Codegraph @

mysql-test/suite/rpl/t/rpl_stm_ignore.test

raw
1 ###############################################################################
2 # Bug#20797764: FAILED CREATE VIEW IS BINLOGGED, AND NOT FILTERED OUT
3 #
4 # Problem:
5 # ========
6 # Replication slave choke on statement that should be ignored instead.
7 #
8 # Test:
9 # =====
10 # Create two database db_a and db_b. Add a replicate-do-db=db_a filter on
11 # slave. On master create a view view_b on master on db_b database. This
12 # statement will be replicated and ignored on slave. Re-executing same CREATE
13 # VIEW statement on master will result in an error. As part of test we prove
14 # that failed CREATE VIEW statement is not binlogged and slave will not error
15 # out saying "query caused different errors on master and slave". Slave should
16 # be in sync with master.
17 ###############################################################################
18 --source include/not_group_replication_plugin.inc
19 --source include/master-slave.inc
20
21 --source include/force_myisam_default.inc
22 --source include/have_myisam.inc
23
24 echo "Test case1";
25 --source include/rpl_connection_master.inc
26 CREATE DATABASE db_a;
27 CREATE DATABASE db_b;
28 --source include/sync_slave_sql_with_master.inc
29 FLUSH LOCAL RELAY LOGS;
30
31 --source include/rpl_connection_master.inc
32 USE db_b;
33 CREATE VIEW view_b AS SELECT NULL;
34 --source include/sync_slave_sql_with_master.inc
35
36 --source include/rpl_connection_master.inc
37 --error ER_TABLE_EXISTS_ERROR
38 CREATE VIEW view_b AS SELECT NULL;
39 # Prove that CREATE VIEW statement is binlogged only once
40 --source include/show_binlog_events.inc
41 # Prove that slave doesnot error out and is in sync with master
42 --source include/sync_slave_sql_with_master.inc
43 # Prove that CREATE VIEW statement was received by slave
44 --let $binlog_file= LAST
45 --source include/show_relaylog_events.inc
46 # Prove that the CREATE VIEW statement is ignored by slave
47 --error ER_NO_SUCH_TABLE
48 EXPLAIN view_b;
49
50 --source include/rpl_connection_master.inc
51 DROP DATABASE db_a;
52 DROP DATABASE db_b;
53 --source include/sync_slave_sql_with_master.inc
54
55 --source include/rpl_reset.inc
56
57 echo "Test case2";
58 # Create two databases db_a and db_b. Execute a partial update statement such
59 # that it results in an error on master and still gets binlogged. When the
60 # statement is received on slave it should not cause the slave to break.
61 # Without fix slave will error out with following error message.
62 # Last_Error Query caused different errors on master and slave. Error on
63 # master: message (format)='Duplicate entry '%-.192s' for key %d' error
64 # code=1062 ; Error on slave: actual message='no error', error code=0. Default
65 # database: 'db_b'. Query: 'update t2 set f=f+2 where f>=2'.
66 --source include/rpl_connection_master.inc
67 CREATE DATABASE db_a;
68 CREATE DATABASE db_b;
69 --source include/sync_slave_sql_with_master.inc
70
71 --source include/rpl_connection_master.inc
72 USE db_b;
73 CREATE TABLE t2 (f INT PRIMARY KEY) ENGINE=MYISAM;
74 INSERT INTO t2 VALUES (1);
75 INSERT INTO t2 VALUES (2);
76 INSERT INTO t2 VALUES (3);
77 INSERT INTO t2 VALUES (5);
78 --source include/sync_slave_sql_with_master.inc
79
80 --source include/rpl_connection_master.inc
81 --error ER_DUP_ENTRY
82 UPDATE t2 SET f=f+2 WHERE f>=2;
83 --source include/sync_slave_sql_with_master.inc
84
85 --source include/rpl_connection_master.inc
86 DROP DATABASE db_a;
87 DROP DATABASE db_b;
88 --source include/sync_slave_sql_with_master.inc
89 --source include/rpl_end.inc