]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix assertion failure when a SELECT DISTINCT ON expression is volatile.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 12 Sep 2009 00:05:07 +0000 (00:05 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 12 Sep 2009 00:05:07 +0000 (00:05 +0000)
commit3a3c2cd59cabb42d07200e3210a772552a9dc856
treeca208b0a755749a02bdb642a35dabfa8804a413f
parent96ca52dbe80a90d191eafbc656f03a33e85107a8
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.
src/backend/optimizer/path/equivclass.c
src/backend/optimizer/path/pathkeys.c
src/test/regress/expected/select_distinct_on.out
src/test/regress/sql/select_distinct_on.sql