Re: SELECT 1 = ANY (SELECT ARRAY[1,2,3]) -> ERROR: operator does not exist: integer = integer[] ?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: SELECT 1 = ANY (SELECT ARRAY[1,2,3]) -> ERROR: operator does not exist: integer = integer[] ?
Дата
Msg-id 26033.1363186411@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: SELECT 1 = ANY (SELECT ARRAY[1,2,3]) -> ERROR: operator does not exist: integer = integer[] ?  (Ian Lawrence Barwick <barwick@gmail.com>)
Список pgsql-general
Ian Lawrence Barwick <barwick@gmail.com> writes:
> 2013/3/13 Thor Michael Støre <thormichael@gmail.com>:
>> Could someone make sense of this for me?

>> postgres=# select 1 = ANY (SELECT ARRAY[1,2,3]);
>> ERROR:  operator does not exist: integer = integer[]

> A bit tricky to explain...

Yeah.  The short answer is that "foo = ANY (SELECT ...)" is mandated by
standard to mean "compare foo to each value in the rowset returned by
the sub-SELECT".  So the above is invalid, and the error message is
giving a perfectly clear reason why.

Postgres has abused the ANY notation by saying that, if the right-hand
side is not a SELECT at the top level (which would be invalid on its
face per spec), then it must be an expression delivering an array value,
and we compare foo to each array element.  This isn't terribly
consistent but it's about the only easy way to shoehorn such an
operation into the language at all.

            regards, tom lane


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

Предыдущее
От: Ian Lawrence Barwick
Дата:
Сообщение: Re: SELECT 1 = ANY (SELECT ARRAY[1,2,3]) -> ERROR: operator does not exist: integer = integer[] ?
Следующее
От: Thor Michael Støre
Дата:
Сообщение: Re: SELECT 1 = ANY (SELECT ARRAY[1,2,3]) -> ERROR: operator does not exist: integer = integer[] ?