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

Alter table (renaming and adding index) fails with "Incorrect key file for table"

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 10.0.18, 10.0.23
    • N/A
    • None
    • Ubuntu 14.04.1 LTS x86_64, 10.0.23 built from source

    Description

      When renaming a column and adding an index on the renamed column in the same alter statement, said statement fails with:

      ERROR 1034 (HY000): Incorrect key file for table 't'; try to repair it

      This can be reproduced consistently as follows:

      DROP TABLE IF EXISTS t;
       
      CREATE TABLE t (
              a INT NOT NULL,
              b INT NOT NULL,
              PRIMARY KEY (a)
      );
       
      ALTER TABLE t
              CHANGE COLUMN b c INT NOT NULL,
              ADD UNIQUE INDEX (c);

      In debug builds, the following (or similar) is written to the error log:

      InnoDB: Error: no matching column for "<8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f><8f>" in index "c"--temporary-- of table "db"."t"!

      This seems to have been broken in 10.0.18 (possibly related to the virtual column changes), as the query succeeds in 10.0.17 and earlier.

      Attachments

        Issue Links

          Activity

            This bug affects only InnoDB tables when used with algorithm=inplace

            MyISAM tables and also using algorithm=copy works

            monty Michael Widenius added a comment - This bug affects only InnoDB tables when used with algorithm=inplace MyISAM tables and also using algorithm=copy works

            We already have this one, MDEV-9469.

            elenst Elena Stepanova added a comment - We already have this one, MDEV-9469 .

            commit c0b6c27dbede85952b3e6cd04b6393267e1aa656
            Author: Jan Lindström <jan.lindstrom@mariadb.com>
            Date: Mon Feb 15 14:43:42 2016 +0200

            MDEV-9548: Alter table (renaming and adding index) fails with "Incorrect key file for table"
            MDEV-9469: 'Incorrect key file' on ALTER TABLE

            InnoDB needs to rebuild table if column name is changed and
            added index (or foreign key) is created based on this new
            name in same alter table.

            jplindst Jan Lindström (Inactive) added a comment - commit c0b6c27dbede85952b3e6cd04b6393267e1aa656 Author: Jan Lindström <jan.lindstrom@mariadb.com> Date: Mon Feb 15 14:43:42 2016 +0200 MDEV-9548 : Alter table (renaming and adding index) fails with "Incorrect key file for table" MDEV-9469 : 'Incorrect key file' on ALTER TABLE InnoDB needs to rebuild table if column name is changed and added index (or foreign key) is created based on this new name in same alter table.

            People

              jplindst Jan Lindström (Inactive)
              davidgow David Gow
              Votes:
              0 Vote for this issue
              Watchers:
              6 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.