tidb icon indicating copy to clipboard operation
tidb copied to clipboard

expression, planner: fix ambiguous column name in overflow error message

Open minleejae opened this issue 3 weeks ago • 13 comments

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:

  1. expression_rewriter.go: In the toColumn() function, when a column is resolved from table metadata directly (fallback path when planCtx == nil), the OrigName was not set.

  2. task.go: In the appendExpr() function used for MPP projection columns, the OrigName was 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.

minleejae avatar Dec 05 '25 13:12 minleejae

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.

ti-chi-bot[bot] avatar Dec 05 '25 13:12 ti-chi-bot[bot]

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:

ti-chi-bot[bot] avatar Dec 05 '25 13:12 ti-chi-bot[bot]

CLA assistant check
All committers have signed the CLA.

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.

tiprow[bot] avatar Dec 05 '25 13:12 tiprow[bot]

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.

codecov[bot] avatar Dec 06 '25 12:12 codecov[bot]

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.

lance6716 avatar Dec 07 '25 05:12 lance6716

/retest

minleejae avatar Dec 07 '25 17:12 minleejae

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.

minleejae avatar Dec 07 '25 17:12 minleejae

/cc @windtalker

lance6716 avatar Dec 08 '25 02:12 lance6716

[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.

ti-chi-bot[bot] avatar Dec 10 '25 00:12 ti-chi-bot[bot]

/retest

hawkingrei avatar Dec 12 '25 15:12 hawkingrei

/retest

hawkingrei avatar Dec 12 '25 16:12 hawkingrei

[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

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[bot] avatar Dec 13 '25 04:12 ti-chi-bot[bot]

/test all

hawkingrei avatar Dec 17 '25 01:12 hawkingrei

@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.

tiprow[bot] avatar Dec 17 '25 01:12 tiprow[bot]

@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.

ti-chi-bot[bot] avatar Dec 17 '25 02:12 ti-chi-bot[bot]