~drizzle-trunk/drizzle/development

1 by brian
clean slate
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,
4
# for completeness.
5
6
connection master;
7
--disable_warnings
8
CREATE SCHEMA IF NOT EXISTS mysqlslap;
9
USE mysqlslap;
10
--enable_warnings
11
12
select @@global.binlog_format;
13
14
#
15
# BUG#25507 "multi-row insert delayed + auto increment causes
16
# duplicate key entries on slave";
17
# happened only in statement-based binlogging.
18
#
19
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')";
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
22
--exec $DRIZZLE_SLAP --silent --concurrency=5 --iterations=200 --query=$query --delimiter=";"
1 by brian
clean slate
23
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;
28
use mysqlslap;
29
SELECT COUNT(*) FROM t1;
30
31
#
32
# BUG#26116 "If multi-row INSERT DELAYED has errors,
33
# statement-based binlogging breaks";
34
# happened only in statement-based binlogging.
35
#
36
37
connection master;
38
truncate table t1;
39
# first scenario: duplicate on first row
40
insert delayed into t1 values(10, "my name");
41
if ($binlog_format_statement)
42
{
43
  # statement below will be converted to non-delayed INSERT and so
44
  # will stop at first error, guaranteeing replication.
45
  --error ER_DUP_ENTRY
46
  insert delayed into t1 values(10, "is Bond"), (20, "James Bond");
47
}
48
if (!$binlog_format_statement)
49
{
50
  insert delayed into t1 values(10, "is Bond"), (20, "James Bond");
51
}
52
flush table t1; # to wait for INSERT DELAYED to be done
53
select * from t1;
54
sync_slave_with_master;
55
# when bug existed in statement-based binlogging, t1 on slave had
56
# different content from on master
57
select * from t1;
58
59
# second scenario: duplicate on second row
60
connection master;
61
delete from t1 where id!=10;
62
if ($binlog_format_statement)
63
{
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).
67
  --error ER_DUP_ENTRY
68
  insert delayed into t1 values(20, "is Bond"), (10, "James Bond");
69
}
70
if (!$binlog_format_statement)
71
{
72
  insert delayed into t1 values(20, "is Bond"), (10, "James Bond");
73
}
74
flush table t1; # to wait for INSERT DELAYED to be done
75
select * from t1;
76
sync_slave_with_master;
77
# when bug existed in statement-based binlogging, query was binlogged
78
# with error_code=0 so slave stopped
79
select * from t1;
80
81
# clean up
82
connection master;
83
USE test;
84
DROP SCHEMA mysqlslap;
85
sync_slave_with_master;
86
use test;
87
connection master;
88
89
#
90
# Bug #29571: INSERT DELAYED IGNORE written to binary log on the master but
91
# on the slave
92
#
93
if  (`SELECT @@global.binlog_format != 'ROW'`)
94
{
95
  #flush the logs before the test
96
  connection slave;
97
  FLUSH LOGS;
98
  connection master;
99
  FLUSH LOGS;
100
}
101
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
106
107
if  (`SELECT @@global.binlog_format != 'ROW'`)
108
{
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;
112
}
113
select * from t1;
114
115
sync_slave_with_master;
116
echo On slave;
117
if  (`SELECT @@global.binlog_format != 'ROW'`)
118
{
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;
122
}
123
select * from t1;
124
125
126
# clean up
127
connection master;
128
drop table t1;
129
sync_slave_with_master;
130
if  (`SELECT @@global.binlog_format != 'ROW'`)
131
{
132
  #flush the logs after the test
133
  FLUSH LOGS;
134
  connection master;
135
  FLUSH LOGS;
136
}
137
connection master;
138
139
140
--echo End of 5.0 tests