MDEV-25292 Cleanups
ddl_log_write_execute_entry() cleanup Rename functions renamed: do_rename() -> rename_table_and_triggers() do_rename_temporary() -> rename_temporary_table() check_rename() -> rename_check_preconditions()
This commit is contained in:
parent
f02af1d229
commit
595dad83ad
@ -2761,7 +2761,7 @@ int ddl_log_execute_recovery()
|
||||
if (ddl_log_entry.entry_type == DDL_LOG_EXECUTE_CODE)
|
||||
{
|
||||
/*
|
||||
Remeber information about executive ddl log entry,
|
||||
Remember information about executive ddl log entry,
|
||||
used for binary logging during recovery
|
||||
*/
|
||||
recovery_state.execute_entry_pos= i;
|
||||
@ -3532,7 +3532,7 @@ bool ddl_log_store_query(THD *thd, DDL_LOG_STATE *ddl_state,
|
||||
ddl_log_entry.extra_name.length= 0;
|
||||
max_query_length= ddl_log_free_space_in_entry(&ddl_log_entry);
|
||||
}
|
||||
if (ddl_log_write_execute_entry(first_entry->entry_pos,
|
||||
if (ddl_log_write_execute_entry(first_entry->entry_pos, 0,
|
||||
&ddl_state->execute_entry))
|
||||
goto err;
|
||||
|
||||
|
@ -264,12 +264,6 @@ bool ddl_log_write_entry(DDL_LOG_ENTRY *ddl_log_entry,
|
||||
|
||||
bool ddl_log_write_execute_entry(uint first_entry, uint cond_entry,
|
||||
DDL_LOG_MEMORY_ENTRY** active_entry);
|
||||
inline
|
||||
bool ddl_log_write_execute_entry(uint first_entry,
|
||||
DDL_LOG_MEMORY_ENTRY **active_entry)
|
||||
{
|
||||
return ddl_log_write_execute_entry(first_entry, 0, active_entry);
|
||||
}
|
||||
bool ddl_log_disable_execute_entry(DDL_LOG_MEMORY_ENTRY **active_entry);
|
||||
|
||||
void ddl_log_complete(DDL_LOG_STATE *ddl_log_state);
|
||||
|
@ -8618,8 +8618,8 @@ bool Table_scope_and_contents_source_st::check_fields(
|
||||
THD *thd, Alter_info *alter_info,
|
||||
const Lex_table_name &table_name, const Lex_table_name &db)
|
||||
{
|
||||
return vers_check_system_fields(thd, alter_info, table_name, db) ||
|
||||
check_period_fields(thd, alter_info);
|
||||
return (vers_check_system_fields(thd, alter_info, table_name, db) ||
|
||||
check_period_fields(thd, alter_info));
|
||||
}
|
||||
|
||||
bool Table_scope_and_contents_source_st::check_period_fields(
|
||||
|
@ -680,9 +680,11 @@ enum Log_event_type
|
||||
/* New MySQL/Sun events are to be added right above this comment */
|
||||
MYSQL_EVENTS_END,
|
||||
|
||||
MARIA_EVENTS_BEGIN= 160,
|
||||
/* New Maria event numbers start from here */
|
||||
ANNOTATE_ROWS_EVENT= 160,
|
||||
/* Keep that here for GDB to display ANNOTATE_ROWS_EVENT */
|
||||
MARIA_EVENTS_BEGIN= 160,
|
||||
|
||||
/*
|
||||
Binlog checkpoint event. Used for XA crash recovery on the master, not used
|
||||
in replication.
|
||||
|
@ -2911,7 +2911,7 @@ struct Item_change_record: public ilink
|
||||
|
||||
|
||||
/*
|
||||
Register an item tree tree transformation, performed by the query
|
||||
Register an item tree transformation, performed by the query
|
||||
optimizer. We need a pointer to runtime_memroot because it may be !=
|
||||
thd->mem_root (due to possible set_n_backup_active_arena called for thd).
|
||||
*/
|
||||
|
@ -6694,7 +6694,7 @@ static bool write_log_rename_frm(ALTER_PARTITION_PARAM_TYPE *lpt)
|
||||
goto error;
|
||||
log_entry= part_info->list;
|
||||
part_info->main_entry= log_entry;
|
||||
if (ddl_log_write_execute_entry(log_entry->entry_pos,
|
||||
if (ddl_log_write_execute_entry(log_entry->entry_pos, 0,
|
||||
&exec_log_entry))
|
||||
goto error;
|
||||
release_part_info_log_entries(old_first_log_entry);
|
||||
@ -6749,7 +6749,7 @@ static bool write_log_drop_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
|
||||
goto error;
|
||||
log_entry= part_info->list;
|
||||
part_info->main_entry= log_entry;
|
||||
if (ddl_log_write_execute_entry(log_entry->entry_pos,
|
||||
if (ddl_log_write_execute_entry(log_entry->entry_pos, 0,
|
||||
&exec_log_entry))
|
||||
goto error;
|
||||
release_part_info_log_entries(old_first_log_entry);
|
||||
@ -6781,7 +6781,7 @@ static bool write_log_convert_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
|
||||
if (write_log_convert_partition(lpt, &next_entry, (const char*)path))
|
||||
goto error;
|
||||
DBUG_ASSERT(next_entry == part_info->list->entry_pos);
|
||||
if (ddl_log_write_execute_entry(part_info->list->entry_pos,
|
||||
if (ddl_log_write_execute_entry(part_info->list->entry_pos, 0,
|
||||
&part_info->execute_entry))
|
||||
goto error;
|
||||
mysql_mutex_unlock(&LOCK_gdl);
|
||||
@ -6836,7 +6836,7 @@ static bool write_log_add_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
|
||||
goto error;
|
||||
log_entry= part_info->list;
|
||||
|
||||
if (ddl_log_write_execute_entry(log_entry->entry_pos,
|
||||
if (ddl_log_write_execute_entry(log_entry->entry_pos, 0,
|
||||
&part_info->execute_entry))
|
||||
goto error;
|
||||
mysql_mutex_unlock(&LOCK_gdl);
|
||||
@ -6903,7 +6903,7 @@ static bool write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
|
||||
log_entry= part_info->list;
|
||||
part_info->main_entry= log_entry;
|
||||
/* Overwrite the revert execute log entry with this retry execute entry */
|
||||
if (ddl_log_write_execute_entry(log_entry->entry_pos,
|
||||
if (ddl_log_write_execute_entry(log_entry->entry_pos, 0,
|
||||
&exec_log_entry))
|
||||
goto error;
|
||||
release_part_info_log_entries(old_first_log_entry);
|
||||
|
@ -382,7 +382,7 @@ static bool exchange_name_with_ddl_log(THD *thd,
|
||||
|
||||
DBUG_EXECUTE_IF("exchange_partition_fail_2", goto err_no_execute_written;);
|
||||
DBUG_EXECUTE_IF("exchange_partition_abort_2", DBUG_SUICIDE(););
|
||||
if (unlikely(ddl_log_write_execute_entry(log_entry->entry_pos,
|
||||
if (unlikely(ddl_log_write_execute_entry(log_entry->entry_pos, 0,
|
||||
&exec_log_entry)))
|
||||
goto err_no_execute_written;
|
||||
/* ddl_log is written and synced */
|
||||
|
@ -208,10 +208,10 @@ err:
|
||||
|
||||
|
||||
static bool
|
||||
do_rename_temporary(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table)
|
||||
rename_temporary_table(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table)
|
||||
{
|
||||
LEX_CSTRING *new_alias;
|
||||
DBUG_ENTER("do_rename_temporary");
|
||||
DBUG_ENTER("rename_temporary_table");
|
||||
|
||||
new_alias= (lower_case_table_names == 2) ? &new_table->alias :
|
||||
&new_table->table_name;
|
||||
@ -228,7 +228,7 @@ do_rename_temporary(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table)
|
||||
|
||||
|
||||
/**
|
||||
Parameters for do_rename
|
||||
Parameters for rename_table_and_triggers()
|
||||
*/
|
||||
|
||||
struct rename_param
|
||||
@ -240,8 +240,6 @@ struct rename_param
|
||||
|
||||
|
||||
/**
|
||||
check_rename()
|
||||
|
||||
Check pre-conditions for rename
|
||||
- From table should exists
|
||||
- To table should not exists.
|
||||
@ -258,14 +256,14 @@ struct rename_param
|
||||
*/
|
||||
|
||||
static int
|
||||
check_rename(THD *thd, rename_param *param,
|
||||
TABLE_LIST *ren_table,
|
||||
const LEX_CSTRING *new_db,
|
||||
const LEX_CSTRING *new_table_name,
|
||||
const LEX_CSTRING *new_table_alias,
|
||||
bool if_exists)
|
||||
rename_check_preconditions(THD *thd, rename_param *param,
|
||||
TABLE_LIST *ren_table,
|
||||
const LEX_CSTRING *new_db,
|
||||
const LEX_CSTRING *new_table_name,
|
||||
const LEX_CSTRING *new_table_alias,
|
||||
bool if_exists)
|
||||
{
|
||||
DBUG_ENTER("check_rename");
|
||||
DBUG_ENTER("rename_check_preconditions");
|
||||
DBUG_PRINT("enter", ("if_exists: %d", (int) if_exists));
|
||||
|
||||
|
||||
@ -316,7 +314,6 @@ check_rename(THD *thd, rename_param *param,
|
||||
Rename a single table or a view
|
||||
|
||||
SYNPOSIS
|
||||
do_rename()
|
||||
thd Thread handle
|
||||
ren_table A table/view to be renamed
|
||||
new_db The database to which the table to be moved to
|
||||
@ -334,15 +331,16 @@ check_rename(THD *thd, rename_param *param,
|
||||
*/
|
||||
|
||||
static bool
|
||||
do_rename(THD *thd, rename_param *param, DDL_LOG_STATE *ddl_log_state,
|
||||
TABLE_LIST *ren_table, const LEX_CSTRING *new_db,
|
||||
bool skip_error, bool *force_if_exists)
|
||||
rename_table_and_triggers(THD *thd, rename_param *param,
|
||||
DDL_LOG_STATE *ddl_log_state,
|
||||
TABLE_LIST *ren_table, const LEX_CSTRING *new_db,
|
||||
bool skip_error, bool *force_if_exists)
|
||||
{
|
||||
int rc= 1;
|
||||
handlerton *hton;
|
||||
LEX_CSTRING *old_alias, *new_alias;
|
||||
TRIGGER_RENAME_PARAM rename_param;
|
||||
DBUG_ENTER("do_rename");
|
||||
DBUG_ENTER("rename_table_and_triggers");
|
||||
DBUG_PRINT("enter", ("skip_error: %d", (int) skip_error));
|
||||
|
||||
old_alias= ¶m->old_alias;
|
||||
@ -515,24 +513,25 @@ rename_tables(THD *thd, TABLE_LIST *table_list, DDL_LOG_STATE *ddl_log_state,
|
||||
pair->from= ren_table;
|
||||
pair->to= new_table;
|
||||
|
||||
if (do_rename_temporary(thd, ren_table, new_table))
|
||||
if (rename_temporary_table(thd, ren_table, new_table))
|
||||
goto revert_rename;
|
||||
}
|
||||
else
|
||||
{
|
||||
int error;
|
||||
rename_param param;
|
||||
error= check_rename(thd, ¶m, ren_table, &new_table->db,
|
||||
&new_table->table_name,
|
||||
&new_table->alias, (skip_error || if_exists));
|
||||
error= rename_check_preconditions(thd, ¶m, ren_table,
|
||||
&new_table->db, &new_table->table_name,
|
||||
&new_table->alias,
|
||||
(skip_error || if_exists));
|
||||
if (error < 0)
|
||||
continue; // Ignore rename (if exists)
|
||||
if (error > 0)
|
||||
goto revert_rename;
|
||||
|
||||
if (do_rename(thd, ¶m, ddl_log_state,
|
||||
ren_table, &new_table->db,
|
||||
skip_error, force_if_exists))
|
||||
if (rename_table_and_triggers(thd, ¶m, ddl_log_state,
|
||||
ren_table, &new_table->db,
|
||||
skip_error, force_if_exists))
|
||||
goto revert_rename;
|
||||
}
|
||||
}
|
||||
@ -542,7 +541,7 @@ revert_rename:
|
||||
/* Revert temporary tables. Normal tables are reverted in the caller */
|
||||
List_iterator_fast<TABLE_PAIR> it(tmp_tables);
|
||||
while (TABLE_PAIR *pair= it++)
|
||||
do_rename_temporary(thd, pair->to, pair->from);
|
||||
rename_temporary_table(thd, pair->to, pair->from);
|
||||
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
@ -869,7 +869,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
|
||||
if (write_log_replace_frm(lpt, part_info->list->entry_pos,
|
||||
(const char*) bak_path,
|
||||
(const char*) path) ||
|
||||
ddl_log_write_execute_entry(part_info->list->entry_pos,
|
||||
ddl_log_write_execute_entry(part_info->list->entry_pos, 0,
|
||||
&part_info->execute_entry))
|
||||
{
|
||||
mysql_mutex_unlock(&LOCK_gdl);
|
||||
|
Loading…
x
Reference in New Issue
Block a user