Skip to content

planner: fix null-safe equality partition pruning#68425

Merged
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
hawkingrei:issue-65991-nulleq-param
May 18, 2026
Merged

planner: fix null-safe equality partition pruning#68425
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
hawkingrei:issue-65991-nulleq-param

Conversation

@hawkingrei

@hawkingrei hawkingrei commented May 16, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: close #65991

Problem Summary:

Queries can panic with invalid input parameternulleq when partition pruning sees a constant-left null-safe equality predicate such as 1 <=> partition_col. The failing issue query derives that shape from a correlated tuple IN predicate over partitioned tables.

What changed and how does it work?

opposite() now treats ast.NullEQ as symmetric when partition pruning normalizes constant-left predicates into column-left predicates. This keeps <=> unchanged after operand flipping instead of falling through to the panic path.

The regression test covers both PARTITION BY RANGE and PARTITION BY RANGE COLUMNS, including non-NULL and NULL constants.

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.

Manual test:

go test -tags=intest,deadlock ./pkg/planner/core/issuetest -run TestPlannerIssueRegressions -count=1
go test -tags=intest,deadlock ./pkg/planner/core/rule -run Test -count=1
make bazel_prepare
git diff --check

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

Fix a panic that could occur during partition pruning for constant-left null-safe equality predicates.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed handling of null-safe equality operator in partition-pruned queries.
  • Tests

    • Added regression test validating partition pruning behavior with null-safe equality operator.

Review Change Stack

@ti-chi-bot ti-chi-bot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. sig/planner SIG: Planner labels May 16, 2026
@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4e187246-663a-4c3e-9421-0001265bac5e

📥 Commits

Reviewing files that changed from the base of the PR and between dd8253c and 014fa0f.

📒 Files selected for processing (2)
  • pkg/planner/core/issuetest/planner_issue_test.go
  • pkg/planner/core/rule/rule_partition_processor.go

📝 Walkthrough

Walkthrough

This PR fixes an invalid-parameter panic in partition range pruning when the null-safe equality operator (<=>) is encountered. The opposite() function in the partition processor now treats null-safe equality as symmetric (returning itself when operands are flipped) instead of falling through to the panic path. A regression test validates the fix across both range and range columns partitioning.

Changes

Null-safe equality partition pruning

Layer / File(s) Summary
Null-safe equality symmetry in opposite()
pkg/planner/core/rule/rule_partition_processor.go
opposite() adds explicit handling for ast.NullEQ so that null-safe equality returns the same operator when operands are flipped, preventing panic in partition pruning logic.
Regression test for constant-left null-safe equality
pkg/planner/core/issuetest/planner_issue_test.go
New cascades test validates partition pruning with null-safe equality on the left side, covering both range and range columns partitioning with NULL values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

sig/planner, size/M

Suggested reviewers

  • AilinKid
  • winoros
  • guo-shaoge

Poem

🐰 Null-safe hops through partition plans,
Symmetric equals, no more panics and cans,
Range pruning blooms where <=> would fall,
Tests verify the fix works for all!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'planner: fix null-safe equality partition pruning' directly and clearly summarizes the main change—fixing partition pruning for null-safe equality operators.
Description check ✅ Passed The description follows the template well, including issue number, problem summary, explanation of changes, test checklist with unit and manual tests marked, manual test commands, and a clear release note.
Linked Issues check ✅ Passed The PR successfully addresses issue #65991 by fixing the panic caused by null-safe equality in partition pruning; the opposite() function now correctly handles ast.NullEQ, resolving the 'invalid input parameternulleq' error.
Out of Scope Changes check ✅ Passed All changes are directly in scope: a fix to the opposite() function and a corresponding regression test case for partition pruning with null-safe equality operators.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@hawkingrei hawkingrei added the AI-Correction Bugfix by AI label May 16, 2026
@codecov

codecov Bot commented May 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.7244%. Comparing base (dd8253c) to head (014fa0f).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #68425        +/-   ##
================================================
- Coverage   77.2764%   75.7244%   -1.5521%     
================================================
  Files          2010       2008         -2     
  Lines        555481     563986      +8505     
================================================
- Hits         429256     427075      -2181     
- Misses       125305     136752     +11447     
+ Partials        920        159       -761     
Flag Coverage Δ
integration 41.1499% <0.0000%> (+1.3559%) ⬆️

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

Components Coverage Δ
dumpling 60.4888% <ø> (ø)
parser ∅ <ø> (∅)
br 49.9725% <ø> (-13.0354%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hawkingrei hawkingrei requested review from AilinKid and qw4990 May 18, 2026 08:59
@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 18, 2026
@ti-chi-bot

ti-chi-bot Bot commented May 18, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, qw4990

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 May 18, 2026
@ti-chi-bot

ti-chi-bot Bot commented May 18, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-05-18 09:03:51.49352243 +0000 UTC m=+168560.997653096: ☑️ agreed by AilinKid.
  • 2026-05-18 09:04:15.55988851 +0000 UTC m=+168585.064019186: ☑️ agreed by qw4990.

@hawkingrei

Copy link
Copy Markdown
Member Author

/retest

@ti-chi-bot ti-chi-bot Bot merged commit a3197bd into pingcap:master May 18, 2026
36 checks passed
yongman pushed a commit to yongman/tidb that referenced this pull request Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Correction Bugfix by AI approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

query return error: invalid input parameternulleq

3 participants