Commit 4227dd2a authored by Sergei Golubchik's avatar Sergei Golubchik

continue DROP TEMPORARY TABLE t1, t2, t3 after error.

normal DROP TABLE with many tables continues after an error,
trying to drop as many tables as possible. But DROP TEMPORARY TABLE
was aborting on the first error. Change it to behave as DROP TABLE does.
parent 6c529316
drop table if exists t1,t2;
drop view if exists v1;
# #
# test basic creation of temporary tables together with normal table # test basic creation of temporary tables together with normal table
# #
...@@ -602,3 +600,22 @@ DROP TEMPORARY TABLE t1; ...@@ -602,3 +600,22 @@ DROP TEMPORARY TABLE t1;
# #
# End of 10.2 tests # End of 10.2 tests
# #
create function f1() returns int
begin
drop temporary table t1, t2;
return 1;
end;
$$
create temporary table t1 (a int);
create temporary table t2 (a int);
insert t1 values (2);
insert t2 values (3);
select a,f1() from t1;
ERROR HY000: Can't reopen table: 't1'
drop function f1;
drop temporary table t1;
drop temporary table t2;
ERROR 42S02: Unknown table 'test.t2'
#
# End of 10.5 tests
#
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
# Test of temporary tables # Test of temporary tables
# #
--disable_warnings
drop table if exists t1,t2;
drop view if exists v1;
--enable_warnings
--echo # --echo #
--echo # test basic creation of temporary tables together with normal table --echo # test basic creation of temporary tables together with normal table
--echo # --echo #
...@@ -658,3 +653,31 @@ DROP TEMPORARY TABLE t1; ...@@ -658,3 +653,31 @@ DROP TEMPORARY TABLE t1;
--echo # --echo #
--echo # End of 10.2 tests --echo # End of 10.2 tests
--echo # --echo #
#
# DROP TEMPORARY TABLE fails in the middle
#
delimiter $$;
create function f1() returns int
begin
drop temporary table t1, t2;
return 1;
end;
$$
delimiter ;$$
create temporary table t1 (a int);
create temporary table t2 (a int);
insert t1 values (2);
insert t2 values (3);
--error ER_CANT_REOPEN_TABLE
select a,f1() from t1;
drop function f1;
drop temporary table t1;
--error ER_BAD_TABLE_ERROR
drop temporary table t2;
--echo #
--echo # End of 10.5 tests
--echo #
...@@ -2338,17 +2338,12 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, ...@@ -2338,17 +2338,12 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
{ {
table_creation_was_logged= table->table->s->table_creation_was_logged; table_creation_was_logged= table->table->s->table_creation_was_logged;
if (thd->drop_temporary_table(table->table, &is_trans, true)) if (thd->drop_temporary_table(table->table, &is_trans, true))
{
/*
This is a very unlikely scenaro as dropping a temporary table
should always work. Would be better if we tried to drop all
temporary tables before giving the error.
*/
error= 1; error= 1;
goto err; else
{
table->table= 0;
temporary_table_was_dropped= 1;
} }
table->table= 0;
temporary_table_was_dropped= 1;
} }
if ((drop_temporary && if_exists) || temporary_table_was_dropped) if ((drop_temporary && if_exists) || temporary_table_was_dropped)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment