~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/extra/binlog_tests/mix_innodb_myisam_side_effects.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# the file to be sourced from binlog.binlog_mix_innodb_myisam
 
2
 
 
3
#
 
4
# Bug #27417    thd->no_trans_update.stmt lost value inside of SF-exec-stack
 
5
# bug #28960    non-trans temp table changes with insert .. select
 
6
#               not binlogged after rollback
 
7
#
 
8
# testing appearence of insert into temp_table in binlog.
 
9
# There are two branches of execution that require different setup.
 
10
 
 
11
# checking binlog content filled with row-based events due to
 
12
# a used stored function modifies non-transactional table
 
13
 
 
14
## send_eof() branch
 
15
 
 
16
# prepare
 
17
 
 
18
create temporary table tt (a int unique);
 
19
create table ti (a int) engine=innodb;
 
20
reset master;
 
21
 
 
22
# action
 
23
 
 
24
begin; 
 
25
insert into ti values (1); 
 
26
insert into ti values (2) ; 
 
27
insert into tt select * from ti;
 
28
rollback;
 
29
 
 
30
# check
 
31
 
 
32
select count(*) from tt /* 2 */;
 
33
source include/show_binlog_events.inc;
 
34
select count(*) from ti /* zero */;
 
35
insert into ti select * from tt;
 
36
select * from ti /* that is what slave would miss - bug#28960 */;
 
37
 
 
38
 
 
39
## send_error() branch
 
40
delete from ti;
 
41
delete from tt where a=1;
 
42
reset master;
 
43
 
 
44
# action
 
45
 
 
46
begin; 
 
47
insert into ti values (1); 
 
48
insert into ti values (2) /* to make the dup error in the following */; 
 
49
--error ER_DUP_ENTRY
 
50
insert into tt select * from ti /* one affected and error */;
 
51
rollback;
 
52
 
 
53
# check
 
54
 
 
55
source include/show_binlog_events.inc; # nothing in binlog with row bilog format
 
56
select count(*) from ti /* zero */;
 
57
insert into ti select * from tt;
 
58
select * from tt /* that is what otherwise slave missed - the bug */;
 
59
 
 
60
drop table ti;
 
61
 
 
62
 
 
63
#
 
64
# Bug #27417 thd->no_trans_update.stmt lost value inside of SF-exec-stack
 
65
#
 
66
# Testing asserts: if there is a side effect of modifying non-transactional
 
67
# table thd->no_trans_update.stmt must be TRUE;
 
68
# the assert is active with debug build
 
69
#
 
70
 
 
71
--disable_warnings
 
72
drop function if exists bug27417;
 
73
drop table if exists t1,t2;
 
74
--enable_warnings
 
75
# side effect table
 
76
CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM;
 
77
# target tables
 
78
CREATE TABLE t2 (a int NOT NULL auto_increment, PRIMARY KEY (a));
 
79
 
 
80
delimiter |;
 
81
create function bug27417(n int) 
 
82
RETURNS int(11)
 
83
begin
 
84
  insert into t1 values (null);
 
85
  return n;
 
86
end|
 
87
delimiter ;|
 
88
 
 
89
reset master;
 
90
 
 
91
# execute
 
92
 
 
93
insert into t2 values (bug27417(1));
 
94
insert into t2 select bug27417(2);
 
95
reset master;
 
96
 
 
97
--error ER_DUP_ENTRY
 
98
insert into t2 values (bug27417(2));
 
99
source include/show_binlog_events.inc; #only (!) with fixes for #23333 will show there is the query
 
100
select count(*) from t1 /* must be 3 */;
 
101
 
 
102
reset master;
 
103
select count(*) from t2;
 
104
delete from t2 where a=bug27417(3);
 
105
select count(*) from t2 /* nothing got deleted */; 
 
106
source include/show_binlog_events.inc; # the query must be in regardless of #23333
 
107
select count(*) from t1 /* must be 5 */;
 
108
 
 
109
--enable_info
 
110
delete t2 from t2 where t2.a=bug27417(100) /* must not affect t2 */;
 
111
--disable_info
 
112
select count(*) from t1 /* must be 7 */;
 
113
 
 
114
# function bug27417 remains for the following testing of bug#23333
 
115
drop table t1,t2;
 
116
 
 
117
#
 
118
# Bug#23333 using the patch (and the test) for bug#27471
 
119
# throughout the bug tests 
 
120
# t1 - non-trans side effects gatherer;
 
121
# t2 - transactional table;
 
122
#
 
123
CREATE TABLE t1 (a int  NOT NULL auto_increment primary key) ENGINE=MyISAM;
 
124
CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
 
125
CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique) ENGINE=MyISAM;
 
126
CREATE TABLE t4 (a int, PRIMARY KEY (a), b int unique) ENGINE=Innodb;
 
127
CREATE TABLE t5 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
 
128
 
 
129
 
 
130
#
 
131
# INSERT
 
132
#
 
133
 
 
134
# prepare
 
135
  
 
136
 insert into t2 values (1);
 
137
 reset master;
 
138
 
 
139
# execute
 
140
 
 
141
 --error ER_DUP_ENTRY
 
142
 insert into t2 values (bug27417(1)); 
 
143
  
 
144
# check
 
145
 
 
146
 source include/show_binlog_events.inc; # must be event of the query
 
147
 select count(*) from t1 /* must be 1 */;
 
148
 
 
149
#
 
150
# INSERT SELECT
 
151
#
 
152
 
 
153
# prepare
 
154
 delete from t1;
 
155
 delete from t2;
 
156
 insert into t2 values (2);
 
157
 reset master;
 
158
 
 
159
# execute
 
160
 
 
161
 --error ER_DUP_ENTRY
 
162
 insert into t2 select bug27417(1) union select bug27417(2); 
 
163
  
 
164
# check
 
165
 
 
166
 source include/show_binlog_events.inc; # must be events of the query
 
167
 select count(*) from t1 /* must be 2 */;
 
168
 
 
169
#
 
170
# UPDATE inc multi-update
 
171
#
 
172
 
 
173
# prepare
 
174
 delete from t1;
 
175
 insert into t3 values (1,1),(2,3),(3,4);
 
176
 reset master;
 
177
 
 
178
# execute
 
179
 --error ER_DUP_ENTRY
 
180
 update t3 set b=b+bug27417(1);
 
181
 
 
182
# check
 
183
 source include/show_binlog_events.inc; # must be events of the query
 
184
 select count(*) from t1 /* must be 2 */;
 
185
 
 
186
## multi_update::send_eof() branch
 
187
 
 
188
# prepare
 
189
 delete from t3;
 
190
 delete from t4;
 
191
 insert into t3 values (1,1);
 
192
 insert into t4 values (1,1),(2,2);
 
193
 
 
194
 reset master;
 
195
 
 
196
# execute
 
197
 --error ER_DUP_ENTRY
 
198
 UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */;
 
199
 
 
200
# check
 
201
 source include/show_binlog_events.inc; # the offset must denote there is the query
 
202
 select count(*) from t1 /* must be 4 */;
 
203
 
 
204
## send_error() branch of multi_update
 
205
 
 
206
# prepare
 
207
 delete from t1;
 
208
 delete from t3;
 
209
 delete from t4;
 
210
 insert into t3 values (1,1),(2,2);
 
211
 insert into t4 values (1,1),(2,2);
 
212
 
 
213
 reset master;
 
214
 
 
215
# execute
 
216
 --error ER_DUP_ENTRY
 
217
 UPDATE t3,t4 SET t3.a=t4.a + bug27417(1);
 
218
 
 
219
# check
 
220
 select count(*) from t1 /* must be 1 */;
 
221
 
 
222
# cleanup
 
223
 drop table t4;
 
224
 
 
225
 
 
226
#
 
227
# DELETE incl multi-delete
 
228
#
 
229
 
 
230
# prepare
 
231
 delete from t1;
 
232
 delete from t2;
 
233
 delete from t3;
 
234
 insert into t2 values (1);
 
235
 insert into t3 values (1,1);
 
236
 create trigger trg_del before delete on t2 for each row 
 
237
   insert into t3 values (bug27417(1), 2);
 
238
 reset master;
 
239
 
 
240
# execute
 
241
 --error ER_DUP_ENTRY
 
242
 delete from t2;
 
243
# check
 
244
 source include/show_binlog_events.inc; # the offset must denote there is the query
 
245
 select count(*) from t1 /* must be 1 */;
 
246
 
 
247
# cleanup
 
248
 drop trigger trg_del;
 
249
 
 
250
# prepare
 
251
 delete from t1;
 
252
 delete from t2;
 
253
 delete from t5;
 
254
 create trigger trg_del_t2 after  delete on t2 for each row
 
255
   insert into t1 values (1);
 
256
 insert into t2 values (2),(3);
 
257
 insert into t5 values (1),(2);
 
258
 reset master;
 
259
 
 
260
# execute
 
261
 --error ER_DUP_ENTRY
 
262
 delete t2.* from t2,t5 where t2.a=t5.a + 1;
 
263
 
 
264
# check
 
265
 source include/show_binlog_events.inc; # must be events of the query
 
266
 select count(*) from t1 /* must be 1 */;
 
267
 
 
268
 
 
269
#
 
270
# LOAD DATA
 
271
#
 
272
 
 
273
# prepare
 
274
 delete from t1;
 
275
 create table t4 (a int default 0, b int primary key) engine=innodb;
 
276
 insert into t4 values (0, 17);
 
277
 reset master;
 
278
 
 
279
# execute
 
280
 --error ER_DUP_ENTRY
 
281
 load data infile '../../std_data/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2);
 
282
# check
 
283
 select * from t4;
 
284
 select count(*) from t1 /* must be 2 */;
 
285
 source include/show_binlog_events.inc; # must be events of the query
 
286
 
 
287
#
 
288
# bug#23333 cleanup
 
289
#
 
290
 
 
291
 
 
292
drop trigger trg_del_t2;
 
293
drop table t1,t2,t3,t4,t5;
 
294
drop function bug27417;