summaryrefslogtreecommitdiff
path: root/mysql-test/r/partition.result
diff options
context:
space:
mode:
authorMattias Jonsson <mattias.jonsson@oracle.com>2010-11-05 12:01:10 +0100
committerMattias Jonsson <mattias.jonsson@oracle.com>2010-11-05 12:01:10 +0100
commitc04318ed243fd85eeb7256399516a9189e12a0b0 (patch)
tree8b7276925b9532dc104baed751d879884fedf169 /mysql-test/r/partition.result
parent9678beb630abaea8b935bf331fefd3594eb6a66c (diff)
downloadmariadb-git-c04318ed243fd85eeb7256399516a9189e12a0b0.tar.gz
Bug#57778: failed primary key add to partitioned innodb table inconsistent and crashes
It was possible to issue an ALTER TABLE ADD PRIMARY KEY on an partitioned InnoDB table that failed and crashed the server. The problem was that it succeeded to create the PK on at least one partition, and then failed on a subsequent partition, due to duplicate key violation. Since the partitions that already had added the PK was not reverted all partitions was not consistent with the table definition, which caused the crash. The solution was to add a revert step to ha_partition::add_index() that dropped the index for the already succeeded partitions, on failure. mysql-test/r/partition.result: updated result mysql-test/t/partition.test: Added test sql/ha_partition.cc: Only allow ADD/DROP flags in pairs, so that they can be reverted on failures. If add_index() fails for a partition, revert (drop the index) for the previous partitions. sql/handler.h: Added some extra info in a comment.
Diffstat (limited to 'mysql-test/r/partition.result')
-rw-r--r--mysql-test/r/partition.result33
1 files changed, 33 insertions, 0 deletions
diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result
index 80676c0d324..a639f9e6b3b 100644
--- a/mysql-test/r/partition.result
+++ b/mysql-test/r/partition.result
@@ -1,5 +1,38 @@
drop table if exists t1, t2;
#
+# Bug#57778: failed primary key add to partitioned innodb table
+# inconsistent and crashes
+#
+CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL)
+PARTITION BY KEY (a) PARTITIONS 2;
+INSERT INTO t1 VALUES (0,1), (0,2);
+ALTER TABLE t1 ADD PRIMARY KEY (a);
+ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 2 */
+SELECT * FROM t1;
+a b
+0 1
+0 2
+UPDATE t1 SET a = 1, b = 1 WHERE a = 0 AND b = 2;
+ALTER TABLE t1 ADD PRIMARY KEY (a);
+SELECT * FROM t1;
+a b
+1 1
+0 1
+ALTER TABLE t1 DROP PRIMARY KEY;
+SELECT * FROM t1;
+a b
+1 1
+0 1
+DROP TABLE t1;
+#
# Bug#57113: ha_partition::extra(ha_extra_function):
# Assertion `m_extra_cache' failed
CREATE TABLE t1