From 01b2e773ef7a19dbd28a345021cd3a9aa6b10603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 20 Apr 2018 10:35:22 +0300 Subject: 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. --- storage/xtradb/handler/handler0alter.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'storage/xtradb/handler') 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++; -- cgit v1.2.1