• Aleksey Midenkov's avatar
    MDEV-22166 CONVERT PARTITION: move out partition into a table · b7bba721
    Aleksey Midenkov authored
    Syntax for CONVERT keyword
    
    ALTER TABLE tbl_name
        [alter_option [, alter_option] ...] |
        [partition_options]
    
    partition_option: {
        ...
        | CONVERT PARTITION partition_name TO TABLE tbl_name
    }
    
    Examples:
    
        ALTER TABLE t1 CONVERT PARTITION p2 TO TABLE tp2;
    
    New ALTER_PARTITION_CONVERT_OUT command for
    fast_alter_partition_table() is done in alter_partition_convert_out()
    function which basically does ha_rename_table().
    
    Partition to extract is marked with the same flag as dropped
    partition: PART_TO_BE_DROPPED. Note that we cannot have multiple
    partitioning commands in one ALTER.
    
    For DDL logging basically the principle is the same as for other
    fast_alter_partition_table() commands. The only difference is that it
    integrates late Atomic DDL functions and introduces additional phase
    of WFRM_BACKUP_ORIGINAL. That is required for binlog consistency
    because otherwise we could not revert back after WFRM_INSTALL_SHADOW
    is done. And before DDL log is complete if we crash or fail the
    altered table will be already new but binlog will miss that ALTER
    command. Note that this is different from all other atomic DDL in that
    it rolls back until the ddl_log_complete() is done even if everything
    was done fully before the crash.
    
    Test cases added to:
    
      parts.alter_table \
      parts.partition_debug \
      versioning.partition \
      atomic.alter_partition
    b7bba721
sql_yacc.yy 582 KB