• Tom Lane's avatar
    Fix assertion failure when a SELECT DISTINCT ON expression is volatile. · d5a4b69c
    Tom Lane authored
    In this case we generate two PathKey references to the expression (one for
    DISTINCT and one for ORDER BY) and they really need to refer to the same
    EquivalenceClass.  However get_eclass_for_sort_expr was being overly paranoid
    and creating two different EC's.  Correct behavior is to use the SortGroupRef
    index to decide whether two references to volatile expressions that are
    equal() (ie textually equivalent) should be considered the same.
    
    Backpatch to 8.4.  Possibly this should be changed in 8.3 as well, but
    I'll refrain in the absence of evidence of a visible failure in that branch.
    
    Per bug #5049.
    d5a4b69c
select_distinct_on.sql 584 Bytes