Commit d51c0518 authored by Sergey Vojtovich's avatar Sergey Vojtovich Committed by Sergei Golubchik

Simplified quick_rm_table() and mysql_rename_table()

Replaced obscure FRM_ONLY, NO_FRM_RENAME, NO_HA_TABLE, NO_PAR_TABLE with
straightforward explicit flags:

QRMT_FRM - [re]moves .frm
QRMT_PAR - [re]moves .par
QRMT_HANDLER - calls ha_delete_table()/ha_rename_table() and [re]moves
               high-level indexes
QRMT_DEFAULT - same as QRMT_FRM | QRMT_HANDLER, which is regular table
               drop/rename.
parent b0aae6ca
......@@ -1985,7 +1985,7 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root,
the original name failed. Now we have to delete the temporary table
and restore the backup.
*/
quick_rm_table(thd, hton, &db, &table, FN_IS_TMP);
quick_rm_table(thd, hton, &db, &table, QRMT_DEFAULT | FN_IS_TMP);
if (!is_renamed)
{
execute_rename_table(ddl_log_entry, file,
......
......@@ -1461,7 +1461,7 @@ void drop_open_table(THD *thd, TABLE *table, const LEX_CSTRING *db_name,
table->s->tdc->flush(thd, true);
close_thread_table(thd, &thd->open_tables);
/* Remove the table from the storage engine and rm the .frm. */
quick_rm_table(thd, table_type, db_name, table_name, 0);
quick_rm_table(thd, table_type, db_name, table_name, QRMT_DEFAULT);
}
DBUG_VOID_RETURN;
}
......
......@@ -4769,7 +4769,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List<Item> *items,
{
quick_rm_table(thd, create_info->db_type, &table_list->db,
table_case_name(create_info, &table_list->table_name),
0);
QRMT_DEFAULT);
}
/* Restore */
table_list->open_strategy= save_open_strategy;
......
......@@ -299,7 +299,7 @@ check_rename(THD *thd, rename_param *param,
Discovery will find the old table when it's accessed
*/
tdc_remove_table(thd, ren_table->db.str, ren_table->table_name.str);
quick_rm_table(thd, 0, &ren_table->db, &param->old_alias, FRM_ONLY, 0);
quick_rm_table(thd, 0, &ren_table->db, &param->old_alias, QRMT_FRM);
DBUG_RETURN(-1);
}
......@@ -380,7 +380,8 @@ do_rename(THD *thd, const rename_param *param, DDL_LOG_STATE *ddl_log_state,
debug_crash_here("ddl_log_rename_before_rename_table");
if (!(rc= mysql_rename_table(hton, &ren_table->db, old_alias,
new_db, new_alias, &param->old_version, 0)))
new_db, new_alias, &param->old_version,
QRMT_DEFAULT)))
{
/* Table rename succeded.
It's safe to start recovery at rename trigger phase
......@@ -415,7 +416,7 @@ do_rename(THD *thd, const rename_param *param, DDL_LOG_STATE *ddl_log_state,
debug_crash_here("ddl_log_rename_after_failed_rename_trigger");
(void) mysql_rename_table(hton, new_db, new_alias,
&ren_table->db, old_alias, &param->old_version,
NO_FK_CHECKS);
QRMT_DEFAULT | NO_FK_CHECKS);
debug_crash_here("ddl_log_rename_after_revert_rename_table");
ddl_log_disable_entry(ddl_log_state);
debug_crash_here("ddl_log_rename_after_disable_entry");
......
This diff is collapsed.
......@@ -66,16 +66,18 @@ enum enum_explain_filename_mode
static const uint FN_FROM_IS_TMP= 1 << 0;
static const uint FN_TO_IS_TMP= 1 << 1;
static const uint FN_IS_TMP= FN_FROM_IS_TMP | FN_TO_IS_TMP;
static const uint NO_FRM_RENAME= 1 << 2;
static const uint FRM_ONLY= 1 << 3;
/** Don't remove table in engine. Remove only .FRM and maybe .PAR files. */
static const uint NO_HA_TABLE= 1 << 4;
/* Remove .frm table metadata. */
static constexpr uint QRMT_FRM= 1 << 2;
/* Remove .par partitioning metadata. */
static constexpr uint QRMT_PAR= 1 << 3;
/* Remove handler files and high-level indexes. */
static constexpr uint QRMT_HANDLER= 1 << 4;
/* Default behaviour is to drop .FRM and handler, but not .par. */
static constexpr uint QRMT_DEFAULT= QRMT_FRM | QRMT_HANDLER;
/** Don't resolve MySQL's fake "foo.sym" symbolic directory names. */
static const uint SKIP_SYMDIR_ACCESS= 1 << 5;
/** Don't check foreign key constraints while renaming table */
static const uint NO_FK_CHECKS= 1 << 6;
/* Don't delete .par table in quick_rm_table() */
static const uint NO_PAR_TABLE= 1 << 7;
uint filename_to_tablename(const char *from, char *to, size_t to_length,
bool stay_quiet = false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment