Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-15937

Assertion failure 'key->flags & 1' on ALTER TABLE

    XMLWordPrintable

Details

    Description

      This was originally reported by Roel as MySQL Bug #89087 Assertion `key->flags & 1' failed.

      CREATE TABLE t1(c1 INT) ENGINE=InnoDB;
      ALTER TABLE t1 ADD CONSTRAINT UNIQUE KEY i1(c1);
      ALTER TABLE t1 CHANGE c1 c1 INT NOT NULL,ADD KEY(c1);
      DROP TABLE t1;
      

      There is a fix for this in MySQL 8.0.11, but I think that we should fix this differently in MariaDB, and starting from the first potentially affected version (10.0). I was not able to repeat a failure on 10.0 even after adding a debug assertion.

      For 10.2, the minimal fix should be as follows:

      diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
      index 02a8428cdc9..20bac687ccf 100644
      --- a/storage/innobase/handler/handler0alter.cc
      +++ b/storage/innobase/handler/handler0alter.cc
      @@ -2597,10 +2597,8 @@ innobase_create_key_defs(
       				DBUG_ASSERT(got_default_clust);
       				DBUG_ASSERT(altered_table->s->primary_key
       					    == 0);
      -				primary_key_number = 0;
      -			} else {
      -				primary_key_number = *add;
       			}
      +			primary_key_number = altered_table->s->primary_key;
       		} else if (got_default_clust) {
       			/* Create the GEN_CLUST_INDEX */
       			index_def_t*	index = indexdef++;
      

      Attachments

        Activity

          People

            marko Marko Mäkelä
            marko Marko Mäkelä
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.