summaryrefslogtreecommitdiff
path: root/sql/sql_rename.cc
diff options
context:
space:
mode:
authorunknown <davi@endora.local>2007-11-20 15:17:53 -0200
committerunknown <davi@endora.local>2007-11-20 15:17:53 -0200
commit4d6543a6f08561fa6aa773d688e00c1766a80058 (patch)
tree54ea6067ff9eaa2f151e4ece310c166653d13957 /sql/sql_rename.cc
parentb3a71e34487b69846553111448fa2b32c86176a9 (diff)
downloadmariadb-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 'sql/sql_rename.cc')
-rw-r--r--sql/sql_rename.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index 750bcd50479..66d89edc146 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -51,6 +51,8 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent)
DBUG_RETURN(1);
}
+ mysql_ha_rm_tables(thd, table_list);
+
if (wait_if_global_read_lock(thd,0,1))
DBUG_RETURN(1);