On Wed, Jul 20, 2016 at 5:38 PM, Bruce Momjian <br...@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.