Re: Why does =ANY() need an extra cast when used - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Why does =ANY() need an extra cast when used
Date
Msg-id 20040823075510.H6667@megazone.bigpanda.com
Whole thread Raw
In response to Why does =ANY() need an extra cast when used on an array returned by a select?  (Frank van Vugt <ftm.van.vugt@foxi.nl>)
List pgsql-general
On Mon, 23 Aug 2004, Frank van Vugt wrote:

> 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?


Barring the cast syntax and such, the first and last query would I believe
be illegal in SQL92/99, so we defined useful behavior for them for this
case.  The second query looks to me to be of the form = ANY (table
subquery) which already had defined behavior by spec. Changing it to act
like the first or last would break that spec behavior.

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Unsupported 3rd-party solutions (Was: Few questions
Next
From: Frank van Vugt
Date:
Subject: Re: Why does =ANY() need an extra cast when used