pgsql: Allow ORDER BY/GROUP BY/etc items to match targetlist items

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Allow ORDER BY/GROUP BY/etc items to match targetlist items
Date: 2010-07-18 19:37:49
Message-ID: 20100718193749.2C22D7541D5@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
Allow ORDER BY/GROUP BY/etc items to match targetlist items regardless of
any implicit casting previously applied to the targetlist item. This is
reasonable because the implicit cast, by definition, wasn't written by the
user; so we are preserving the expected behavior that ORDER BY items match
textually equivalent tlist items. The case never arose before because there
couldn't be any implicit casting of a top-level SELECT item before we process
ORDER BY etc. But now it can arise in the context of aggregates containing
ORDER BY clauses, since the "targetlist" is the already-casted list of
arguments for the aggregate. The net effect is that the datatype used for
ORDER BY/DISTINCT purposes is the aggregate's declared input type, not that
of the original input column; which is a bit debatable but not horrendous,
and to do otherwise would require major rework that doesn't seem justified.

Per bug #5564 from Daniel Grace. Back-patch to 9.0 where aggregate ORDER BY
was implemented.

Modified Files:
--------------
pgsql/src/backend/parser:
parse_clause.c (r1.198 -> r1.199)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_clause.c?r1=1.198&r2=1.199)
pgsql/src/test/regress/expected:
aggregates.out (r1.21 -> r1.22)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/aggregates.out?r1=1.21&r2=1.22)
pgsql/src/test/regress/sql:
aggregates.sql (r1.17 -> r1.18)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/aggregates.sql?r1=1.17&r2=1.18)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2010-07-18 19:37:57 pgsql: Allow ORDER BY/GROUP BY/etc items to match targetlist items
Previous Message Tom Lane 2010-07-18 17:08:11 pgsql: Fix up poor handling of unsupported-platform case in requirepeer