From 8e735d2c119bc74c75868e4c9ad4198e42e4d26d Mon Sep 17 00:00:00 2001 From: "konstantin@bodhi.netgear" <> Date: Thu, 6 Jul 2006 23:59:04 +0400 Subject: A fix and a test case for Bug#19399 "res 'Lost Connection' when dropping/creating tables". The bug could lead to a crash when multi-delete statements were prepared and used with temporary tables. The bug was caused by lack of clean-up of multi-delete tables before re-execution of a prepared statement. In a statement like DELETE t1 FROM t1, t2 WHERE ... the first table list (t1) is moved to lex->auxilliary_table_list and excluded from lex->query_tables or select_lex->tables. Thus it was unaccessible to reinit_stmt_before_use and not cleaned up before re-execution of a prepared statement. --- sql/table.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'sql/table.cc') diff --git a/sql/table.cc b/sql/table.cc index 513f42665a6..26da6dc4605 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1523,6 +1523,23 @@ db_type get_table_type(const char *name) DBUG_RETURN(ha_checktype((enum db_type) (uint) *(head+3))); } +/* + Cleanup this table for re-execution. + + SYNOPSIS + st_table_list::reinit_before_use() +*/ + +void st_table_list::reinit_before_use(THD * /* thd */) +{ + /* + Reset old pointers to TABLEs: they are not valid since the tables + were closed in the end of previous prepare or execute call. + */ + table= 0; + table_list= 0; +} + /***************************************************************************** ** Instansiate templates -- cgit v1.2.1