pgsql: Fix assertion failure when a SELECT DISTINCT ON expression is

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix assertion failure when a SELECT DISTINCT ON expression is
Date: 2009-09-12 00:05:07
Message-ID: 20090912000507.34945753FB7@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Tags:
----
REL8_4_STABLE

Modified Files:
--------------
pgsql/src/backend/optimizer/path:
equivclass.c (r1.19 -> r1.19.2.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/equivclass.c?r1=1.19&r2=1.19.2.1)
pathkeys.c (r1.97.2.1 -> r1.97.2.2)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/pathkeys.c?r1=1.97.2.1&r2=1.97.2.2)
pgsql/src/test/regress/expected:
select_distinct_on.out (r1.5 -> r1.5.2.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/select_distinct_on.out?r1=1.5&r2=1.5.2.1)
pgsql/src/test/regress/sql:
select_distinct_on.sql (r1.4 -> r1.4.24.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/select_distinct_on.sql?r1=1.4&r2=1.4.24.1)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2009-09-12 15:21:28 pgsql: Remove TODO file; it has been added to the main Todo list in the
Previous Message Tom Lane 2009-09-12 00:04:59 pgsql: Fix assertion failure when a SELECT DISTINCT ON expression is