• Nikita Malyavin's avatar
    MDEV-23632 ALTER TABLE...ADD KEY creates corrupted index on virtual column · 9a645dae
    Nikita Malyavin authored
    mysql_col_offset was not updated after the new column has been added by an
    INSTANT ALTER TABLE -- table data dictionary had been remaining the same.
    
    When the virtual column is added or removed, table was usually evicted and
    then reopened, which triggered vcol info rebuild on the next open.
    
    However this also should be done when the usual column is added or removed:
    mariadb always stores virtual field at the end of maria record,
    so the shift should always happen.
    
    Fix:
    expand the eviction condition to the case when usual fields are
    added/removed
    
    Note:
    this should happen only in the case of !new_clustered:
    * When new_clustered is true, a new data dictionary is created, and vcol
    metadata is rebuilt in `alter_rebuild_apply_log()`
    * We can't do it in `new_clustered` case, because the old table is not yet
    subctituted correctly
    9a645dae
innodb-virtual-columns2.test 1.99 KB