Skip to content

*: extend DXF collation handling to support partition table and partial index#69734

Draft
joechenrh wants to merge 8 commits into
pingcap:masterfrom
joechenrh:dxf-collation-followup
Draft

*: extend DXF collation handling to support partition table and partial index#69734
joechenrh wants to merge 8 commits into
pingcap:masterfrom
joechenrh:dxf-collation-followup

Conversation

@joechenrh

@joechenrh joechenrh commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #69563

Problem Summary:

In next-gen deployments, DXF workers may run in a keyspace whose new-collation setting differs from the user keyspace that submitted the task. Some remaining ADD INDEX and IMPORT INTO paths still built expressions, encoded keys, or converted string-like values using the worker/global collation mode. This can make background execution use collation semantics that do not match the submitted task.

What changed and how does it work?

This PR keeps the new-collation mode captured by the submitted task/table snapshot and uses it in the remaining collation-sensitive DXF paths:

  • Introduce table.EncodingConfig as the explicit encoding snapshot carried by table/index/expression helpers.
  • Keep the normal TableFromMeta(allocs, tblInfo) path unchanged, and let DXF paths pass tables.WithEncodingConfig(...) when they need a fixed task snapshot.
  • Build partition expressions and list partition encoded keys with the table collation snapshot.
  • Build partial-index backfill conditions with the collation mode carried by the coprocessor context.
  • Make BuildSimpleExpr honor WithUseNewCollate when it builds schema from WithTableInfo.
  • Add explicit ENUM/SET parsing and datum conversion helpers, and use the table collation snapshot in IMPORT/Lightning cast and generated-column evaluation paths.
  • Add focused regression tests for mismatched global/table collation modes.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Validated locally:

make bazel_prepare
go test ./pkg/types -run 'Test(Enum|Set)$' -count=1
go test ./pkg/ddl/copr -run 'Test(NewCopContextSingleIndex|CopContextConditionUsesFixedCollation)' -count=1
./tools/check/failpoint-go-test.sh pkg/planner/core -run TestBuildSimpleExprWithTableInfoUsesFixedCollation -count=1
./tools/check/failpoint-go-test.sh pkg/executor/importer -run 'TestKVEncoderCast(Enum|EnumSet)' -count=1
./tools/check/failpoint-go-test.sh pkg/table/tables/test/partition -run TestPartitionTableUsesTableCollationSnapshot -count=1
go test -run '^$' ./pkg/ddl/copr ./pkg/lightning/backend/kv ./pkg/table -count=1
./tools/check/failpoint-go-test.sh pkg/table/tables -run '^$' -count=1
go test -run '^$' ./pkg/dxf/importinto -count=1
./tools/check/failpoint-go-test.sh pkg/table/tables -run TestTableFromMetaEncodingConfigOptionUsesFixedMode -count=1
./tools/check/failpoint-go-test.sh pkg/ddl -run '^$' -count=1
git diff --check
make lint

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.

Fix an issue that DXF ADD INDEX or IMPORT INTO might use the worker keyspace's new-collation setting instead of the submitted task's setting in some collation-sensitive paths.

@ti-chi-bot ti-chi-bot Bot added do-not-merge/needs-linked-issue do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Jul 9, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 9, 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 release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 87f89a96-9e4f-4a65-b728-c4ed084bc37f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ti-chi-bot ti-chi-bot Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. sig/planner SIG: Planner labels Jul 9, 2026
@ti-chi-bot ti-chi-bot Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 9, 2026
@ti-chi-bot ti-chi-bot Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 9, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 9, 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 benjamin2037 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

@joechenrh joechenrh changed the title *: extend DXF collation snapshot coverage *: extend DXF collation coverage Jul 10, 2026
@joechenrh joechenrh changed the title *: extend DXF collation coverage *: extend DXF collation handling to support partition table and partial index Jul 10, 2026
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. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner 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.

nextgen: tasks can use SYSTEM new_collation_enabled when encoding user keyspace KV

1 participant