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-2.1: sql/sem/tree: bugfix in handling unary negatives #39368

Merged
merged 1 commit into from Aug 7, 2019

Commits on Aug 6, 2019

  1. sql/sem/tree: bugfix in handling unary negatives

    When performing constant folding, we will now always evaluate unary
    negatives right away. To facilitate this, this commit extracts a NumExpr
    interface that is implemented by *NumVal. The new interface has methods
    to access the constant.Value of the *NumVal, and this accessor always
    will perform the necessary unary negation operator.
    
    This works because unary negation has high precedence (only preceded by
    the typecast operation).
    
    This change requires us to inspect the Negative flags of both the Expr
    and inner Decimal value when resolving a NumExpr that contains a
    Decimal, since on some operations like division, the negative value will
    now get folded into the Decimal.
    
    Many eval tests are added to ensure compatibility with Postgres.
    
    Tests are not backported since there have been significant changes in
    testing infrastructure.
    
    Release note (bug fix): unary negatives in constant arithmetic expressions
    are no longer ignored.
    rafiss committed Aug 6, 2019
    Configuration menu
    Copy the full SHA
    75a8d24 View commit details
    Browse the repository at this point in the history