--innodb-optimize-keys does not work correctly with table without PRIMARY KEY

Bug #851674 reported by Alexey Kopytov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Server moved to https://jira.percona.com/projects/PS
Fix Released
Undecided
Alexey Kopytov
5.1
Fix Released
Undecided
Alexey Kopytov
5.5
Fix Released
Undecided
Alexey Kopytov
Rnt-5.1
Fix Released
Undecided
Alexey Kopytov

Bug Description

The mysqldump option --innodb-optimize-keys does not work correctly with tables where the first UNIQUE key on non-nullable columns was picked as the clustered index by InnoDB in the absence of a PRIMARY KEY.

Example:

mysql> CREATE TABLE t1 (a INT NOT NULL, UNIQUE KEY (a)) ENGINE=InnoDB;
Query OK, 0 rows affected (0.02 sec)

mysql> SHOW COLUMNS FROM t1;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| a | int(11) | NO | PRI | NULL | |
+-------+---------+------+-----+---------+-------+
1 row in set (0.00 sec)

Output of mysqldump --innodb-optimize-keys:

CREATE TABLE `t1` (
  `a` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
...
ALTER TABLE `t1` ADD UNIQUE KEY `a` (`a`);

The optimization should detect such tables and keep the unique key in CREATE TABLE.

Tags: cr i14678

Related branches

Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-2681

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.