• Vicențiu Ciorbaru's avatar
    MDEV-30324: Wrong result upon SELECT DISTINCT ... WITH TIES · 4afa3b64
    Vicențiu Ciorbaru authored
    WITH TIES would not take effect if SELECT DISTINCT was used in a
    context where an INDEX is used to resolve the ORDER BY clause.
    
    WITH TIES relies on the `JOIN::order` to contain the non-constant
    fields to test the equality of ORDER BY fiels required for WITH TIES.
    
    The cause of the problem was a premature removal of the `JOIN::order`
    member during a DISTINCT optimization. This lead to WITH TIES code assuming
    ORDER BY only contained "constant" elements.
    
    Disable this optimization when WITH TIES is in effect.
    
    (side-note: the order by removal does not impact any current tests, thus
    it will be removed in a future version)
    
    Reviewed by: monty@mariadb.org
    4afa3b64
fetch_first.result 29.1 KB