MDEV-18266 Changing an index comment unnecessarily rebuilds index
ALTER_CHANGE_INDEX_COMMENT: new handler flag added Compare_keys::EqualButComment: new outcome of compare_keys_but_name()
This commit is contained in:
parent
70c2bde931
commit
a0230bc76d
@ -2533,3 +2533,17 @@ WHERE variable_name = 'innodb_instant_alter_column';
|
||||
instants
|
||||
181
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;
|
||||
#
|
||||
# MDEV-18266: Changing an index comment unnecessarily rebuilds index
|
||||
#
|
||||
CREATE TABLE t1(a INT, b INT) ENGINE=INNODB;
|
||||
CREATE INDEX i1 ON t1(a) COMMENT 'comment1';
|
||||
ALTER TABLE t1 DROP INDEX i1, ADD INDEX i1(a) COMMENT 'comment2', ALGORITHM=INSTANT;
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) DEFAULT NULL,
|
||||
KEY `i1` (`a`) COMMENT 'comment2'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1;
|
||||
|
@ -752,3 +752,13 @@ SELECT variable_value-@old_instant instants
|
||||
FROM information_schema.global_status
|
||||
WHERE variable_name = 'innodb_instant_alter_column';
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-18266: Changing an index comment unnecessarily rebuilds index
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1(a INT, b INT) ENGINE=INNODB;
|
||||
CREATE INDEX i1 ON t1(a) COMMENT 'comment1';
|
||||
ALTER TABLE t1 DROP INDEX i1, ADD INDEX i1(a) COMMENT 'comment2', ALGORITHM=INSTANT;
|
||||
SHOW CREATE TABLE t1;
|
||||
DROP TABLE t1;
|
||||
|
@ -643,6 +643,7 @@ typedef ulonglong alter_table_operations;
|
||||
#define ALTER_ADD_FOREIGN_KEY (1ULL << 21)
|
||||
// Set for DROP FOREIGN KEY
|
||||
#define ALTER_DROP_FOREIGN_KEY (1ULL << 22)
|
||||
#define ALTER_CHANGE_INDEX_COMMENT (1ULL << 23)
|
||||
// Set for ADD [COLUMN] FIRST | AFTER
|
||||
#define ALTER_COLUMN_ORDER (1ULL << 25)
|
||||
#define ALTER_ADD_CHECK_CONSTRAINT (1ULL << 27)
|
||||
|
@ -37,6 +37,10 @@ static inline bool cmp(const LEX_CSTRING *a, const LEX_CSTRING *b)
|
||||
return (a->length != b->length ||
|
||||
memcmp(a->str, b->str, a->length));
|
||||
}
|
||||
static inline bool cmp(const LEX_CSTRING a, const LEX_CSTRING b)
|
||||
{
|
||||
return a.length != b.length || memcmp(a.str, b.str, a.length);
|
||||
}
|
||||
|
||||
/*
|
||||
Compare if two LEX_CSTRING are equal. Assumption is that
|
||||
|
@ -6521,10 +6521,11 @@ static int compare_uint(const uint *s, const uint *t)
|
||||
return (*s < *t) ? -1 : ((*s > *t) ? 1 : 0);
|
||||
}
|
||||
|
||||
enum class Compare_keys
|
||||
enum class Compare_keys : uint32_t
|
||||
{
|
||||
Equal,
|
||||
EqualButKeyPartLength,
|
||||
EqualButComment,
|
||||
NotEqual
|
||||
};
|
||||
|
||||
@ -6608,11 +6609,12 @@ Compare_keys compare_keys_but_name(const KEY *table_key, const KEY *new_key,
|
||||
return Compare_keys::NotEqual;
|
||||
|
||||
/* Check that key comment is not changed. */
|
||||
if (table_key->comment.length != new_key->comment.length ||
|
||||
(table_key->comment.length &&
|
||||
memcmp(table_key->comment.str, new_key->comment.str,
|
||||
table_key->comment.length) != 0))
|
||||
return Compare_keys::NotEqual;
|
||||
if (cmp(table_key->comment, new_key->comment) != 0)
|
||||
{
|
||||
if (result != Compare_keys::Equal)
|
||||
return Compare_keys::NotEqual;
|
||||
result= Compare_keys::EqualButComment;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -7002,6 +7004,9 @@ static bool fill_alter_inplace_info(THD *thd, TABLE *table, bool varchar,
|
||||
case Compare_keys::EqualButKeyPartLength:
|
||||
ha_alter_info->handler_flags|= ALTER_COLUMN_INDEX_LENGTH;
|
||||
continue;
|
||||
case Compare_keys::EqualButComment:
|
||||
ha_alter_info->handler_flags|= ALTER_CHANGE_INDEX_COMMENT;
|
||||
continue;
|
||||
case Compare_keys::NotEqual:
|
||||
break;
|
||||
}
|
||||
|
@ -108,7 +108,8 @@ static const alter_table_operations INNOBASE_INPLACE_IGNORE
|
||||
| ALTER_VIRTUAL_GCOL_EXPR
|
||||
| ALTER_DROP_CHECK_CONSTRAINT
|
||||
| ALTER_RENAME
|
||||
| ALTER_COLUMN_INDEX_LENGTH;
|
||||
| ALTER_COLUMN_INDEX_LENGTH
|
||||
| ALTER_CHANGE_INDEX_COMMENT;
|
||||
|
||||
/** Operations on foreign key definitions (changing the schema only) */
|
||||
static const alter_table_operations INNOBASE_FOREIGN_OPERATIONS
|
||||
|
Loading…
x
Reference in New Issue
Block a user