1include/master-slave.inc
2[connection master]
3==== Initialize ====
4connection master;
5CREATE TABLE t1(a INT PRIMARY KEY);
6connection slave;
7==== Test: SQL thread sees 'INSERT' of existing key ====
8---- Prepare slave so that it will get duplicate key error ----
9INSERT INTO t1 VALUES (1);
10---- Insert rows on master ----
11connection master;
12INSERT INTO t1 VALUES (1);
13SELECT * FROM t1;
14a
151
16connection slave;
17---- Wait until slave stops with an error ----
18include/wait_for_slave_sql_error.inc [errno=1062]
19Last_SQL_Error (expected "duplicate key" error)
20Error 'Duplicate entry '1' for key 'PRIMARY'' on query. Default database: 'test'. Query: 'INSERT INTO t1 VALUES (1)'
21call mtr.add_suppression("Slave SQL.*Duplicate entry .1. for key .PRIMARY.* error.* 1062");
22SELECT * FROM t1;
23a
241
25---- Resolve the conflict on the slave and restart SQL thread ----
26DELETE FROM t1 WHERE a = 1;
27START SLAVE SQL_THREAD;
28include/wait_for_slave_sql_to_start.inc
29---- Sync slave and verify that there is no error ----
30Last_SQL_Error = '' (expected no error)
31SELECT * FROM t1;
32a
331
34==== Test: SQL thread sees 'DELETE' of non-existing row ====
35---- On master, insert two rows, the second with binlogging off ----
36connection master;
37DELETE FROM t1;
38INSERT INTO t1 VALUES (1);
39connection slave;
40DELETE FROM t1 WHERE a = 1;
41---- On master, remove the row that does not exist on slave ----
42connection master;
43DELETE FROM t1 WHERE a = 1;
44SELECT * FROM t1;
45a
46connection slave;
47---- Sync slave and verify that there is no error ----
48Last_SQL_Error =  (expected no error)
49SELECT * FROM t1;
50a
51==== Clean up ====
52connection master;
53DROP TABLE t1;
54connection slave;
55include/rpl_end.inc
56