• Marko Mäkelä's avatar
    MDEV-26294 Duplicate entries in unique index not detected when changing collation · f8240a27
    Marko Mäkelä authored
    Problem:
    =======
    ALTER TABLE in InnoDB fails to detect duplicate entries
    for the unique index when the character set or collation of
    an indexed column is changed in such a way that the character
    encoding is compatible with the old table definition.
    In this case, any secondary indexes on the changed columns
    would be rebuilt (DROP INDEX, ADD INDEX).
    
    Solution:
    ========
    During ALTER TABLE, InnoDB keeps track of columns whose collation
    changed, and will fill in the correct metadata when sorting the
    index records, or applying changes from concurrent DML.
    This metadata will be allocated in the dict_index_t::heap of
    the being-created secondary indexes.
    
    The fix was developed by Thirunarayanan Balathandayuthapani
    and simplified by me.
    f8240a27
change_column_collation.test 3.44 KB