summaryrefslogtreecommitdiff
path: root/storage/myisam
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2021-11-03 12:31:47 +0300
committerAleksey Midenkov <midenok@gmail.com>2021-11-03 12:31:47 +0300
commitb3bdc1c1425948295156b35b1dbed3f18deb4865 (patch)
treeefd0b498a78ea9e8a56aabf3f3820ff220815822 /storage/myisam
parenta8ded395578ccab9c256b9beee7e62d4ada08522 (diff)
downloadmariadb-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 'storage/myisam')
-rw-r--r--storage/myisam/mi_create.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c
index 51354e0e8b5..30537cef3e7 100644
--- a/storage/myisam/mi_create.c
+++ b/storage/myisam/mi_create.c
@@ -713,7 +713,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++)
{