pgsql: Throw error for indeterminate collation of an ORDER/GROUP/DISTIN

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Throw error for indeterminate collation of an ORDER/GROUP/DISTIN
Date: 2011-03-22 19:58:31
Message-ID: E1Q27ip-00040H-G7@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Throw error for indeterminate collation of an ORDER/GROUP/DISTINCT target.

This restores a parse error that was thrown (though only in the ORDER BY
case) by the original collation patch. I had removed it in my recent
revisions because it was thrown at a place where collations now haven't
been computed yet; but I thought of another way to handle it.

Throwing the error at parse time, rather than leaving it to be done at
runtime, is good because a syntax error pointer is helpful for localizing
the problem. We can reasonably assume that the comparison function for a
collatable datatype will complain if it doesn't have a collation to use.
Now the planner might choose to implement GROUP or DISTINCT via hashing,
in which case no runtime error would actually occur, but it seems better
to throw error consistently rather than let the error depend on what the
planner chooses to do. Another possible objection is that the user might
specify a nondefault sort operator that doesn't care about collation
... but that's surely an uncommon usage, and it wouldn't hurt him to throw
in a COLLATE clause anyway. This change also makes the ORDER BY/GROUP
BY/DISTINCT case more consistent with the UNION/INTERSECT/EXCEPT case,
which was already coded to throw this error even though the same objections
could be raised there.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/37d6d07dda28a5dffcad6ff195ab2c83aaebcc9e

Modified Files
--------------
src/backend/parser/parse_collate.c | 24 ++++++++++++++++++++++
src/test/regress/expected/collate.linux.utf8.out | 5 ++++
src/test/regress/expected/collate.out | 5 ++++
src/test/regress/sql/collate.linux.utf8.sql | 1 +
src/test/regress/sql/collate.sql | 1 +
5 files changed, 36 insertions(+), 0 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2011-03-22 20:33:11 Re: Re: [COMMITTERS] pgsql: Efficient transaction-controlled synchronous replication.
Previous Message Tom Lane 2011-03-22 17:01:37 pgsql: Avoid potential deadlock in InitCatCachePhase2().

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-03-22 20:12:42 Re: wrap alpha4 tomorrow ~9am Eastern (was: Alpha4 release blockers)
Previous Message Devrim GÜNDÜZ 2011-03-22 19:55:32 Re: 2nd Level Buffer Cache