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

From Thor Michael Støre
Subject SELECT 1 = ANY (SELECT ARRAY[1,2,3]) -> ERROR: operator does not exist: integer = integer[] ?
Date
Msg-id 2F624E3A-5C94-44CB-B6D3-B1502D436FB5@gmail.com
Whole thread Raw
Responses Re: SELECT 1 = ANY (SELECT ARRAY[1,2,3]) -> ERROR: operator does not exist: integer = integer[] ?
List pgsql-general
Hello,

Could someone make sense of this for me?

$ /Library/PostgreSQL/9.2/bin/psql -d postgres postgres
psql (9.2.3)
Type "help" for help.

postgres=# select 1 = ANY (ARRAY[1,2,3]);
 ?column? 
----------
 t
(1 row)

postgres=# select 1 = ANY (SELECT ARRAY[1,2,3]);
ERROR:  operator does not exist: integer = integer[]
LINE 1: select 1 = ANY (SELECT ARRAY[1,2,3]);
                 ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
postgres=# select 1 = ANY ((SELECT ARRAY[1,2,3])::int[]);
 ?column? 
----------
 t
(1 row)

Why do I have to add an explicit cast to int array on something that is an int array to begin with? Based on the error message containing "integer = integer[]" I'd say PostgreSQL manages to figure out the right type anyhow, and ::int[] shouldn't change anything, but I still get a message that doesn't make sense when I have an ANY there.

Thanks,
Michael

pgsql-general by date:

Previous
From: Fabrízio de Royes Mello
Date:
Subject: Re: Select rotate in PostgreSql
Next
From: Ian Lawrence Barwick
Date:
Subject: Re: SELECT 1 = ANY (SELECT ARRAY[1,2,3]) -> ERROR: operator does not exist: integer = integer[] ?