Skip to content

mysql-compatibility: clarify multi schema change DDL limits#23170

Draft
joechenrh wants to merge 1 commit into
pingcap:masterfrom
joechenrh:docs/clarify-multi-schema-change-ddl
Draft

mysql-compatibility: clarify multi schema change DDL limits#23170
joechenrh wants to merge 1 commit into
pingcap:masterfrom
joechenrh:docs/clarify-multi-schema-change-ddl

Conversation

@joechenrh

@joechenrh joechenrh commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What is changed, added or deleted? (Required)

Clarify TiDB DDL compatibility limits for multi-schema-change ALTER TABLE statements:

  • TiDB validates dependencies in statement order, while MySQL might allow some statements based on the final table definition.
  • Examples include ADD INDEX idx_c(c), ADD COLUMN c INT and ADD INDEX idx(...), DROP INDEX idx with idx already existing.

Which TiDB version(s) do your changes apply to? (Required)

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)
  • v6.1 (TiDB 6.1 versions)

What is the related PR or file link(s)?

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

@ti-chi-bot

ti-chi-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 30, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kissmydb for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added missing-translation-status This PR does not have translation status info. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 30, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates mysql-compatibility.md to document two additional restrictions on multi-schema ALTER TABLE DDL operations in TiDB compared to MySQL: dependency validation order and modifying the same index multiple times in a single statement. The review feedback suggests minor phrasing adjustments to adhere to the style guide, specifically using the second person ("you"), avoiding passive voice, and correcting a minor grammatical article omission.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread mysql-compatibility.md Outdated
In TiDB, all supported DDL changes can be performed online. However, there are some major restrictions on DDL operations in TiDB compared to MySQL:

* When using a single `ALTER TABLE` statement to alter multiple schema objects (such as columns or indexes) of a table, specifying the same object in multiple changes is not supported. For example, if you execute the `ALTER TABLE t1 MODIFY COLUMN c1 INT, DROP COLUMN c1` command, the `Unsupported operate same column/index` error is output.
* When using a single `ALTER TABLE` statement to alter multiple schema objects, TiDB validates the dependencies in the statement order. MySQL might allow some multi-schema-change statements based on the final table definition. For example, MySQL supports `ALTER TABLE t ADD INDEX idx_c(c), ADD COLUMN c INT`, but TiDB returns an error because column `c` does not exist when the `ADD INDEX` clause is processed. Rewrite it as `ALTER TABLE t ADD COLUMN c INT, ADD INDEX idx_c(c)`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

low

To adhere to the style guide, we should write in the second person ("you") and avoid passive voice ("is processed").

Suggested change
* When using a single `ALTER TABLE` statement to alter multiple schema objects, TiDB validates the dependencies in the statement order. MySQL might allow some multi-schema-change statements based on the final table definition. For example, MySQL supports `ALTER TABLE t ADD INDEX idx_c(c), ADD COLUMN c INT`, but TiDB returns an error because column `c` does not exist when the `ADD INDEX` clause is processed. Rewrite it as `ALTER TABLE t ADD COLUMN c INT, ADD INDEX idx_c(c)`.
* When you use a single `ALTER TABLE` statement to alter multiple schema objects, TiDB validates the dependencies in the statement order. MySQL might allow some multi-schema-change statements based on the final table definition. For example, MySQL supports `ALTER TABLE t ADD INDEX idx_c(c), ADD COLUMN c INT`, but TiDB returns an error because column `c` does not exist when TiDB processes the `ADD INDEX` clause. You can rewrite the statement as `ALTER TABLE t ADD COLUMN c INT, ADD INDEX idx_c(c)`.
References
  1. Write in second person ("you") when addressing users. (link)
  2. Avoid passive voice overuse. (link)

Comment thread mysql-compatibility.md Outdated

* When using a single `ALTER TABLE` statement to alter multiple schema objects (such as columns or indexes) of a table, specifying the same object in multiple changes is not supported. For example, if you execute the `ALTER TABLE t1 MODIFY COLUMN c1 INT, DROP COLUMN c1` command, the `Unsupported operate same column/index` error is output.
* When using a single `ALTER TABLE` statement to alter multiple schema objects, TiDB validates the dependencies in the statement order. MySQL might allow some multi-schema-change statements based on the final table definition. For example, MySQL supports `ALTER TABLE t ADD INDEX idx_c(c), ADD COLUMN c INT`, but TiDB returns an error because column `c` does not exist when the `ADD INDEX` clause is processed. Rewrite it as `ALTER TABLE t ADD COLUMN c INT, ADD INDEX idx_c(c)`.
* If table `t` already has an index named `idx`, MySQL can treat `ADD INDEX idx(...), DROP INDEX idx` in a single `ALTER TABLE` statement as replacing the existing index. TiDB does not support modifying the same index multiple times in a single `ALTER TABLE` statement. Rewrite it as separate statements, such as `ALTER TABLE t DROP INDEX idx` followed by `ALTER TABLE t ADD INDEX idx(...)`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

low

To adhere to the style guide, we should write in the second person ("you") and improve the grammar ("If table t" -> "If a table t").

Suggested change
* If table `t` already has an index named `idx`, MySQL can treat `ADD INDEX idx(...), DROP INDEX idx` in a single `ALTER TABLE` statement as replacing the existing index. TiDB does not support modifying the same index multiple times in a single `ALTER TABLE` statement. Rewrite it as separate statements, such as `ALTER TABLE t DROP INDEX idx` followed by `ALTER TABLE t ADD INDEX idx(...)`.
* If a table `t` already has an index named `idx`, MySQL can treat `ADD INDEX idx(...), DROP INDEX idx` in a single `ALTER TABLE` statement as replacing the existing index. TiDB does not support modifying the same index multiple times in a single `ALTER TABLE` statement. You can rewrite the statement as separate statements, such as `ALTER TABLE t DROP INDEX idx` followed by `ALTER TABLE t ADD INDEX idx(...)`.
References
  1. Write in second person ("you") when addressing users. (link)

@joechenrh joechenrh force-pushed the docs/clarify-multi-schema-change-ddl branch 3 times, most recently from 604ad33 to 5d346dc Compare June 30, 2026 03:56
@joechenrh joechenrh force-pushed the docs/clarify-multi-schema-change-ddl branch from 5d346dc to 8c6cece Compare June 30, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. missing-translation-status This PR does not have translation status info. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant