Skip to content
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

Merged

Commits on Sep 12, 2023

  1. sql: fix decimal evaluation edge cases

    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`.
    DrewKimball committed Sep 12, 2023
    Configuration menu
    Copy the full SHA
    51743a3 View commit details
    Browse the repository at this point in the history