diff options
Diffstat (limited to 'sql/sql_parse.cc')
| -rw-r--r-- | sql/sql_parse.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 221ed09c215..15d7e19188e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2221,6 +2221,7 @@ mysql_execute_command(THD *thd) Rpl_filter *rpl_filter= thd->rpl_filter; #endif DBUG_ENTER("mysql_execute_command"); + #ifdef WITH_PARTITION_STORAGE_ENGINE thd->work_part_info= 0; #endif @@ -5091,6 +5092,7 @@ finish: DBUG_ASSERT(!thd->in_active_multi_stmt_transaction() || thd->in_multi_stmt_transaction_mode()); + lex->unit.cleanup(); if (! thd->in_sub_stmt) { @@ -5122,7 +5124,6 @@ finish: ha_maria::implicit_commit(thd, FALSE); #endif } - lex->unit.cleanup(); /* Free tables */ THD_STAGE_INFO(thd, stage_closing_tables); @@ -6739,7 +6740,11 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, ptr->schema_table= schema_table; } ptr->select_lex= lex->current_select; - ptr->cacheable_table= 1; + /* + We can't cache internal temporary tables between prepares as the + table may be deleted before next exection. + */ + ptr->cacheable_table= !table->is_derived_table(); ptr->index_hints= index_hints_arg; ptr->option= option ? option->str : 0; /* check that used name is unique */ |
