• Georgi Kodinov's avatar
    Bug #38637: COUNT DISTINCT prevents NULL testing in HAVING clause · f1a1e89f
    Georgi Kodinov authored
    IS NULL was not checking the correct row in a HAVING context.
    At the first row of a new group (where the HAVING clause is evaluated)
    the column and SELECT list references in the HAVING clause should 
    refer to the last row of the previous group and not to the current one. 
    This was not done for IS NULL, because it was using Item::is_null() doesn't
    have a  Item_is_null_result() counterpart to access the data from the 
    last row of the previous group. Note that all the Item::val_xxx() functions 
    (e.g. Item::val_int()) have their _result counterparts (e.g. Item::val_int_result()).
    
    Fixed by implementing a is_null_result() (similarly to int_result()) and
    calling this instead of is_null() column and SELECT list references inside
    the HAVING clause.
    f1a1e89f
having.test 13.8 KB