diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2021-11-02 04:52:03 +0300 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2021-11-02 04:52:03 +0300 |
commit | 63c922ae0c9e5896505f3843eeb0524ae97fe779 (patch) | |
tree | 895298d1605b34f5f854969f4c642c65418b7829 /storage | |
parent | 1203b65849cd1ecefe5f2df07f3165b9aa5e2a9d (diff) | |
download | mariadb-git-63c922ae0c9e5896505f3843eeb0524ae97fe779.tar.gz |
MDEV-25803 Inplace ALTER breaks MyISAM/Aria table when order of keys is changed
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.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/maria/ha_maria.cc | 5 | ||||
-rw-r--r-- | storage/myisam/mi_create.c | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index c0163473f3a..12a55f2349e 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -707,6 +707,11 @@ static int table2maria(TABLE *table_arg, data_file_type row_type, - compare SPATIAL keys; - compare FIELD_SKIP_ZERO which is converted to FIELD_NORMAL correctly (should be correctly detected in table2maria). + + FIXME: + maria_check_definition() is never used! CHECK TABLE does not detect the + corruption! Do maria_check_definition() like check_definition() is done + by MyISAM (related to MDEV-25803). */ int maria_check_definition(MARIA_KEYDEF *t1_keyinfo, diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index de516d9fb6a..ebe139bb342 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -711,7 +711,11 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, } #endif - /* Write key and keyseg definitions */ + /* Write key and keyseg definitions + + TODO: update key and keyseg definitions for inplace alter (grep sql layer by + MDEV-25803). Do the same for Aria. + */ DBUG_PRINT("info", ("write key and keyseg definitions")); for (i=0 ; i < share.base.keys - uniques; i++) { |