• kaa@kaamos.(none)'s avatar
    Fix for bug #34512: CAST( AVG( double ) AS DECIMAL ) · 4ca61aa3
    kaa@kaamos.(none) authored
                        returns wrong results
    
    Casting AVG() to DECIMAL led to incorrect results when the arguments
    had a non-DECIMAL type, because in this case
    Item_sum_avg::val_decimal() performed the division by the number of
    arguments twice.
    
    Fixed by changing Item_sum_avg::val_decimal() to not rely on
    Item_sum_sum::val_decimal(), i.e. calculate sum and divide using
    DECIMAL arithmetics for DECIMAL arguments, and utilize val_real() with
    subsequent conversion to DECIMAL otherwise.
    4ca61aa3
item_sum.cc 85.4 KB