• Marko Mäkelä's avatar
    MDEV-20590 Introduce a file format constraint to ALTER TABLE · b092d35f
    Marko Mäkelä authored
    If a table is altered using the MDEV-11369/MDEV-15562/MDEV-13134
    ALGORITHM=INSTANT, it can force the table to use a non-canonical
    format:
    
    * A hidden metadata record at the start of the clustered index
    is used to store each column's DEFAULT value. This makes it possible
    to add new columns that have default values without rebuilding the table.
    
    * Starting with MDEV-15562 in MariaDB Server 10.4, a BLOB in the
    hidden metadata record is used to store column mappings. This makes
    it possible to drop or reorder columns without rebuilding the table.
    This also makes it possible to add columns to any position or drop
    columns from any position in the table without rebuilding the table.
    
    If a column is dropped without rebuilding the table, old records
    will contain garbage in that column's former position, and new records
    will be written with NULL values, empty strings, or dummy values.
    
    This is generally not a problem. However, there may be cases where
    users may want to avoid putting a table into this format.
    For example, users may want to ensure that future UPDATE operations
    after an ADD COLUMN will be performed in-place, to reduce write
    amplification. (Instantly added columns are essentially always
    variable-length.) Users might also want to avoid bugs similar to
    MDEV-19916, or they may want to be able to export tables to
    older versions of the server.
    
    We will introduce the option innodb_instant_alter_column_allowed,
    with the following values:
    
    * never (0): Do not allow instant add/drop/reorder,
    to maintain format compatibility with MariaDB 10.x and MySQL 5.x.
    If the table (or partition) is not in the canonical format, then
    any ALTER TABLE (even one that does not involve instant column
    operations) will force a table rebuild.
    
    * add_last (1, default in 10.3): Store a hidden metadata record that
    allows columns to be appended to the table instantly (MDEV-11369).
    In 10.4 or later, if the table (or partition) is not in this format,
    then any ALTER TABLE (even one that does not involve column changes)
    will force a table rebuild.
    
    Starting with 10.4:
    
    * add_drop_reorder (2, default): Like 'add_last', but allow the
    metadata record to store a column map, to support instant
    add/drop/reorder of columns (MDEV-15562).
    b092d35f
instant_alter.result 128 KB