• Monty's avatar
    MDEV-24395 Atomic DROP TRIGGER · 407e9b78
    Monty authored
    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.
    407e9b78
ddl_log.cc 67.6 KB