• Alexander Barkov's avatar
    MDEV-23032 FLOOR()/CEIL() incorrectly calculate the precision of a DECIMAL(M,D) column · 6a2ee9c8
    Alexander Barkov authored
    The code in Item_func_int_val::fix_length_and_dec_int_or_decimal()
    calculated badly the result data type for FLOOR()/CEIL(), so for example
    the decimal(38,10) input created a decimal(28,0) result.
    That was not correct, because one extra integer digit is needed.
       floor(-9.9) -> -10
       ceil(9.9)   ->  10
    
    Rewritting the code in a more straightforward way.
    Additional changes:
    - FLOOR() now takes into account the presence of the UNSIGNED
    flag of the argument: FLOOR(unsigned decimal) does not need an extra digits.
    - FLOOR()/CEILING() now preserve the unsigned flag in the result
      data type is decimal.
    These changes give nicer data types.
    6a2ee9c8
item_func.h 108 KB