summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2021-06-17 16:06:46 +0300
committerMonty <monty@mariadb.org>2021-06-19 03:46:00 +0300
commit87de0e2129fbc1ade1d129520f1ebf0338672321 (patch)
tree1b6147712ab5ca2ba7a669424a295e3771db0263
parent83a471344f448950956b914e1150e845833a71ee (diff)
downloadmariadb-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
-rw-r--r--sql/ddl_log.cc29
-rw-r--r--sql/ddl_log.h6
-rw-r--r--sql/sql_trigger.cc2
3 files changed, 24 insertions, 13 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,
diff --git a/sql/ddl_log.h b/sql/ddl_log.h
index 7033539963d..a2a6af76a77 100644
--- a/sql/ddl_log.h
+++ b/sql/ddl_log.h
@@ -34,13 +34,13 @@ enum ddl_log_entry_code
DDL_LOG_ENTRY_CODE:
An entry to be executed in a linked list from an execute log
entry.
- DDL_IGNORE_LOG_ENTRY_CODE:
+ DDL_LOG_IGNORE_ENTRY_CODE:
An entry that is to be ignored
*/
DDL_LOG_UNKNOWN= 0,
DDL_LOG_EXECUTE_CODE= 1,
DDL_LOG_ENTRY_CODE= 2,
- DDL_IGNORE_LOG_ENTRY_CODE= 3,
+ DDL_LOG_IGNORE_ENTRY_CODE= 3,
DDL_LOG_ENTRY_CODE_LAST= 4
};
@@ -267,7 +267,7 @@ bool ddl_log_write_execute_entry(uint first_entry,
bool ddl_log_disable_execute_entry(DDL_LOG_MEMORY_ENTRY **active_entry);
void ddl_log_complete(DDL_LOG_STATE *ddl_log_state);
-void ddl_log_revert(THD *thd, DDL_LOG_STATE *ddl_log_state);
+bool ddl_log_revert(THD *thd, DDL_LOG_STATE *ddl_log_state);
bool ddl_log_update_phase(DDL_LOG_STATE *entry, uchar phase);
bool ddl_log_add_flag(DDL_LOG_STATE *entry, uint16 flag);
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 81d6fedb4e3..379461cc32c 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -697,7 +697,7 @@ end:
ddl_log_complete(&ddl_log_state);
debug_crash_here("ddl_log_drop_before_delete_tmp");
/* delete any created log files */
- ddl_log_revert(thd, &ddl_log_state_tmp_file);
+ result|= ddl_log_revert(thd, &ddl_log_state_tmp_file);
/*
If we are under LOCK TABLES we should restore original state of
meta-data locks. Otherwise all locks will be released along