Why does =ANY() need an extra cast when used on an array returned by a select? - Mailing list pgsql-general

From Frank van Vugt
Subject Why does =ANY() need an extra cast when used on an array returned by a select?
Date
Msg-id 200408231614.22148.ftm.van.vugt@foxi.nl
Whole thread Raw
In response to Re: Greatest/Least functions?  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: Why does =ANY() need an extra cast when used
List pgsql-general
Hi,

The following works :

db=# select 1 = ANY ('{1,2,3}'::int[]);
 ?column?
----------
 t
(1 row)


This doesn't :

db=# select 1 = ANY (select '{1,2,3}'::int[]);
ERROR:  operator does not exist: integer = integer[]
HINT:  No operator matches the given name and argument type(s). You may need
to add explicit type casts.

Using an extra case, the above can easily be made to work :

db=# select 1 = ANY ((select '{1,2,3}'::int[])::int[]);
 ?column?
----------
 t
(1 row)


I'm just wondering why the array returned by the inner select is not casted by
ANY() automagically?


db=# select version();
                               version
---------------------------------------------------------------------
 PostgreSQL 7.4.5 on i686-pc-linux-gnu, compiled by GCC egcs-2.91.66
(1 row)





--
Best,




Frank.


pgsql-general by date:

Previous
From: Christopher Browne
Date:
Subject: Re: postgres replication only some datas
Next
From: Thomas Hallgren
Date:
Subject: Re: Unsupported 3rd-party solutions (Was: Few questions