1 # Test replication, when using special non-replicated tables.
3 # This test involve special statements that use non-replicated tables.
4 # Changes affecting non replicated tables are never written to the binlog.
5 # Executing these statements may or may not work, as the statements involved
7 # In MIXED or ROW binlog format, execution should succeed,
8 # and only partial data (the rows affecting replicated tables only)
9 # should be written to the binlog.
10 # In STATEMENT binlog format, execution should
11 # raise a warning (ER_BINLOG_UNSAFE_STATEMENT) if a non replicated table is
12 # only read from, or fail with an error (ER_BINLOG_STMT_MODE_AND_NO_REPL_TABLES)
13 # if a non replicated table is written to.
15 # SHOW ERRORS will print in the
16 # test .result file the exact outcome.
21 drop database
if exists my_replicated_db;
24 call
mtr.add_suppression(
"Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
26 create database my_replicated_db;
28 create
table my_replicated_db.my_tx_table(a bigint) engine = innodb;
29 create
table my_replicated_db.my_non_tx_table(a bigint) engine = myisam;
30 create
table my_replicated_db.my_bh_table(a bigint) engine = blackhole;
33 drop
table if exists marker_start;
37 insert into my_tx_table(a)
38 values (1000), (2000), (3000);
40 insert into my_non_tx_table(a)
41 values (1000), (2000), (3000);
43 insert into my_bh_table(a)
44 values (1000), (2000), (3000);
47 drop
table if exists marker_insert_select;
52 # The queries used here do not make any sense (no semantic).
53 # What this test is interrested in, is check the behavior
54 # when replicating queries that mix both:
55 # - non replicated tables
58 insert into my_tx_table(a)
59 select thread_id from performance_schema.threads;
61 insert into my_non_tx_table(a)
62 select thread_id from performance_schema.threads;
64 insert into my_bh_table(a)
65 select thread_id from performance_schema.threads;
67 # For the information_schema,
68 # no error is enforced yet.
69 # Documenting the current behavior
71 insert into my_tx_table(a)
72 select
id from information_schema.processlist;
74 insert into my_non_tx_table(a)
75 select
id from information_schema.processlist;
77 insert into my_bh_table(a)
78 select
id from information_schema.processlist;
80 insert into my_tx_table(a)
81 select thread_id from mysql.general_log;
83 insert into my_non_tx_table(a)
84 select thread_id from mysql.general_log;
86 insert into my_bh_table(a)
87 select thread_id from mysql.general_log;
89 insert into my_tx_table(a)
90 select thread_id from mysql.slow_log;
92 insert into my_non_tx_table(a)
93 select thread_id from mysql.slow_log;
95 insert into my_bh_table(a)
96 select thread_id from mysql.slow_log;
98 insert into my_tx_table(a)
99 select Relay_log_pos from mysql.slave_relay_log_info;
101 insert into my_non_tx_table(a)
102 select Relay_log_pos from mysql.slave_relay_log_info;
104 insert into my_bh_table(a)
105 select Relay_log_pos from mysql.slave_relay_log_info;
107 insert into my_tx_table(a)
108 select Master_log_pos from mysql.slave_master_info;
110 insert into my_non_tx_table(a)
111 select Master_log_pos from mysql.slave_master_info;
113 insert into my_bh_table(a)
114 select Master_log_pos from mysql.slave_master_info;
116 insert into my_tx_table(a)
117 select Relay_log_pos from mysql.slave_worker_info;
119 insert into my_non_tx_table(a)
120 select Relay_log_pos from mysql.slave_worker_info;
122 insert into my_bh_table(a)
123 select Relay_log_pos from mysql.slave_worker_info;
126 drop
table if exists marker_multi_update;
128 use my_replicated_db;
130 --error 0, ER_BINLOG_STMT_MODE_AND_NO_REPL_TABLES
131 update my_tx_table, performance_schema.setup_instruments
132 set my_tx_table.a = my_tx_table.a + 1,
133 performance_schema.setup_instruments.timed= 'NO';
135 --error 0, ER_BINLOG_STMT_MODE_AND_NO_REPL_TABLES
136 update my_non_tx_table, performance_schema.setup_instruments
137 set my_non_tx_table.a = my_non_tx_table.a + 1,
138 performance_schema.setup_instruments.timed= 'NO';
140 --error 0, ER_BINLOG_STMT_MODE_AND_NO_REPL_TABLES
141 update my_bh_table, performance_schema.setup_instruments
142 set my_bh_table.a = my_bh_table.a + 1,
143 performance_schema.setup_instruments.timed= 'NO';
146 drop
table if exists marker_multi_delete;
148 use my_replicated_db;
150 insert into performance_schema.setup_actors
151 values ('FOO', 'FOO', 'FOO');
153 --error 0, ER_BINLOG_STMT_MODE_AND_NO_REPL_TABLES
154 delete my_tx_table.*, performance_schema.setup_actors.*
155 from my_tx_table, performance_schema.setup_actors
156 where my_tx_table.a != 1000
157 or performance_schema.setup_actors.role='FOO';
159 insert into performance_schema.setup_actors
160 values ('BAR', 'BAR', 'BAR');
162 --error 0, ER_BINLOG_STMT_MODE_AND_NO_REPL_TABLES
163 delete my_non_tx_table.*, performance_schema.setup_actors.*
164 from my_non_tx_table, performance_schema.setup_actors
165 where my_non_tx_table.a != 1000
166 or performance_schema.setup_actors.role='BAR';
168 insert into performance_schema.setup_actors
169 values ('BAZ', 'BAZ', 'BAZ');
171 --error 0, ER_BINLOG_STMT_MODE_AND_NO_REPL_TABLES
172 delete my_bh_table.*, performance_schema.setup_actors.*
173 from my_bh_table, performance_schema.setup_actors
174 where my_bh_table.a != 1000
175 or performance_schema.setup_actors.role='BAZ';
178 drop
table if exists marker_end;
180 drop database my_replicated_db;
182 --source include/show_binlog_events.inc
184 # Restore performance_schema.setup_actors, damaged by this script
186 truncate
table performance_schema.setup_actors;
187 insert into performance_schema.setup_actors values (
'%',
'%',
'%');