-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
release-23.1: sql: fix decimal evaluation edge cases #110296
release-23.1: sql: fix decimal evaluation edge cases #110296
Conversation
Thanks for opening a backport. Please check the backport criteria before merging:
If some of the basic criteria cannot be satisfied, ensure that the exceptional criteria are satisfied within.
Add a brief release justification to the body of your PR to justify this backport. Some other things to consider:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intentionally omit the removal of the skip in sqlsmith (looks like that is the only difference from #106472)?
Reviewed 14 of 14 files at r1, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @DrewKimball)
No, thanks for catching that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving assuming you'll remove the skip before merging (although that might invalidate the approval).
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @DrewKimball)
Previously, the logic for decimal and float division, floor division and mod operators was incorrect for a few edge cases involving `NaN` or `Infinity` values. For example, `'NaN'::DECIMAL / 0` would throw a division-by-zero error when it should evaluate to `NaN` and `0/'inf'::DECIMAL` returned `0E-2019` instead of just `0`. This patch updates the special-case logic to mirror that of postgres, so division-by-zero errors always check the `NaN` case and the division by infinity case returns a `0` without extra digits. Fixes cockroachdb#40929 Fixes cockroachdb#103633 Release note (bug fix): Fixed edge cases in decimal and float evaluation for division operators. `'NaN'::DECIMAL / 0` will now return `NaN` instead of a division-by-zero error, and `0 / 'inf'::DECIMAL` will return `0` instead of `0E-2019`.
ad65462
to
51743a3
Compare
Backport 1/1 commits from #106472.
/cc @cockroachdb/release
Previously, the logic for decimal and float division, floor division and mod operators was incorrect for a few edge cases involving
NaN
orInfinity
values. For example,'NaN'::DECIMAL / 0
would throw a division-by-zero error when it should evaluate toNaN
and0/'inf'::DECIMAL
returned0E-2019
instead of just0
.This patch updates the special-case logic to mirror that of postgres, so division-by-zero errors always check the
NaN
case and the division by infinity case returns a0
without extra digits.Fixes #40929
Fixes #103633
Release note (bug fix): Fixed edge cases in decimal and float evaluation for division operators.
'NaN'::DECIMAL / 0
will now returnNaN
instead of a division-by-zero error, and0 / 'inf'::DECIMAL
will return0
instead of0E-2019
.Release justification: Fix for a decimal-precision edge case that is causing randomized test failures.