expression, planner: fix ambiguous column name in overflow error message
What problem does this PR solve?
Issue Number: close #17993
Problem Summary: When an arithmetic overflow occurs, the error message displays "Column#N" instead of the actual column name, making it difficult for users to identify which column caused the issue.
Before:
mysql> SELECT col3 from t5 where t5.col7 * ABS(-9223372036854775807);
ERROR 1690 (22003): BIGINT value is out of range in '(Column#0 * 9223372036854775807)'
After:
mysql> SELECT col3 from t5 where t5.col7 * ABS(-9223372036854775807);
ERROR 1690 (22003): BIGINT value is out of range in '(t5.col7 * 9223372036854775807)'
What changed and how does it work?
The root cause is that the OrigName field of Column struct was not being set in certain code paths:
-
expression_rewriter.go: In thetoColumn()function, when a column is resolved from table metadata directly (fallback path whenplanCtx == nil), theOrigNamewas not set. -
task.go: In theappendExpr()function used for MPP projection columns, theOrigNamewas not set for newly created columns.
This fix ensures OrigName is properly set in both locations, so error messages display meaningful column names.
Check List
Tests
- [x] Unit test
- [ ] Integration test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test
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 the issue that overflow error messages display "Column#N" instead of the actual column name, improving error message clarity for debugging.
Hi @minleejae. Thanks for your PR.
I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test label.
I understand the commands that are listed here.
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.
Welcome @minleejae!
It looks like this is your first PR to pingcap/tidb 🎉.
I'm the bot to help you request reviewers, add labels and more, See available commands.
We want to make sure your contribution gets all the attention it needs!
Thank you, and welcome to pingcap/tidb. :smiley:
Hi @minleejae. Thanks for your PR.
PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.
I understand the commands that are listed here.
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.
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 74.5117%. Comparing base (dd1df3f) to head (100c2de).
:warning: Report is 94 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #64887 +/- ##
================================================
- Coverage 74.7253% 74.5117% -0.2136%
================================================
Files 1888 1876 -12
Lines 515164 527891 +12727
================================================
+ Hits 384958 393341 +8383
- Misses 106388 112589 +6201
+ Partials 23818 21961 -1857
| Flag | Coverage Δ | |
|---|---|---|
| integration | 42.4430% <0.0000%> (-5.7155%) |
:arrow_down: |
| unit | 73.9186% <100.0000%> (+1.6280%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Components | Coverage Δ | |
|---|---|---|
| dumpling | 52.8700% <ø> (ø) |
|
| parser | ∅ <ø> (∅) |
|
| br | 45.4765% <0.0000%> (-17.7199%) |
:arrow_down: |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Hi @minleejae you can see TestIssue59877 is failed in CI. The output format is changed which is not acceptable to me. Please limit the change scopr of your PR.
/retest
Hi @lance6716 I've removed the task.go changes that were causing the TestIssue59877 failure.
The fix now only modifies expression_rewriter.go to set OrigName in the fallback path.
/cc @windtalker
[LGTM Timeline notifier]
Timeline:
2025-12-08 02:28:43.149809439 +0000 UTC m=+835267.963587010: :ballot_box_with_check: agreed by lance6716.2025-12-10 00:34:59.041116328 +0000 UTC m=+1001243.854893900: :ballot_box_with_check: agreed by windtalker.
/retest
/retest
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: hawkingrei, lance6716, windtalker
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~pkg/expression/OWNERS~~ [windtalker]
- ~~pkg/planner/OWNERS~~ [hawkingrei]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
/test all
@minleejae: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:
| Test name | Commit | Details | Required | Rerun command |
|---|---|---|---|---|
| fast_test_tiprow | 100c2de5e5db5245a4c22bdb15b4952f28594c14 | link | true | /test fast_test_tiprow |
| tidb_parser_test | 100c2de5e5db5245a4c22bdb15b4952f28594c14 | link | true | /test tidb_parser_test |
Full PR test history. Your PR dashboard.
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. I understand the commands that are listed here.
@minleejae: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:
| Test name | Commit | Details | Required | Rerun command |
|---|---|---|---|---|
| idc-jenkins-ci-tidb/mysql-test | 100c2de5e5db5245a4c22bdb15b4952f28594c14 | link | true | /test mysql-test |
Full PR test history. Your PR dashboard.
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. I understand the commands that are listed here.