Debian Codegraph @

mysql-test/suite/handler/innodb.result

raw
1 SET SESSION DEFAULT_STORAGE_ENGINE = InnoDB;
2 drop table if exists t1,t3,t4,t5;
3 create table t1 (a int, b char(10), key a using btree (a), key b using btree (a,b));
4 insert into t1 values
5 (17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
6 (14,"aaa"),(16,"ccc"),(16,"xxx"),
7 (20,"ggg"),(21,"hhh"),(22,"iii"),(23,"xxx"),(24,"xxx"),(25,"xxx");
8 handler t1 open as t2;
9 handler t2 read b first;
10 a b
11 14 aaa
12 handler t2 read b next;
13 a b
14 16 ccc
15 handler t2 read b next;
16 a b
17 16 xxx
18 handler t2 read b prev;
19 a b
20 16 ccc
21 handler t2 read b last;
22 a b
23 25 xxx
24 handler t2 read b prev;
25 a b
26 24 xxx
27 handler t2 read b prev;
28 a b
29 23 xxx
30 handler t2 read b first;
31 a b
32 14 aaa
33 handler t2 read b prev;
34 a b
35 handler t2 read b last;
36 a b
37 25 xxx
38 handler t2 read b prev;
39 a b
40 24 xxx
41 handler t2 read b next;
42 a b
43 25 xxx
44 handler t2 read b next;
45 a b
46 handler t2 read a=(15);
47 a b
48 handler t2 read a=(21);
49 a b
50 21 hhh
51 handler t2 read a=(19,"fff");
52 ERROR 42000: Too many key parts specified; max 1 parts allowed
53 handler t2 read b=(19,"fff");
54 a b
55 19 fff
56 handler t2 read b=(19,"yyy");
57 a b
58 19 yyy
59 handler t2 read b=(19);
60 a b
61 19 fff
62 handler t1 read a last;
63 ERROR 42S02: Unknown table 't1' in HANDLER
64 handler t2 read a=(11);
65 a b
66 handler t2 read a>=(11);
67 a b
68 14 aaa
69 handler t2 read b=(18);
70 a b
71 18 eee
72 handler t2 read b>=(18);
73 a b
74 18 eee
75 handler t2 read b>(18);
76 a b
77 19 fff
78 handler t2 read b<=(18);
79 a b
80 18 eee
81 handler t2 read b<(18);
82 a b
83 17 ddd
84 handler t2 read a=(15);
85 a b
86 handler t2 read a>=(15) limit 2;
87 a b
88 16 ccc
89 16 xxx
90 handler t2 read a>(15) limit 2;
91 a b
92 16 ccc
93 16 xxx
94 handler t2 read a<=(15);
95 a b
96 14 aaa
97 handler t2 read a<(15);
98 a b
99 14 aaa
100 handler t2 read a=(54);
101 a b
102 handler t2 read a>=(54);
103 a b
104 handler t2 read a>(54);
105 a b
106 handler t2 read a<=(54);
107 a b
108 25 xxx
109 handler t2 read a<(54);
110 a b
111 25 xxx
112 handler t2 read a=(1);
113 a b
114 handler t2 read a>=(1);
115 a b
116 14 aaa
117 handler t2 read a>(1);
118 a b
119 14 aaa
120 handler t2 read a<=(1);
121 a b
122 handler t2 read a<(1);
123 a b
124 handler t2 read b first limit 5;
125 a b
126 14 aaa
127 16 ccc
128 16 xxx
129 17 ddd
130 18 eee
131 handler t2 read b next limit 3;
132 a b
133 19 fff
134 19 yyy
135 20 ggg
136 handler t2 read b prev limit 10;
137 a b
138 19 yyy
139 19 fff
140 18 eee
141 17 ddd
142 16 xxx
143 16 ccc
144 14 aaa
145 handler t2 read b>=(16) limit 4;
146 a b
147 16 ccc
148 16 xxx
149 17 ddd
150 18 eee
151 handler t2 read b>=(16) limit 2,2;
152 a b
153 17 ddd
154 18 eee
155 select * from t1 where a>=16 order by a,b limit 2,2;
156 a b
157 17 ddd
158 18 eee
159 handler t2 read a last limit 3;
160 a b
161 25 xxx
162 24 xxx
163 23 xxx
164 handler t2 read b=(16) limit 1,3;
165 a b
166 16 xxx
167 handler t2 read b=(19);
168 a b
169 19 fff
170 handler t2 read b=(19) where b="yyy";
171 a b
172 19 yyy
173 handler t2 read first;
174 a b
175 17 ddd
176 handler t2 read next;
177 a b
178 18 eee
179 handler t2 read next;
180 a b
181 19 fff
182 handler t2 close;
183 handler t1 open;
184 handler t1 read b next;
185 a b
186 14 aaa
187 handler t1 read b next;
188 a b
189 16 ccc
190 handler t1 close;
191 handler t1 open;
192 handler t1 read a prev;
193 a b
194 25 xxx
195 handler t1 read a prev;
196 a b
197 24 xxx
198 handler t1 close;
199 handler t1 open as t2;
200 handler t2 read first;
201 a b
202 17 ddd
203 alter table t1 engine = InnoDB;
204 handler t2 read first;
205 ERROR 42S02: Unknown table 't2' in HANDLER
206 handler t1 open;
207 handler t1 read a=(20) limit 1,3;
208 a b
209 flush tables;
210 handler t1 read a=(20) limit 1,3;
211 a b
212 handler t1 close;
213 handler t1 open;
214 handler t1 read a=(25);
215 a b
216 25 xxx
217 handler t1 read a next;
218 a b
219 handler t1 read a next;
220 a b
221 handler t1 read a next;
222 a b
223 handler t1 read a prev;
224 a b
225 25 xxx
226 handler t1 read a=(1000);
227 a b
228 handler t1 read a next;
229 a b
230 handler t1 read a prev;
231 a b
232 25 xxx
233 handler t1 read a=(1000);
234 a b
235 handler t1 read a prev;
236 a b
237 25 xxx
238 handler t1 read a=(14);
239 a b
240 14 aaa
241 handler t1 read a prev;
242 a b
243 handler t1 read a prev;
244 a b
245 handler t1 read a next;
246 a b
247 14 aaa
248 handler t1 read a=(1);
249 a b
250 handler t1 read a prev;
251 a b
252 handler t1 read a next;
253 a b
254 14 aaa
255 handler t1 read a=(1);
256 a b
257 handler t1 read a next;
258 a b
259 14 aaa
260 handler t1 close;
261 handler t1 open;
262 prepare stmt from 'handler t1 read a=(?) limit ?,?';
263 set @a=20,@b=1,@c=100;
264 execute stmt using @a,@b,@c;
265 a b
266 set @a=20,@b=2,@c=1;
267 execute stmt using @a,@b,@c;
268 a b
269 set @a=20,@b=0,@c=2;
270 execute stmt using @a,@b,@c;
271 a b
272 20 ggg
273 deallocate prepare stmt;
274 prepare stmt from 'handler t1 read a next limit ?';
275 handler t1 read a>=(21);
276 a b
277 21 hhh
278 set @a=3;
279 execute stmt using @a;
280 a b
281 22 iii
282 23 xxx
283 24 xxx
284 execute stmt using @a;
285 a b
286 25 xxx
287 execute stmt using @a;
288 a b
289 deallocate prepare stmt;
290 prepare stmt from 'handler t1 read b prev limit ?';
291 execute stmt using @a;
292 a b
293 25 xxx
294 24 xxx
295 23 xxx
296 execute stmt using @a;
297 a b
298 22 iii
299 21 hhh
300 20 ggg
301 execute stmt using @a;
302 a b
303 19 yyy
304 19 fff
305 18 eee
306 execute stmt using @a;
307 a b
308 17 ddd
309 16 xxx
310 16 ccc
311 deallocate prepare stmt;
312 prepare stmt from 'handler t1 read b=(?,?)';
313 set @a=14, @b='aaa';
314 execute stmt using @a,@b;
315 a b
316 14 aaa
317 set @a=14, @b='not found';
318 execute stmt using @a,@b;
319 a b
320 deallocate prepare stmt;
321 prepare stmt from 'handler t1 read b=(1+?) limit 10';
322 set @a=15;
323 execute stmt using @a;
324 a b
325 16 ccc
326 16 xxx
327 execute stmt using @a;
328 a b
329 16 ccc
330 16 xxx
331 deallocate prepare stmt;
332 prepare stmt from 'handler t1 read b>=(?) where a < ? limit 5';
333 set @a=17, @b=24;
334 execute stmt using @a,@b;
335 a b
336 17 ddd
337 18 eee
338 19 fff
339 19 yyy
340 20 ggg
341 execute stmt using @a,@b;
342 a b
343 17 ddd
344 18 eee
345 19 fff
346 19 yyy
347 20 ggg
348 deallocate prepare stmt;
349 prepare stmt from 'handler t1 read a=(?)';
350 set @a=17;
351 execute stmt using @a;
352 a b
353 17 ddd
354 alter table t1 add c int;
355 execute stmt using @a;
356 ERROR 42S02: Unknown table 't1' in HANDLER
357 deallocate prepare stmt;
358 handler t1 close;
359 ERROR 42S02: Unknown table 't1' in HANDLER
360 handler t1 open;
361 prepare stmt from 'handler t1 read a=(?)';
362 flush tables;
363 set @a=17;
364 execute stmt using @a;
365 a b c
366 17 ddd NULL
367 deallocate prepare stmt;
368 handler t1 close;
369 handler t1 open as t2;
370 drop table t1;
371 create table t1 (a int not null);
372 insert into t1 values (17);
373 handler t2 read first;
374 ERROR 42S02: Unknown table 't2' in HANDLER
375 handler t1 open as t2;
376 alter table t1 engine=csv;
377 handler t2 read first;
378 ERROR 42S02: Unknown table 't2' in HANDLER
379 drop table t1;
380 create table t1 (a int);
381 insert into t1 values (1),(2),(3),(4),(5),(6);
382 delete from t1 limit 2;
383 handler t1 open;
384 handler t1 read first;
385 a
386 3
387 handler t1 read first limit 1,1;
388 a
389 4
390 handler t1 read first limit 2,2;
391 a
392 5
393 6
394 delete from t1 limit 3;
395 handler t1 read first;
396 a
397 6
398 drop table t1;
399 create table t1(a int, index using btree (a));
400 insert into t1 values (1), (2), (3);
401 handler t1 open;
402 handler t1 read a=(W);
403 ERROR 42S22: Unknown column 'W' in 'HANDLER ... READ'
404 handler t1 read a=(a);
405 ERROR HY000: Incorrect arguments to HANDLER ... READ
406 drop table t1;
407 create table t1 (a char(5));
408 insert into t1 values ("Ok");
409 handler t1 open as t;
410 handler t read first;
411 a
412 Ok
413 use mysql;
414 handler t read first;
415 a
416 Ok
417 handler t close;
418 handler test.t1 open as t;
419 handler t read first;
420 a
421 Ok
422 handler t close;
423 use test;
424 drop table t1;
425 create table t1 ( a int, b int, INDEX a using btree (a) );
426 insert into t1 values (1,2), (2,1);
427 handler t1 open;
428 handler t1 read a=(1) where b=2;
429 a b
430 1 2
431 handler t1 read a=(1) where b=3;
432 a b
433 handler t1 read a=(1) where b=1;
434 a b
435 handler t1 close;
436 drop table t1;
437 create table t1 (c1 char(20));
438 insert into t1 values ("t1");
439 handler t1 open as h1;
440 handler h1 read first limit 9;
441 c1
442 t1
443 create table t2 (c1 char(20));
444 insert into t2 values ("t2");
445 handler t2 open as h2;
446 handler h2 read first limit 9;
447 c1
448 t2
449 create table t3 (c1 char(20));
450 insert into t3 values ("t3");
451 handler t3 open as h3;
452 handler h3 read first limit 9;
453 c1
454 t3
455 create table t4 (c1 char(20));
456 insert into t4 values ("t4");
457 handler t4 open as h4;
458 handler h4 read first limit 9;
459 c1
460 t4
461 create table t5 (c1 char(20));
462 insert into t5 values ("t5");
463 handler t5 open as h5;
464 handler h5 read first limit 9;
465 c1
466 t5
467 alter table t1 engine=MyISAM;
468 handler h1 read first limit 9;
469 ERROR 42S02: Unknown table 'h1' in HANDLER
470 handler h2 read first limit 9;
471 c1
472 t2
473 handler h3 read first limit 9;
474 c1
475 t3
476 handler h4 read first limit 9;
477 c1
478 t4
479 handler h5 read first limit 9;
480 c1
481 t5
482 alter table t5 engine=MyISAM;
483 handler h1 read first limit 9;
484 ERROR 42S02: Unknown table 'h1' in HANDLER
485 handler h2 read first limit 9;
486 c1
487 t2
488 handler h3 read first limit 9;
489 c1
490 t3
491 handler h4 read first limit 9;
492 c1
493 t4
494 handler h5 read first limit 9;
495 ERROR 42S02: Unknown table 'h5' in HANDLER
496 alter table t3 engine=MyISAM;
497 handler h1 read first limit 9;
498 ERROR 42S02: Unknown table 'h1' in HANDLER
499 handler h2 read first limit 9;
500 c1
501 t2
502 handler h3 read first limit 9;
503 ERROR 42S02: Unknown table 'h3' in HANDLER
504 handler h4 read first limit 9;
505 c1
506 t4
507 handler h5 read first limit 9;
508 ERROR 42S02: Unknown table 'h5' in HANDLER
509 handler h2 close;
510 handler h4 close;
511 handler t1 open as h1_1;
512 handler t1 open as h1_2;
513 handler t1 open as h1_3;
514 handler h1_1 read first limit 9;
515 c1
516 t1
517 handler h1_2 read first limit 9;
518 c1
519 t1
520 handler h1_3 read first limit 9;
521 c1
522 t1
523 alter table t1 engine=InnoDB;
524 handler h1_1 read first limit 9;
525 ERROR 42S02: Unknown table 'h1_1' in HANDLER
526 handler h1_2 read first limit 9;
527 ERROR 42S02: Unknown table 'h1_2' in HANDLER
528 handler h1_3 read first limit 9;
529 ERROR 42S02: Unknown table 'h1_3' in HANDLER
530 drop table t1;
531 drop table t2;
532 drop table t3;
533 drop table t4;
534 drop table t5;
535 create table t1 (c1 int);
536 insert into t1 values (1);
537 handler t1 open;
538 handler t1 read first;
539 c1
540 1
541 connect con2,localhost,root,,;
542 connection con2;
543 send the below to another connection, do not wait for the result
544 optimize table t1;
545 connection default;
546 handler t1 read next;
547 c1
548 handler t1 close;
549 connection con2;
550 Table Op Msg_type Msg_text
551 test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
552 test.t1 optimize status OK
553 connection default;
554 drop table t1;
555 CREATE TABLE t1 ( no1 smallint(5) NOT NULL default '0', no2 int(10) NOT NULL default '0', PRIMARY KEY using btree (no1,no2));
556 INSERT INTO t1 VALUES (1,274),(1,275),(2,6),(2,8),(4,1),(4,2);
557 HANDLER t1 OPEN;
558 HANDLER t1 READ `primary` = (1, 1000);
559 no1 no2
560 HANDLER t1 READ `primary` PREV;
561 no1 no2
562 1 275
563 HANDLER t1 READ `primary` = (1, 1000);
564 no1 no2
565 HANDLER t1 READ `primary` NEXT;
566 no1 no2
567 2 6
568 DROP TABLE t1;
569 create table t1 (c1 int);
570 insert into t1 values (14397);
571 flush tables with read lock;
572 drop table t1;
573 ERROR HY000: Can't execute the query because you have a conflicting read lock
574 connection con2;
575 drop table t1;
576 connection default;
577 select * from t1;
578 c1
579 14397
580 unlock tables;
581 connection con2;
582 read the result from the other connection
583 connection default;
584 select * from t1;
585 ERROR 42S02: Table 'test.t1' doesn't exist
586 drop table if exists t1;
587 Warnings:
588 Note 1051 Unknown table 'test.t1'
589 create table t1 (a int not null) ENGINE=csv;
590 connection con2;
591 handler t1 open;
592 ERROR HY000: Storage engine CSV of the table `test`.`t1` doesn't have this option
593 connection default;
594 drop table t1;
595 disconnect con2;
596 create table t1 (a int);
597 handler t1 open as t1_alias;
598 handler t1_alias read a next;
599 ERROR 42000: Key 'a' doesn't exist in table 't1_alias'
600 handler t1_alias READ a next where inexistent > 0;
601 ERROR 42S22: Unknown column 'inexistent' in 'WHERE'
602 handler t1_alias read a next;
603 ERROR 42000: Key 'a' doesn't exist in table 't1_alias'
604 handler t1_alias READ a next where inexistent > 0;
605 ERROR 42S22: Unknown column 'inexistent' in 'WHERE'
606 handler t1_alias close;
607 drop table t1;
608 create temporary table t1 (a int, b char(1), key a using btree (a), key b using btree (a,b));
609 insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"),
610 (5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"),(9,'k');
611 select a,b from t1;
612 a b
613 0 a
614 1 b
615 2 c
616 3 d
617 4 e
618 5 f
619 6 g
620 7 h
621 8 i
622 9 j
623 9 k
624 handler t1 open as a1;
625 handler a1 read a=(1);
626 a b
627 1 b
628 handler a1 read a next;
629 a b
630 2 c
631 handler a1 read a next;
632 a b
633 3 d
634 select a,b from t1;
635 a b
636 0 a
637 1 b
638 2 c
639 3 d
640 4 e
641 5 f
642 6 g
643 7 h
644 8 i
645 9 j
646 9 k
647 handler a1 read a prev;
648 a b
649 2 c
650 handler a1 read a prev;
651 a b
652 1 b
653 handler a1 read a=(6) where b="g";
654 a b
655 6 g
656 handler a1 close;
657 select a,b from t1;
658 a b
659 0 a
660 1 b
661 2 c
662 3 d
663 4 e
664 5 f
665 6 g
666 7 h
667 8 i
668 9 j
669 9 k
670 handler t1 open as a2;
671 handler a2 read b=(9);
672 a b
673 9 j
674 handler a2 read b next;
675 a b
676 9 k
677 handler a2 read b prev limit 2;
678 a b
679 9 j
680 8 i
681 handler a2 read b last;
682 a b
683 9 k
684 handler a2 read b prev;
685 a b
686 9 j
687 handler a2 close;
688 drop table t1;
689 create table t1 (a int);
690 create temporary table t2 (a int, key using btree (a));
691 handler t1 open as a1;
692 handler t2 open as a2;
693 handler a2 read a first;
694 a
695 drop table t1, t2;
696 handler a2 read a next;
697 ERROR 42S02: Unknown table 'a2' in HANDLER
698 handler a1 close;
699 ERROR 42S02: Unknown table 'a1' in HANDLER
700 create table t1 (a int, key using btree (a));
701 create table t2 like t1;
702 handler t1 open as a1;
703 handler t2 open as a2;
704 handler a1 read a first;
705 a
706 handler a2 read a first;
707 a
708 alter table t1 add b int;
709 handler a1 close;
710 ERROR 42S02: Unknown table 'a1' in HANDLER
711 handler a2 close;
712 drop table t1, t2;
713 create table t1 (a int, key using btree (a));
714 handler t1 open as a1;
715 handler a1 read a first;
716 a
717 rename table t1 to t2;
718 handler a1 read a first;
719 ERROR 42S02: Unknown table 'a1' in HANDLER
720 drop table t2;
721 create table t1 (a int, key using btree (a));
722 create table t2 like t1;
723 handler t1 open as a1;
724 handler t2 open as a2;
725 handler a1 read a first;
726 a
727 handler a2 read a first;
728 a
729 optimize table t1;
730 Table Op Msg_type Msg_text
731 test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
732 test.t1 optimize status OK
733 handler a1 close;
734 ERROR 42S02: Unknown table 'a1' in HANDLER
735 handler a2 close;
736 drop table t1, t2;
737 #
738 # Add test coverage for HANDLER and LOCK TABLES, HANDLER and DDL.
739 #
740 drop table if exists t1, t2, t3;
741 create table t1 (a int, key a (a));
742 insert into t1 (a) values (1), (2), (3), (4), (5);
743 create table t2 (a int, key a (a)) select * from t1;
744 create temporary table t3 (a int, key a (a)) select * from t2;
745 handler t1 open;
746 handler t2 open;
747 handler t3 open;
748 #
749 # No HANDLER sql is allowed under LOCK TABLES.
750 # But it does not implicitly closes all handlers.
751 #
752 lock table t1 read;
753 handler t1 open;
754 ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
755 handler t1 read next;
756 ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
757 handler t2 close;
758 ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
759 handler t3 open;
760 ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
761 # After UNLOCK TABLES handlers should be around and
762 # we should be able to continue reading through them.
763 unlock tables;
764 handler t1 read next;
765 a
766 1
767 handler t1 close;
768 handler t2 read next;
769 a
770 1
771 handler t2 close;
772 handler t3 read next;
773 a
774 1
775 handler t3 close;
776 drop temporary table t3;
777 #
778 # Other operations that implicitly close handler:
779 #
780 # TRUNCATE
781 #
782 handler t1 open;
783 truncate table t1;
784 handler t1 read next;
785 ERROR 42S02: Unknown table 't1' in HANDLER
786 handler t1 open;
787 #
788 # CREATE TRIGGER
789 #
790 create trigger t1_ai after insert on t1 for each row set @a=1;
791 handler t1 read next;
792 ERROR 42S02: Unknown table 't1' in HANDLER
793 #
794 # DROP TRIGGER
795 #
796 handler t1 open;
797 drop trigger t1_ai;
798 handler t1 read next;
799 ERROR 42S02: Unknown table 't1' in HANDLER
800 #
801 # ALTER TABLE
802 #
803 handler t1 open;
804 alter table t1 add column b int;
805 handler t1 read next;
806 ERROR 42S02: Unknown table 't1' in HANDLER
807 #
808 # ANALYZE TABLE
809 #
810 handler t1 open;
811 analyze table t1;
812 Table Op Msg_type Msg_text
813 test.t1 analyze status Engine-independent statistics collected
814 test.t1 analyze status OK
815 handler t1 read next;
816 ERROR 42S02: Unknown table 't1' in HANDLER
817 #
818 # OPTIMIZE TABLE
819 #
820 handler t1 open;
821 optimize table t1;
822 Table Op Msg_type Msg_text
823 test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
824 test.t1 optimize status OK
825 handler t1 read next;
826 ERROR 42S02: Unknown table 't1' in HANDLER
827 #
828 # REPAIR TABLE
829 #
830 handler t1 open;
831 repair table t1;
832 Table Op Msg_type Msg_text
833 test.t1 repair status OK
834 handler t1 read next;
835 ERROR 42S02: Unknown table 't1' in HANDLER
836 #
837 # DROP TABLE, naturally.
838 #
839 handler t1 open;
840 drop table t1;
841 handler t1 read next;
842 ERROR 42S02: Unknown table 't1' in HANDLER
843 create table t1 (a int, b int, key a using btree (a)) select a from t2;
844 #
845 # RENAME TABLE, naturally
846 #
847 handler t1 open;
848 rename table t1 to t3;
849 handler t1 read next;
850 ERROR 42S02: Unknown table 't1' in HANDLER
851 #
852 # CREATE TABLE (even with IF NOT EXISTS clause,
853 # and the table exists).
854 #
855 handler t2 open;
856 create table if not exists t2 (a int);
857 Warnings:
858 Note 1050 Table 't2' already exists
859 handler t2 read next;
860 ERROR 42S02: Unknown table 't2' in HANDLER
861 rename table t3 to t1;
862 drop table t2;
863 #
864 # FLUSH TABLE doesn't close the table but loses the position
865 #
866 handler t1 open;
867 handler t1 read a prev;
868 b a
869 NULL 5
870 flush table t1;
871 handler t1 read a prev;
872 b a
873 NULL 5
874 handler t1 close;
875 #
876 # FLUSH TABLES WITH READ LOCK behaves like FLUSH TABLE.
877 #
878 handler t1 open;
879 handler t1 read a prev;
880 b a
881 NULL 5
882 flush tables with read lock;
883 handler t1 read a prev;
884 b a
885 NULL 5
886 handler t1 close;
887 unlock tables;
888 #
889 # Let us also check that these operations behave in similar
890 # way under LOCK TABLES.
891 #
892 # TRUNCATE under LOCK TABLES.
893 #
894 handler t1 open;
895 lock tables t1 write;
896 truncate table t1;
897 unlock tables;
898 handler t1 read next;
899 ERROR 42S02: Unknown table 't1' in HANDLER
900 handler t1 open;
901 #
902 # CREATE TRIGGER under LOCK TABLES.
903 #
904 lock tables t1 write;
905 create trigger t1_ai after insert on t1 for each row set @a=1;
906 unlock tables;
907 handler t1 read next;
908 ERROR 42S02: Unknown table 't1' in HANDLER
909 #
910 # DROP TRIGGER under LOCK TABLES.
911 #
912 handler t1 open;
913 lock tables t1 write;
914 drop trigger t1_ai;
915 unlock tables;
916 handler t1 read next;
917 ERROR 42S02: Unknown table 't1' in HANDLER
918 #
919 # ALTER TABLE under LOCK TABLES.
920 #
921 handler t1 open;
922 lock tables t1 write;
923 alter table t1 drop column b;
924 unlock tables;
925 handler t1 read next;
926 ERROR 42S02: Unknown table 't1' in HANDLER
927 #
928 # ANALYZE TABLE under LOCK TABLES.
929 #
930 handler t1 open;
931 lock tables t1 write;
932 analyze table t1;
933 Table Op Msg_type Msg_text
934 test.t1 analyze status Engine-independent statistics collected
935 test.t1 analyze status OK
936 unlock tables;
937 handler t1 read next;
938 ERROR 42S02: Unknown table 't1' in HANDLER
939 #
940 # OPTIMIZE TABLE under LOCK TABLES.
941 #
942 handler t1 open;
943 lock tables t1 write;
944 optimize table t1;
945 Table Op Msg_type Msg_text
946 test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
947 test.t1 optimize status OK
948 unlock tables;
949 handler t1 read next;
950 ERROR 42S02: Unknown table 't1' in HANDLER
951 #
952 # REPAIR TABLE under LOCK TABLES.
953 #
954 handler t1 open;
955 lock tables t1 write;
956 repair table t1;
957 Table Op Msg_type Msg_text
958 test.t1 repair status OK
959 unlock tables;
960 handler t1 read next;
961 ERROR 42S02: Unknown table 't1' in HANDLER
962 #
963 # DROP TABLE under LOCK TABLES, naturally.
964 #
965 handler t1 open;
966 lock tables t1 write;
967 drop table t1;
968 unlock tables;
969 handler t1 read next;
970 ERROR 42S02: Unknown table 't1' in HANDLER
971 create table t1 (a int, b int, key a using btree (a));
972 insert into t1 (a) values (1), (2), (3), (4), (5);
973 #
974 # FLUSH TABLE doesn't close the table but loses the position
975 #
976 handler t1 open;
977 handler t1 read a prev;
978 a b
979 5 NULL
980 lock tables t1 write;
981 flush table t1;
982 unlock tables;
983 handler t1 read a prev;
984 a b
985 5 NULL
986 handler t1 close;
987 #
988 # Explore the effect of HANDLER locks on concurrent DDL
989 #
990 handler t1 open;
991 connect con1, localhost, root,,;
992 connect con2, localhost, root,,;
993 connect con3, localhost, root,,;
994 connection con1;
995 # Sending:
996 drop table t1 ;
997 # We can't use connection 'default' as wait_condition will
998 # autoclose handlers.
999 connection con2;
1000 # Waitng for 'drop table t1' to get blocked...
1001 connection default;
1002 handler t1 read a prev;
1003 a b
1004 5 NULL
1005 handler t1 read a prev;
1006 a b
1007 4 NULL
1008 handler t1 close;
1009 connection con1;
1010 # Reaping 'drop table t1'...
1011 connection default;
1012 #
1013 # Explore the effect of HANDLER locks in parallel with SELECT
1014 #
1015 create table t1 (a int, key a using btree (a));
1016 insert into t1 (a) values (1), (2), (3), (4), (5);
1017 begin;
1018 select * from t1;
1019 a
1020 1
1021 2
1022 3
1023 4
1024 5
1025 handler t1 open;
1026 handler t1 read a prev;
1027 a
1028 5
1029 handler t1 read a prev;
1030 a
1031 4
1032 handler t1 close;
1033 connection con1;
1034 # Sending:
1035 drop table t1 ;
1036 connection con2;
1037 # Waiting for 'drop table t1' to get blocked...
1038 connection default;
1039 # We can still use the table, it's part of the transaction
1040 select * from t1;
1041 a
1042 1
1043 2
1044 3
1045 4
1046 5
1047 # Such are the circumstances that t1 is a part of transaction,
1048 # thus we can reopen it in the handler
1049 handler t1 open;
1050 # We can commit the transaction, it doesn't close the handler
1051 # and doesn't let DROP to proceed.
1052 commit;
1053 handler t1 read a prev;
1054 a
1055 5
1056 handler t1 read a prev;
1057 a
1058 4
1059 handler t1 read a prev;
1060 a
1061 3
1062 handler t1 close;
1063 connection con1;
1064 # Now drop can proceed
1065 # Reaping 'drop table t1'...
1066 connection default;
1067 #
1068 # Demonstrate that HANDLER locks and transaction locks
1069 # reside in the same context.
1070 #
1071 create table t1 (a int, key a (a));
1072 insert into t1 (a) values (1), (2), (3), (4), (5);
1073 create table t0 (a int, key a using btree (a));
1074 insert into t0 (a) values (1), (2), (3), (4), (5);
1075 begin;
1076 select * from t1;
1077 a
1078 1
1079 2
1080 3
1081 4
1082 5
1083 connection con2;
1084 # Sending:
1085 rename table t0 to t3, t1 to t0, t3 to t1;
1086 connection con1;
1087 # Waiting for 'rename table ...' to get blocked...
1088 connection default;
1089 # We back-off on hitting deadlock condition.
1090 handler t0 open;
1091 ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
1092 select * from t0;
1093 a
1094 1
1095 2
1096 3
1097 4
1098 5
1099 handler t1 open;
1100 commit;
1101 handler t1 close;
1102 connection con2;
1103 # Reaping 'rename table ...'...
1104 connection default;
1105 handler t1 open;
1106 handler t1 read a prev;
1107 a
1108 5
1109 handler t1 close;
1110 drop table t0;
1111 #
1112 # Originally there was a deadlock error in this test.
1113 # With implementation of deadlock detector
1114 # we no longer deadlock, but block and wait on a lock.
1115 # The HANDLER is auto-closed as soon as the connection
1116 # sees a pending conflicting lock against it.
1117 #
1118 create table t2 (a int, key a (a));
1119 handler t1 open;
1120 connection con1;
1121 lock tables t2 read;
1122 connection con2;
1123 # Sending 'drop table t2'...
1124 drop table t2;
1125 connection con1;
1126 # Waiting for 'drop table t2' to get blocked...
1127 connection default;
1128 # Sending 'select * from t2'
1129 select * from t2;
1130 connection con1;
1131 # Waiting for 'select * from t2' to get blocked...
1132 unlock tables;
1133 connection con2;
1134 # Reaping 'drop table t2'...
1135 connection default;
1136 # Reaping 'select * from t2'
1137 ERROR 42S02: Table 'test.t2' doesn't exist
1138 handler t1 close;
1139 drop table t1;
1140 #
1141 # If we have to wait on an exclusive locks while having
1142 # an open HANDLER, ER_LOCK_DEADLOCK is reported.
1143 #
1144 create table t1 (a int, key a(a));
1145 handler t1 open;
1146 connection con1;
1147 select get_lock('lock1', 10);
1148 get_lock('lock1', 10)
1149 1
1150 connection default;
1151 select get_lock('lock1', 10);
1152 connection con2;
1153 # Waiting for 'select get_lock('lock1', 10)' to get blocked...
1154 connection con1;
1155 drop table t1;
1156 ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
1157 select release_lock('lock1');
1158 release_lock('lock1')
1159 1
1160 connection default;
1161 get_lock('lock1', 10)
1162 1
1163 select release_lock('lock1');
1164 release_lock('lock1')
1165 1
1166 # Demonstrate that there is no deadlock with FLUSH TABLE,
1167 # even though it is waiting for the other table to go away
1168 create table t2 like t1;
1169 # Sending:
1170 flush table t2;
1171 connection con2;
1172 drop table t1;
1173 connection con1;
1174 unlock tables;
1175 connection default;
1176 # Reaping 'flush table t2'...
1177 drop table t2;
1178 #
1179 # Bug #46224 HANDLER statements within a transaction might
1180 # lead to deadlocks
1181 #
1182 create table t1 (a int, key using btree (a));
1183 insert into t1 values (1), (2);
1184 connection default;
1185 begin;
1186 select * from t1;
1187 a
1188 1
1189 2
1190 handler t1 open;
1191 connection con1;
1192 # Sending:
1193 lock tables t1 write;
1194 connection con2;
1195 # Check that 'lock tables t1 write' waits until transaction which
1196 # has read from the table commits.
1197 connection default;
1198 # The below 'handler t1 read ...' should not be blocked as
1199 # 'lock tables t1 write' has not succeeded yet.
1200 handler t1 read a next;
1201 a
1202 1
1203 # Unblock 'lock tables t1 write'.
1204 select * from t1;
1205 a
1206 1
1207 2
1208 commit;
1209 connection con1;
1210 # Reap 'lock tables t1 write'.
1211 connection default;
1212 # Sending:
1213 handler t1 read a next;
1214 connection con1;
1215 # Waiting for 'handler t1 read a next' to get blocked...
1216 # The below 'drop table t1' should be able to proceed without
1217 # waiting as it will force HANDLER to be closed.
1218 drop table t1;
1219 unlock tables;
1220 connection default;
1221 # Reaping 'handler t1 read a next'...
1222 ERROR 42S02: Table 'test.t1' doesn't exist
1223 handler t1 close;
1224 connection con1;
1225 disconnect con1;
1226 connection con2;
1227 disconnect con2;
1228 connection con3;
1229 disconnect con3;
1230 connection default;
1231 #
1232 # A temporary table test.
1233 # Check that we don't loose positions of HANDLER opened
1234 # against a temporary table.
1235 #
1236 create table t1 (a int, b int, key using btree (a));
1237 insert into t1 (a) values (1), (2), (3), (4), (5);
1238 create temporary table t2 (a int, b int, key using btree (a));
1239 insert into t2 (a) select a from t1;
1240 handler t1 open;
1241 handler t1 read a next;
1242 a b
1243 1 NULL
1244 handler t2 open;
1245 handler t2 read a next;
1246 a b
1247 1 NULL
1248 flush table t1;
1249 handler t2 read a next;
1250 a b
1251 2 NULL
1252 # Sic: the position is lost
1253 handler t1 read a next;
1254 a b
1255 1 NULL
1256 select * from t1;
1257 a b
1258 1 NULL
1259 2 NULL
1260 3 NULL
1261 4 NULL
1262 5 NULL
1263 # Sic: the position is not lost
1264 handler t2 read a next;
1265 a b
1266 3 NULL
1267 select * from t2;
1268 a b
1269 1 NULL
1270 2 NULL
1271 3 NULL
1272 4 NULL
1273 5 NULL
1274 handler t2 read a next;
1275 a b
1276 4 NULL
1277 drop table t1;
1278 drop temporary table t2;
1279 #
1280 # A test for lock_table_names()/unlock_table_names() function.
1281 # It should work properly in presence of open HANDLER.
1282 #
1283 create table t1 (a int, b int, key a (a));
1284 create table t2 like t1;
1285 create table t3 like t1;
1286 create table t4 like t1;
1287 handler t1 open;
1288 handler t2 open;
1289 rename table t4 to t5, t3 to t4, t5 to t3;
1290 handler t1 read first;
1291 a b
1292 handler t2 read first;
1293 a b
1294 drop table t1, t2, t3, t4;
1295 #
1296 # A test for FLUSH TABLES WITH READ LOCK and HANDLER statements.
1297 #
1298 set autocommit=0;
1299 create table t1 (a int, b int, key a (a));
1300 insert into t1 (a, b) values (1, 1), (2, 1), (3, 2), (4, 2), (5, 5);
1301 create table t2 like t1;
1302 insert into t2 (a, b) select a, b from t1;
1303 create table t3 like t1;
1304 insert into t3 (a, b) select a, b from t1;
1305 commit;
1306 flush tables with read lock;
1307 handler t1 open;
1308 lock table t1 read;
1309 handler t1 read next;
1310 ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
1311 # This implicitly leaves LOCK TABLES but doesn't drop the GLR
1312 lock table not_exists_write read;
1313 ERROR 42S02: Table 'test.not_exists_write' doesn't exist
1314 # We still have the read lock.
1315 drop table t1;
1316 ERROR HY000: Can't execute the query because you have a conflicting read lock
1317 handler t1 open;
1318 select a from t2;
1319 a
1320 1
1321 2
1322 3
1323 4
1324 5
1325 handler t1 read next;
1326 a b
1327 1 1
1328 flush tables with read lock;
1329 handler t2 open;
1330 flush tables with read lock;
1331 handler t1 read next;
1332 a b
1333 2 1
1334 select a from t3;
1335 a
1336 1
1337 2
1338 3
1339 4
1340 5
1341 handler t2 read next;
1342 a b
1343 1 1
1344 handler t1 close;
1345 rollback;
1346 handler t2 close;
1347 drop table t1;
1348 ERROR HY000: Can't execute the query because you have a conflicting read lock
1349 commit;
1350 flush tables;
1351 drop table t1;
1352 ERROR HY000: Can't execute the query because you have a conflicting read lock
1353 unlock tables;
1354 drop table t1;
1355 set autocommit=default;
1356 drop table t2, t3;
1357 #
1358 # HANDLER statement and operation-type aware metadata locks.
1359 # Check that when we clone a ticket for HANDLER we downrade
1360 # the lock.
1361 #
1362 connect con1,localhost,root,,;
1363 connection default;
1364 create table t1 (a int, b int, key using btree (a));
1365 insert into t1 (a, b) values (1, 1), (2, 1), (3, 2), (4, 2), (5, 5);
1366 begin;
1367 insert into t1 (a, b) values (6, 6);
1368 handler t1 open;
1369 handler t1 read a last;
1370 a b
1371 6 6
1372 insert into t1 (a, b) values (7, 7);
1373 handler t1 read a last;
1374 a b
1375 7 7
1376 commit;
1377 connection default;
1378 handler t1 read a prev;
1379 a b
1380 6 6
1381 handler t1 close;
1382 # Cleanup.
1383 drop table t1;
1384 connection con1;
1385 disconnect con1;
1386 connection default;
1387 #
1388 # A test for Bug#50555 "handler commands crash server in
1389 # my_hash_first()".
1390 #
1391 handler no_such_table read no_such_index first;
1392 ERROR 42S02: Unknown table 'no_such_table' in HANDLER
1393 handler no_such_table close;
1394 ERROR 42S02: Unknown table 'no_such_table' in HANDLER
1395 #
1396 # Bug#50907 Assertion `hash_tables->table->next == __null' on
1397 # HANDLER OPEN
1398 #
1399 DROP TABLE IF EXISTS t1, t2;
1400 CREATE TEMPORARY TABLE t1 (i INT);
1401 CREATE TEMPORARY TABLE t2 (i INT);
1402 HANDLER t2 OPEN;
1403 HANDLER t2 READ FIRST;
1404 i
1405 HANDLER t2 CLOSE;
1406 DROP TABLE t1, t2;
1407 #
1408 # Bug#50912 Assertion `ticket->m_type >= mdl_request->type'
1409 # failed on HANDLER + I_S
1410 #
1411 DROP TABLE IF EXISTS t1;
1412 CREATE TABLE t1 (id INT);
1413 HANDLER t1 OPEN;
1414 SELECT table_name, table_comment FROM information_schema.tables
1415 WHERE table_schema= 'test' AND table_name= 't1';
1416 table_name table_comment
1417 t1
1418 HANDLER t1 CLOSE;
1419 DROP TABLE t1;
1420 #
1421 # Test for bug #50908 "Assertion `handler_tables_hash.records == 0'
1422 # failed in enter_locked_tables_mode".
1423 #
1424 drop tables if exists t1, t2;
1425 drop function if exists f1;
1426 create table t1 (i int);
1427 insert into t1 values (1), (2);
1428 create table t2 (j int);
1429 insert into t2 values (1);
1430 create function f1() returns int return (select count(*) from t2);
1431 # Check that open HANDLER survives statement executed in
1432 # prelocked mode.
1433 handler t1 open;
1434 handler t1 read next;
1435 i
1436 1
1437 # The below statement were aborted due to an assertion failure.
1438 select f1() from t2;
1439 f1()
1440 1
1441 handler t1 read next;
1442 i
1443 2
1444 handler t1 close;
1445 # Check that the same happens under GLOBAL READ LOCK.
1446 flush tables with read lock;
1447 handler t1 open;
1448 handler t1 read next;
1449 i
1450 1
1451 select f1() from t2;
1452 f1()
1453 1
1454 handler t1 read next;
1455 i
1456 2
1457 unlock tables;
1458 handler t1 close;
1459 # Now, check that the same happens if LOCK TABLES is executed.
1460 handler t1 open;
1461 handler t1 read next;
1462 i
1463 1
1464 lock table t2 read;
1465 select * from t2;
1466 j
1467 1
1468 unlock tables;
1469 handler t1 read next;
1470 i
1471 2
1472 handler t1 close;
1473 # Finally, check scenario with GRL and LOCK TABLES.
1474 flush tables with read lock;
1475 handler t1 open;
1476 handler t1 read next;
1477 i
1478 1
1479 lock table t2 read;
1480 select * from t2;
1481 j
1482 1
1483 # This unlocks both tables and GRL.
1484 unlock tables;
1485 handler t1 read next;
1486 i
1487 2
1488 handler t1 close;
1489 # Clean-up.
1490 drop function f1;
1491 drop tables t1, t2;
1492 #
1493 # Test for bug #51136 "Crash in pthread_rwlock_rdlock on TEMPORARY +
1494 # HANDLER + LOCK + SP".
1495 # Also see additional coverage for this bug in flush.test.
1496 #
1497 drop tables if exists t1, t2;
1498 create table t1 (i int);
1499 create temporary table t2 (j int);
1500 handler t1 open;
1501 lock table t2 read;
1502 # This commit should not release any MDL locks.
1503 commit;
1504 unlock tables;
1505 # The below statement crashed before the bug fix as it
1506 # has attempted to release metadata lock which was
1507 # already released by commit.
1508 handler t1 close;
1509 drop tables t1, t2;
1510 #
1511 # Bug#51355 handler stmt cause assertion in
1512 # bool MDL_context::try_acquire_lock(MDL_request*)
1513 #
1514 DROP TABLE IF EXISTS t1;
1515 connect con51355, localhost, root;
1516 connection default;
1517 CREATE TABLE t1(id INT, KEY id(id));
1518 HANDLER t1 OPEN;
1519 connection con51355;
1520 # Sending:
1521 DROP TABLE t1;
1522 connection default;
1523 # This I_S query will cause the handler table to be closed and
1524 # the metadata lock to be released. This will allow DROP TABLE
1525 # to proceed. Waiting for the table to be removed.
1526 connection con51355;
1527 # Reaping: DROP TABLE t1
1528 connection default;
1529 HANDLER t1 READ id NEXT;
1530 ERROR 42S02: Table 'test.t1' doesn't exist
1531 HANDLER t1 READ id NEXT;
1532 ERROR 42S02: Table 'test.t1' doesn't exist
1533 HANDLER t1 CLOSE;
1534 connection con51355;
1535 disconnect con51355;
1536 connection default;
1537 #
1538 # Bug#54401 assert in Diagnostics_area::set_eof_status , HANDLER
1539 #
1540 DROP TABLE IF EXISTS t1, t2;
1541 DROP FUNCTION IF EXISTS f1;
1542 CREATE FUNCTION f1() RETURNS INTEGER
1543 BEGIN
1544 SELECT 1 FROM t2 INTO @a;
1545 RETURN 1;
1546 END|
1547 SELECT f1();
1548 ERROR 42S02: Table 'test.t2' doesn't exist
1549 CREATE TABLE t1(a INT);
1550 INSERT INTO t1 VALUES (1);
1551 HANDLER t1 OPEN;
1552 HANDLER t1 READ FIRST WHERE f1() = 1;
1553 ERROR 42000: This version of MariaDB doesn't yet support 'stored functions in HANDLER ... READ'
1554 HANDLER t1 CLOSE;
1555 DROP FUNCTION f1;
1556 DROP TABLE t1;
1557 #
1558 # Bug#54920 Stored functions are allowed in HANDLER statements,
1559 # but broken.
1560 #
1561 DROP TABLE IF EXISTS t1;
1562 DROP FUNCTION IF EXISTS f1;
1563 CREATE TABLE t1 (a INT);
1564 INSERT INTO t1 VALUES (1), (2);
1565 CREATE FUNCTION f1() RETURNS INT RETURN 1;
1566 HANDLER t1 OPEN;
1567 HANDLER t1 READ FIRST WHERE f1() = 1;
1568 ERROR 42000: This version of MariaDB doesn't yet support 'stored functions in HANDLER ... READ'
1569 HANDLER t1 CLOSE;
1570 DROP FUNCTION f1;
1571 DROP TABLE t1;
1572 #
1573 # BUG#51877 - HANDLER interface causes invalid memory read
1574 #
1575 CREATE TABLE t1(a INT, KEY using btree (a));
1576 HANDLER t1 OPEN;
1577 HANDLER t1 READ a FIRST;
1578 a
1579 INSERT INTO t1 VALUES(1);
1580 HANDLER t1 READ a NEXT;
1581 a
1582 HANDLER t1 CLOSE;
1583 DROP TABLE t1;
1584 #
1585 # Testing savepoints with handlers that supports it
1586 #
1587 connect con1, localhost, root,,;
1588 connect con2, localhost, root,,;
1589 connect con3, localhost, root,,;
1590 connection default;
1591 #
1592 # ROLLBACK TO SAVEPOINT releases transactional locks,
1593 # but has no effect on open HANDLERs
1594 #
1595 create table t1 (a int, key a (a));
1596 insert into t1 (a) values (1), (2), (3), (4), (5);
1597 create table t2 like t1;
1598 create table t3 like t1;
1599 begin;
1600 # Have something before the savepoint
1601 select * from t3;
1602 a
1603 savepoint sv;
1604 handler t1 open;
1605 handler t1 read a first;
1606 a
1607 1
1608 handler t1 read a next;
1609 a
1610 2
1611 select * from t2;
1612 a
1613 connection con1;
1614 # Sending:
1615 drop table t1;
1616 connection con2;
1617 # Sending:
1618 drop table t2;
1619 connection default;
1620 # Let DROP TABLE statements sync in. We must use
1621 # a separate connection for that, because otherwise SELECT
1622 # will auto-close the HANDLERs, becaues there are pending
1623 # exclusive locks against them.
1624 connection con3;
1625 # Waiting for 'drop table t1' to get blocked...
1626 # Waiting for 'drop table t2' to get blocked...
1627 # Demonstrate that t2 lock was released and t2 was dropped
1628 # after ROLLBACK TO SAVEPOINT
1629 connection default;
1630 rollback to savepoint sv;
1631 connection con2;
1632 # Reaping 'drop table t2'...
1633 # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler
1634 # lock.
1635 connection default;
1636 handler t1 read a next;
1637 a
1638 3
1639 handler t1 read a next;
1640 a
1641 4
1642 # Demonstrate that the drop will go through as soon as we close the
1643 # HANDLER
1644 handler t1 close;
1645 connection con1;
1646 # Reaping 'drop table t1'...
1647 connection default;
1648 commit;
1649 drop table t3;
1650 #
1651 # A few special cases when using SAVEPOINT/ROLLBACK TO
1652 # SAVEPOINT and HANDLER.
1653 #
1654 # Show that rollback to the savepoint taken in the beginning
1655 # of the transaction doesn't release mdl lock on
1656 # the HANDLER that was opened later.
1657 #
1658 create table t1 (a int, key using btree (a));
1659 insert into t1 (a) values (1), (2), (3), (4), (5);
1660 create table t2 like t1;
1661 begin;
1662 savepoint sv;
1663 handler t1 open;
1664 handler t1 read a first;
1665 a
1666 1
1667 handler t1 read a next;
1668 a
1669 2
1670 select * from t2;
1671 a
1672 connection con1;
1673 # Sending:
1674 drop table t1;
1675 connection con2;
1676 # Sending:
1677 drop table t2;
1678 connection default;
1679 # Let DROP TABLE statements sync in. We must use
1680 # a separate connection for that, because otherwise SELECT
1681 # will auto-close the HANDLERs, becaues there are pending
1682 # exclusive locks against them.
1683 connection con3;
1684 # Waiting for 'drop table t1' to get blocked...
1685 # Waiting for 'drop table t2' to get blocked...
1686 # Demonstrate that t2 lock was released and t2 was dropped
1687 # after ROLLBACK TO SAVEPOINT
1688 connection default;
1689 rollback to savepoint sv;
1690 connection con2;
1691 # Reaping 'drop table t2'...
1692 # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler
1693 # lock.
1694 connection default;
1695 handler t1 read a next;
1696 a
1697 3
1698 handler t1 read a next;
1699 a
1700 4
1701 # Demonstrate that the drop will go through as soon as we close the
1702 # HANDLER
1703 handler t1 close;
1704 connection con1;
1705 # Reaping 'drop table t1'...
1706 connection default;
1707 commit;
1708 #
1709 # Show that rollback to the savepoint taken in the beginning
1710 # of the transaction works properly (no valgrind warnins, etc),
1711 # even though it's done after the HANDLER mdl lock that was there
1712 # at the beginning is released and added again.
1713 #
1714 create table t1 (a int, key using btree (a));
1715 insert into t1 (a) values (1), (2), (3), (4), (5);
1716 create table t2 like t1;
1717 create table t3 like t1;
1718 insert into t3 (a) select a from t1;
1719 begin;
1720 handler t1 open;
1721 savepoint sv;
1722 handler t1 read a first;
1723 a
1724 1
1725 select * from t2;
1726 a
1727 handler t1 close;
1728 handler t3 open;
1729 handler t3 read a first;
1730 a
1731 1
1732 rollback to savepoint sv;
1733 connection con1;
1734 drop table t1, t2;
1735 # Sending:
1736 drop table t3;
1737 # Let DROP TABLE statement sync in.
1738 connection con2;
1739 # Waiting for 'drop table t3' to get blocked...
1740 # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler
1741 # lock.
1742 connection default;
1743 handler t3 read a next;
1744 a
1745 2
1746 # Demonstrate that the drop will go through as soon as we close the
1747 # HANDLER
1748 handler t3 close;
1749 connection con1;
1750 # Reaping 'drop table t3'...
1751 connection default;
1752 commit;
1753 #
1754 # Cleanup for savepoint.inc
1755 #
1756 connection con1;
1757 disconnect con1;
1758 connection con2;
1759 disconnect con2;
1760 connection con3;
1761 disconnect con3;
1762 connection default;
1763 CREATE TABLE t1 (f1 integer, f2 integer, primary key (f1), key (f2)) engine=innodb;
1764 INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
1765 HANDLER t1 OPEN;
1766 HANDLER t1 READ FIRST WHERE f2 <= 1;
1767 f1 f2
1768 1 1
1769 HANDLER t1 READ `PRIMARY` PREV;
1770 f1 f2
1771 3 3
1772 DROP TABLE t1;
1773 #
1774 # 10.2 Test
1775 #
1776 # MDEV-20207: Assertion `! is_set()' failed in
1777 # Diagnostics_area::set_eof_status upon HANDLER READ
1778 #
1779 DROP TABLE IF EXISTS t1;
1780 Warnings:
1781 Note 1051 Unknown table 'test.t1'
1782 CREATE TABLE t1 (a POINT, KEY(a));
1783 HANDLER t1 OPEN h;
1784 HANDLER h READ a = (0);
1785 ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
1786 HANDLER h CLOSE;
1787 DROP TABLE t1;
1788 # End of 10.2 Test