~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/commit_1innodb.result

  • Committer: Brian Aker
  • Date: 2008-11-04 15:39:09 UTC
  • mfrom: (575.1.2 devel)
  • Revision ID: brian@tangent.org-20081104153909-c72hn65udxs1ccal
Merge of Monty's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
set sql_mode=no_engine_substitution;
2
1
set storage_engine = InnoDB;
3
2
set autocommit=1;
4
3
drop table if exists t1;
5
4
drop table if exists t2;
6
5
drop table if exists t3;
7
 
drop function if exists f2;
8
 
drop procedure if exists bug12713_call;
9
 
drop procedure if exists bug12713_dump_spvars;
10
 
drop procedure if exists dummy;
11
6
create table t1 (a int);
12
7
create table t2 (a int unique);
13
8
create table t3 (a int);
14
 
set sql_mode=default;
15
9
insert into t1 (a) values (1), (2);
16
10
insert into t3 (a) values (1), (2);
17
 
create function f2(x int) returns int
18
 
begin
19
 
insert into t2 (a) values (x);
20
 
insert into t2 (a) values (x);
21
 
return x;
22
 
end|
23
 
set autocommit=0;
24
 
flush status;
25
11
insert into t2 (a) values (1001);
26
 
insert into t1 (a) values (f2(1));
27
 
ERROR 23000: Duplicate entry '1' for key 'a'
 
12
insert into t1 (a) values (1);
28
13
select * from t2;
29
14
a
30
15
1001
31
16
rollback;
32
17
select * from t2;
33
18
a
 
19
1001
34
20
insert into t2 (a) values (1002);
35
 
insert into t3 (a) select f2(2) from t1;
36
 
ERROR 23000: Duplicate entry '2' for key 'a'
37
21
select * from t2;
38
22
a
 
23
1001
39
24
1002
40
25
rollback;
41
26
select * from t2;
42
27
a
 
28
1001
 
29
1002
43
30
insert into t2 (a) values (1003);
44
 
update t1 set a= a + f2(3);
45
 
ERROR 23000: Duplicate entry '3' for key 'a'
 
31
update t1 set a= a + 3;
46
32
select * from t2;
47
33
a
 
34
1001
 
35
1002
48
36
1003
49
37
rollback;
50
38
select * from t2;
51
39
a
 
40
1001
 
41
1002
 
42
1003
52
43
insert into t2 (a) values (1004);
53
 
update t1, t3 set t1.a = 0, t3.a = 0 where (f2(4) = 4) and (t1.a = t3.a);
54
 
ERROR 23000: Duplicate entry '4' for key 'a'
 
44
update t1, t3 set t1.a = 0, t3.a = 0 where (4 = 4) and (t1.a = t3.a);
55
45
select * from t2;
56
46
a
 
47
1001
 
48
1002
 
49
1003
57
50
1004
58
51
rollback;
59
52
select * from t2;
60
53
a
 
54
1001
 
55
1002
 
56
1003
 
57
1004
61
58
insert into t2 (a) values (1005);
62
 
delete from t1 where (a = f2(5));
63
 
ERROR 23000: Duplicate entry '5' for key 'a'
 
59
delete from t1 where (a = 5);
64
60
select * from t2;
65
61
a
 
62
1001
 
63
1002
 
64
1003
 
65
1004
66
66
1005
67
67
rollback;
68
68
select * from t2;
69
69
a
 
70
1001
 
71
1002
 
72
1003
 
73
1004
 
74
1005
70
75
insert into t2 (a) values (1006);
71
 
delete from t1, t3 using t1, t3 where (f2(6) = 6) ;
72
 
ERROR 23000: Duplicate entry '6' for key 'a'
 
76
delete from t1, t3 using t1, t3 where (6 = 6) ;
73
77
select * from t2;
74
78
a
 
79
1001
 
80
1002
 
81
1003
 
82
1004
 
83
1005
75
84
1006
76
85
rollback;
77
86
select * from t2;
78
87
a
 
88
1001
 
89
1002
 
90
1003
 
91
1004
 
92
1005
 
93
1006
79
94
insert into t2 (a) values (1007);
80
 
replace t1 values (f2(7));
81
 
ERROR 23000: Duplicate entry '7' for key 'a'
 
95
replace t1 values (7);
82
96
select * from t2;
83
97
a
 
98
1001
 
99
1002
 
100
1003
 
101
1004
 
102
1005
 
103
1006
84
104
1007
85
105
rollback;
86
106
select * from t2;
87
107
a
 
108
1001
 
109
1002
 
110
1003
 
111
1004
 
112
1005
 
113
1006
 
114
1007
88
115
insert into t2 (a) values (1008);
89
 
replace into t3 (a) select f2(8) from t1;
90
 
ERROR 23000: Duplicate entry '8' for key 'a'
 
116
replace into t3 (a) select 8 from t1;
91
117
select * from t2;
92
118
a
 
119
1001
 
120
1002
 
121
1003
 
122
1004
 
123
1005
 
124
1006
 
125
1007
93
126
1008
94
127
rollback;
95
128
select * from t2;
96
129
a
 
130
1001
 
131
1002
 
132
1003
 
133
1004
 
134
1005
 
135
1006
 
136
1007
 
137
1008
97
138
insert into t2 (a) values (1009);
98
 
select f2(9) from t1 ;
99
 
ERROR 23000: Duplicate entry '9' for key 'a'
 
139
select 9 from t1 ;
 
140
9
 
141
9
100
142
select * from t2;
101
143
a
 
144
1001
 
145
1002
 
146
1003
 
147
1004
 
148
1005
 
149
1006
 
150
1007
 
151
1008
102
152
1009
103
153
rollback;
104
154
select * from t2;
105
155
a
 
156
1001
 
157
1002
 
158
1003
 
159
1004
 
160
1005
 
161
1006
 
162
1007
 
163
1008
 
164
1009
106
165
insert into t2 (a) values (1010);
107
 
show databases where (f2(10) = 10);
108
 
ERROR 23000: Duplicate entry '10' for key 'a'
109
166
select * from t2;
110
167
a
 
168
1001
 
169
1002
 
170
1003
 
171
1004
 
172
1005
 
173
1006
 
174
1007
 
175
1008
 
176
1009
111
177
1010
112
178
rollback;
113
179
select * from t2;
114
180
a
 
181
1001
 
182
1002
 
183
1003
 
184
1004
 
185
1005
 
186
1006
 
187
1007
 
188
1008
 
189
1009
 
190
1010
115
191
insert into t2 (a) values (1011);
116
 
show tables where (f2(11) = 11);
117
 
ERROR 23000: Duplicate entry '11' for key 'a'
118
 
select * from t2;
119
 
a
120
 
1011
121
 
rollback;
122
 
select * from t2;
123
 
a
124
 
insert into t2 (a) values (1012);
125
 
show triggers where (f2(12) = 12);
126
 
ERROR 23000: Duplicate entry '12' for key 'a'
127
 
select * from t2;
128
 
a
129
 
1012
130
 
rollback;
131
 
select * from t2;
132
 
a
 
192
select * from t2;
 
193
a
 
194
1001
 
195
1002
 
196
1003
 
197
1004
 
198
1005
 
199
1006
 
200
1007
 
201
1008
 
202
1009
 
203
1010
 
204
1011
 
205
rollback;
 
206
select * from t2;
 
207
a
 
208
1001
 
209
1002
 
210
1003
 
211
1004
 
212
1005
 
213
1006
 
214
1007
 
215
1008
 
216
1009
 
217
1010
 
218
1011
 
219
select * from t2;
 
220
a
 
221
1001
 
222
1002
 
223
1003
 
224
1004
 
225
1005
 
226
1006
 
227
1007
 
228
1008
 
229
1009
 
230
1010
 
231
1011
133
232
insert into t2 (a) values (1013);
134
 
show table status where (f2(13) = 13);
135
 
ERROR 23000: Duplicate entry '13' for key 'a'
136
233
select * from t2;
137
234
a
 
235
1001
 
236
1002
 
237
1003
 
238
1004
 
239
1005
 
240
1006
 
241
1007
 
242
1008
 
243
1009
 
244
1010
 
245
1011
138
246
1013
139
247
rollback;
140
248
select * from t2;
141
249
a
 
250
1001
 
251
1002
 
252
1003
 
253
1004
 
254
1005
 
255
1006
 
256
1007
 
257
1008
 
258
1009
 
259
1010
 
260
1011
 
261
1013
142
262
insert into t2 (a) values (1014);
143
 
show open tables where (f2(14) = 14);
144
 
ERROR 23000: Duplicate entry '14' for key 'a'
 
263
show open tables;
 
264
Database        Table   In_use  Name_locked
 
265
test    t2      0       0
 
266
test    t1      0       0
 
267
test    t3      0       0
145
268
select * from t2;
146
269
a
 
270
1001
 
271
1002
 
272
1003
 
273
1004
 
274
1005
 
275
1006
 
276
1007
 
277
1008
 
278
1009
 
279
1010
 
280
1011
 
281
1013
147
282
1014
148
283
rollback;
149
284
select * from t2;
150
285
a
 
286
1001
 
287
1002
 
288
1003
 
289
1004
 
290
1005
 
291
1006
 
292
1007
 
293
1008
 
294
1009
 
295
1010
 
296
1011
 
297
1013
 
298
1014
151
299
insert into t2 (a) values (1015);
152
 
show columns in mysql.proc where (f2(15) = 15);
153
 
ERROR 23000: Duplicate entry '15' for key 'a'
154
300
select * from t2;
155
301
a
 
302
1001
 
303
1002
 
304
1003
 
305
1004
 
306
1005
 
307
1006
 
308
1007
 
309
1008
 
310
1009
 
311
1010
 
312
1011
 
313
1013
 
314
1014
156
315
1015
157
316
rollback;
158
317
select * from t2;
159
318
a
 
319
1001
 
320
1002
 
321
1003
 
322
1004
 
323
1005
 
324
1006
 
325
1007
 
326
1008
 
327
1009
 
328
1010
 
329
1011
 
330
1013
 
331
1014
 
332
1015
160
333
insert into t2 (a) values (1016);
161
 
show status where (f2(16) = 16);
162
 
ERROR 23000: Duplicate entry '16' for key 'a'
163
334
select * from t2;
164
335
a
 
336
1001
 
337
1002
 
338
1003
 
339
1004
 
340
1005
 
341
1006
 
342
1007
 
343
1008
 
344
1009
 
345
1010
 
346
1011
 
347
1013
 
348
1014
 
349
1015
165
350
1016
166
351
rollback;
167
352
select * from t2;
168
353
a
 
354
1001
 
355
1002
 
356
1003
 
357
1004
 
358
1005
 
359
1006
 
360
1007
 
361
1008
 
362
1009
 
363
1010
 
364
1011
 
365
1013
 
366
1014
 
367
1015
 
368
1016
169
369
insert into t2 (a) values (1017);
170
 
show variables where (f2(17) = 17);
171
 
ERROR 23000: Duplicate entry '17' for key 'a'
172
370
select * from t2;
173
371
a
 
372
1001
 
373
1002
 
374
1003
 
375
1004
 
376
1005
 
377
1006
 
378
1007
 
379
1008
 
380
1009
 
381
1010
 
382
1011
 
383
1013
 
384
1014
 
385
1015
 
386
1016
174
387
1017
175
388
rollback;
176
389
select * from t2;
177
390
a
 
391
1001
 
392
1002
 
393
1003
 
394
1004
 
395
1005
 
396
1006
 
397
1007
 
398
1008
 
399
1009
 
400
1010
 
401
1011
 
402
1013
 
403
1014
 
404
1015
 
405
1016
 
406
1017
178
407
insert into t2 (a) values (1018);
179
 
show charset where (f2(18) = 18);
180
 
ERROR 23000: Duplicate entry '18' for key 'a'
181
408
select * from t2;
182
409
a
 
410
1001
 
411
1002
 
412
1003
 
413
1004
 
414
1005
 
415
1006
 
416
1007
 
417
1008
 
418
1009
 
419
1010
 
420
1011
 
421
1013
 
422
1014
 
423
1015
 
424
1016
 
425
1017
183
426
1018
184
427
rollback;
185
428
select * from t2;
186
429
a
 
430
1001
 
431
1002
 
432
1003
 
433
1004
 
434
1005
 
435
1006
 
436
1007
 
437
1008
 
438
1009
 
439
1010
 
440
1011
 
441
1013
 
442
1014
 
443
1015
 
444
1016
 
445
1017
 
446
1018
187
447
insert into t2 (a) values (1019);
188
 
show collation where (f2(19) = 19);
189
 
ERROR 23000: Duplicate entry '19' for key 'a'
190
 
select * from t2;
191
 
a
192
 
1019
193
 
rollback;
194
 
select * from t2;
195
 
a
196
 
# We need at least one procedure to make sure the WHERE clause is
197
 
# evaluated
198
 
create procedure dummy() begin end;
199
 
insert into t2 (a) values (1020);
200
 
show procedure status where (f2(20) = 20);
201
 
ERROR 23000: Duplicate entry '20' for key 'a'
202
 
select * from t2;
203
 
a
204
 
1020
205
 
rollback;
206
 
select * from t2;
207
 
a
208
 
drop procedure dummy;
 
448
select * from t2;
 
449
a
 
450
1001
 
451
1002
 
452
1003
 
453
1004
 
454
1005
 
455
1006
 
456
1007
 
457
1008
 
458
1009
 
459
1010
 
460
1011
 
461
1013
 
462
1014
 
463
1015
 
464
1016
 
465
1017
 
466
1018
 
467
1019
 
468
rollback;
 
469
select * from t2;
 
470
a
 
471
1001
 
472
1002
 
473
1003
 
474
1004
 
475
1005
 
476
1006
 
477
1007
 
478
1008
 
479
1009
 
480
1010
 
481
1011
 
482
1013
 
483
1014
 
484
1015
 
485
1016
 
486
1017
 
487
1018
 
488
1019
 
489
select * from t2;
 
490
a
 
491
1001
 
492
1002
 
493
1003
 
494
1004
 
495
1005
 
496
1006
 
497
1007
 
498
1008
 
499
1009
 
500
1010
 
501
1011
 
502
1013
 
503
1014
 
504
1015
 
505
1016
 
506
1017
 
507
1018
 
508
1019
 
509
rollback;
 
510
select * from t2;
 
511
a
 
512
1001
 
513
1002
 
514
1003
 
515
1004
 
516
1005
 
517
1006
 
518
1007
 
519
1008
 
520
1009
 
521
1010
 
522
1011
 
523
1013
 
524
1014
 
525
1015
 
526
1016
 
527
1017
 
528
1018
 
529
1019
209
530
insert into t2 (a) values (1021);
210
 
show function status where (f2(21) = 21);
211
 
ERROR 23000: Duplicate entry '21' for key 'a'
212
531
select * from t2;
213
532
a
 
533
1001
 
534
1002
 
535
1003
 
536
1004
 
537
1005
 
538
1006
 
539
1007
 
540
1008
 
541
1009
 
542
1010
 
543
1011
 
544
1013
 
545
1014
 
546
1015
 
547
1016
 
548
1017
 
549
1018
 
550
1019
214
551
1021
215
552
rollback;
216
553
select * from t2;
217
554
a
 
555
1001
 
556
1002
 
557
1003
 
558
1004
 
559
1005
 
560
1006
 
561
1007
 
562
1008
 
563
1009
 
564
1010
 
565
1011
 
566
1013
 
567
1014
 
568
1015
 
569
1016
 
570
1017
 
571
1018
 
572
1019
 
573
1021
218
574
insert into t2 (a) values (1022);
219
 
prepare stmt from "insert into t1 (a) values (f2(22))";
220
 
execute stmt;
221
 
ERROR 23000: Duplicate entry '22' for key 'a'
222
575
select * from t2;
223
576
a
 
577
1001
 
578
1002
 
579
1003
 
580
1004
 
581
1005
 
582
1006
 
583
1007
 
584
1008
 
585
1009
 
586
1010
 
587
1011
 
588
1013
 
589
1014
 
590
1015
 
591
1016
 
592
1017
 
593
1018
 
594
1019
 
595
1021
224
596
1022
225
597
rollback;
226
598
select * from t2;
227
599
a
 
600
1001
 
601
1002
 
602
1003
 
603
1004
 
604
1005
 
605
1006
 
606
1007
 
607
1008
 
608
1009
 
609
1010
 
610
1011
 
611
1013
 
612
1014
 
613
1015
 
614
1016
 
615
1017
 
616
1018
 
617
1019
 
618
1021
 
619
1022
228
620
insert into t2 (a) values (1023);
229
 
do (f2(23));
230
 
Warnings:
231
 
Error   1062    Duplicate entry '23' for key 'a'
232
 
select * from t2;
233
 
a
234
 
1023
235
 
rollback;
236
 
select * from t2;
237
 
a
238
 
create procedure bug12713_call ()
239
 
begin
240
 
insert into t2 (a) values (24);
241
 
insert into t2 (a) values (24);
242
 
end|
243
 
insert into t2 (a) values (1024);
244
 
call bug12713_call();
245
 
ERROR 23000: Duplicate entry '24' for key 'a'
246
 
select * from t2;
247
 
a
248
 
24
249
 
1024
250
 
rollback;
251
 
select * from t2;
252
 
a
 
621
select * from t2;
 
622
a
 
623
1001
 
624
1002
 
625
1003
 
626
1004
 
627
1005
 
628
1006
 
629
1007
 
630
1008
 
631
1009
 
632
1010
 
633
1011
 
634
1013
 
635
1014
 
636
1015
 
637
1016
 
638
1017
 
639
1018
 
640
1019
 
641
1021
 
642
1022
 
643
1023
 
644
rollback;
 
645
select * from t2;
 
646
a
 
647
1001
 
648
1002
 
649
1003
 
650
1004
 
651
1005
 
652
1006
 
653
1007
 
654
1008
 
655
1009
 
656
1010
 
657
1011
 
658
1013
 
659
1014
 
660
1015
 
661
1016
 
662
1017
 
663
1018
 
664
1019
 
665
1021
 
666
1022
 
667
1023
253
668
=======================================================================
254
669
Testing select_to_file
255
670
=======================================================================
256
671
insert into t2 (a) values (1025);
257
 
select f2(25) into outfile "../tmp/dml.out" from t1;
258
 
ERROR 23000: Duplicate entry '25' for key 'a'
 
672
select 25 into outfile "../tmp/dml.out" from t1;
259
673
select * from t2;
260
674
a
 
675
1001
 
676
1002
 
677
1003
 
678
1004
 
679
1005
 
680
1006
 
681
1007
 
682
1008
 
683
1009
 
684
1010
 
685
1011
 
686
1013
 
687
1014
 
688
1015
 
689
1016
 
690
1017
 
691
1018
 
692
1019
 
693
1021
 
694
1022
 
695
1023
261
696
1025
262
697
rollback;
263
698
select * from t2;
264
699
a
 
700
1001
 
701
1002
 
702
1003
 
703
1004
 
704
1005
 
705
1006
 
706
1007
 
707
1008
 
708
1009
 
709
1010
 
710
1011
 
711
1013
 
712
1014
 
713
1015
 
714
1016
 
715
1017
 
716
1018
 
717
1019
 
718
1021
 
719
1022
 
720
1023
 
721
1025
265
722
insert into t2 (a) values (1026);
266
 
load data infile "../std_data_ln/words.dat" into table t1 (a) set a:=f2(26);
267
 
ERROR 23000: Duplicate entry '26' for key 'a'
 
723
load data infile "../std_data_ln/words.dat" into table t1 (a) set a:=26;
 
724
ERROR HY000: Incorrect integer value: 'Aarhus' for column 'a' at row 1
268
725
select * from t2;
269
726
a
 
727
1001
 
728
1002
 
729
1003
 
730
1004
 
731
1005
 
732
1006
 
733
1007
 
734
1008
 
735
1009
 
736
1010
 
737
1011
 
738
1013
 
739
1014
 
740
1015
 
741
1016
 
742
1017
 
743
1018
 
744
1019
 
745
1021
 
746
1022
 
747
1023
 
748
1025
270
749
1026
271
750
rollback;
272
751
select * from t2;
273
752
a
 
753
1001
 
754
1002
 
755
1003
 
756
1004
 
757
1005
 
758
1006
 
759
1007
 
760
1008
 
761
1009
 
762
1010
 
763
1011
 
764
1013
 
765
1014
 
766
1015
 
767
1016
 
768
1017
 
769
1018
 
770
1019
 
771
1021
 
772
1022
 
773
1023
 
774
1025
 
775
1026
274
776
=======================================================================
275
777
Testing select_dumpvar
276
778
=======================================================================
277
779
insert into t2 (a) values (1027);
278
 
select f2(27) into @foo;
279
 
ERROR 23000: Duplicate entry '27' for key 'a'
280
 
select * from t2;
281
 
a
282
 
1027
283
 
rollback;
284
 
select * from t2;
285
 
a
286
 
=======================================================================
287
 
Testing Select_fetch_into_spvars 
288
 
=======================================================================
289
 
create procedure bug12713_dump_spvars ()
290
 
begin
291
 
declare foo int;
292
 
declare continue handler for sqlexception
293
 
begin
294
 
select "Exception trapped";
295
 
end;
296
 
select f2(28) into foo;
297
 
select * from t2;
298
 
end|
299
 
insert into t2 (a) values (1028);
300
 
call bug12713_dump_spvars ();
301
 
Exception trapped
302
 
Exception trapped
303
 
a
304
 
1028
305
 
rollback;
306
 
select * from t2;
307
 
a
 
780
select 27 into @foo;
 
781
select * from t2;
 
782
a
 
783
1001
 
784
1002
 
785
1003
 
786
1004
 
787
1005
 
788
1006
 
789
1007
 
790
1008
 
791
1009
 
792
1010
 
793
1011
 
794
1013
 
795
1014
 
796
1015
 
797
1016
 
798
1017
 
799
1018
 
800
1019
 
801
1021
 
802
1022
 
803
1023
 
804
1025
 
805
1026
 
806
1027
 
807
rollback;
 
808
select * from t2;
 
809
a
 
810
1001
 
811
1002
 
812
1003
 
813
1004
 
814
1005
 
815
1006
 
816
1007
 
817
1008
 
818
1009
 
819
1010
 
820
1011
 
821
1013
 
822
1014
 
823
1015
 
824
1016
 
825
1017
 
826
1018
 
827
1019
 
828
1021
 
829
1022
 
830
1023
 
831
1025
 
832
1026
 
833
1027
308
834
=======================================================================
309
835
Cleanup
310
836
=======================================================================
312
838
drop table t1;
313
839
drop table t2;
314
840
drop table t3;
315
 
drop function f2;
316
 
drop procedure bug12713_call;
317
 
drop procedure bug12713_dump_spvars;
318
841
#
319
842
# Bug#12713 Error in a stored function called from a SELECT doesn't
320
843
# cause ROLLBACK of statem
329
852
set autocommit=0;
330
853
drop table if exists t1;
331
854
drop table if exists t2;
332
 
drop function if exists f1;
333
 
drop procedure if exists p_verify_status_increment;
334
 
set @binlog_format=@@global.binlog_format;
335
 
set sql_mode=no_engine_substitution;
336
 
create table t1 (a int unique);
337
 
create table t2 (a int) engine=myisam;
338
 
set sql_mode=default;
339
 
#
340
 
# An auxiliary procedure to track Handler_prepare and Handler_commit
341
 
# statistics.
342
 
#
343
 
create procedure
344
 
p_verify_status_increment(commit_inc_mixed int, prepare_inc_mixed int,
345
 
commit_inc_row int, prepare_inc_row int)
346
 
begin
347
 
declare commit_inc int;
348
 
declare prepare_inc int;
349
 
declare old_commit_count int default ifnull(@commit_count, 0);
350
 
declare old_prepare_count int default ifnull(@prepare_count, 0);
351
 
declare c_res int;
352
 
# Use a cursor to have just one access to I_S instead of 2, it is very slow
353
 
# and amounts for over 90% of test CPU time
354
 
declare c cursor for
355
 
select variable_value
356
 
from information_schema.session_status
357
 
where variable_name='Handler_commit' or variable_name='Handler_prepare'
358
 
     order by variable_name;
359
 
if @binlog_format = 'ROW' then
360
 
set commit_inc= commit_inc_row;
361
 
set prepare_inc= prepare_inc_row;
362
 
else
363
 
set commit_inc= commit_inc_mixed;
364
 
set prepare_inc= prepare_inc_mixed;
365
 
end if;
366
 
open c;
367
 
fetch c into c_res;
368
 
set @commit_count=c_res;
369
 
fetch c into c_res;
370
 
set @prepare_count=c_res;
371
 
close c;
372
 
if old_commit_count + commit_inc <> @commit_count then
373
 
select concat("Expected commit increment: ", commit_inc,
374
 
" actual: ", @commit_count - old_commit_count)
375
 
as 'ERROR';
376
 
elseif old_prepare_count + prepare_inc <> @prepare_count then
377
 
select concat("Expected prepare increment: ", prepare_inc,
378
 
" actual: ", @prepare_count - old_prepare_count)
379
 
as 'ERROR';
380
 
else
381
 
select '' as 'SUCCESS';
382
 
end if;
383
 
end|
384
 
# Reset Handler_commit and Handler_prepare counters
385
 
flush status;
386
 
#
387
 
# 1. Read-only statement: SELECT
388
 
#
389
 
select * from t1;
390
 
a
391
 
call p_verify_status_increment(1, 0, 1, 0);
392
 
SUCCESS
393
 
 
394
 
commit;
395
 
call p_verify_status_increment(1, 0, 1, 0);
396
 
SUCCESS
397
 
 
398
 
# 2. Read-write statement: INSERT, insert 1 row. 
399
 
#
400
 
insert into t1 (a) values (1);
401
 
call p_verify_status_increment(2, 2, 2, 2);
402
 
SUCCESS
403
 
 
404
 
commit;
405
 
call p_verify_status_increment(2, 2, 2, 2);
406
 
SUCCESS
407
 
 
408
 
# 3. Read-write statement: UPDATE, update 1 row. 
409
 
#
410
 
update t1 set a=2;
411
 
call p_verify_status_increment(2, 2, 2, 2);
412
 
SUCCESS
413
 
 
414
 
commit;
415
 
call p_verify_status_increment(2, 2, 2, 2);
416
 
SUCCESS
417
 
 
418
 
# 4. Read-write statement: UPDATE, update 0 rows, 1 row matches WHERE 
419
 
#
420
 
update t1 set a=2;
421
 
call p_verify_status_increment(2, 2, 1, 0);
422
 
SUCCESS
423
 
 
424
 
commit;
425
 
call p_verify_status_increment(2, 2, 1, 0);
426
 
SUCCESS
427
 
 
428
 
# 5. Read-write statement: UPDATE, update 0 rows, 0 rows match WHERE 
429
 
#
430
 
# In mixed replication mode, there is a read-only transaction
431
 
# in InnoDB and also the statement is written to the binary log.
432
 
# So we have two commits but no 2pc, since the first engine's
433
 
# transaction is read-only.
434
 
# In the row level replication mode, we only have the read-only
435
 
# transaction in InnoDB and nothing is written to the binary log.
436
 
#
437
 
update t1 set a=3 where a=1;
438
 
call p_verify_status_increment(2, 0, 1, 0);
439
 
SUCCESS
440
 
 
441
 
commit;
442
 
call p_verify_status_increment(2, 0, 1, 0);
443
 
SUCCESS
444
 
 
445
 
# 6. Read-write statement: DELETE, delete 0 rows. 
446
 
#
447
 
delete from t1 where a=1;
448
 
call p_verify_status_increment(2, 0, 1, 0);
449
 
SUCCESS
450
 
 
451
 
commit;
452
 
call p_verify_status_increment(2, 0, 1, 0);
453
 
SUCCESS
454
 
 
455
 
# 7. Read-write statement: DELETE, delete 1 row. 
456
 
#
457
 
delete from t1 where a=2;
458
 
call p_verify_status_increment(2, 2, 2, 2);
459
 
SUCCESS
460
 
 
461
 
commit;
462
 
call p_verify_status_increment(2, 2, 2, 2);
463
 
SUCCESS
464
 
 
465
 
# 8. Read-write statement: unqualified DELETE
466
 
#
467
 
# In statement or mixed replication mode, we call
468
 
# handler::ha_delete_all_rows() and write statement text
469
 
# to the binary log. This results in two read-write transactions.
470
 
# In row level replication mode, we do not call
471
 
# handler::ha_delete_all_rows(), but delete rows one by one.
472
 
# Since there are no rows, nothing is written to the binary log.
473
 
# Thus we have just one read-only transaction in InnoDB.
474
 
delete from t1;
475
 
call p_verify_status_increment(2, 2, 1, 0);
476
 
SUCCESS
477
 
 
478
 
commit;
479
 
call p_verify_status_increment(2, 2, 1, 0);
480
 
SUCCESS
481
 
 
482
 
# 9. Read-write statement: REPLACE, change 1 row. 
483
 
#
484
 
replace t1 set a=1;
485
 
call p_verify_status_increment(2, 2, 2, 2);
486
 
SUCCESS
487
 
 
488
 
commit;
489
 
call p_verify_status_increment(2, 2, 2, 2);
490
 
SUCCESS
491
 
 
492
 
# 10. Read-write statement: REPLACE, change 0 rows. 
493
 
#
494
 
replace t1 set a=1;
495
 
call p_verify_status_increment(2, 2, 1, 0);
496
 
SUCCESS
497
 
 
498
 
commit;
499
 
call p_verify_status_increment(2, 2, 1, 0);
500
 
SUCCESS
501
 
 
502
 
# 11. Read-write statement: IODKU, change 1 row. 
503
 
#
504
 
insert t1 set a=1 on duplicate key update a=a+1;
505
 
call p_verify_status_increment(2, 2, 2, 2);
506
 
SUCCESS
507
 
 
508
 
select * from t1;
509
 
a
510
 
2
511
 
call p_verify_status_increment(1, 0, 1, 0);
512
 
SUCCESS
513
 
 
514
 
commit;
515
 
call p_verify_status_increment(2, 2, 2, 2);
516
 
SUCCESS
517
 
 
518
 
# 12. Read-write statement: IODKU, change 0 rows. 
519
 
#
520
 
insert t1 set a=2 on duplicate key update a=2;
521
 
call p_verify_status_increment(1, 0, 1, 0);
522
 
SUCCESS
523
 
 
524
 
commit;
525
 
call p_verify_status_increment(1, 0, 1, 0);
526
 
SUCCESS
527
 
 
528
 
# 13. Read-write statement: INSERT IGNORE, change 0 rows. 
529
 
#
530
 
insert ignore t1 set a=2;
531
 
call p_verify_status_increment(1, 0, 1, 0);
532
 
SUCCESS
533
 
 
534
 
commit;
535
 
call p_verify_status_increment(1, 0, 1, 0);
536
 
SUCCESS
537
 
 
538
 
# 14. Read-write statement: INSERT IGNORE, change 1 row. 
539
 
#
540
 
insert ignore t1 set a=1;
541
 
call p_verify_status_increment(2, 2, 2, 2);
542
 
SUCCESS
543
 
 
544
 
commit;
545
 
call p_verify_status_increment(2, 2, 2, 2);
546
 
SUCCESS
547
 
 
548
 
# 15. Read-write statement: UPDATE IGNORE, change 0 rows. 
549
 
#
550
 
update ignore t1 set a=2 where a=1;
551
 
call p_verify_status_increment(2, 2, 1, 0);
552
 
SUCCESS
553
 
 
554
 
commit;
555
 
call p_verify_status_increment(2, 2, 1, 0);
556
 
SUCCESS
557
 
 
558
 
#
559
 
# Create a stored function that modifies a
560
 
# non-transactional table. Demonstrate that changes in
561
 
# non-transactional tables do not affect the two phase commit
562
 
# algorithm.
563
 
#
564
 
create function f1() returns int
565
 
begin
566
 
insert t2 set a=2;
567
 
return 2;
568
 
end|
569
 
call p_verify_status_increment(0, 0, 0, 0);
570
 
SUCCESS
571
 
 
572
 
# 16. A function changes non-trans-table.
573
 
#
574
 
# For row-based logging, there is an extra commit for the
575
 
# non-transactional changes saved in the transaction cache to
576
 
# the binary log. 
577
 
#
578
 
select f1();
579
 
f1()
580
 
2
581
 
call p_verify_status_increment(0, 0, 1, 0);
582
 
SUCCESS
583
 
 
584
 
commit;
585
 
call p_verify_status_increment(0, 0, 1, 0);
586
 
SUCCESS
587
 
 
588
 
# 17. Read-only statement, a function changes non-trans-table.
589
 
#
590
 
# For row-based logging, there is an extra commit for the
591
 
# non-transactional changes saved in the transaction cache to
592
 
# the binary log. 
593
 
#
594
 
select f1() from t1;
595
 
f1()
596
 
2
597
 
2
598
 
call p_verify_status_increment(1, 0, 2, 0);
599
 
SUCCESS
600
 
 
601
 
commit;
602
 
call p_verify_status_increment(1, 0, 2, 0);
603
 
SUCCESS
604
 
 
605
 
# 18. Read-write statement: UPDATE, change 0 (transactional) rows. 
606
 
#
607
 
select count(*) from t2;
608
 
count(*)
609
 
3
610
 
update t1 set a=2 where a=f1()+10;
611
 
select count(*) from t2;
612
 
count(*)
613
 
5
614
 
call p_verify_status_increment(2, 0, 2, 0);
615
 
SUCCESS
616
 
 
617
 
commit;
618
 
call p_verify_status_increment(2, 0, 2, 0);
619
 
SUCCESS
620
 
 
621
 
#
622
 
# Replace the non-transactional table with a temporary
623
 
# transactional table. Demonstrate that a change to a temporary
624
 
# transactional table does not provoke 2-phase commit, although
625
 
# does trigger a commit and a binlog write (in statement mode).
626
 
#
627
 
drop table t2;
628
 
set sql_mode=no_engine_substitution;
629
 
create temporary table t2 (a int);
630
 
call p_verify_status_increment(0, 0, 0, 0);
631
 
SUCCESS
632
 
 
633
 
set sql_mode=default;
634
 
# 19. A function changes temp-trans-table.
635
 
#
636
 
select f1();
637
 
f1()
638
 
2
639
 
# Two commits because a binary log record is written
640
 
call p_verify_status_increment(2, 0, 1, 0);
641
 
SUCCESS
642
 
 
643
 
commit;
644
 
call p_verify_status_increment(2, 0, 1, 0);
645
 
SUCCESS
646
 
 
647
 
# 20. Read-only statement, a function changes non-trans-table.
648
 
#
649
 
select f1() from t1;
650
 
f1()
651
 
2
652
 
2
653
 
# Two commits because a binary log record is written
654
 
call p_verify_status_increment(2, 0, 1, 0);
655
 
SUCCESS
656
 
 
657
 
commit;
658
 
call p_verify_status_increment(2, 0, 1, 0);
659
 
SUCCESS
660
 
 
661
 
# 21. Read-write statement: UPDATE, change 0 (transactional) rows. 
662
 
#
663
 
update t1 set a=2 where a=f1()+10;
664
 
call p_verify_status_increment(2, 0, 1, 0);
665
 
SUCCESS
666
 
 
667
 
commit;
668
 
call p_verify_status_increment(2, 0, 1, 0);
669
 
SUCCESS
670
 
 
671
 
# 22. DDL: ALTER TEMPORARY TABLE, should not cause a 2pc
672
 
#
673
 
alter table t2 add column b int default 5;
674
 
# A commit is done internally by ALTER. 
675
 
call p_verify_status_increment(2, 0, 2, 0);
676
 
SUCCESS
677
 
 
678
 
commit;
679
 
# There is nothing left to commit
680
 
call p_verify_status_increment(0, 0, 0, 0);
681
 
SUCCESS
682
 
 
683
 
# 23. DDL: RENAME TEMPORARY TABLE, does not start a transaction
684
 
 
685
 
# No test because of Bug#8729 "rename table fails on temporary table"
686
 
# 24. DDL: TRUNCATE TEMPORARY TABLE, does not start a transaction
687
 
 
688
 
truncate table t2;
689
 
call p_verify_status_increment(2, 0, 2, 0);
690
 
SUCCESS
691
 
 
692
 
commit;
693
 
# There is nothing left to commit
694
 
call p_verify_status_increment(0, 0, 0, 0);
695
 
SUCCESS
696
 
 
697
 
# 25. Read-write statement: unqualified DELETE 
698
 
 
699
 
delete from t2;
700
 
call p_verify_status_increment(2, 0, 1, 0);
701
 
SUCCESS
702
 
 
703
 
commit;
704
 
# There is nothing left to commit
705
 
call p_verify_status_increment(2, 0, 1, 0);
706
 
SUCCESS
707
 
 
708
 
# 25. DDL: DROP TEMPORARY TABLE, does not start a transaction
709
 
#
710
 
drop temporary table t2;
711
 
call p_verify_status_increment(0, 0, 0, 0);
712
 
SUCCESS
713
 
 
714
 
commit;
715
 
call p_verify_status_increment(0, 0, 0, 0);
716
 
SUCCESS
717
 
 
718
 
# 26. Verify that SET AUTOCOMMIT issues an implicit commit
719
 
#
720
 
insert t1 set a=3;
721
 
call p_verify_status_increment(2, 2, 2, 2);
722
 
SUCCESS
723
 
 
724
 
set autocommit=1;
725
 
call p_verify_status_increment(2, 2, 2, 2);
726
 
SUCCESS
727
 
 
728
 
rollback;
729
 
select a from t1 where a=3;
730
 
a
731
 
3
732
 
call p_verify_status_increment(1, 0, 1, 0);
733
 
SUCCESS
734
 
 
735
 
delete from t1 where a=3;
736
 
call p_verify_status_increment(2, 2, 2, 2);
737
 
SUCCESS
738
 
 
739
 
commit;
740
 
call p_verify_status_increment(0, 0, 0, 0);
741
 
SUCCESS
742
 
 
743
 
set autocommit=0;
744
 
call p_verify_status_increment(0, 0, 0, 0);
745
 
SUCCESS
746
 
 
747
 
insert t1 set a=3;
748
 
call p_verify_status_increment(2, 2, 2, 2);
749
 
SUCCESS
750
 
 
751
 
# Sic: not actually changing the value of autocommit
752
 
set autocommit=0;
753
 
call p_verify_status_increment(0, 0, 0, 0);
754
 
SUCCESS
755
 
 
756
 
rollback;
757
 
select a from t1 where a=3;
758
 
a
759
 
call p_verify_status_increment(1, 0, 1, 0);
760
 
SUCCESS
761
 
 
762
 
# 27. Savepoint management
763
 
#
764
 
insert t1 set a=3;
765
 
call p_verify_status_increment(2, 2, 2, 2);
766
 
SUCCESS
767
 
 
768
 
savepoint a;
769
 
call p_verify_status_increment(0, 0, 0, 0);
770
 
SUCCESS
771
 
 
772
 
insert t1 set a=4;
773
 
# Sic: a bug. Binlog did not register itself this time.
774
 
call p_verify_status_increment(1, 0, 1, 0);
775
 
SUCCESS
776
 
 
777
 
release savepoint a;
778
 
rollback;
779
 
call p_verify_status_increment(0, 0, 0, 0);
780
 
SUCCESS
781
 
 
782
 
select a from t1 where a=3;
783
 
a
784
 
call p_verify_status_increment(1, 0, 1, 0);
785
 
SUCCESS
786
 
 
787
 
commit;
788
 
call p_verify_status_increment(1, 0, 1, 0);
789
 
SUCCESS
790
 
 
791
 
# 28. Read-write statement: DO
792
 
#
793
 
create table t2 (a int);
794
 
call p_verify_status_increment(0, 0, 0, 0);
795
 
SUCCESS
796
 
 
797
 
do (select f1() from t1 where a=2);
798
 
call p_verify_status_increment(2, 2, 2, 2);
799
 
SUCCESS
800
 
 
801
 
commit;
802
 
call p_verify_status_increment(2, 2, 2, 2);
803
 
SUCCESS
804
 
 
805
 
# 29. Read-write statement: MULTI-DELETE
806
 
807
 
delete t1, t2 from t1 join t2 on (t1.a=t2.a) where t1.a=2;
808
 
commit;
809
 
call p_verify_status_increment(4, 4, 4, 4);
810
 
SUCCESS
811
 
 
812
 
# 30. Read-write statement: INSERT-SELECT, MULTI-UPDATE, REPLACE-SELECT
813
 
814
 
insert into t2 select a from t1;
815
 
commit;
816
 
replace into t2 select a from t1;
817
 
commit;
818
 
call p_verify_status_increment(8, 8, 8, 8);
819
 
SUCCESS
820
 
 
821
 
update t1, t2 set t1.a=4, t2.a=8 where t1.a=t2.a and t1.a=1;
822
 
commit;
823
 
call p_verify_status_increment(4, 4, 4, 4);
824
 
SUCCESS
825
 
 
826
 
# 31. DDL: various DDL with transactional tables
827
 
#
828
 
# Sic: no table is created.
829
 
create table if not exists t2 (a int) select 6 union select 7;
830
 
Warnings:
831
 
Note    1050    Table 't2' already exists
832
 
# Sic: first commits the statement, and then the transaction.
833
 
call p_verify_status_increment(4, 4, 4, 4);
834
 
SUCCESS
835
 
 
836
 
create table t3 select a from t2;
837
 
call p_verify_status_increment(4, 4, 4, 4);
838
 
SUCCESS
839
 
 
840
 
alter table t3 add column (b int);
841
 
call p_verify_status_increment(2, 0, 2, 0);
842
 
SUCCESS
843
 
 
844
 
alter table t3 rename t4;
845
 
call p_verify_status_increment(1, 0, 1, 0);
846
 
SUCCESS
847
 
 
848
 
rename table t4 to t3;
849
 
call p_verify_status_increment(1, 0, 1, 0);
850
 
SUCCESS
851
 
 
852
 
truncate table t3;
853
 
call p_verify_status_increment(2, 2, 2, 2);
854
 
SUCCESS
855
 
 
856
 
create view v1 as select * from t2;
857
 
call p_verify_status_increment(1, 0, 1, 0);
858
 
SUCCESS
859
 
 
860
 
check table t1;
861
 
Table   Op      Msg_type        Msg_text
862
 
test.t1 check   status  OK
863
 
call p_verify_status_increment(3, 0, 3, 0);
864
 
SUCCESS
865
 
 
866
 
# Sic: after this bug is fixed, CHECK leaves no pending transaction
867
 
commit;
868
 
call p_verify_status_increment(0, 0, 0, 0);
869
 
SUCCESS
870
 
 
871
 
check table t1, t2, t3;
872
 
Table   Op      Msg_type        Msg_text
873
 
test.t1 check   status  OK
874
 
test.t2 check   status  OK
875
 
test.t3 check   status  OK
876
 
call p_verify_status_increment(6, 0, 6, 0);
877
 
SUCCESS
878
 
 
879
 
commit;
880
 
call p_verify_status_increment(0, 0, 0, 0);
881
 
SUCCESS
882
 
 
883
 
drop view v1;
884
 
call p_verify_status_increment(0, 0, 0, 0);
885
 
SUCCESS
886
 
 
887
 
#
888
 
# Cleanup
889
 
#
890
 
drop table t1, t2, t3;
891
 
drop procedure p_verify_status_increment;
892
 
drop function f1;
 
855
drop table if exists t3;