Skip to content

MDEV-34951: InnoDB index corruption when renaming key name with same letter to upper case#4906

Open
raghunandanbhat wants to merge 1 commit into10.6from
10.6-mdev-34951
Open

MDEV-34951: InnoDB index corruption when renaming key name with same letter to upper case#4906
raghunandanbhat wants to merge 1 commit into10.6from
10.6-mdev-34951

Conversation

@raghunandanbhat
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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., bB).

Changes:

  • Switched key-name matching from case-insensitive lex_string_cmp() to case-sensitive cmp() in fill_alter_inplace_info() and mysql_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.

Comment thread mysql-test/main/alter_table.test Outdated
Comment thread mysql-test/main/alter_table.result Outdated
Comment thread mysql-test/suite/parts/t/alter_table.test Outdated
Comment thread mysql-test/suite/parts/r/alter_table.result Outdated
Copy link
Copy Markdown
Member

@sanja-byelkin sanja-byelkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use charset recommended by Alexander Barkov (see my comment) otherwise Ok if copilot find nothing.

Comment thread sql/sql_table.cc
new_key++)
{
if (!lex_string_cmp(system_charset_info, &table_key->name,
&new_key->name))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better change system on my_charset_utf8_bin

Copy link
Copy Markdown
Member

@sanja-byelkin sanja-byelkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants