Incorrect index name when dropping/adding index in the same statement
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
New
|
Undecided
|
Unassigned | ||
MySQL Server |
Fix Released
|
Undecided
|
Unassigned | ||
Percona Server moved to https://jira.percona.com/projects/PS |
Won't Fix
|
Low
|
Unassigned |
Bug 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).
Changed in percona-server: | |
status: | New → Confirmed |
importance: | Undecided → Low |
That behavior is also present in the upstream server. I only checked 5.5.11, but I'm fairly sure it's in 5.1 as well.