summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/alter_table_trans.result8
-rw-r--r--mysql-test/t/alter_table_trans.test12
2 files changed, 20 insertions, 0 deletions
diff --git a/mysql-test/r/alter_table_trans.result b/mysql-test/r/alter_table_trans.result
index 67ae4075d57..435f5abd9d0 100644
--- a/mysql-test/r/alter_table_trans.result
+++ b/mysql-test/r/alter_table_trans.result
@@ -16,3 +16,11 @@ insert t1 values (repeat('3', 8193),3,1,1);
ALTER TABLE t1 ADD PRIMARY KEY (col4(10)) , ADD UNIQUE KEY uidx (col3);
ERROR 23000: Duplicate entry '1' for key 'uidx'
DROP TABLE t1;
+CREATE TABLE t1 (a INT) ENGINE = InnoDB;
+INSERT INTO t1 VALUES (2);
+ALTER TABLE t1 ADD PRIMARY KEY (a);
+ALTER TABLE t1 DROP PRIMARY KEY;
+INSERT INTO t1 VALUES (2);
+ALTER TABLE t1 ADD PRIMARY KEY (a);
+ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
+DROP TABLE t1;
diff --git a/mysql-test/t/alter_table_trans.test b/mysql-test/t/alter_table_trans.test
index 29b9b4c212f..19b40d84b22 100644
--- a/mysql-test/t/alter_table_trans.test
+++ b/mysql-test/t/alter_table_trans.test
@@ -32,4 +32,16 @@ insert t1 values (repeat('3', 8193),3,1,1);
ALTER TABLE t1 ADD PRIMARY KEY (col4(10)) , ADD UNIQUE KEY uidx (col3);
DROP TABLE t1;
+#
+# MDEV-5743 Server crashes in mysql_alter_table on an attempt to add a primary key to InnoDB table
+#
+
+CREATE TABLE t1 (a INT) ENGINE = InnoDB;
+INSERT INTO t1 VALUES (2);
+ALTER TABLE t1 ADD PRIMARY KEY (a);
+ALTER TABLE t1 DROP PRIMARY KEY;
+INSERT INTO t1 VALUES (2);
+--error ER_DUP_ENTRY
+ALTER TABLE t1 ADD PRIMARY KEY (a);
+DROP TABLE t1;