Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.1.4, 10.2.0, 10.3.0, 10.4.0
Description
MariaDB fails to optimize away DROP INDEX, ADD INDEX pairs if the index comment is being changed. This can be repeated with the example that was posted to MDEV-7816:
CREATE TABLE t1(a INT, b 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; |
Ever since the MDEV-7816 fix, the ALTER TABLE is unnecessarily requesting the storage engine to rebuild (drop and create) the index:
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: |
We only need the metadata (t1.frm file) to be updated.
Attachments
Issue Links
- is caused by
-
MDEV-7816 ALTER with DROP INDEX and ADD INDEX .. COMMENT='comment2' ignores the new comment
- Closed
- relates to
-
MDEV-11424 Instant ALTER TABLE of failure-free record format changes
- Closed
- links to