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

sql: improve the ROUND and EXP functions. #8822

Merged
merged 1 commit into from Aug 27, 2016
Merged

Commits on Aug 27, 2016

  1. sql: improve the ROUND and EXP functions.

    Prior to this patch the computation would take too long or too much
    memory if EXP was given an argument too large or if the 2nd ROUND
    argument was negative with a large absolute value.
    
    This patch addresses this issue by limiting the range of acceptable
    arguments (1024 for EXP, anything that causes more than 2000 extra "0"
    digits to be appended on the right for ROUND).
    
    It improves both functions as follows:
    
    - a negative ROUND scale is now supported as in PostgreSQL and Oracle;
      this rounds to positions on the left of the decimal separator.
    
    - the ROUND function for floats is now performed on floats directly,
      instead of using Printf/ParseFloat as previously (faster).
    
    - the ROUND function for decimals is now faster if the 2nd argument is
      negative and its absolute value is larger than the number of digits
      in the 1st argument on the left of its decimal separator.
    
    - ROUND for both floats and decimal now use half to even rounding,
      also called unbiased rounding or bankers' rounding.
    knz committed Aug 27, 2016
    Configuration menu
    Copy the full SHA
    6655414 View commit details
    Browse the repository at this point in the history