diff options
author | Monty <monty@mariadb.org> | 2020-12-14 15:57:04 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2021-05-19 22:54:13 +0200 |
commit | 407e9b78cf64a3b8aca441ab585601e173f9ba32 (patch) | |
tree | 242f7059e66a0a08ace9183e07e87284e6f412b6 /sql/sql_trigger.h | |
parent | e3cfb7c8034f4281029f81996cff8d938f06ec67 (diff) | |
download | mariadb-git-407e9b78cf64a3b8aca441ab585601e173f9ba32.tar.gz |
MDEV-24395 Atomic DROP TRIGGER
The purpose of this task is to ensure that DROP TRIGGER is atomic.
Description of how atomic drop trigger works:
Logging of DROP TRIGGER
Log the following information:
db
table name
trigger name
xid /* Used to check if query was already logged to binary log */
initial length of the .TRG file
query if there is space for it, if not log a zero length query.
Recovery operations:
- Delete if exists 'database/trigger_name.TRN~'
- If this file existed, it means that we crashed before the trigger
was deleted and there is nothing else to do.
- Get length of .TRG file
- If file length is unchanged, trigger was not dropped. Nothing else to
do.
- Log original query to binary, if it was stored in the ddl log. If it was
not stored (long query string), log the following query to binary log:
use `database` ; DROP TRIGGER IF EXISTS `trigger_name`
/* generated by ddl log */;
Other things:
- Added trigger name and DDL_LOG_STATE to drop_trigger()
Trigger name was added to make the interface more consistent and
more general.
Diffstat (limited to 'sql/sql_trigger.h')
-rw-r--r-- | sql/sql_trigger.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h index 040d8eba989..f0eae8c348f 100644 --- a/sql/sql_trigger.h +++ b/sql/sql_trigger.h @@ -28,6 +28,7 @@ class sp_name; class Query_tables_list; struct TABLE_LIST; class Query_tables_list; +typedef struct st_ddl_log_state DDL_LOG_STATE; /** Event on which trigger is invoked. */ enum trg_event_type @@ -220,7 +221,9 @@ public: ~Table_triggers_list(); bool create_trigger(THD *thd, TABLE_LIST *table, String *stmt_query); - bool drop_trigger(THD *thd, TABLE_LIST *table, String *stmt_query); + bool drop_trigger(THD *thd, TABLE_LIST *table, + LEX_CSTRING *sp_name, + String *stmt_query, DDL_LOG_STATE *ddl_log_state); bool process_triggers(THD *thd, trg_event_type event, trg_action_time_type time_type, bool old_row_is_record1); @@ -324,6 +327,8 @@ bool load_table_name_for_trigger(THD *thd, const LEX_CSTRING *trn_path, LEX_CSTRING *tbl_name); bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create); +bool rm_trigname_file(char *path, const LEX_CSTRING *db, + const LEX_CSTRING *trigger_name, myf MyFlags); extern const char * const TRG_EXT; extern const char * const TRN_EXT; |