summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
authorramil/ram@mysql.com/myoffice.izhnet.ru <>2006-11-27 13:24:24 +0400
committerramil/ram@mysql.com/myoffice.izhnet.ru <>2006-11-27 13:24:24 +0400
commit55aa6e04bd7a7b8b5b86fa15efe9d253a9650eeb (patch)
tree971fa749151a84c6076f08303a977feaa2d22906 /sql/sql_base.cc
parentbc9ca699fb12b8ecabb6edbc41b9406dd4a00dd4 (diff)
downloadmariadb-git-55aa6e04bd7a7b8b5b86fa15efe9d253a9650eeb.tar.gz
Fix for bug #21587: FLUSH TABLES causes server crash when used with HANDLER statements
Problems (appear only under some circumstances): 1. we get a reference to a deleted table searching in the thd->handler_tables_hash in the mysql_ha_read(). 2. DBUG_ASSERT(table->file->inited == handler::NONE); assert fails in the close_thread_table(). Fix: end open index scans and table scans and remove references to the tables from the handler tables hash. After this preparation it is safe to close the tables. The close can no longer fail on open index/table scans and the closed table will not be used again by handler functions.
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 0f6715fc078..053f6fcb845 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -519,7 +519,15 @@ void close_thread_tables(THD *thd, bool lock_in_use, bool skip_derived)
DBUG_PRINT("info", ("thd->open_tables: %p", thd->open_tables));
- found_old_table= 0;
+
+ /*
+ End open index scans and table scans and remove references to the tables
+ from the handler tables hash. After this preparation it is safe to close
+ the tables.
+ */
+ mysql_ha_mark_tables_for_reopen(thd, thd->open_tables);
+
+ found_old_table= 0;
while (thd->open_tables)
found_old_table|=close_thread_table(thd, &thd->open_tables);
thd->some_tables_deleted=0;