diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-04-20 10:35:22 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-04-23 13:04:58 +0300 |
commit | 01b2e773ef7a19dbd28a345021cd3a9aa6b10603 (patch) | |
tree | db8051f56c54de6dc7a6e05fffa2e03ee572308d /storage | |
parent | f2433b8dd3c10b1e26a6f0b98dfbaa45b22fe0af (diff) | |
download | mariadb-git-01b2e773ef7a19dbd28a345021cd3a9aa6b10603.tar.gz |
MDEV-15937 Assertion failure 'key->flags & 1' on ALTER TABLE
While the test case crashes a MariaDB 10.2 debug build only,
let us apply the fix to the earliest applicable MariaDB series (10.0)
to avoid any data corruption on a table-rebuilding ALTER TABLE
using ALGORITHM=INPLACE.
innobase_create_key_defs(): Use altered_table->s->primary_key
when a new primary key is being created.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/handler/handler0alter.cc | 12 | ||||
-rw-r--r-- | storage/xtradb/handler/handler0alter.cc | 12 |
2 files changed, 8 insertions, 16 deletions
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 8761d5434b5..8a9ec1865b4 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -1594,6 +1594,7 @@ innobase_create_index_def( if (key_clustered) { DBUG_ASSERT(!(key->flags & HA_FULLTEXT)); + DBUG_ASSERT(key->flags & HA_NOSAME); index->ind_type |= DICT_CLUSTERED; } else if (key->flags & HA_FULLTEXT) { DBUG_ASSERT(!(key->flags & HA_KEYFLAG_MASK @@ -1909,14 +1910,9 @@ innobase_create_key_defs( ulint primary_key_number; if (new_primary) { - if (n_add == 0) { - DBUG_ASSERT(got_default_clust); - DBUG_ASSERT(altered_table->s->primary_key - == 0); - primary_key_number = 0; - } else { - primary_key_number = *add; - } + DBUG_ASSERT(n_add || got_default_clust); + DBUG_ASSERT(n_add || !altered_table->s->primary_key); + primary_key_number = altered_table->s->primary_key; } else if (got_default_clust) { /* Create the GEN_CLUST_INDEX */ index_def_t* index = indexdef++; diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc index e5be3aea44a..4a50b324e22 100644 --- a/storage/xtradb/handler/handler0alter.cc +++ b/storage/xtradb/handler/handler0alter.cc @@ -1595,6 +1595,7 @@ innobase_create_index_def( if (key_clustered) { DBUG_ASSERT(!(key->flags & HA_FULLTEXT)); + DBUG_ASSERT(key->flags & HA_NOSAME); index->ind_type |= DICT_CLUSTERED; } else if (key->flags & HA_FULLTEXT) { DBUG_ASSERT(!(key->flags & HA_KEYFLAG_MASK @@ -1910,14 +1911,9 @@ innobase_create_key_defs( ulint primary_key_number; if (new_primary) { - if (n_add == 0) { - DBUG_ASSERT(got_default_clust); - DBUG_ASSERT(altered_table->s->primary_key - == 0); - primary_key_number = 0; - } else { - primary_key_number = *add; - } + DBUG_ASSERT(n_add || got_default_clust); + DBUG_ASSERT(n_add || !altered_table->s->primary_key); + primary_key_number = altered_table->s->primary_key; } else if (got_default_clust) { /* Create the GEN_CLUST_INDEX */ index_def_t* index = indexdef++; |