Skip to content

Commit 02619ed

Browse files
committed
Cleanup close_all_tables_for_name()
close_all_tables_for_name() is always preceded by wait_while_table_is_used(), which makes tdc_remove_table() redundant. The only (now fixed) exception was close_cached_tables(). Part of MDEV-17882 - Cleanup refresh version
1 parent e0743bd commit 02619ed

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

sql/sql_base.cc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -388,13 +388,12 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables,
388388
if (! table)
389389
continue;
390390

391-
if (thd->mdl_context.upgrade_shared_lock(table->mdl_ticket, MDL_EXCLUSIVE,
392-
timeout))
391+
if (wait_while_table_is_used(thd, table,
392+
HA_EXTRA_PREPARE_FOR_FORCED_CLOSE))
393393
{
394394
result= true;
395395
break;
396396
}
397-
table->file->extra(HA_EXTRA_PREPARE_FOR_FORCED_CLOSE);
398397
close_all_tables_for_name(thd, table->s, HA_EXTRA_NOT_USED, NULL);
399398
}
400399
/*
@@ -800,11 +799,10 @@ close_all_tables_for_name(THD *thd, TABLE_SHARE *share,
800799
TABLE *skip_table)
801800
{
802801
DBUG_ASSERT(!share->tmp_table);
802+
DBUG_ASSERT(share->tdc->flushed);
803803

804804
char key[MAX_DBKEY_LENGTH];
805805
size_t key_length= share->table_cache_key.length;
806-
const char *db= key;
807-
const char *table_name= db + share->db.length + 1;
808806
bool remove_from_locked_tables= extra != HA_EXTRA_NOT_USED;
809807

810808
memcpy(key, share->table_cache_key.str, key_length);
@@ -841,9 +839,6 @@ close_all_tables_for_name(THD *thd, TABLE_SHARE *share,
841839
prev= &table->next;
842840
}
843841
}
844-
/* Remove the table share from the cache. */
845-
if (skip_table == NULL)
846-
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, db, table_name);
847842
}
848843

849844

sql/sql_partition.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6819,11 +6819,11 @@ static int alter_close_table(ALTER_PARTITION_PARAM_TYPE *lpt)
68196819
@param close_table Table is still open, close it before reverting
68206820
*/
68216821

6822-
void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt,
6823-
bool action_completed,
6824-
bool drop_partition,
6825-
bool frm_install,
6826-
bool close_table)
6822+
static void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt,
6823+
bool action_completed,
6824+
bool drop_partition,
6825+
bool frm_install,
6826+
bool close_table)
68276827
{
68286828
partition_info *part_info= lpt->part_info;
68296829
THD *thd= lpt->thd;

sql/sql_table.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2480,7 +2480,6 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
24802480
error= -1;
24812481
goto err;
24822482
}
2483-
/* the following internally does TDC_RT_REMOVE_ALL */
24842483
close_all_tables_for_name(thd, table->table->s,
24852484
HA_EXTRA_PREPARE_FOR_DROP, NULL);
24862485
table->table= 0;

0 commit comments

Comments
 (0)