diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-01-24 14:43:29 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-01-24 14:43:29 +0200 |
commit | 25161e6219de4a65b7f8776771bad2af6eb0446e (patch) | |
tree | 28a3488cb929d63620d81d8ce4e0f42d0540ad65 /sql/sql_table.cc | |
parent | 7930ab7e3326408e6b4d18ca057db93a8b61cc49 (diff) | |
parent | 65350042a42b46e63d24e0e84453619d57d4e203 (diff) | |
download | mariadb-git-25161e6219de4a65b7f8776771bad2af6eb0446e.tar.gz |
Merge 10.1 into 10.2
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 9e72278db8d..1b426f80a88 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -6634,6 +6634,12 @@ static bool fill_alter_inplace_info(THD *thd, KEY *new_key; KEY *new_key_end= ha_alter_info->key_info_buffer + ha_alter_info->key_count; + /* + Primary key index for the new table + */ + const KEY* const new_pk= (ha_alter_info->key_count > 0 && + is_candidate_key(ha_alter_info->key_info_buffer)) ? + ha_alter_info->key_info_buffer : NULL; DBUG_PRINT("info", ("index count old: %d new: %d", table->s->keys, ha_alter_info->key_count)); @@ -6709,6 +6715,16 @@ static bool fill_alter_inplace_info(THD *thd, goto index_changed; } + /* + Rebuild the index if following condition get satisfied: + + (i) Old table doesn't have primary key, new table has it and vice-versa + (ii) Primary key changed to another existing index + */ + if ((new_key == new_pk) != + ((uint) (table_key - table->key_info) == table->s->primary_key)) + goto index_changed; + /* Check that key comment is not changed. */ if (table_key->comment.length != new_key->comment.length || (table_key->comment.length && |