Why does =ANY(<array>) need an extra cast when used on an array returned by a select?

From: Frank van Vugt <ftm(dot)van(dot)vugt(at)foxi(dot)nl>
To: pgsql-general(at)postgresql(dot)org
Subject: Why does =ANY(<array>) need an extra cast when used on an array returned by a select?
Date: 2004-08-23 14:14:22
Message-ID: 200408231614.22148.ftm.van.vugt@foxi.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jan Wieck 2004-08-23 14:17:36 Re: Few questions on postgresql (dblink, 2pc, clustering)
Previous Message Thomas Hallgren 2004-08-23 14:09:03 Re: Unsupported 3rd-party solutions (Was: Few questions