MDEV-34951: InnoDB index corruption when renaming key name with same letter to upper case#4906
MDEV-34951: InnoDB index corruption when renaming key name with same letter to upper case#4906raghunandanbhat wants to merge 1 commit into10.6from
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes MDEV-34951 by ensuring the SQL layer treats index names as case-sensitive when matching keys during ALTER TABLE (and when comparing table metadata for partition exchange), preventing InnoDB metadata/index mismatches when renaming an index with case-only changes (e.g., b → B).
Changes:
- Switched key-name matching from case-insensitive
lex_string_cmp()to case-sensitivecmp()infill_alter_inplace_info()andmysql_compare_tables(). - Added regression tests for case-only index renames (main suite) and for partition exchange metadata mismatch due to index-name case differences (parts suite).
- Updated expected result files to reflect the new tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| sql/sql_table.cc | Use case-sensitive key-name comparison so case-only renames are detected as renames (and metadata comparisons catch mismatches). |
| mysql-test/suite/parts/t/alter_table.test | Adds partition-exchange regression test for index-name case mismatch. |
| mysql-test/suite/parts/r/alter_table.result | Expected output for the new parts suite test. |
| mysql-test/main/alter_table.test | Adds regression tests for ALTER TABLE ... RENAME KEY with case-only changes. |
| mysql-test/main/alter_table.result | Expected output for the new main suite tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sanja-byelkin
left a comment
There was a problem hiding this comment.
Please use charset recommended by Alexander Barkov (see my comment) otherwise Ok if copilot find nothing.
| new_key++) | ||
| { | ||
| if (!lex_string_cmp(system_charset_info, &table_key->name, | ||
| &new_key->name)) |
There was a problem hiding this comment.
It is better change system on my_charset_utf8_bin
sanja-byelkin
left a comment
There was a problem hiding this comment.
More discussiong with Bar lead to solution in this case better cmp i.e. it is OK as is
…letter to upper case. Problem: InnoDB index corruption occurs when an index is renamed to a name that differs only in case (e.g., 'b' to 'B'). The SQL layer uses case-insensitive comparison and fails to recognize the change. Fix: Use case-sensitive comparison when matching index names during ALTER TABLE to correctly identify and handle case changes.
a23f213 to
89f0845
Compare
Fixes MDEV-34951
Problem:
InnoDB index corruption occurs when an index is renamed to a name that differs only in case (e.g., 'b' to 'B'). The SQL layer uses case-insensitive comparison and fails to recognize the change.
Fix:
Use case-sensitive comparison when matching index names during ALTER TABLE to correctly identify and handle case changes.