diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 90e563c824e..3a04c14dee9 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -388,13 +388,12 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, if (! table) continue; - if (thd->mdl_context.upgrade_shared_lock(table->mdl_ticket, MDL_EXCLUSIVE, - timeout)) + if (wait_while_table_is_used(thd, table, + HA_EXTRA_PREPARE_FOR_FORCED_CLOSE)) { result= true; break; } - table->file->extra(HA_EXTRA_PREPARE_FOR_FORCED_CLOSE); close_all_tables_for_name(thd, table->s, HA_EXTRA_NOT_USED, NULL); } /* @@ -800,11 +799,10 @@ close_all_tables_for_name(THD *thd, TABLE_SHARE *share, TABLE *skip_table) { DBUG_ASSERT(!share->tmp_table); + DBUG_ASSERT(share->tdc->flushed); char key[MAX_DBKEY_LENGTH]; size_t key_length= share->table_cache_key.length; - const char *db= key; - const char *table_name= db + share->db.length + 1; bool remove_from_locked_tables= extra != HA_EXTRA_NOT_USED; memcpy(key, share->table_cache_key.str, key_length); @@ -841,9 +839,6 @@ close_all_tables_for_name(THD *thd, TABLE_SHARE *share, prev= &table->next; } } - /* Remove the table share from the cache. */ - if (skip_table == NULL) - tdc_remove_table(thd, TDC_RT_REMOVE_ALL, db, table_name); } diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index e08432a2318..ce2ee1b5aa2 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -6819,11 +6819,11 @@ static int alter_close_table(ALTER_PARTITION_PARAM_TYPE *lpt) @param close_table Table is still open, close it before reverting */ -void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt, - bool action_completed, - bool drop_partition, - bool frm_install, - bool close_table) +static void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt, + bool action_completed, + bool drop_partition, + bool frm_install, + bool close_table) { partition_info *part_info= lpt->part_info; THD *thd= lpt->thd; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 639890df9f2..2cbda99e313 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2480,7 +2480,6 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, error= -1; goto err; } - /* the following internally does TDC_RT_REMOVE_ALL */ close_all_tables_for_name(thd, table->table->s, HA_EXTRA_PREPARE_FOR_DROP, NULL); table->table= 0;