Debian Codegraph @

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

raw
1 # ==== Purpose ====
2 #
3 # Check that when the exectuion of a DROP TABLE command with single table
4 # fails it should not be written to the binary log. Also test that when the
5 # execution of DROP TABLE command with multiple tables fails then the fact
6 # if it will be logged or not depends on if any non-InnoDB tables are
7 # involved (as failed InnoDB-only multi-table DROP TABLE will have no
8 # effect).
9 #
10 # The above also provides coverage for changes to binary logging of failed
11 # DROP TABLES implemented as part of WL#7743 "New data dictionary: changes
12 # to DDL-related parts of SE API".
13 #
14 # ==== Implementation ====
15 # Create a database `db1` on master and ignore this database on the slave side
16 # using --replicate-ignore-db=db1 --replicate-wild-ignore-table=db1.%. Now
17 # execute a DROP TABLE command with single table in it and the command should
18 # fail thanks to error injection. Check in the binlog that query should
19 # not be binlogged. Slave should also be up and running without any errors.
20 # Execute another DROP TABLE command with multiple InnoDB tables in the drop
21 # list which will also fail. Check that the query is not binlogged in this
22 # case (as the whole statement is rolled back). Finally, execute multi-table
23 # DROP TABLE command involving MyISAM table which fails after deleting it.
24 # Check that query gets written into the binary log and slave should not fail
25 # since query is filtered on it.
26 #
27 # ==== References ====
28 #
29 # Bug#21435502: DROP TABLE IF EXISTS MAY BRAKE REPLICATION IF SLAVE HAS
30 # REPLICATION FILTERS.
31 #
32 ################################################################################
33 --source include/master-slave.inc
34 -- source include/have_debug.inc
35
36 CREATE DATABASE `db1`;
37
38 USE `db1`;
39
40 CREATE TABLE `t1` (`ID` bigint(20) primary key) ENGINE=InnoDB;
41
42 CREATE TABLE `t2` (`ID` bigint(20) primary key) ENGINE=InnoDB;
43
44 CREATE TABLE `t3` (`ID` bigint(20) primary key) ENGINE=InnoDB;
45
46 # Save master position
47 --let $saved_master_pos=query_get_value('SHOW MASTER STATUS', Position, 1)
48
49 # Test a single table drop failure
50 SET SESSION DEBUG='+d,rm_table_no_locks_abort_after_atomic_tables';
51 --error ER_UNKNOWN_ERROR
52 DROP TABLE IF EXISTS `db1`.`t1`;
53 SET SESSION DEBUG='-d,rm_table_no_locks_abort_after_atomic_tables';
54 --let $current_master_pos=query_get_value('SHOW MASTER STATUS', Position, 1)
55 --let $assert_text= Drop with single table should not be written to the binary log if the query execution fails
56 --let $assert_cond= $current_master_pos = $saved_master_pos
57 --source include/assert.inc
58
59 # Test a multiple table InnoDB-only drop failure
60 SET SESSION DEBUG='+d,rm_table_no_locks_abort_after_atomic_tables';
61 --error ER_UNKNOWN_ERROR
62 DROP TABLE `t3`, `t1`, `t2`;
63 SET SESSION DEBUG='-d,rm_table_no_locks_abort_after_atomic_tables';
64 --let $current_master_pos=query_get_value('SHOW MASTER STATUS', Position, 1)
65 --let $assert_text= Drop with multiple InnoDB-only tables should not be written to the binary log if the query execution fails
66 --let $assert_cond= $current_master_pos = $saved_master_pos
67 --source include/assert.inc
68
69 --let $binlog_start= $saved_master_pos
70 --source include/show_binlog_events.inc
71
72 --source include/sync_slave_sql_with_master.inc
73
74 --echo Cleanup
75 --source include/rpl_connection_master.inc
76 DROP DATABASE `db1`;
77
78 --source include/rpl_end.inc