diff options
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 47237d94d87..7013cb2301c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -69,6 +69,7 @@ #include "my_json_writer.h" #include "opt_trace.h" #include "create_tmp_table.h" +#include "derived_handler.h" /* A key part number that means we're using a fulltext scan. @@ -14382,6 +14383,7 @@ void JOIN_TAB::cleanup() delete filesort->select; delete filesort; filesort= NULL; + /* Skip non-existing derived tables/views result tables */ if (table && (table->s->tmp_table != INTERNAL_TMP_TABLE || table->is_created())) @@ -14882,11 +14884,11 @@ void JOIN::cleanup(bool full) delete pushdown_query; pushdown_query= 0; - if (!join_tab) + List_iterator<TABLE_LIST> li(*join_list); + TABLE_LIST *table_ref; + while ((table_ref= li++)) { - List_iterator<TABLE_LIST> li(*join_list); - TABLE_LIST *table_ref; - while ((table_ref= li++)) + if (!join_tab) { if (table_ref->table && table_ref->jtbm_subselect && @@ -14896,6 +14898,13 @@ void JOIN::cleanup(bool full) table_ref->table= NULL; } } + if (table_ref->pushdown_derived) + { + delete table_ref->pushdown_derived; + table_ref->pushdown_derived= NULL; + } + delete table_ref->dt_handler; + table_ref->dt_handler= NULL; } } /* Restore ref array to original state */ @@ -28516,12 +28525,6 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result) result, unit, first); } - if (unit->derived && unit->derived->pushdown_derived) - { - delete unit->derived->pushdown_derived; - unit->derived->pushdown_derived= NULL; - } - DBUG_RETURN(res || thd->is_error()); } |