Skip to content

Commit 4feaa06

Browse files
committed
MDEV-7816 ALTER with DROP INDEX and ADD INDEX .. COMMENT='comment2' ignores the new comment
Consider two indexes different if their comments differ
1 parent bd2ae78 commit 4feaa06

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

mysql-test/r/alter_table.result

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,3 +2007,13 @@ INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8);
20072007
INSERT INTO t1 SELECT a.* FROM t1 a, t1 b, t1 c, t1 d, t1 e;
20082008
ALTER TABLE t1 MODIFY i FLOAT;
20092009
DROP TABLE t1;
2010+
CREATE TABLE t1(a INT);
2011+
CREATE INDEX i1 ON t1(a) COMMENT 'comment1';
2012+
ALTER TABLE t1 DROP INDEX i1, ADD INDEX i1(a) COMMENT 'comment2';
2013+
SHOW CREATE TABLE t1;
2014+
Table Create Table
2015+
t1 CREATE TABLE `t1` (
2016+
`a` int(11) DEFAULT NULL,
2017+
KEY `i1` (`a`) COMMENT 'comment2'
2018+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
2019+
DROP TABLE t1;

mysql-test/t/alter_table.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,3 +1697,11 @@ INSERT INTO t1 SELECT a.* FROM t1 a, t1 b, t1 c, t1 d, t1 e;
16971697
ALTER TABLE t1 MODIFY i FLOAT;
16981698
DROP TABLE t1;
16991699

1700+
#
1701+
# MDEV-7816 ALTER with DROP INDEX and ADD INDEX .. COMMENT='comment2' ignores the new comment
1702+
#
1703+
CREATE TABLE t1(a INT);
1704+
CREATE INDEX i1 ON t1(a) COMMENT 'comment1';
1705+
ALTER TABLE t1 DROP INDEX i1, ADD INDEX i1(a) COMMENT 'comment2';
1706+
SHOW CREATE TABLE t1;
1707+
DROP TABLE t1;

sql/sql_table.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6368,6 +6368,13 @@ static bool fill_alter_inplace_info(THD *thd,
63686368
new_field->field->field_index != key_part->fieldnr - 1)
63696369
goto index_changed;
63706370
}
6371+
6372+
/* Check that key comment is not changed. */
6373+
if (table_key->comment.length != new_key->comment.length ||
6374+
(table_key->comment.length &&
6375+
strcmp(table_key->comment.str, new_key->comment.str) != 0))
6376+
goto index_changed;
6377+
63716378
continue;
63726379

63736380
index_changed:

0 commit comments

Comments
 (0)