mysqldump --innodb-optimize-keys produces incorrect CREATE TABLE statement for partitioned tables
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Server moved to https://jira.percona.com/projects/PS |
Fix Released
|
Medium
|
Patryk Pomykalski | ||
5.1 |
Won't Fix
|
Medium
|
Unassigned | ||
5.5 |
Fix Released
|
Medium
|
Patryk Pomykalski | ||
5.6 |
Fix Released
|
Medium
|
Patryk Pomykalski |
Bug Description
mysqldump --innodb-
Here an example:
mysql [localhost] {msandbox} (test) > SELECT @@version;
+------
| @@version |
+------
| 5.5.33-rel31.1-log |
+------
1 row in set (0.00 sec)
mysql [localhost] {msandbox} ((none)) > use test
Database changed
mysql [localhost] {msandbox} (test) > CREATE TABLE tb1 (id INT NOT NULL AUTO_INCREMENT, created datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id, created), c1 INT, c2 INT, INDEX (c1), INDEX(c2))
-> ENGINE=INNODB DEFAULT CHARSET=utf8 ROW_FORMAT=
-> PARTITION BY RANGE (TO_DAYS(created))
-> (PARTITION p83 VALUES LESS THAN (735484) ENGINE = InnoDB,
-> PARTITION p84 VALUES LESS THAN (735491) ENGINE = InnoDB,
-> PARTITION p85 VALUES LESS THAN (735498) ENGINE = InnoDB
-> );
Query OK, 0 rows affected (0.01 sec)
mysql [localhost] {msandbox} (test) > SHOW CREATE TABLE tb1\G
*******
Table: tb1
Create Table: CREATE TABLE `tb1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL,
PRIMARY KEY (`id`,`created`),
KEY `c1` (`c1`),
KEY `c2` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=
/*!50100 PARTITION BY RANGE (TO_DAYS(created))
(PARTITION p83 VALUES LESS THAN (735484) ENGINE = InnoDB,
PARTITION p84 VALUES LESS THAN (735491) ENGINE = InnoDB,
PARTITION p85 VALUES LESS THAN (735498) ENGINE = InnoDB) */
1 row in set (0.00 sec)
[rene@db-bkup msb_5_5_33]$ ./my sqldump --innodb-
-- MySQL dump 10.13 Distrib 5.5.33, for Linux (x86_64)
--
-- Host: localhost Database: test
-- -------
-- Server version 5.5.33-rel31.1-log
/*!40101 SET @OLD_CHARACTER_
/*!40101 SET @OLD_CHARACTER_
/*!40101 SET @OLD_COLLATION_
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_
/*!40014 SET @OLD_FOREIGN_
/*!40101 SET @OLD_SQL_
/*!40111 SET @OLD_SQL_
--
-- Table structure for table `tb1`
--
DROP TABLE IF EXISTS `tb1`;
/*!40101 SET @saved_cs_client = @@character_
/*!40101 SET character_
CREATE TABLE `tb1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL,
PRIMARY KEY (`id`,`created`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=
/*!50100 PARTITION BY RANGE (TO_DAYS(created))
(PARTITION p83 VALUES LESS THAN (735484) ENGINE = InnoDB,
PARTITION p84 VALUES LESS THAN (735491) ENGINE = InnoDB,
PARTITION p85 VALUES LESS THAN (735498) ENGINE = InnoDB) */;
/*!40101 SET character_
--
-- Dumping data for table `tb1`
--
LOCK TABLES `tb1` WRITE;
/*!40000 ALTER TABLE `tb1` DISABLE KEYS */;
ALTER TABLE `tb1` ADD KEY `c1` (`c1`), ADD KEY `c2` (`c2`);
/*!40000 ALTER TABLE `tb1` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=
/*!40101 SET SQL_MODE=
/*!40014 SET FOREIGN_
/*!40014 SET UNIQUE_
/*!40101 SET CHARACTER_
/*!40101 SET CHARACTER_
/*!40101 SET COLLATION_
/*!40111 SET SQL_NOTES=
-- Dump completed on 2013-10-01 13:14:35
The CREATE TABLE statement has a syntax error here (extra comma) :
PRIMARY KEY (`id`,`created`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=
=======
mysqldump --innodb-
mysql [localhost] {msandbox} (test) > ALTER TABLE tb1 REMOVE PARTITIONING;
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql [localhost] {msandbox} (test) > SHOW CREATE TABLE tb1\G
*******
Table: tb1
Create Table: CREATE TABLE `tb1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL,
PRIMARY KEY (`id`,`created`),
KEY `c1` (`c1`),
KEY `c2` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=
1 row in set (0.00 sec)
mysql [localhost] {msandbox} (test) > \q
Bye
[rene@db-bkup msb_5_5_33]$ ./my sqldump --innodb-
-- MySQL dump 10.13 Distrib 5.5.33, for Linux (x86_64)
--
-- Host: localhost Database: test
-- -------
-- Server version 5.5.33-rel31.1-log
/*!40101 SET @OLD_CHARACTER_
/*!40101 SET @OLD_CHARACTER_
/*!40101 SET @OLD_COLLATION_
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_
/*!40014 SET @OLD_FOREIGN_
/*!40101 SET @OLD_SQL_
/*!40111 SET @OLD_SQL_
--
-- Table structure for table `tb1`
--
DROP TABLE IF EXISTS `tb1`;
/*!40101 SET @saved_cs_client = @@character_
/*!40101 SET character_
CREATE TABLE `tb1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL,
PRIMARY KEY (`id`,`created`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=
/*!40101 SET character_
--
-- Dumping data for table `tb1`
--
LOCK TABLES `tb1` WRITE;
/*!40000 ALTER TABLE `tb1` DISABLE KEYS */;
ALTER TABLE `tb1` ADD KEY `c1` (`c1`), ADD KEY `c2` (`c2`);
/*!40000 ALTER TABLE `tb1` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=
/*!40101 SET SQL_MODE=
/*!40014 SET FOREIGN_
/*!40014 SET UNIQUE_
/*!40101 SET CHARACTER_
/*!40101 SET CHARACTER_
/*!40101 SET COLLATION_
/*!40111 SET SQL_NOTES=
-- Dump completed on 2013-10-01 13:19:31
Related branches
- Alexey Kopytov (community): Approve
-
Diff: 124 lines (+83/-2)3 files modifiedPercona-Server/client/mysqldump.c (+7/-2)
Percona-Server/mysql-test/r/percona_mysqldump_innodb_optimize_keys.result (+49/-0)
Percona-Server/mysql-test/t/percona_mysqldump_innodb_optimize_keys.test (+27/-0)
- Alexey Kopytov (community): Approve
-
Diff: 124 lines (+83/-2)3 files modifiedPercona-Server/client/mysqldump.c (+7/-2)
Percona-Server/mysql-test/r/percona_mysqldump_innodb_optimize_keys.result (+49/-0)
Percona-Server/mysql-test/t/percona_mysqldump_innodb_optimize_keys.test (+27/-0)
information type: | Public → Public Security |
information type: | Public Security → Private Security |
information type: | Private Security → Public Security |
information type: | Public Security → Public |
This is easy to verify:
[openxs@chief p5.5]$ bin/mysql --no-defaults -uroot test
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.32 MySQL Community Server (GPL)
Copyright (c) 2009-2013 Percona Ireland Ltd.
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE TABLE tb1 ( COMPRESSED
-> id INT NOT NULL AUTO_INCREMENT,
-> created datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
-> PRIMARY KEY (id, created),
-> c1 INT,
-> c2 INT,
-> INDEX (c1),
-> INDEX(c2)
-> ) ENGINE=INNODB DEFAULT CHARSET=utf8 ROW_FORMAT=
-> PARTITION BY RANGE (TO_DAYS(created))
-> (
-> PARTITION p83 VALUES LESS THAN (735484) ENGINE = InnoDB,
-> PARTITION p84 VALUES LESS THAN (735491) ENGINE = InnoDB,
-> PARTITION p85 VALUES LESS THAN (735498) ENGINE = InnoDB
-> );
Query OK, 0 rows affected, 6 warnings (0.19 sec)
mysql> show create table tb1\G ******* ******* ****** 1. row ******* ******* ******* ****** COMPRESSED
*******
Table: tb1
Create Table: CREATE TABLE `tb1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL,
PRIMARY KEY (`id`,`created`),
KEY `c1` (`c1`),
KEY `c2` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=
/*!50100 PARTITION BY RANGE (TO_DAYS(created))
(PARTITION p83 VALUES LESS THAN (735484) ENGINE = InnoDB,
PARTITION p84 VALUES LESS THAN (735491) ENGINE = InnoDB,
PARTITION p85 VALUES LESS THAN (735498) ENGINE = InnoDB) */
1 row in set (0.00 sec)
mysql> exit optimize- keys -uroot test tb1 ------- ------- ------- ------- ------- ------- -----
Bye
[openxs@chief p5.5]$ bin/mysqldump --no-defaults --innodb-
-- MySQL dump 10.13 Distrib 5.5.32, for Linux (x86_64)
--
-- Host: localhost Database: test
-- -------
-- Server version 5.5.32
/*!40101 SET @OLD_CHARACTER_ SET_CLIENT= @@CHARACTER_ SET_CLIENT */; SET_RESULTS= @@CHARACTER_ SET_RESULTS */; CONNECTION= @@COLLATION_ CONNECTION */; ZONE=@@ TIME_ZONE */; CHECKS= @@UNIQUE_ CHECKS, UNIQUE_CHECKS=0 */; KEY_CHECKS= @@FOREIGN_ KEY_CHECKS, FOREIGN_ KEY_CHECKS= 0 */; MODE=@@ SQL_MODE, SQL_MODE= 'NO_AUTO_ VALUE_ON_ ZERO' */; NOTES=@ @SQL_NOTES, SQL_NOTES=0 */;
/*!40101 SET @OLD_CHARACTER_
/*!40101 SET @OLD_COLLATION_
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_
/*!40014 SET @OLD_FOREIGN_
/*!40101 SET @OLD_SQL_
/*!40111 SET @OLD_SQL_
--
-- Table structure for table `tb1`
--
DROP TABLE IF EXISTS `tb1`; set_client */; set_client = utf8 */; COMPRESSED
/*!40101 SET @saved_cs_client = @@character_
/*!40101 SET character_
CREATE TABLE `tb1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`c1` int(11) DEFAULT NULL,
`c2` int(11) DEFAULT NULL,
PRIMARY KEY (`id`,`created`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=
/*!501...