• Aleksey Midenkov's avatar
    MDEV-25803 Inplace ALTER breaks MyISAM/Aria table when order of keys is changed · 63c922ae
    Aleksey Midenkov authored
    mysql_prepare_create_table() does my_qsort(sort_keys) on key
    info. This sorting is indeterministic: a table is created with one
    order and inplace alter may overwrite frm with another order. Since
    inplace alter does nothing about key info for MyISAM/Aria storage
    engines this results in discrepancy between frm and storage engine key
    definitions.
    
    The fix avoids the sorting of keys when no new keys added by ALTER
    (and this is ok for MyISAM/Aria since it cannot add new keys inplace).
    
    Notes:
    
    mi_keydef_write()/mi_keyseg_write() are used only in mi_create(). They
    should be used in ha_inplace_alter_table() as well.
    
    Aria corruption detection is unimplemented: maria_check_definition()
    is never used!
    
    MySQL 8.0 has this bug as well as of 8.0.26.
    
    This breaks main.long_unique in 10.4. The new result is correct and
    should be applied as it just different (original) order of keys.
    63c922ae
mi_create.c 29.1 KB