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

LP:775661 - Incorrect index name when dropping/adding index in the same statement

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 10.0.1, 5.5.30, 5.1.67, 5.2.14, 5.3.12
    • 10.0.4
    • None

    Description

      Not sure if this is a Percona Server or a MySQL bug, I'll report it here and let you decide. I've tested this both against 5.5.11-55 Percona Server (GPL), Release 20.2 and 5.1.56-rel12.7 (Percona Server (GPL), 12.7, Revision 224). I can't seem to be able to drop and create an index with the same name with a single statement:

      CREATE TABLE `txtest` (
        `id` int(11) NOT NULL AUTO_INCREMENT,
        `sec` int(11) DEFAULT NULL,
        PRIMARY KEY (`id`),
        KEY `sec` (`sec`)
      ) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8;
       
      ALTER TABLE txtest DROP KEY sec, ADD KEY (sec, id);
      ERROR 1280 (42000): Incorrect index name 'sec'
       
      mysql> ALTER TABLE txtest DROP KEY sec;
      Query OK, 0 rows affected (0.00 sec)
      Records: 0  Duplicates: 0  Warnings: 0
       
      mysql> ALTER TABLE txtest ADD KEY (sec, id);
      Query OK, 0 rows affected (0.00 sec)
      Records: 0  Duplicates: 0  Warnings: 0

      Oh and interestingly enough if I explicitly specify the index name, it seems to work:

      mysql> ALTER TABLE txtest DROP KEY sec, ADD KEY sec (sec, id);
      Query OK, 12 rows affected (0.00 sec)
      Records: 12  Duplicates: 0  Warnings: 0

      As a side note, I wonder why when I'm running two statements I get 0 rows affected both times while in the last example it says 12 rows affected (which is total amount of rows in that table).

      Attachments

        Activity

          People

            serg Sergei Golubchik
            aurimasmikalauskas Aurimas Mikalauskas (Inactive)
            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.