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:04:59
Message-ID: 20090912000459.46D8F753FB7@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.

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)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2009-09-12 00:05:07 pgsql: Fix assertion failure when a SELECT DISTINCT ON expression is
Previous Message Tom Lane 2009-09-11 19:21:30 Re: Re: [COMMITTERS] pgsql: On Windows, when a file is deleted and another process still has