Last active
May 12, 2016 22:02
-
-
Save nirbhayc/2be49d74f5bece54fd4181c1349f0b7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Case 1: | |
drop table if exists t1; | |
delimiter | | |
create function f1() returns int | |
begin | |
drop temporary table t1; | |
return 1; | |
end| | |
delimiter ; | |
create temporary table t1 as select f1(); | |
# Case 2: | |
drop table if exists t1; | |
delimiter | | |
create function f1() returns int | |
begin | |
create temporary table t1(i int); | |
return 1; | |
end| | |
delimiter ; | |
create temporary table t1 as select f1(); | |
# Case 3: | |
create temporary table t1 as select 1 as a; | |
delimiter |; | |
create procedure p1() | |
begin | |
drop temporary table t1; | |
end| | |
create function f1() returns int | |
begin | |
call p1(); | |
return 1; | |
end| | |
delimiter ;| | |
--error ER_NO_SUCH_TABLE (??) | |
prepare stmt from "select f1() as my_column, a from t1"; | |
# Case 4: | |
create temporary table t1 (i int); | |
delimiter | | |
create function f1() returns int | |
begin | |
drop temporary table t1; | |
return 1; | |
end| | |
delimiter ; | |
select f1() from t1; | |
# Case 5: | |
create temporary table t1 as select 1 as a; | |
delimiter | | |
create procedure p1() | |
begin | |
drop temporary table t1; | |
end| | |
create function f1() returns int | |
begin | |
call p1(); | |
return 1; | |
end| | |
delimiter ; | |
select f1() as my_column, a from t1; | |
# Case 6: | |
create temporary table t1 (i int); | |
--error ER_TRG_ON_VIEW_OR_TEMP_TABLE | |
create trigger trg before insert on t1 for each row set @a:=1; | |
drop table t1; | |
# Case 7: | |
# With temp tables updates should be accepted: | |
create temporary table t3 (a int); | |
create temporary table t4 (a int) select * from t3; | |
insert into t3 values(1); | |
insert into t4 select * from t3; | |
# Case 8 (CTAS) | |
create table t1(i int); | |
insert into t1 values(1), (2); | |
create temporary table t1 as select * from t1 as temp_1, t2 as temp_2; | |
select * from t1; | |
drop table t1; | |
select * from t1; | |
drop table t1; | |
# Case 9 (HANDER): | |
create table t1 (a int, key a (a)); | |
insert into t1 (a) values (1), (2), (3), (4), (5); | |
create table t2 (a int, key a (a)) select * from t1; | |
create temporary table t3 (a int, key a (a)) select * from t2; | |
handler t3 open; | |
select * from t1; | |
lock table t1 read; | |
handler t3 open; | |
unlock tables; | |
handler t3 read next; | |
handler t3 open; | |
handler t3 open as t3_1; | |
handler t3 open as t3_2; | |
handler t3 close; | |
handler t3_1 close; | |
handker t3_2 close; | |
drop temporary table t3; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment