2
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
5
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
7
CREATE TABLE t1 (a INT PRIMARY KEY);
8
CREATE TABLE t2 (a INT);
9
INSERT INTO t1 VALUES (-1),(-2),(-3);
10
INSERT INTO t2 VALUES (-1),(-2),(-3);
11
DELETE FROM t1 WHERE a = -2;
12
DELETE FROM t2 WHERE a = -2;
13
DELETE FROM t1 WHERE a = -2;
14
DELETE FROM t2 WHERE a = -2;
15
SELECT * FROM t1 ORDER BY a;
19
SELECT * FROM t2 ORDER BY a;
23
SELECT * FROM t1 ORDER BY a;
27
SELECT * FROM t2 ORDER BY a;
33
INSERT IGNORE INTO t1 VALUES (-2);
34
INSERT IGNORE INTO t1 VALUES (-2);
35
SELECT * FROM t1 ORDER BY a;
40
SELECT * FROM t1 ORDER BY a;
47
UPDATE t1 SET a = 1 WHERE a = -1;
48
UPDATE t2 SET a = 1 WHERE a = -1;
49
UPDATE t1 SET a = 1 WHERE a = -1;
50
UPDATE t2 SET a = 1 WHERE a = -1;
51
SELECT * FROM t1 ORDER BY a;
56
SELECT * FROM t2 ORDER BY a;
60
SELECT * FROM t1 ORDER BY a;
65
SELECT * FROM t2 ORDER BY a;
72
select @@global.slave_exec_mode /* must be IDEMPOTENT */;
73
@@global.slave_exec_mode
75
create table ti1 (b int primary key) engine = innodb;
76
create table ti2 (a int primary key, b int, foreign key (b) references ti1(b))
78
set foreign_key_checks=1 /* ensure the check */;
79
insert into ti1 values (1),(2),(3);
80
insert into ti2 set a=2, b=2;
81
select * from ti1 order by b /* must be (1),(2),(3) */;
86
insert into ti2 set a=1, b=1;
87
select * from ti2 order by b /* must be (1,1) (2,2) */;
91
set @save_binlog_format= @@session.binlog_format;
92
set @@session.binlog_format= row;
93
delete from ti1 where b=1;
94
select * from ti1 order by b /* must be (2),(3) */;
98
select * from ti1 order by b /* must stays as were on master (1),(2),(3) */;
103
delete from ti1 where b=3;
104
insert into ti2 set a=3, b=3;
105
select * from ti2 order by b /* must be (1,1),(2,2) - not inserted */;
109
set global slave_exec_mode='IDEMPOTENT';
110
set global slave_exec_mode='STRICT';
111
set global slave_exec_mode='IDEMPOTENT,STRICT';
112
ERROR HY000: Ambiguous slave modes combination.
113
select @@global.slave_exec_mode /* must be STRICT */;
114
@@global.slave_exec_mode
116
*** foreign keys errors as above now forces to stop
117
set foreign_key_checks=0;
119
create table ti1 (b int primary key) engine = innodb;
120
create table ti2 (a int primary key, b int, foreign key (b) references ti1(b))
122
set foreign_key_checks=1 /* ensure the check */;
123
insert into ti1 values (1),(2),(3);
124
insert into ti2 set a=2, b=2;
125
select * from ti1 order by b /* must be (1),(2),(3) */;
130
*** conspire future problem
131
insert into ti2 set a=1, b=1;
132
select * from ti2 order by b /* must be (1,1) (2,2) */;
136
delete from ti1 where b=1 /* offending delete event */;
137
select * from ti1 order by b /* must be (2),(3) */;
144
select * from ti1 order by b /* must be (1),(2),(3) - not deleted */;
149
set foreign_key_checks= 0;
150
delete from ti2 where b=1;
151
set foreign_key_checks= 1;
152
set global slave_exec_mode='IDEMPOTENT';
153
start slave sql_thread;
154
set global slave_exec_mode='STRICT';
155
*** conspire the following insert failure
156
*** conspire future problem
157
delete from ti1 where b=3;
158
insert into ti2 set a=3, b=3 /* offending write event */;
162
select * from ti2 order by b /* must be (2,2) */;
165
set foreign_key_checks= 0;
166
insert into ti1 set b=3;
167
set foreign_key_checks= 1;
168
set global slave_exec_mode='IDEMPOTENT';
169
start slave sql_thread;
170
set global slave_exec_mode='STRICT';
171
select * from ti2 order by b /* must be (2,2),(3,3) */;
177
insert into ti1 set b=1;
178
insert into ti1 set b=1 /* offending write event */;
182
set foreign_key_checks= 0;
183
delete from ti1 where b=1;
184
set foreign_key_checks= 1;
185
set global slave_exec_mode='IDEMPOTENT';
186
start slave sql_thread;
187
set global slave_exec_mode='STRICT';
188
CREATE TABLE t1 (a INT PRIMARY KEY);
189
CREATE TABLE t2 (a INT);
190
INSERT INTO t1 VALUES (-1),(-2),(-3);
191
INSERT INTO t2 VALUES (-1),(-2),(-3);
192
DELETE FROM t1 WHERE a = -2;
193
DELETE FROM t2 WHERE a = -2;
194
DELETE FROM t1 WHERE a = -2;
198
set global slave_exec_mode='IDEMPOTENT';
199
start slave sql_thread;
200
set global slave_exec_mode='STRICT';
201
DELETE FROM t2 WHERE a = -2;
205
set global slave_exec_mode='IDEMPOTENT';
206
start slave sql_thread;
207
set global slave_exec_mode='STRICT';
208
UPDATE t1 SET a = 1 WHERE a = -1;
209
UPDATE t2 SET a = 1 WHERE a = -1;
210
UPDATE t1 SET a = 1 WHERE a = -1;
214
set global slave_exec_mode='IDEMPOTENT';
215
start slave sql_thread;
216
set global slave_exec_mode='STRICT';
217
UPDATE t2 SET a = 1 WHERE a = -1;
221
set global slave_exec_mode='IDEMPOTENT';
222
start slave sql_thread;
223
set global slave_exec_mode='STRICT';
224
set @@session.binlog_format= @save_binlog_format;
225
drop table t1,t2,ti2,ti1;