summaryrefslogtreecommitdiff
path: root/sql/ddl_log.h
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2021-01-17 16:34:01 +0200
committerSergei Golubchik <serg@mariadb.org>2021-05-19 22:54:13 +0200
commitd494abd175d45aa114efbe3c35e2e765441b65b5 (patch)
tree95cf4287893c649a7ee8101662a9cad21d4b24e1 /sql/ddl_log.h
parent6aa9a552c213246d4db6cfce78c75fd4b7f32df5 (diff)
downloadmariadb-git-d494abd175d45aa114efbe3c35e2e765441b65b5.tar.gz
MDEV-24607 Atomic CREATE VIEW
The logic of the new code is: - Log CREATE view to DDL log, with a marker if old view existed - If old view exists (in case of CREATE or REPLACE view), make a copy of the old view as view_name.frm- - Create the new view definition file - Delete copy of view if it was created. Crash recovery: - Delete view_name.frm~ file (Temporary file for view definition) - If query was logged to binary log - Delete copy of view if it exists - else -rename the copy of the view over the .frm file (restoring the old definition) One benefit of the new code is that CREATE OR REPLACE VIEW for an existing view is no fully atomic: Either the view will be replaced or the old one will be left unchanged.
Diffstat (limited to 'sql/ddl_log.h')
-rw-r--r--sql/ddl_log.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/sql/ddl_log.h b/sql/ddl_log.h
index 368b887b6c5..38c0129f4bf 100644
--- a/sql/ddl_log.h
+++ b/sql/ddl_log.h
@@ -83,6 +83,8 @@ enum ddl_log_action_code
DDL_LOG_DROP_TRIGGER_ACTION= 10,
DDL_LOG_DROP_DB_ACTION=11,
DDL_LOG_CREATE_TABLE_ACTION=12,
+ DDL_LOG_CREATE_VIEW_ACTION=13,
+ DDL_LOG_DELETE_TMP_FILE_ACTION=14,
DDL_LOG_LAST_ACTION /* End marker */
};
@@ -125,6 +127,14 @@ enum enum_ddl_log_create_table_phase {
DDL_CREATE_TABLE_PHASE_END
};
+enum enum_ddl_log_create_view_phase {
+ DDL_CREATE_VIEW_PHASE_NO_OLD_VIEW,
+ DDL_CREATE_VIEW_PHASE_DELETE_VIEW_COPY,
+ DDL_CREATE_VIEW_PHASE_OLD_VIEW_COPIED,
+ DDL_CREATE_VIEW_PHASE_END
+};
+
+
/*
Setting ddl_log_entry.phase to this has the same effect as setting
the phase to the maximum phase (..PHASE_END) for an entry.
@@ -266,5 +276,11 @@ bool ddl_log_create_table(THD *thd, DDL_LOG_STATE *ddl_state,
const LEX_CSTRING *db,
const LEX_CSTRING *table,
bool only_frm);
+bool ddl_log_create_view(THD *thd, DDL_LOG_STATE *ddl_state,
+ const LEX_CSTRING *path,
+ enum_ddl_log_create_view_phase phase);
+bool ddl_log_delete_tmp_file(THD *thd, DDL_LOG_STATE *ddl_state,
+ const LEX_CSTRING *path,
+ DDL_LOG_STATE *depending_state);
extern mysql_mutex_t LOCK_gdl;
#endif /* DDL_LOG_INCLUDED */