diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2021-11-03 12:31:47 +0300 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2021-11-03 12:31:47 +0300 |
commit | b3bdc1c1425948295156b35b1dbed3f18deb4865 (patch) | |
tree | efd0b498a78ea9e8a56aabf3f3820ff220815822 /sql/handler.h | |
parent | a8ded395578ccab9c256b9beee7e62d4ada08522 (diff) | |
download | mariadb-git-b3bdc1c1425948295156b35b1dbed3f18deb4865.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).
There is a case when implicit primary key may be changed when removing
NOT NULL from the part of unique key. In that case we update
modified_primary_key which is then used to not skip key sorting.
According to is_candidate_key() there is no other cases when primary
key may be changed implicitly.
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.
Diffstat (limited to 'sql/handler.h')
-rw-r--r-- | sql/handler.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/sql/handler.h b/sql/handler.h index 38c78e1961f..e58f56122d7 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -479,6 +479,7 @@ enum chf_create_flags { #define HA_CREATE_TMP_ALTER 8U #define HA_LEX_CREATE_SEQUENCE 16U #define HA_VERSIONED_TABLE 32U +#define HA_SKIP_KEY_SORT 64U #define HA_MAX_REC_LENGTH 65535 |