Re: Odd error when using UNION and COLLATE

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Odd error when using UNION and COLLATE
Date: 2016-07-20 21:58:53
Message-ID: CAKFQuwZSrzXhpnhox4fs7CyY2gnKsrx0hSxm6FmNMcQUNkTu5A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jul 20, 2016 at 5:38 PM, Bruce Momjian <bruce(at)momjian(dot)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.​

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2016-07-20 21:59:52 Re: Odd error when using UNION and COLLATE
Previous Message Greg Stark 2016-07-20 21:55:38 Re: Odd error when using UNION and COLLATE