diff options
author | unknown <davi@endora.local> | 2007-11-20 15:17:53 -0200 |
---|---|---|
committer | unknown <davi@endora.local> | 2007-11-20 15:17:53 -0200 |
commit | 4d6543a6f08561fa6aa773d688e00c1766a80058 (patch) | |
tree | 54ea6067ff9eaa2f151e4ece310c166653d13957 /mysql-test/r/handler_innodb.result | |
parent | b3a71e34487b69846553111448fa2b32c86176a9 (diff) | |
download | mariadb-git-4d6543a6f08561fa6aa773d688e00c1766a80058.tar.gz |
Bug#31397 Inconsistent drop table behavior of handler tables.
The problem is that DROP TABLE and other DDL statements failed to
automatically close handlers associated with tables that were marked
for reopen (FLUSH TABLES).
The current implementation fails to properly discard handlers of
dropped tables (that were marked for reopen) because it searches
on the open handler tables list and using the current alias of the
table being dropped. The problem is that it must not use the open
handler tables list to search because the table might have been
closed (marked for reopen) by a flush tables command and also it
must not use the current table alias at all since multiple different
aliases may be associated with a single table. This is specially
visible when a user has two open handlers (using alias) of a same
table and a flush tables command is issued before the table is
dropped (see test case). Scanning the handler table list is also
useless for dropping handlers associated with temporary tables,
because temporary tables are not kept in the THD::handler_tables
list.
The solution is to simple scan the handlers hash table searching
for, and deleting all handlers with matching table names if the
reopen flag is not passed to the flush function, indicating that
the handlers should be deleted. All matching handlers are deleted
even if the associated the table is not open.
mysql-test/include/handler.inc:
Add test case for Bug#31397
mysql-test/r/handler_innodb.result:
Add test case result for Bug#31397
mysql-test/r/handler_myisam.result:
Add test case result for Bug#31397
sql/mysql_priv.h:
Rename flush functions to better match the intent of the caller and
update functions prototypes and remove unused flags.
sql/sql_base.cc:
Rename flush functions to better match the intent of the caller.
sql/sql_class.cc:
Rename the flush functions to better match the intent of the caller.
The hash_free function is moved to the cleanup.
sql/sql_handler.cc:
When dropping tables for a final close, scan the handler's hash table since
the table might not be in the handlers open table list because the table was
marked for reopen or because it's a temporary table.
sql/sql_rename.cc:
Drop handlers associated with tables that are being renamed.
sql/sql_table.cc:
Now that temporary tables are properly removed even when opened
by a SQL HANDLER, enable the assert since this branch can't be taken
outside of SF/trigger/prelocked mode.
Diffstat (limited to 'mysql-test/r/handler_innodb.result')
-rw-r--r-- | mysql-test/r/handler_innodb.result | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/mysql-test/r/handler_innodb.result b/mysql-test/r/handler_innodb.result index d9a1a0aa12b..9d269f78d10 100644 --- a/mysql-test/r/handler_innodb.result +++ b/mysql-test/r/handler_innodb.result @@ -637,3 +637,94 @@ a b 8 i handler a2 close; drop table t1; +drop table if exists t1,t2; +create table t1 (a int); +handler t1 open as t1_alias; +drop table t1; +create table t1 (a int); +handler t1 open as t1_alias; +flush tables; +drop table t1; +create table t1 (a int); +handler t1 open as t1_alias; +handler t1_alias close; +drop table t1; +create table t1 (a int); +handler t1 open as t1_alias; +handler t1_alias read first; +a +drop table t1; +handler t1_alias read next; +ERROR 42S02: Unknown table 't1_alias' in HANDLER +create table t1 (a int); +create temporary table t2 (a int, key(a)); +handler t1 open as a1; +handler t2 open as a2; +handler a2 read a first; +a +drop table t1, t2; +handler a2 read a next; +ERROR 42S02: Unknown table 'a2' in HANDLER +handler a1 close; +ERROR 42S02: Unknown table 'a1' in HANDLER +create table t1 (a int, key(a)); +create table t2 like t1; +handler t1 open as a1; +handler t2 open as a2; +handler a1 read a first; +a +handler a2 read a first; +a +alter table t1 add b int; +handler a1 close; +ERROR 42S02: Unknown table 'a1' in HANDLER +handler a2 close; +drop table t1, t2; +create table t1 (a int, key(a)); +handler t1 open as a1; +handler a1 read a first; +a +rename table t1 to t2; +handler a1 read a first; +ERROR 42S02: Unknown table 'a1' in HANDLER +drop table t2; +create table t1 (a int, key(a)); +create table t2 like t1; +handler t1 open as a1; +handler t2 open as a2; +handler a1 read a first; +a +handler a2 read a first; +a +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +handler a1 close; +ERROR 42S02: Unknown table 'a1' in HANDLER +handler a2 close; +drop table t1, t2; +create table t1 (a int, b char(1), key a(a), key b(a,b)); +insert into t1 values (0,"a"),(1,"b"),(2,"c"),(3,"d"),(4,"e"), +(5,"f"),(6,"g"),(7,"h"),(8,"i"),(9,"j"); +handler t1 open; +handler t1 read a first; +a b +0 a +handler t1 read a next; +a b +1 b +flush tables; +handler t1 read a next; +a b +0 a +handler t1 read a next; +a b +1 b +flush tables with read lock; +handler t1 read a next; +a b +0 a +unlock tables; +drop table t1; +handler t1 read a next; +ERROR 42S02: Unknown table 't1' in HANDLER |