pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <rhodiumtoad@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Postpone aggregate checks until after collation is assigned.
Date: Thu, 17 Jan 2019 06:47:51 +0000
Message-ID: <E1gk1Sx-0005Kh-Eh@gemulon.postgresql.org> (raw)

Postpone aggregate checks until after collation is assigned.

Previously, parseCheckAggregates was run before
assign_query_collations, but this causes problems if any expression
has already had a collation assigned by some transform function (e.g.
transformCaseExpr) before parseCheckAggregates runs. The differing
collations would cause expressions not to be recognized as equal to
the ones in the GROUP BY clause, leading to spurious errors about
unaggregated column references.

The result was that CASE expr WHEN val ... would fail when "expr"
contained a GROUPING() expression or matched one of the group by
expressions, and where collatable types were involved; whereas the
supposedly identical CASE WHEN expr = val ... would succeed.

Backpatch all the way; this appears to have been wrong ever since
collations were introduced.

Per report from Guillaume Lelarge, analysis and patch by me.

Discussion: https://postgr.es/m/CAECtzeVSO_US8C2Khgfv54ZMUOBR4sWq+6_bLrETnWExHT=rFg@mail.gmail.com
Discussion: https://postgr.es/m/87muo0k0c7.fsf@news-spur.riddles.org.uk

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/409230a721cf32a2df4fd02338e785b3993f9c7a

Modified Files
--------------
src/backend/parser/analyze.c               | 18 ++++++++++++------
src/test/regress/expected/aggregates.out   | 19 +++++++++++++++++++
src/test/regress/expected/groupingsets.out | 25 +++++++++++++++++++++++++
src/test/regress/sql/aggregates.sql        |  8 ++++++++
src/test/regress/sql/groupingsets.sql      | 11 +++++++++++
5 files changed, 75 insertions(+), 6 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1gk1Sx-0005Kh-Eh@gemulon.postgresql.org>
Permalink:  ../E1gk1Sx-0005Kh-Eh@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1gk1Sx-0005Kh-Eh@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: rhodiumtoad@postgresql.org
  Subject: Re: pgsql: Postpone aggregate checks until after collation is assigned.
  In-Reply-To: <E1gk1Sx-0005Kh-Eh@gemulon.postgresql.org>
  References: <E1gk1Sx-0005Kh-Eh@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox