1
# The two bugs below (BUG#25507 and BUG#26116) existed only in
2
# statement-based binlogging; we test that now they are fixed;
3
# we also test that mixed and row-based binlogging work too,
8
CREATE SCHEMA IF NOT EXISTS mysqlslap;
12
select @@global.binlog_format;
15
# BUG#25507 "multi-row insert delayed + auto increment causes
16
# duplicate key entries on slave";
17
# happened only in statement-based binlogging.
20
CREATE TABLE t1 (id INT primary key auto_increment, name VARCHAR(64));
21
let $query = "INSERT DELAYED INTO t1 VALUES (null, 'Dr. No'), (null, 'From Russia With Love'), (null, 'Goldfinger'), (null, 'Thunderball'), (null, 'You Only Live Twice')";
22
--exec $DRIZZLE_SLAP --silent --concurrency=5 --iterations=200 --query=$query --delimiter=";"
24
FLUSH TABLE t1; # another way to be sure INSERT DELAYED has inserted
25
SELECT COUNT(*) FROM t1;
26
# when bug existed slave failed below ("duplicate key" error at random INSERT)
27
sync_slave_with_master;
29
SELECT COUNT(*) FROM t1;
32
# BUG#26116 "If multi-row INSERT DELAYED has errors,
33
# statement-based binlogging breaks";
34
# happened only in statement-based binlogging.
39
# first scenario: duplicate on first row
40
insert delayed into t1 values(10, "my name");
41
if ($binlog_format_statement)
43
# statement below will be converted to non-delayed INSERT and so
44
# will stop at first error, guaranteeing replication.
46
insert delayed into t1 values(10, "is Bond"), (20, "James Bond");
48
if (!$binlog_format_statement)
50
insert delayed into t1 values(10, "is Bond"), (20, "James Bond");
52
flush table t1; # to wait for INSERT DELAYED to be done
54
sync_slave_with_master;
55
# when bug existed in statement-based binlogging, t1 on slave had
56
# different content from on master
59
# second scenario: duplicate on second row
61
delete from t1 where id!=10;
62
if ($binlog_format_statement)
64
# statement below will be converted to non-delayed INSERT and so
65
# will be binlogged with its ER_DUP_ENTRY error code, guaranteeing
66
# replication (slave will hit the same error code and so be fine).
68
insert delayed into t1 values(20, "is Bond"), (10, "James Bond");
70
if (!$binlog_format_statement)
72
insert delayed into t1 values(20, "is Bond"), (10, "James Bond");
74
flush table t1; # to wait for INSERT DELAYED to be done
76
sync_slave_with_master;
77
# when bug existed in statement-based binlogging, query was binlogged
78
# with error_code=0 so slave stopped
84
DROP SCHEMA mysqlslap;
85
sync_slave_with_master;
90
# Bug #29571: INSERT DELAYED IGNORE written to binary log on the master but
93
if (`SELECT @@global.binlog_format != 'ROW'`)
95
#flush the logs before the test
102
CREATE TABLE t1(a int, UNIQUE(a));
103
INSERT DELAYED IGNORE INTO t1 VALUES(1);
104
INSERT DELAYED IGNORE INTO t1 VALUES(1);
105
flush table t1; # to wait for INSERT DELAYED to be done
107
if (`SELECT @@global.binlog_format != 'ROW'`)
109
#must show two INSERT DELAYED
110
--replace_column 1 x 2 x 3 x 4 x 5 x
111
show binlog events in 'master-bin.000002' LIMIT 2,2;
115
sync_slave_with_master;
117
if (`SELECT @@global.binlog_format != 'ROW'`)
119
#must show two INSERT DELAYED
120
--replace_column 1 x 2 x 3 x 4 x 5 x
121
show binlog events in 'slave-bin.000002' LIMIT 2,2;
129
sync_slave_with_master;
130
if (`SELECT @@global.binlog_format != 'ROW'`)
132
#flush the logs after the test
140
--echo End of 5.0 tests