Re: Odd error when using UNION and COLLATE - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: Odd error when using UNION and COLLATE
Date
Msg-id CAKFQuwZSrzXhpnhox4fs7CyY2gnKsrx0hSxm6FmNMcQUNkTu5A@mail.gmail.com
Whole thread Raw
In response to Odd error when using UNION and COLLATE  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
On Wed, Jul 20, 2016 at 5:38 PM, Bruce Momjian <bruce@momjian.us> wrote:
I think the 'ORDER BY x COLLATE "C"' is being parsed as an a_expr, and
we don't allow a_expr in a UNION.  Perhaps we are too strict here, but I
can't tell.

​ORDER BY 1 COLLATE "C" is indeed an expression - the number no longer refers to a column position but it is a constant.  The presence or absence of UNION doesn't factor into things here - the expression itself is useless on its face.​

This one is a bit different in cause but I suspect is working as well as can be expected.

SELECT 'a-c' AS x UNION ALL SELECT 'ab' AS x ORDER BY x COLLATE "C";

​David J.​

pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: Odd error when using UNION and COLLATE
Next
From: Greg Stark
Date:
Subject: Re: Odd error when using UNION and COLLATE