~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
drop table if exists t1, t2;
2
create table t1 (a int) engine=innodb;
3
create table t2 (a int) engine=myisam;
4
reset master;
5
begin;
6
insert into t1 values(1);
7
insert into t2 select * from t1;
8
commit;
9
show binlog events from <binlog_start>;
10
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
11
master-bin.000001	#	Query	#	#	use `test`; BEGIN
12
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(1)
13
master-bin.000001	#	Query	#	#	use `test`; insert into t2 select * from t1
14
master-bin.000001	#	Xid	#	#	COMMIT /* XID */
15
delete from t1;
16
delete from t2;
17
reset master;
18
begin;
19
insert into t1 values(2);
20
insert into t2 select * from t1;
21
rollback;
22
Warnings:
23
Warning	1196	Some non-transactional changed tables couldn't be rolled back
24
show binlog events from <binlog_start>;
25
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
26
master-bin.000001	#	Query	#	#	use `test`; BEGIN
27
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(2)
28
master-bin.000001	#	Query	#	#	use `test`; insert into t2 select * from t1
29
master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
30
delete from t1;
31
delete from t2;
32
reset master;
33
begin;
34
insert into t1 values(3);
35
savepoint my_savepoint;
36
insert into t1 values(4);
37
insert into t2 select * from t1;
38
rollback to savepoint my_savepoint;
39
Warnings:
40
Warning	1196	Some non-transactional changed tables couldn't be rolled back
41
commit;
42
show binlog events from <binlog_start>;
43
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
44
master-bin.000001	#	Query	#	#	use `test`; BEGIN
45
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(3)
46
master-bin.000001	#	Query	#	#	use `test`; savepoint my_savepoint
47
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(4)
48
master-bin.000001	#	Query	#	#	use `test`; insert into t2 select * from t1
49
master-bin.000001	#	Query	#	#	use `test`; rollback to savepoint my_savepoint
50
master-bin.000001	#	Xid	#	#	COMMIT /* XID */
51
delete from t1;
52
delete from t2;
53
reset master;
54
begin;
55
insert into t1 values(5);
56
savepoint my_savepoint;
57
insert into t1 values(6);
58
insert into t2 select * from t1;
59
rollback to savepoint my_savepoint;
60
Warnings:
61
Warning	1196	Some non-transactional changed tables couldn't be rolled back
62
insert into t1 values(7);
63
commit;
64
select a from t1 order by a;
65
a
66
5
67
7
68
show binlog events from <binlog_start>;
69
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
70
master-bin.000001	#	Query	#	#	use `test`; BEGIN
71
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(5)
72
master-bin.000001	#	Query	#	#	use `test`; savepoint my_savepoint
73
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(6)
74
master-bin.000001	#	Query	#	#	use `test`; insert into t2 select * from t1
75
master-bin.000001	#	Query	#	#	use `test`; rollback to savepoint my_savepoint
76
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(7)
77
master-bin.000001	#	Xid	#	#	COMMIT /* XID */
78
delete from t1;
79
delete from t2;
80
reset master;
81
select get_lock("a",10);
82
get_lock("a",10)
83
1
84
begin;
85
insert into t1 values(8);
86
insert into t2 select * from t1;
87
select get_lock("a",10);
88
get_lock("a",10)
89
1
90
show binlog events from <binlog_start>;
91
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
92
master-bin.000001	#	Query	#	#	use `test`; BEGIN
93
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(8)
94
master-bin.000001	#	Query	#	#	use `test`; insert into t2 select * from t1
95
master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
96
delete from t1;
97
delete from t2;
98
reset master;
99
insert into t1 values(9);
100
insert into t2 select * from t1;
101
show binlog events from <binlog_start>;
102
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
103
master-bin.000001	#	Query	#	#	use `test`; BEGIN
104
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(9)
105
master-bin.000001	#	Xid	#	#	COMMIT /* XID */
106
master-bin.000001	#	Query	#	#	use `test`; insert into t2 select * from t1
107
delete from t1;
108
delete from t2;
109
reset master;
110
insert into t1 values(10);
111
begin;
112
insert into t2 select * from t1;
113
show binlog events from <binlog_start>;
114
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
115
master-bin.000001	#	Query	#	#	use `test`; BEGIN
116
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(10)
117
master-bin.000001	#	Xid	#	#	COMMIT /* XID */
118
master-bin.000001	#	Query	#	#	use `test`; insert into t2 select * from t1
119
insert into t1 values(11);
120
commit;
121
show binlog events from <binlog_start>;
122
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
123
master-bin.000001	#	Query	#	#	use `test`; BEGIN
124
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(10)
125
master-bin.000001	#	Xid	#	#	COMMIT /* XID */
126
master-bin.000001	#	Query	#	#	use `test`; insert into t2 select * from t1
127
master-bin.000001	#	Query	#	#	use `test`; BEGIN
128
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(11)
129
master-bin.000001	#	Xid	#	#	COMMIT /* XID */
130
alter table t2 engine=INNODB;
131
delete from t1;
132
delete from t2;
133
reset master;
134
begin;
135
insert into t1 values(12);
136
insert into t2 select * from t1;
137
commit;
138
show binlog events from <binlog_start>;
139
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
140
master-bin.000001	#	Query	#	#	use `test`; BEGIN
141
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(12)
142
master-bin.000001	#	Query	#	#	use `test`; insert into t2 select * from t1
143
master-bin.000001	#	Xid	#	#	COMMIT /* XID */
144
delete from t1;
145
delete from t2;
146
reset master;
147
begin;
148
insert into t1 values(13);
149
insert into t2 select * from t1;
150
rollback;
151
show binlog events from <binlog_start>;
152
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
153
delete from t1;
154
delete from t2;
155
reset master;
156
begin;
157
insert into t1 values(14);
158
savepoint my_savepoint;
159
insert into t1 values(15);
160
insert into t2 select * from t1;
161
rollback to savepoint my_savepoint;
162
commit;
163
show binlog events from <binlog_start>;
164
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
165
master-bin.000001	#	Query	#	#	use `test`; BEGIN
166
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(14)
167
master-bin.000001	#	Xid	#	#	COMMIT /* XID */
168
delete from t1;
169
delete from t2;
170
reset master;
171
begin;
172
insert into t1 values(16);
173
savepoint my_savepoint;
174
insert into t1 values(17);
175
insert into t2 select * from t1;
176
rollback to savepoint my_savepoint;
177
insert into t1 values(18);
178
commit;
179
select a from t1 order by a;
180
a
181
16
182
18
183
show binlog events from <binlog_start>;
184
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
185
master-bin.000001	#	Query	#	#	use `test`; BEGIN
186
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(16)
187
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(18)
188
master-bin.000001	#	Xid	#	#	COMMIT /* XID */
189
delete from t1;
190
delete from t2;
191
alter table t2 engine=MyISAM;
192
insert into t1 values (1);
193
begin;
194
select * from t1 for update;
195
a
196
1
197
select (@before:=unix_timestamp())*0;
198
(@before:=unix_timestamp())*0
199
0
200
begin;
201
select * from t1 for update;
202
insert into t2 values (20);
203
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
204
select (@after:=unix_timestamp())*0;
205
(@after:=unix_timestamp())*0
206
0
207
select (@after-@before) >= 2;
208
(@after-@before) >= 2
209
1
210
drop table t1,t2;
211
commit;
212
begin;
213
create temporary table ti (a int) engine=innodb;
214
rollback;
215
insert into ti values(1);
216
set autocommit=0;
217
create temporary table t1 (a int) engine=myisam;
218
commit;
219
insert t1 values (1);
220
rollback;
221
Warnings:
222
Warning	1196	Some non-transactional changed tables couldn't be rolled back
223
create table t0 (n int);
224
insert t0 select * from t1;
225
set autocommit=1;
226
insert into t0 select GET_LOCK("lock1",null);
227
set autocommit=0;
228
create table t2 (n int) engine=innodb;
229
insert into t2 values (3);
230
select get_lock("lock1",60);
231
get_lock("lock1",60)
232
1
233
show binlog events from <binlog_start>;
234
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
235
master-bin.000001	#	Query	#	#	use `test`; BEGIN
236
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(16)
237
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(18)
238
master-bin.000001	#	Xid	#	#	COMMIT /* XID */
239
master-bin.000001	#	Query	#	#	use `test`; BEGIN
240
master-bin.000001	#	Query	#	#	use `test`; delete from t1
241
master-bin.000001	#	Xid	#	#	COMMIT /* XID */
242
master-bin.000001	#	Query	#	#	use `test`; BEGIN
243
master-bin.000001	#	Query	#	#	use `test`; delete from t2
244
master-bin.000001	#	Xid	#	#	COMMIT /* XID */
245
master-bin.000001	#	Query	#	#	use `test`; alter table t2 engine=MyISAM
246
master-bin.000001	#	Query	#	#	use `test`; BEGIN
247
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values (1)
248
master-bin.000001	#	Xid	#	#	COMMIT /* XID */
249
master-bin.000001	#	Query	#	#	use `test`; insert into t2 values (20)
250
master-bin.000001	#	Query	#	#	use `test`; drop table t1,t2
251
master-bin.000001	#	Query	#	#	use `test`; create temporary table ti (a int) engine=innodb
252
master-bin.000001	#	Query	#	#	use `test`; BEGIN
253
master-bin.000001	#	Query	#	#	use `test`; insert into ti values(1)
254
master-bin.000001	#	Query	#	#	use `test`; COMMIT
255
master-bin.000001	#	Query	#	#	use `test`; create temporary table t1 (a int) engine=myisam
256
master-bin.000001	#	Query	#	#	use `test`; insert t1 values (1)
257
master-bin.000001	#	Query	#	#	use `test`; create table t0 (n int)
258
master-bin.000001	#	Query	#	#	use `test`; insert t0 select * from t1
259
master-bin.000001	#	Query	#	#	use `test`; insert into t0 select GET_LOCK("lock1",null)
260
master-bin.000001	#	Query	#	#	use `test`; create table t2 (n int) engine=innodb
261
master-bin.000001	#	Query	#	#	use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `test`.`t1`,`test`.`ti`
262
do release_lock("lock1");
263
drop table t0,t2;
264
set autocommit=0;
265
CREATE TABLE t1 (a int, b int) engine=myisam;
266
reset master;
267
INSERT INTO t1 values (1,1),(1,2);
268
CREATE TABLE t2 (primary key (a)) engine=innodb select * from t1;
269
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
270
DROP TABLE if exists t2;
271
Warnings:
272
Note	1051	Unknown table 't2'
273
INSERT INTO t1 values (3,3);
274
CREATE TEMPORARY TABLE t2 (primary key (a)) engine=innodb select * from t1;
275
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
276
ROLLBACK;
277
Warnings:
278
Warning	1196	Some non-transactional changed tables couldn't be rolled back
279
DROP TABLE IF EXISTS t2;
280
Warnings:
281
Note	1051	Unknown table 't2'
282
CREATE TABLE t2 (a int, b int, primary key (a)) engine=innodb;
283
INSERT INTO t1 VALUES (4,4);
284
CREATE TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
285
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
286
SELECT * from t2;
287
a	b
288
TRUNCATE table t2;
289
INSERT INTO t1 VALUES (5,5);
290
INSERT INTO t2 select * from t1;
291
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
292
SELECT * FROM t2;
293
a	b
294
DROP TABLE t2;
295
INSERT INTO t1 values (6,6);
296
CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a)) engine=innodb ;
297
INSERT INTO t1 values (7,7);
298
ROLLBACK;
299
Warnings:
300
Warning	1196	Some non-transactional changed tables couldn't be rolled back
301
INSERT INTO t1 values (8,8);
302
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
303
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
304
COMMIT;
305
INSERT INTO t1 values (9,9);
306
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
307
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
308
ROLLBACK;
309
Warnings:
310
Warning	1196	Some non-transactional changed tables couldn't be rolled back
311
SELECT * from t2;
312
a	b
313
TRUNCATE table t2;
314
INSERT INTO t1 values (10,10);
315
INSERT INTO t2 select * from t1;
316
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
317
SELECT * from t1;
318
a	b
319
1	1
320
1	2
321
3	3
322
4	4
323
5	5
324
6	6
325
7	7
326
8	8
327
9	9
328
10	10
329
INSERT INTO t2 values (100,100);
330
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
331
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
332
COMMIT;
333
INSERT INTO t2 values (101,101);
334
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
335
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
336
ROLLBACK;
337
SELECT * from t2;
338
a	b
339
100	100
340
DROP TABLE t1,t2;
341
show binlog events from <binlog_start>;
342
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
343
master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 values (1,1),(1,2)
344
master-bin.000001	#	Query	#	#	use `test`; DROP TABLE if exists t2
345
master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 values (3,3)
346
master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS t2
347
master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t2 (a int, b int, primary key (a)) engine=innodb
348
master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (4,4)
349
master-bin.000001	#	Query	#	#	use `test`; BEGIN
350
master-bin.000001	#	Query	#	#	use `test`; TRUNCATE table t2
351
master-bin.000001	#	Xid	#	#	COMMIT /* XID */
352
master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (5,5)
353
master-bin.000001	#	Query	#	#	use `test`; DROP TABLE t2
354
master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 values (6,6)
355
master-bin.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a)) engine=innodb
356
master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 values (7,7)
357
master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 values (8,8)
358
master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 values (9,9)
359
master-bin.000001	#	Query	#	#	use `test`; BEGIN
360
master-bin.000001	#	Query	#	#	use `test`; TRUNCATE table t2
361
master-bin.000001	#	Query	#	#	use `test`; COMMIT
362
master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 values (10,10)
363
master-bin.000001	#	Query	#	#	use `test`; BEGIN
364
master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t2 values (100,100)
365
master-bin.000001	#	Query	#	#	use `test`; COMMIT
366
master-bin.000001	#	Query	#	#	use `test`; DROP TABLE t1,t2
367
reset master;
368
create table t1 (a int) engine=innodb;
369
create table t2 (a int) engine=myisam;
370
select get_lock("a",10);
371
get_lock("a",10)
372
1
373
begin;
374
insert into t1 values(8);
375
insert into t2 select * from t1;
376
select get_lock("a",10);
377
get_lock("a",10)
378
1
379
flush logs;
380
select
381
(@a:=load_file("MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output"))
382
is not null;
383
(@a:=load_file("MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output"))
384
is not null
385
1
386
select
387
@a like "%#%error_code=0%ROLLBACK\n/*!*/;%ROLLBACK /* added by mysqlbinlog */;%" OR
388
@a like "%#%error_code=0%ROLLBACK\r\n/*!*/;%ROLLBACK /* added by mysqlbinlog */;%",
389
@a not like "%#%error_code=%error_code=%";
390
@a like "%#%error_code=0%ROLLBACK\n/*!*/;%ROLLBACK /* added by mysqlbinlog */;%" OR
391
@a like "%#%error_code=0%ROLLBACK\r\n/*!*/;%ROLLBACK /* added by mysqlbinlog */;%"	@a not like "%#%error_code=%error_code=%"
392
1	1
393
drop table t1, t2;
394
create temporary table tt (a int unique);
395
create table ti (a int) engine=innodb;
396
reset master;
397
begin;
398
insert into ti values (1);
399
insert into ti values (2) ;
400
insert into tt select * from ti;
401
rollback;
402
Warnings:
403
Warning	1196	Some non-transactional changed tables couldn't be rolled back
404
select count(*) from tt /* 2 */;
405
count(*)
406
2
407
show binlog events from <binlog_start>;
408
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
409
master-bin.000001	#	Query	#	#	use `test`; BEGIN
410
master-bin.000001	#	Query	#	#	use `test`; insert into ti values (1)
411
master-bin.000001	#	Query	#	#	use `test`; insert into ti values (2)
412
master-bin.000001	#	Query	#	#	use `test`; insert into tt select * from ti
413
master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
414
select count(*) from ti /* zero */;
415
count(*)
416
0
417
insert into ti select * from tt;
418
select * from ti /* that is what slave would miss - a bug */;
419
a
420
1
421
2
422
delete from ti;
423
delete from tt where a=1;
424
reset master;
425
begin;
426
insert into ti values (1);
427
insert into ti values (2) /* to make the dup error in the following */;
428
insert into tt select * from ti /* one affected and error */;
429
ERROR 23000: Duplicate entry '2' for key 'a'
430
rollback;
431
Warnings:
432
Warning	1196	Some non-transactional changed tables couldn't be rolled back
433
show binlog events from <binlog_start>;
434
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
435
master-bin.000001	#	Query	#	#	use `test`; BEGIN
436
master-bin.000001	#	Query	#	#	use `test`; insert into ti values (1)
437
master-bin.000001	#	Query	#	#	use `test`; insert into ti values (2) /* to make the dup error in the following */
438
master-bin.000001	#	Query	#	#	use `test`; insert into tt select * from ti /* one affected and error */
439
master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
440
select count(*) from ti /* zero */;
441
count(*)
442
0
443
insert into ti select * from tt;
444
select * from tt /* that is what otherwise slave missed - the bug */;
445
a
446
1
447
2
448
drop table ti, tt;
449
drop function if exists bug27417;
450
drop table if exists t1,t2;
451
CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM;
452
CREATE TABLE t2 (a int NOT NULL auto_increment, PRIMARY KEY (a));
453
create function bug27417(n int)
454
RETURNS int(11)
455
begin
456
insert into t1 values (null);
457
return n;
458
end|
459
reset master;
460
insert into t2 values (bug27417(1));
461
insert into t2 select bug27417(2);
462
reset master;
463
insert into t2 values (bug27417(2));
464
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
465
show binlog events from <binlog_start>;
466
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
467
master-bin.000001	#	Intvar	#	#	INSERT_ID=3
468
master-bin.000001	#	Query	#	#	use `test`; insert into t2 values (bug27417(2))
469
/* only (!) with fixes for #23333 will show there is the query */;
470
select count(*) from t1 /* must be 3 */;
471
count(*)
472
3
473
reset master;
474
select count(*) from t2;
475
count(*)
476
2
477
delete from t2 where a=bug27417(3);
478
select count(*) from t2 /* nothing got deleted */;
479
count(*)
480
2
481
show binlog events from <binlog_start>;
482
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
483
master-bin.000001	#	Intvar	#	#	INSERT_ID=4
484
master-bin.000001	#	Query	#	#	use `test`; delete from t2 where a=bug27417(3)
485
/* the query must be in regardless of #23333 */;
486
select count(*) from t1 /* must be 5 */;
487
count(*)
488
5
489
delete t2 from t2 where t2.a=bug27417(100) /* must not affect t2 */;
490
affected rows: 0
491
select count(*) from t1 /* must be 7 */;
492
count(*)
493
7
494
drop table t1,t2;
495
CREATE TABLE t1 (a int  NOT NULL auto_increment primary key) ENGINE=MyISAM;
496
CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
497
CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique) ENGINE=MyISAM;
498
CREATE TABLE t4 (a int, PRIMARY KEY (a), b int unique) ENGINE=Innodb;
499
CREATE TABLE t5 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
500
insert into t2 values (1);
501
reset master;
502
insert into t2 values (bug27417(1));
503
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
504
show binlog events from <binlog_start>;
505
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
506
master-bin.000001	#	Query	#	#	use `test`; BEGIN
507
master-bin.000001	#	Intvar	#	#	INSERT_ID=1
508
master-bin.000001	#	Query	#	#	use `test`; insert into t2 values (bug27417(1))
509
master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
510
/* the output must denote there is the query */;
511
select count(*) from t1 /* must be 1 */;
512
count(*)
513
1
514
delete from t1;
515
delete from t2;
516
insert into t2 values (2);
517
reset master;
518
insert into t2 select bug27417(1) union select bug27417(2);
519
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
520
show binlog events from <binlog_start>;
521
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
522
master-bin.000001	#	Query	#	#	use `test`; BEGIN
523
master-bin.000001	#	Intvar	#	#	INSERT_ID=2
524
master-bin.000001	#	Query	#	#	use `test`; insert into t2 select bug27417(1) union select bug27417(2)
525
master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
526
/* the output must denote there is the query */;
527
select count(*) from t1 /* must be 2 */;
528
count(*)
529
2
530
delete from t1;
531
insert into t3 values (1,1),(2,3),(3,4);
532
reset master;
533
update t3 set b=b+bug27417(1);
534
ERROR 23000: Duplicate entry '4' for key 'b'
535
show binlog events from <binlog_start>;
536
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
537
master-bin.000001	#	Intvar	#	#	INSERT_ID=4
538
master-bin.000001	#	Query	#	#	use `test`; update t3 set b=b+bug27417(1)
539
/* the output must denote there is the query */;
540
select count(*) from t1 /* must be 2 */;
541
count(*)
542
2
543
delete from t3;
544
delete from t4;
545
insert into t3 values (1,1);
546
insert into t4 values (1,1),(2,2);
547
reset master;
548
UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */;
549
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
550
show binlog events from <binlog_start>;
551
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
552
master-bin.000001	#	Intvar	#	#	INSERT_ID=6
553
master-bin.000001	#	Query	#	#	use `test`; UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */
554
/* the output must denote there is the query */;
555
select count(*) from t1 /* must be 4 */;
556
count(*)
557
4
558
delete from t1;
559
delete from t3;
560
delete from t4;
561
insert into t3 values (1,1),(2,2);
562
insert into t4 values (1,1),(2,2);
563
reset master;
564
UPDATE t3,t4 SET t3.a=t4.a + bug27417(1);
565
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
566
select count(*) from t1 /* must be 1 */;
567
count(*)
568
1
569
drop table t4;
570
delete from t1;
571
delete from t2;
572
delete from t3;
573
insert into t2 values (1);
574
insert into t3 values (1,1);
575
create trigger trg_del before delete on t2 for each row 
576
insert into t3 values (bug27417(1), 2);
577
reset master;
578
delete from t2;
579
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
580
show binlog events from <binlog_start>;
581
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
582
master-bin.000001	#	Query	#	#	use `test`; BEGIN
583
master-bin.000001	#	Intvar	#	#	INSERT_ID=9
584
master-bin.000001	#	Query	#	#	use `test`; delete from t2
585
master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
586
/* the output must denote there is the query */;
587
select count(*) from t1 /* must be 1 */;
588
count(*)
589
1
590
drop trigger trg_del;
591
delete from t1;
592
delete from t2;
593
delete from t5;
594
create trigger trg_del_t2 after  delete on t2 for each row
595
insert into t1 values (1);
596
insert into t2 values (2),(3);
597
insert into t5 values (1),(2);
598
reset master;
599
delete t2.* from t2,t5 where t2.a=t5.a + 1;
600
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
601
show binlog events from <binlog_start>;
602
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
603
master-bin.000001	#	Query	#	#	use `test`; BEGIN
604
master-bin.000001	#	Query	#	#	use `test`; delete t2.* from t2,t5 where t2.a=t5.a + 1
605
master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
606
/* the output must denote there is the query */;
607
select count(*) from t1 /* must be 1 */;
608
count(*)
609
1
610
delete from t1;
611
create table t4 (a int default 0, b int primary key) engine=innodb;
612
insert into t4 values (0, 17);
613
reset master;
614
load data infile '../std_data_ln/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2);
615
ERROR 23000: Duplicate entry '17' for key 'PRIMARY'
616
select * from t4;
617
a	b
618
0	17
619
select count(*) from t1 /* must be 2 */;
620
count(*)
621
2
622
show binlog events from <binlog_start>;
623
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
624
master-bin.000001	#	Query	#	#	use `test`; BEGIN
625
master-bin.000001	#	Intvar	#	#	INSERT_ID=10
626
master-bin.000001	#	Begin_load_query	#	#	;file_id=#;block_len=12
627
master-bin.000001	#	Intvar	#	#	INSERT_ID=10
628
master-bin.000001	#	Execute_load_query	#	#	use `test`; load data infile '../std_data_ln/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2) ;file_id=#
629
master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
630
/* the output must denote there is the query */;
631
drop trigger trg_del_t2;
632
drop table t1,t2,t3,t4,t5;
633
drop function bug27417;
634
end of tests
635
set @@session.binlog_format=statement;
636
create temporary table tt (a int unique);
637
create table ti (a int) engine=innodb;
638
reset master;
639
begin;
640
insert into ti values (1);
641
insert into ti values (2) ;
642
insert into tt select * from ti;
643
rollback;
644
Warnings:
645
Warning	1196	Some non-transactional changed tables couldn't be rolled back
646
select count(*) from tt /* 2 */;
647
count(*)
648
2
649
show binlog events from <binlog_start>;
650
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
651
master-bin.000001	#	Query	#	#	use `test`; BEGIN
652
master-bin.000001	#	Query	#	#	use `test`; insert into ti values (1)
653
master-bin.000001	#	Query	#	#	use `test`; insert into ti values (2)
654
master-bin.000001	#	Query	#	#	use `test`; insert into tt select * from ti
655
master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
656
select count(*) from ti /* zero */;
657
count(*)
658
0
659
insert into ti select * from tt;
660
select * from ti /* that is what slave would miss - bug#28960 */;
661
a
662
1
663
2
664
delete from ti;
665
delete from tt where a=1;
666
reset master;
667
begin;
668
insert into ti values (1);
669
insert into ti values (2) /* to make the dup error in the following */;
670
insert into tt select * from ti /* one affected and error */;
671
ERROR 23000: Duplicate entry '2' for key 'a'
672
rollback;
673
Warnings:
674
Warning	1196	Some non-transactional changed tables couldn't be rolled back
675
show binlog events from <binlog_start>;
676
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
677
master-bin.000001	#	Query	#	#	use `test`; BEGIN
678
master-bin.000001	#	Query	#	#	use `test`; insert into ti values (1)
679
master-bin.000001	#	Query	#	#	use `test`; insert into ti values (2) /* to make the dup error in the following */
680
master-bin.000001	#	Query	#	#	use `test`; insert into tt select * from ti /* one affected and error */
681
master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
682
select count(*) from ti /* zero */;
683
count(*)
684
0
685
insert into ti select * from tt;
686
select * from tt /* that is what otherwise slave missed - the bug */;
687
a
688
1
689
2
690
drop table ti;
691
drop function if exists bug27417;
692
drop table if exists t1,t2;
693
CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM;
694
CREATE TABLE t2 (a int NOT NULL auto_increment, PRIMARY KEY (a));
695
create function bug27417(n int) 
696
RETURNS int(11)
697
begin
698
insert into t1 values (null);
699
return n;
700
end|
701
reset master;
702
insert into t2 values (bug27417(1));
703
insert into t2 select bug27417(2);
704
reset master;
705
insert into t2 values (bug27417(2));
706
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
707
show binlog events from <binlog_start>;
708
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
709
master-bin.000001	#	Intvar	#	#	INSERT_ID=3
710
master-bin.000001	#	Query	#	#	use `test`; insert into t2 values (bug27417(2))
711
select count(*) from t1 /* must be 3 */;
712
count(*)
713
3
714
reset master;
715
select count(*) from t2;
716
count(*)
717
2
718
delete from t2 where a=bug27417(3);
719
select count(*) from t2 /* nothing got deleted */;
720
count(*)
721
2
722
show binlog events from <binlog_start>;
723
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
724
master-bin.000001	#	Intvar	#	#	INSERT_ID=4
725
master-bin.000001	#	Query	#	#	use `test`; delete from t2 where a=bug27417(3)
726
select count(*) from t1 /* must be 5 */;
727
count(*)
728
5
729
delete t2 from t2 where t2.a=bug27417(100) /* must not affect t2 */;
730
affected rows: 0
731
select count(*) from t1 /* must be 7 */;
732
count(*)
733
7
734
drop table t1,t2;
735
CREATE TABLE t1 (a int  NOT NULL auto_increment primary key) ENGINE=MyISAM;
736
CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
737
CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique) ENGINE=MyISAM;
738
CREATE TABLE t4 (a int, PRIMARY KEY (a), b int unique) ENGINE=Innodb;
739
CREATE TABLE t5 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
740
insert into t2 values (1);
741
reset master;
742
insert into t2 values (bug27417(1));
743
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
744
show binlog events from <binlog_start>;
745
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
746
master-bin.000001	#	Query	#	#	use `test`; BEGIN
747
master-bin.000001	#	Intvar	#	#	INSERT_ID=1
748
master-bin.000001	#	Query	#	#	use `test`; insert into t2 values (bug27417(1))
749
master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
750
select count(*) from t1 /* must be 1 */;
751
count(*)
752
1
753
delete from t1;
754
delete from t2;
755
insert into t2 values (2);
756
reset master;
757
insert into t2 select bug27417(1) union select bug27417(2);
758
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
759
show binlog events from <binlog_start>;
760
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
761
master-bin.000001	#	Query	#	#	use `test`; BEGIN
762
master-bin.000001	#	Intvar	#	#	INSERT_ID=2
763
master-bin.000001	#	Query	#	#	use `test`; insert into t2 select bug27417(1) union select bug27417(2)
764
master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
765
select count(*) from t1 /* must be 2 */;
766
count(*)
767
2
768
delete from t1;
769
insert into t3 values (1,1),(2,3),(3,4);
770
reset master;
771
update t3 set b=b+bug27417(1);
772
ERROR 23000: Duplicate entry '4' for key 'b'
773
show binlog events from <binlog_start>;
774
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
775
master-bin.000001	#	Intvar	#	#	INSERT_ID=4
776
master-bin.000001	#	Query	#	#	use `test`; update t3 set b=b+bug27417(1)
777
select count(*) from t1 /* must be 2 */;
778
count(*)
779
2
780
delete from t3;
781
delete from t4;
782
insert into t3 values (1,1);
783
insert into t4 values (1,1),(2,2);
784
reset master;
785
UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */;
786
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
787
show binlog events from <binlog_start>;
788
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
789
master-bin.000001	#	Intvar	#	#	INSERT_ID=6
790
master-bin.000001	#	Query	#	#	use `test`; UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */
791
select count(*) from t1 /* must be 4 */;
792
count(*)
793
4
794
delete from t1;
795
delete from t3;
796
delete from t4;
797
insert into t3 values (1,1),(2,2);
798
insert into t4 values (1,1),(2,2);
799
reset master;
800
UPDATE t3,t4 SET t3.a=t4.a + bug27417(1);
801
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
802
select count(*) from t1 /* must be 1 */;
803
count(*)
804
1
805
drop table t4;
806
delete from t1;
807
delete from t2;
808
delete from t3;
809
insert into t2 values (1);
810
insert into t3 values (1,1);
811
create trigger trg_del before delete on t2 for each row 
812
insert into t3 values (bug27417(1), 2);
813
reset master;
814
delete from t2;
815
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
816
show binlog events from <binlog_start>;
817
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
818
master-bin.000001	#	Query	#	#	use `test`; BEGIN
819
master-bin.000001	#	Intvar	#	#	INSERT_ID=9
820
master-bin.000001	#	Query	#	#	use `test`; delete from t2
821
master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
822
select count(*) from t1 /* must be 1 */;
823
count(*)
824
1
825
drop trigger trg_del;
826
delete from t1;
827
delete from t2;
828
delete from t5;
829
create trigger trg_del_t2 after  delete on t2 for each row
830
insert into t1 values (1);
831
insert into t2 values (2),(3);
832
insert into t5 values (1),(2);
833
reset master;
834
delete t2.* from t2,t5 where t2.a=t5.a + 1;
835
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
836
show binlog events from <binlog_start>;
837
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
838
master-bin.000001	#	Query	#	#	use `test`; BEGIN
839
master-bin.000001	#	Query	#	#	use `test`; delete t2.* from t2,t5 where t2.a=t5.a + 1
840
master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
841
select count(*) from t1 /* must be 1 */;
842
count(*)
843
1
844
delete from t1;
845
create table t4 (a int default 0, b int primary key) engine=innodb;
846
insert into t4 values (0, 17);
847
reset master;
848
load data infile '../std_data_ln/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2);
849
ERROR 23000: Duplicate entry '17' for key 'PRIMARY'
850
select * from t4;
851
a	b
852
0	17
853
select count(*) from t1 /* must be 2 */;
854
count(*)
855
2
856
show binlog events from <binlog_start>;
857
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
858
master-bin.000001	#	Query	#	#	use `test`; BEGIN
859
master-bin.000001	#	Intvar	#	#	INSERT_ID=10
860
master-bin.000001	#	User var	#	#	@`b`=_latin1 0x3135 COLLATE latin1_swedish_ci
861
master-bin.000001	#	Begin_load_query	#	#	;file_id=#;block_len=12
862
master-bin.000001	#	Intvar	#	#	INSERT_ID=10
863
master-bin.000001	#	User var	#	#	@`b`=_latin1 0x3135 COLLATE latin1_swedish_ci
864
master-bin.000001	#	Execute_load_query	#	#	use `test`; load data infile '../std_data_ln/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2) ;file_id=#
865
master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
866
drop trigger trg_del_t2;
867
drop table t1,t2,t3,t4,t5;
868
drop function bug27417;
869
set @@session.binlog_format=@@global.binlog_format;
870
end of tests