Skip to content

Commit 595dad8

Browse files
committed
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()
1 parent f02af1d commit 595dad8

File tree

9 files changed

+39
-44
lines changed

9 files changed

+39
-44
lines changed

sql/ddl_log.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2761,7 +2761,7 @@ int ddl_log_execute_recovery()
27612761
if (ddl_log_entry.entry_type == DDL_LOG_EXECUTE_CODE)
27622762
{
27632763
/*
2764-
Remeber information about executive ddl log entry,
2764+
Remember information about executive ddl log entry,
27652765
used for binary logging during recovery
27662766
*/
27672767
recovery_state.execute_entry_pos= i;
@@ -3532,7 +3532,7 @@ bool ddl_log_store_query(THD *thd, DDL_LOG_STATE *ddl_state,
35323532
ddl_log_entry.extra_name.length= 0;
35333533
max_query_length= ddl_log_free_space_in_entry(&ddl_log_entry);
35343534
}
3535-
if (ddl_log_write_execute_entry(first_entry->entry_pos,
3535+
if (ddl_log_write_execute_entry(first_entry->entry_pos, 0,
35363536
&ddl_state->execute_entry))
35373537
goto err;
35383538

sql/ddl_log.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,6 @@ bool ddl_log_write_entry(DDL_LOG_ENTRY *ddl_log_entry,
264264

265265
bool ddl_log_write_execute_entry(uint first_entry, uint cond_entry,
266266
DDL_LOG_MEMORY_ENTRY** active_entry);
267-
inline
268-
bool ddl_log_write_execute_entry(uint first_entry,
269-
DDL_LOG_MEMORY_ENTRY **active_entry)
270-
{
271-
return ddl_log_write_execute_entry(first_entry, 0, active_entry);
272-
}
273267
bool ddl_log_disable_execute_entry(DDL_LOG_MEMORY_ENTRY **active_entry);
274268

275269
void ddl_log_complete(DDL_LOG_STATE *ddl_log_state);

sql/handler.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8618,8 +8618,8 @@ bool Table_scope_and_contents_source_st::check_fields(
86188618
THD *thd, Alter_info *alter_info,
86198619
const Lex_table_name &table_name, const Lex_table_name &db)
86208620
{
8621-
return vers_check_system_fields(thd, alter_info, table_name, db) ||
8622-
check_period_fields(thd, alter_info);
8621+
return (vers_check_system_fields(thd, alter_info, table_name, db) ||
8622+
check_period_fields(thd, alter_info));
86238623
}
86248624

86258625
bool Table_scope_and_contents_source_st::check_period_fields(

sql/log_event.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,11 @@ enum Log_event_type
680680
/* New MySQL/Sun events are to be added right above this comment */
681681
MYSQL_EVENTS_END,
682682

683-
MARIA_EVENTS_BEGIN= 160,
684683
/* New Maria event numbers start from here */
685684
ANNOTATE_ROWS_EVENT= 160,
685+
/* Keep that here for GDB to display ANNOTATE_ROWS_EVENT */
686+
MARIA_EVENTS_BEGIN= 160,
687+
686688
/*
687689
Binlog checkpoint event. Used for XA crash recovery on the master, not used
688690
in replication.

sql/sql_class.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2911,7 +2911,7 @@ struct Item_change_record: public ilink
29112911

29122912

29132913
/*
2914-
Register an item tree tree transformation, performed by the query
2914+
Register an item tree transformation, performed by the query
29152915
optimizer. We need a pointer to runtime_memroot because it may be !=
29162916
thd->mem_root (due to possible set_n_backup_active_arena called for thd).
29172917
*/

sql/sql_partition.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6694,7 +6694,7 @@ static bool write_log_rename_frm(ALTER_PARTITION_PARAM_TYPE *lpt)
66946694
goto error;
66956695
log_entry= part_info->list;
66966696
part_info->main_entry= log_entry;
6697-
if (ddl_log_write_execute_entry(log_entry->entry_pos,
6697+
if (ddl_log_write_execute_entry(log_entry->entry_pos, 0,
66986698
&exec_log_entry))
66996699
goto error;
67006700
release_part_info_log_entries(old_first_log_entry);
@@ -6749,7 +6749,7 @@ static bool write_log_drop_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
67496749
goto error;
67506750
log_entry= part_info->list;
67516751
part_info->main_entry= log_entry;
6752-
if (ddl_log_write_execute_entry(log_entry->entry_pos,
6752+
if (ddl_log_write_execute_entry(log_entry->entry_pos, 0,
67536753
&exec_log_entry))
67546754
goto error;
67556755
release_part_info_log_entries(old_first_log_entry);
@@ -6781,7 +6781,7 @@ static bool write_log_convert_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
67816781
if (write_log_convert_partition(lpt, &next_entry, (const char*)path))
67826782
goto error;
67836783
DBUG_ASSERT(next_entry == part_info->list->entry_pos);
6784-
if (ddl_log_write_execute_entry(part_info->list->entry_pos,
6784+
if (ddl_log_write_execute_entry(part_info->list->entry_pos, 0,
67856785
&part_info->execute_entry))
67866786
goto error;
67876787
mysql_mutex_unlock(&LOCK_gdl);
@@ -6836,7 +6836,7 @@ static bool write_log_add_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
68366836
goto error;
68376837
log_entry= part_info->list;
68386838

6839-
if (ddl_log_write_execute_entry(log_entry->entry_pos,
6839+
if (ddl_log_write_execute_entry(log_entry->entry_pos, 0,
68406840
&part_info->execute_entry))
68416841
goto error;
68426842
mysql_mutex_unlock(&LOCK_gdl);
@@ -6903,7 +6903,7 @@ static bool write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
69036903
log_entry= part_info->list;
69046904
part_info->main_entry= log_entry;
69056905
/* Overwrite the revert execute log entry with this retry execute entry */
6906-
if (ddl_log_write_execute_entry(log_entry->entry_pos,
6906+
if (ddl_log_write_execute_entry(log_entry->entry_pos, 0,
69076907
&exec_log_entry))
69086908
goto error;
69096909
release_part_info_log_entries(old_first_log_entry);

sql/sql_partition_admin.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ static bool exchange_name_with_ddl_log(THD *thd,
382382

383383
DBUG_EXECUTE_IF("exchange_partition_fail_2", goto err_no_execute_written;);
384384
DBUG_EXECUTE_IF("exchange_partition_abort_2", DBUG_SUICIDE(););
385-
if (unlikely(ddl_log_write_execute_entry(log_entry->entry_pos,
385+
if (unlikely(ddl_log_write_execute_entry(log_entry->entry_pos, 0,
386386
&exec_log_entry)))
387387
goto err_no_execute_written;
388388
/* ddl_log is written and synced */

sql/sql_rename.cc

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent,
208208

209209

210210
static bool
211-
do_rename_temporary(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table)
211+
rename_temporary_table(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table)
212212
{
213213
LEX_CSTRING *new_alias;
214-
DBUG_ENTER("do_rename_temporary");
214+
DBUG_ENTER("rename_temporary_table");
215215

216216
new_alias= (lower_case_table_names == 2) ? &new_table->alias :
217217
&new_table->table_name;
@@ -228,7 +228,7 @@ do_rename_temporary(THD *thd, TABLE_LIST *ren_table, TABLE_LIST *new_table)
228228

229229

230230
/**
231-
Parameters for do_rename
231+
Parameters for rename_table_and_triggers()
232232
*/
233233

234234
struct rename_param
@@ -240,8 +240,6 @@ struct rename_param
240240

241241

242242
/**
243-
check_rename()
244-
245243
Check pre-conditions for rename
246244
- From table should exists
247245
- To table should not exists.
@@ -258,14 +256,14 @@ struct rename_param
258256
*/
259257

260258
static int
261-
check_rename(THD *thd, rename_param *param,
262-
TABLE_LIST *ren_table,
263-
const LEX_CSTRING *new_db,
264-
const LEX_CSTRING *new_table_name,
265-
const LEX_CSTRING *new_table_alias,
266-
bool if_exists)
259+
rename_check_preconditions(THD *thd, rename_param *param,
260+
TABLE_LIST *ren_table,
261+
const LEX_CSTRING *new_db,
262+
const LEX_CSTRING *new_table_name,
263+
const LEX_CSTRING *new_table_alias,
264+
bool if_exists)
267265
{
268-
DBUG_ENTER("check_rename");
266+
DBUG_ENTER("rename_check_preconditions");
269267
DBUG_PRINT("enter", ("if_exists: %d", (int) if_exists));
270268

271269

@@ -316,7 +314,6 @@ check_rename(THD *thd, rename_param *param,
316314
Rename a single table or a view
317315
318316
SYNPOSIS
319-
do_rename()
320317
thd Thread handle
321318
ren_table A table/view to be renamed
322319
new_db The database to which the table to be moved to
@@ -334,15 +331,16 @@ check_rename(THD *thd, rename_param *param,
334331
*/
335332

336333
static bool
337-
do_rename(THD *thd, rename_param *param, DDL_LOG_STATE *ddl_log_state,
338-
TABLE_LIST *ren_table, const LEX_CSTRING *new_db,
339-
bool skip_error, bool *force_if_exists)
334+
rename_table_and_triggers(THD *thd, rename_param *param,
335+
DDL_LOG_STATE *ddl_log_state,
336+
TABLE_LIST *ren_table, const LEX_CSTRING *new_db,
337+
bool skip_error, bool *force_if_exists)
340338
{
341339
int rc= 1;
342340
handlerton *hton;
343341
LEX_CSTRING *old_alias, *new_alias;
344342
TRIGGER_RENAME_PARAM rename_param;
345-
DBUG_ENTER("do_rename");
343+
DBUG_ENTER("rename_table_and_triggers");
346344
DBUG_PRINT("enter", ("skip_error: %d", (int) skip_error));
347345

348346
old_alias= &param->old_alias;
@@ -515,24 +513,25 @@ rename_tables(THD *thd, TABLE_LIST *table_list, DDL_LOG_STATE *ddl_log_state,
515513
pair->from= ren_table;
516514
pair->to= new_table;
517515

518-
if (do_rename_temporary(thd, ren_table, new_table))
516+
if (rename_temporary_table(thd, ren_table, new_table))
519517
goto revert_rename;
520518
}
521519
else
522520
{
523521
int error;
524522
rename_param param;
525-
error= check_rename(thd, &param, ren_table, &new_table->db,
526-
&new_table->table_name,
527-
&new_table->alias, (skip_error || if_exists));
523+
error= rename_check_preconditions(thd, &param, ren_table,
524+
&new_table->db, &new_table->table_name,
525+
&new_table->alias,
526+
(skip_error || if_exists));
528527
if (error < 0)
529528
continue; // Ignore rename (if exists)
530529
if (error > 0)
531530
goto revert_rename;
532531

533-
if (do_rename(thd, &param, ddl_log_state,
534-
ren_table, &new_table->db,
535-
skip_error, force_if_exists))
532+
if (rename_table_and_triggers(thd, &param, ddl_log_state,
533+
ren_table, &new_table->db,
534+
skip_error, force_if_exists))
536535
goto revert_rename;
537536
}
538537
}
@@ -542,7 +541,7 @@ rename_tables(THD *thd, TABLE_LIST *table_list, DDL_LOG_STATE *ddl_log_state,
542541
/* Revert temporary tables. Normal tables are reverted in the caller */
543542
List_iterator_fast<TABLE_PAIR> it(tmp_tables);
544543
while (TABLE_PAIR *pair= it++)
545-
do_rename_temporary(thd, pair->to, pair->from);
544+
rename_temporary_table(thd, pair->to, pair->from);
546545

547546
DBUG_RETURN(1);
548547
}

sql/sql_table.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
869869
if (write_log_replace_frm(lpt, part_info->list->entry_pos,
870870
(const char*) bak_path,
871871
(const char*) path) ||
872-
ddl_log_write_execute_entry(part_info->list->entry_pos,
872+
ddl_log_write_execute_entry(part_info->list->entry_pos, 0,
873873
&part_info->execute_entry))
874874
{
875875
mysql_mutex_unlock(&LOCK_gdl);

0 commit comments

Comments
 (0)