diff options
author | Monty <monty@mariadb.org> | 2021-06-17 16:06:46 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2021-06-19 03:46:00 +0300 |
commit | 87de0e2129fbc1ade1d129520f1ebf0338672321 (patch) | |
tree | 1b6147712ab5ca2ba7a669424a295e3771db0263 /sql/ddl_log.cc | |
parent | 83a471344f448950956b914e1150e845833a71ee (diff) | |
download | mariadb-git-87de0e2129fbc1ade1d129520f1ebf0338672321.tar.gz |
Minor cleanups of atomic ddl code
- Rename DDL_IGNORE_LOG_ENTRY_CODE to DDL_LOG_IGNORE_ENTRY_CODE
This makes it similar to all other ddl_log_entry_code's.
- Added some new comments
- ddl_log_revert() now returns != 0 if revert didn't succeed
Diffstat (limited to 'sql/ddl_log.cc')
-rw-r--r-- | sql/ddl_log.cc | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/sql/ddl_log.cc b/sql/ddl_log.cc index 8b2813327df..15bb836047b 100644 --- a/sql/ddl_log.cc +++ b/sql/ddl_log.cc @@ -421,7 +421,7 @@ static bool disable_execute_entry(uint entry_pos) uchar buff[1]; DBUG_ENTER("disable_execute_entry"); - buff[0]= DDL_IGNORE_LOG_ENTRY_CODE; + buff[0]= DDL_LOG_IGNORE_ENTRY_CODE; DBUG_RETURN(mysql_file_pwrite(global_ddl_log.file_id, buff, sizeof(buff), global_ddl_log.io_size * entry_pos + DDL_LOG_ENTRY_TYPE_POS, @@ -858,7 +858,7 @@ static bool ddl_log_increment_phase_no_lock(uint entry_pos) if (ddl_log_entry_phases[action] <= phase) { DBUG_ASSERT(phase == ddl_log_entry_phases[action]); - /* Same effect as setting DDL_IGNORE_LOG_ENTRY_CODE */ + /* Same effect as setting DDL_LOG_IGNORE_ENTRY_CODE */ phase= DDL_LOG_FINAL_PHASE; } file_entry_buf[DDL_LOG_PHASE_POS]= phase; @@ -1306,7 +1306,7 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, ddl_log_entry->from_name.str, ddl_log_entry->tmp_name.str)); - if (ddl_log_entry->entry_type == DDL_IGNORE_LOG_ENTRY_CODE || + if (ddl_log_entry->entry_type == DDL_LOG_IGNORE_ENTRY_CODE || ddl_log_entry->phase == DDL_LOG_FINAL_PHASE) DBUG_RETURN(FALSE); @@ -1421,7 +1421,7 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, (void) file->ha_rename_table(ddl_log_entry->tmp_name.str, ddl_log_entry->name.str); /* disable the entry and sync */ - file_entry_buf[DDL_LOG_ENTRY_TYPE_POS]= DDL_IGNORE_LOG_ENTRY_CODE; + file_entry_buf[DDL_LOG_ENTRY_TYPE_POS]= DDL_LOG_IGNORE_ENTRY_CODE; (void) write_ddl_log_file_entry(entry_pos); (void) ddl_log_sync_no_lock(); break; @@ -2400,7 +2400,7 @@ static bool ddl_log_execute_entry_no_lock(THD *thd, uint first_entry) break; } DBUG_ASSERT(ddl_log_entry.entry_type == DDL_LOG_ENTRY_CODE || - ddl_log_entry.entry_type == DDL_IGNORE_LOG_ENTRY_CODE); + ddl_log_entry.entry_type == DDL_LOG_IGNORE_ENTRY_CODE); if (ddl_log_execute_action(thd, &mem_root, &ddl_log_entry)) { @@ -2902,23 +2902,24 @@ void ddl_log_complete(DDL_LOG_STATE *state) This is called for failed rename table, create trigger or drop trigger. */ -void ddl_log_revert(THD *thd, DDL_LOG_STATE *state) +bool ddl_log_revert(THD *thd, DDL_LOG_STATE *state) { + bool res= 0; DBUG_ENTER("ddl_log_revert"); if (unlikely(!state->list)) - DBUG_VOID_RETURN; // ddl log not used + DBUG_RETURN(0); // ddl log not used mysql_mutex_lock(&LOCK_gdl); if (likely(state->execute_entry)) { - ddl_log_execute_entry_no_lock(thd, state->list->entry_pos); + res= ddl_log_execute_entry_no_lock(thd, state->list->entry_pos); ddl_log_disable_execute_entry(&state->execute_entry); } ddl_log_release_entries(state); mysql_mutex_unlock(&LOCK_gdl); state->list= 0; - DBUG_VOID_RETURN; + DBUG_RETURN(res); } @@ -3124,6 +3125,16 @@ bool ddl_log_drop_view_init(THD *thd, DDL_LOG_STATE *ddl_state, db, &empty_clex_str); } + +/** + Log DROP TABLE to the ddl log. + + This code does not call ddl_log_write() as we want the events to + be stored in call order instead of reverse order, which is the normal + case for all other events. + See also comment before ddl_log_drop_init(). +*/ + static bool ddl_log_drop(THD *thd, DDL_LOG_STATE *ddl_state, ddl_log_action_code action_code, uint phase, |