Skip to content

ddl: enable modify column on partitioned table#40634

Merged
ti-chi-bot[bot] merged 39 commits into
pingcap:masterfrom
mjonss:part-modify-col
Nov 25, 2025
Merged

ddl: enable modify column on partitioned table#40634
ti-chi-bot[bot] merged 39 commits into
pingcap:masterfrom
mjonss:part-modify-col

Conversation

@mjonss
Copy link
Copy Markdown
Contributor

@mjonss mjonss commented Jan 16, 2023

What problem does this PR solve?

Issue Number: close #38297 ref #39915 close #57780

Similar to #39922

Problem Summary:
There were an issue (#39915) with modify column on partitioned tables, which caused a revert. This will add that code back and include a fix (reset the PhysicaTablelD).

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot
Copy link
Copy Markdown
Member

[REVIEW NOTIFICATION]

This pull request has not been approved.

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Details

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 16, 2023
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 18, 2023
@ti-chi-bot
Copy link
Copy Markdown
Member

@mjonss: PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot Bot deleted a comment from ti-chi-bot Dec 19, 2023
@ti-chi-bot ti-chi-bot Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 27, 2024
@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 27, 2024

Codecov Report

❌ Patch coverage is 74.57627% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.7624%. Comparing base (80c817a) to head (e5801cd).
⚠️ Report is 44 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #40634        +/-   ##
================================================
+ Coverage   72.6924%   75.7624%   +3.0700%     
================================================
  Files          1866       1889        +23     
  Lines        506215     524971     +18756     
================================================
+ Hits         367980     397731     +29751     
+ Misses       115858     103618     -12240     
- Partials      22377      23622      +1245     
Flag Coverage Δ
integration 48.9795% <22.0339%> (?)
unit 73.4438% <74.5762%> (+1.1782%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.8700% <ø> (ø)
parser ∅ <ø> (∅)
br 63.7415% <ø> (+17.5628%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ti-chi-bot ti-chi-bot Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 28, 2024
@mjonss mjonss requested review from Copilot and wjhuang2016 November 4, 2025 16:44
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

This PR enables support for modifying columns on partitioned tables, a feature that was previously blocked. The implementation adds validation logic to ensure column modifications on partitioning columns are safe and don't affect partition distribution.

  • Removes the blanket restriction on modifying columns in partitioned tables
  • Adds pre-check and post-check validation for partitioning column modifications
  • Updates tests to reflect the new capability and adjusted error messages

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/ddl/modify_column.go Moved partition table restriction to conditional validation; added preCheckPartitionModifiableColumn and postCheckPartitionModifiableColumn functions with extracted logic from GetModifiableColumnJob
pkg/ddl/column.go Added support for ActionModifyColumn in partition table handling logic; removed TODO comments blocking partition table support
pkg/ddl/index.go Added logic to handle partition iteration for modify column operations (case 5)
pkg/ddl/tests/partition/db_partition_test.go Removed test skip; updated error message expectations; added new comprehensive test TestAlterModifyColumnOnPartitionedTable and regression test TestIssue57780
pkg/ddl/tests/partition/multi_domain_test.go Simplified expected error messages to remove key-specific suffix variations
pkg/ddl/tests/fail/fail_db_test.go Updated expected error message for partition table modification
pkg/ddl/index_modify_test.go Changed test from expecting error to expecting successful execution
tests/realtikvtest/addindextest3/temp_index_test.go Enhanced assertion message with more diagnostic information

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/ddl/modify_column.go Outdated
Comment thread pkg/ddl/modify_column.go
Comment thread tests/realtikvtest/addindextest3/temp_index_test.go
@mjonss
Copy link
Copy Markdown
Contributor Author

mjonss commented Nov 10, 2025

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Nov 10, 2025

@mjonss: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Comment thread pkg/ddl/column.go Outdated
Comment thread pkg/ddl/modify_column.go Outdated
@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Nov 18, 2025
@joechenrh joechenrh self-requested a review November 18, 2025 11:37
Copy link
Copy Markdown
Contributor

@joechenrh joechenrh left a comment

Choose a reason for hiding this comment

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

Rest LGTM

Comment thread pkg/ddl/modify_column.go
Comment thread pkg/ddl/modify_column.go
Comment on lines -1656 to -1657
// TODO: update the partitioning columns with new names if column is renamed
// Would be an extension from MySQL which does not support it.
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.

Prefer keeping this comment, so later we can easily understand why we don't support changing column name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I removed it since I an not aware that you can rename during MODIFY COLUMN? I can still keep it, but is it the right place for the comment?

Copy link
Copy Markdown
Contributor

@joechenrh joechenrh Nov 24, 2025

Choose a reason for hiding this comment

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

I just saw we still check the name in checkPartitionColumnModifiable, and return error if the name has changed, but it's OK to remove it.

Comment thread pkg/ddl/modify_column.go
" PARTITION `pMax` VALUES LESS THAN (MAXVALUE))"))
tk.MustExec(`set session tidb_enable_fast_table_check = off`)
tk.MustExec(`admin check table t`)
tk.MustExec(`alter table t modify b varchar(200) charset latin1`)
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.

Why can this line execute success, I think we check and require the charset must be same at https://github.com/pingcap/tidb/pull/40634/files#diff-d6c304fd538040182d3a53c3f82abff03e074b59725b87ab711779d00f91222eR1562-R1563

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.

I think we only check the partition column, which is a here

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.

Oh~~, indeed. Maybe we can add some unsupported modify column cases

@joechenrh joechenrh changed the title ddl: Enable modify column on partitioned table ddl: enable modify column on partitioned table Nov 19, 2025
@joechenrh joechenrh removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 25, 2025
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Nov 25, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: joechenrh, wjhuang2016

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

The pull request process is described 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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 25, 2025
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Nov 25, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-11-18 11:01:48.509591432 +0000 UTC m=+9472.158785889: ☑️ agreed by wjhuang2016.
  • 2025-11-25 02:58:28.900689023 +0000 UTC m=+585272.549883480: ☑️ agreed by joechenrh.

@ti-chi-bot ti-chi-bot Bot merged commit 939455c into pingcap:master Nov 25, 2025
32 checks passed
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Nov 25, 2025
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Copy Markdown
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #64658.

@mjonss mjonss deleted the part-modify-col branch December 18, 2025 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parition table can not change decimal type Support MODIFY COLUMN of partitioned tables

6 participants