pgsql: Fix assertion failure when a SELECT DISTINCT ON expression is - Mailing list pgsql-committers

From tgl@postgresql.org (Tom Lane)
Subject pgsql: Fix assertion failure when a SELECT DISTINCT ON expression is
Date
Msg-id 20090912000459.46D8F753FB7@cvs.postgresql.org
Whole thread Raw
List pgsql-committers
Log Message:
-----------
Fix assertion failure when a SELECT DISTINCT ON expression is volatile.
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.

Modified Files:
--------------
    pgsql/src/backend/optimizer/path:
        equivclass.c (r1.19 -> r1.20)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/equivclass.c?r1=1.19&r2=1.20)
        pathkeys.c (r1.98 -> r1.99)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/pathkeys.c?r1=1.98&r2=1.99)
    pgsql/src/test/regress/expected:
        select_distinct_on.out (r1.5 -> r1.6)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/select_distinct_on.out?r1=1.5&r2=1.6)
    pgsql/src/test/regress/sql:
        select_distinct_on.sql (r1.4 -> r1.5)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/select_distinct_on.sql?r1=1.4&r2=1.5)

pgsql-committers by date:

Previous
From: tgl@postgresql.org (Tom Lane)
Date:
Subject: pgsql: Increase the maximum value of extra_float_digits to 3, and have
Next
From: tgl@postgresql.org (Tom Lane)
Date:
Subject: pgsql: Fix assertion failure when a SELECT DISTINCT ON expression is