Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group