summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-01-24 13:24:13 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-01-24 13:24:13 +0200
commit65350042a42b46e63d24e0e84453619d57d4e203 (patch)
tree2aeb90cdca361657af443d65cfd6aef82506e299 /sql
parentba1ce3aeae49b6c8055d673e6dafff741f1a9713 (diff)
parentedeba0c8733409865c3abcab881af0d48b7be94f (diff)
downloadmariadb-git-65350042a42b46e63d24e0e84453619d57d4e203.tar.gz
Merge 10.0 into 10.1
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_table.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 3db7dc76011..670838a4cbb 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -6485,6 +6485,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));
@@ -6560,6 +6566,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 &&