Odd error when using UNION and COLLATE

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Odd error when using UNION and COLLATE
Дата
Msg-id 20160720213821.GO24590@momjian.us
обсуждение исходный текст
Ответы Re: Odd error when using UNION and COLLATE  (Greg Stark <stark@mit.edu>)
Re: Odd error when using UNION and COLLATE  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-hackers
Seems you can't use UNION and COLLATE in the same SELECT statement;  you
have to put the UNION inside of WITH and then do the COLLATE outside:
test=> SELECT 'a-c' AS x UNION ALL SELECT 'ab' AS x ORDER BY 1 COLLATE "C";ERROR:  collations are not supported by type
integerLINE1: ... 'a-c' AS x UNION ALL SELECT 'ab' AS x ORDER BY 1 COLLATE "C...
                   ^
 

test=> SELECT 'a-c' AS x UNION ALL SELECT 'ab' AS x ORDER BY x COLLATE "C";ERROR:  invalid UNION/INTERSECT/EXCEPT ORDER
BYclauseLINE 1: ...CT 'a-c' AS x UNION ALL SELECT 'ab' AS x ORDER BY x COLLATE ...
                     ^DETAIL:  Only result column names can be used, not expressions or functions.HINT:  Add the
expression/functionto every SELECT, or move the UNION into a FROM clause.
 

test=> WITH d AS (SELECT 'a-c' AS x UNION ALL SELECT 'ab' AS x) SELECT * FROM d ORDER BY x COLLATE "C";  x----- a-c
ab(2rows)
 

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.

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com

+ As you are, so once was I. As I am, so you will be. +
+                     Ancient Roman grave inscription +



В списке pgsql-hackers по дате отправления:

Предыдущее
От: David Fetter
Дата:
Сообщение: Re: Password identifiers, protocol aging and SCRAM protocol
Следующее
От: Greg Stark
Дата:
Сообщение: Re: Odd error when using UNION and COLLATE