1
# BUG#33029 5.0 to 5.1 replication fails on dup key when inserting
4
# For all 5.0 up to 5.0.58 exclusive, and 5.1 up to 5.1.12 exclusive,
5
# if one statement in a SP generated AUTO_INCREMENT value by the top
6
# statement, all statements after it would be considered generated
7
# AUTO_INCREMENT value by the top statement, and a erroneous INSERT_ID
8
# value might be associated with these statement, which could cause
9
# duplicate entry error and stop the slave.
11
source include/have_binlog_format_statement.inc;
12
source include/master-slave.inc;
15
DROP TABLE IF EXISTS t1, t2;
16
DROP PROCEDURE IF EXISTS p1;
17
DROP PROCEDURE IF EXISTS p2;
18
DROP TRIGGER IF EXISTS tr1;
19
DROP FUNCTION IF EXISTS f1;
22
CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY);
23
CREATE TABLE t2 (id INT AUTO_INCREMENT PRIMARY KEY);
29
DECLARE ins_count INT DEFAULT 10;
31
WHILE ins_count > 0 DO
32
INSERT INTO t1 VALUES (NULL);
33
SET ins_count = ins_count - 1;
36
DELETE FROM t1 WHERE id = 1;
37
DELETE FROM t1 WHERE id = 2;
38
DELETE FROM t2 WHERE id = 1;
39
DELETE FROM t2 WHERE id = 2;
44
INSERT INTO t1 VALUES (NULL);
45
DELETE FROM t1 WHERE id = f1(3);
46
DELETE FROM t1 WHERE id = f1(4);
47
DELETE FROM t2 WHERE id = 3;
48
DELETE FROM t2 WHERE id = 4;
51
CREATE TRIGGER tr1 BEFORE DELETE
54
INSERT INTO t2 VALUES (NULL);
57
CREATE FUNCTION f1 (i int) RETURNS int
59
INSERT INTO t2 VALUES (NULL);
65
# the $binlog_start will be used by the show_binlog_events.inc, so
66
# that we can skip binlog events we don't care
67
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
69
source include/show_binlog_events.inc;
71
echo # Result on master;
75
sync_slave_with_master;
77
echo # Result on slave;
85
# the $binlog_start will be used by the show_binlog_events.inc, so
86
# that we can skip binlog events we don't care
87
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
89
source include/show_binlog_events.inc;
91
echo # Result on master;
95
sync_slave_with_master;
97
echo # Result on slave;
104
DROP TABLE IF EXISTS t1, t2;
105
DROP PROCEDURE IF EXISTS p1;
106
DROP PROCEDURE IF EXISTS p2;
107
DROP FUNCTION IF EXISTS f1;
108
DROP TRIGGER IF EXISTS tr1;
110
sync_slave_with_master;