expression: fix signed bigint subtraction overflow | tidb-test=pr/2742#68441
expression: fix signed bigint subtraction overflow | tidb-test=pr/2742#68441hawkingrei wants to merge 2 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
📝 WalkthroughWalkthroughThis PR fixes a silent overflow bug where ChangesBIGINT minus overflow edge case
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #68441 +/- ##
================================================
- Coverage 77.2762% 76.4914% -0.7849%
================================================
Files 2010 1992 -18
Lines 555477 557613 +2136
================================================
- Hits 429252 426526 -2726
- Misses 125305 131043 +5738
+ Partials 920 44 -876
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
/retest-required |
What problem does this PR solve?
Issue Number: close #67211
Problem Summary:
Signed BIGINT subtraction missed the
0 - math.MinInt64overflow boundary. TiDB could return-9223372036854775808without warnings for(0) - awhenawas-9223372036854775808, while MySQL reports an out-of-range error.What changed and how does it work?
The signed/signed integer subtraction overflow check now treats zero the same as other non-negative left operands when subtracting a negative right operand. This preserves in-range cases such as
-1 - math.MinInt64while raising overflow for0 - math.MinInt64.Regression coverage was added for both row-based and vectorized BIGINT subtraction evaluation.
Check List
Tests
Unit test:
./tools/check/failpoint-go-test.sh pkg/expression -run 'TestArithmeticMinus|TestVectorizedDecimalErrOverflow' -count=1 make lintManual test:
(0) - areturned-9223372036854775808without warnings.(0) - aand(1) - areturn error 1690, while(-1) - astill returns9223372036854775807.Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.
Summary by CodeRabbit
Bug Fixes
Tests