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