1# Test to see if slave can detect certain known bugs present
2# on the master, and appropriately decides to stop
3# (assuming the bug is fixed in the slave, slave cannot of course
4# imitate the bug, so it has to stop).
5
6call mtr.add_suppression("Unsafe statement written to the binary log using statement format");
7
8source include/have_debug.inc;
9# because of pretend_version_50034_in_binlog the test can't run with checksum
10source include/have_binlog_checksum_off.inc;
11
12# Currently only statement-based-specific bugs are here
13-- source include/have_binlog_format_statement.inc
14
15source include/master-slave.inc;
16
17# testcase with INSERT SELECT
18connection master;
19CREATE TABLE t1 (
20  id bigint(20) unsigned NOT NULL auto_increment,
21  field_1 int(10) unsigned NOT NULL,
22  field_2 varchar(255) NOT NULL,
23  field_3 varchar(255) NOT NULL,
24  PRIMARY KEY (id),
25  UNIQUE KEY field_1 (field_1, field_2)
26);
27CREATE TABLE t2 (
28  field_a int(10) unsigned NOT NULL,
29  field_b varchar(255) NOT NULL,
30  field_c varchar(255) NOT NULL
31);
32INSERT INTO t2 (field_a, field_b, field_c) VALUES (1, 'a', '1a');
33INSERT INTO t2 (field_a, field_b, field_c) VALUES (2, 'b', '2b');
34INSERT INTO t2 (field_a, field_b, field_c) VALUES (3, 'c', '3c');
35INSERT INTO t2 (field_a, field_b, field_c) VALUES (4, 'd', '4d');
36INSERT INTO t2 (field_a, field_b, field_c) VALUES (5, 'e', '5e');
37sync_slave_with_master;
38connection master;
39# Updating table t1 based on values from table t2
40INSERT INTO t1 (field_1, field_2, field_3)
41SELECT t2.field_a, t2.field_b, t2.field_c
42FROM t2
43ON DUPLICATE KEY UPDATE
44t1.field_3 = t2.field_c;
45# Inserting new record into t2
46INSERT INTO t2 (field_a, field_b, field_c) VALUES (6, 'f', '6f');
47# Updating t1 again
48INSERT INTO t1 (field_1, field_2, field_3)
49SELECT t2.field_a, t2.field_b, t2.field_c
50FROM t2
51ON DUPLICATE KEY UPDATE
52t1.field_3 = t2.field_c;
53SELECT * FROM t1;
54connection slave;
55
56# show the error message
57#1105 = ER_UNKNOWN_ERROR
58--let $slave_sql_errno= 1105
59--let $show_slave_sql_error= 1
60--source include/wait_for_slave_sql_error.inc
61
62# show that it was not replicated
63SELECT * FROM t1;
64connection master;
65
66# clean up
67drop table t1, t2;
68connection slave;
69drop table t1, t2;
70# clear error message in sql thread
71--source include/stop_slave_io.inc
72RESET SLAVE;
73
74# End of 5.0 tests
75--let $rpl_only_running_threads= 1
76--source include/rpl_end.inc
77