The purpose of this task is to ensure that DROP TRIGGER is atomic.
Description of how atomic drop trigger should work:
Logging of DROP TRIGGER
- Log to ddl log:
- 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.
- 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 */