diff options
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f9bfa6d120b..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 @@ -4221,14 +4222,16 @@ end_with_restore_list: if (check_global_access(thd,RELOAD_ACL)) goto error; - if (first_table && lex->type & REFRESH_READ_LOCK) + if (first_table && lex->type & (REFRESH_READ_LOCK|REFRESH_FOR_EXPORT)) { /* Check table-level privileges. */ if (check_table_access(thd, LOCK_TABLES_ACL | SELECT_ACL, all_tables, FALSE, UINT_MAX, FALSE)) goto error; + if (flush_tables_with_read_lock(thd, all_tables)) goto error; + my_ok(thd); break; } @@ -5089,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) { @@ -5120,7 +5124,6 @@ finish: ha_maria::implicit_commit(thd, FALSE); #endif } - lex->unit.cleanup(); /* Free tables */ THD_STAGE_INFO(thd, stage_closing_tables); @@ -6737,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 */ |