From f4adb7c6e4cd855499d92c9352dd4d75aab5e1b0 Mon Sep 17 00:00:00 2001 From: Jan Wedvik Date: Tue, 11 Jan 2011 12:09:54 +0100 Subject: [PATCH] Fix for bug#58553, "Queries with pushed conditions causes 'explain extended' to crash mysqld". handler::pushed_cond was not always properly reset when table objects where recycled via the table cache. handler::pushed_cond is now set to NULL in handler::ha_reset(). This should prevent pushed conditions from (incorrectly) re-apperaring in later queries. --- sql/handler.cc | 1 + sql/sql_base.cc | 5 +++++ sql/sql_select.cc | 1 - 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sql/handler.cc b/sql/handler.cc index ce4e4a9e3a9..711d2942ce0 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4657,6 +4657,7 @@ int handler::ha_reset() free_io_cache(table); /* reset the bitmaps to point to defaults */ table->default_column_bitmaps(); + pushed_cond= NULL; DBUG_RETURN(reset()); } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 13876b8b331..f609a073161 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2993,6 +2993,11 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, table->insert_values= 0; table->fulltext_searched= 0; table->file->ft_handler= 0; + /* + Check that there is no reference to a condtion from an earlier query + (cf. Bug#58553). + */ + DBUG_ASSERT(table->file->pushed_cond == NULL); table->reginfo.impossible_range= 0; /* Catch wrong handling of the auto_increment_field_not_null. */ DBUG_ASSERT(!table->auto_increment_field_not_null); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9e0a82aa342..067f3cfc95d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6380,7 +6380,6 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) tab->select_cond=sel->cond=tmp; /* Push condition to storage engine if this is enabled and the condition is not guarded */ - tab->table->file->pushed_cond= NULL; if (thd->variables.engine_condition_pushdown) { COND *push_cond=