diff options
author | Eugene Kosov <claprix@yandex.ru> | 2019-07-10 21:15:12 +0300 |
---|---|---|
committer | Eugene Kosov <claprix@yandex.ru> | 2019-07-10 21:36:29 +0300 |
commit | a0230bc76d78202178f43d2f4f6a7e3322c19a16 (patch) | |
tree | 47d1bafa6345c7516cab8ae48a53ceca1ecd735c /sql | |
parent | 70c2bde931246ea4966d82fa56773b8ef1e0074f (diff) | |
download | mariadb-git-bb-10.4-MDEV-18266-index-comment.tar.gz |
MDEV-18266 Changing an index comment unnecessarily rebuilds indexbb-10.4-MDEV-18266-index-comment
ALTER_CHANGE_INDEX_COMMENT: new handler flag added
Compare_keys::EqualButComment: new outcome of compare_keys_but_name()
Diffstat (limited to 'sql')
-rw-r--r-- | sql/handler.h | 1 | ||||
-rw-r--r-- | sql/lex_string.h | 4 | ||||
-rw-r--r-- | sql/sql_table.cc | 17 |
3 files changed, 16 insertions, 6 deletions
diff --git a/sql/handler.h b/sql/handler.h index 7bdcb637485..f3a95022b4f 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -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) diff --git a/sql/lex_string.h b/sql/lex_string.h index a5209165be0..88a7154b064 100644 --- a/sql/lex_string.h +++ b/sql/lex_string.h @@ -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 diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 67f17b893d0..efccd2226c3 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -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; } |