From 4feaa06c842b0ae1cc8ab2d6e7f0bbd00c000e87 Mon Sep 17 00:00:00 2001 From: f4rnham Date: Thu, 26 Mar 2015 00:00:12 +0100 Subject: [PATCH] MDEV-7816 ALTER with DROP INDEX and ADD INDEX .. COMMENT='comment2' ignores the new comment Consider two indexes different if their comments differ --- mysql-test/r/alter_table.result | 10 ++++++++++ mysql-test/t/alter_table.test | 8 ++++++++ sql/sql_table.cc | 7 +++++++ 3 files changed, 25 insertions(+) diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 544e64e6373..a7f8ffcc9ec 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -2007,3 +2007,13 @@ INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8); INSERT INTO t1 SELECT a.* FROM t1 a, t1 b, t1 c, t1 d, t1 e; ALTER TABLE t1 MODIFY i FLOAT; DROP TABLE t1; +CREATE TABLE t1(a INT); +CREATE INDEX i1 ON t1(a) COMMENT 'comment1'; +ALTER TABLE t1 DROP INDEX i1, ADD INDEX i1(a) COMMENT 'comment2'; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + KEY `i1` (`a`) COMMENT 'comment2' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index ab1fb4e4c54..0c0672de3e2 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -1697,3 +1697,11 @@ INSERT INTO t1 SELECT a.* FROM t1 a, t1 b, t1 c, t1 d, t1 e; ALTER TABLE t1 MODIFY i FLOAT; DROP TABLE t1; +# +# MDEV-7816 ALTER with DROP INDEX and ADD INDEX .. COMMENT='comment2' ignores the new comment +# +CREATE TABLE t1(a INT); +CREATE INDEX i1 ON t1(a) COMMENT 'comment1'; +ALTER TABLE t1 DROP INDEX i1, ADD INDEX i1(a) COMMENT 'comment2'; +SHOW CREATE TABLE t1; +DROP TABLE t1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c4b07ad2035..5986e8201c4 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -6368,6 +6368,13 @@ static bool fill_alter_inplace_info(THD *thd, new_field->field->field_index != key_part->fieldnr - 1) goto index_changed; } + + /* Check that key comment is not changed. */ + if (table_key->comment.length != new_key->comment.length || + (table_key->comment.length && + strcmp(table_key->comment.str, new_key->comment.str) != 0)) + goto index_changed; + continue; index_changed: