= ANY (SELECT ..) and type casts, what's going on here?

From: Russell Smith <mr-russ(at)pws(dot)com(dot)au>
To: PostgreSQL - General ML <pgsql-general(at)postgresql(dot)org>
Cc: Ben Kelada <B(dot)Kelada(at)latrobe(dot)edu(dot)au>
Subject: = ANY (SELECT ..) and type casts, what's going on here?
Date: 2011-06-15 22:12:35
Message-ID: 4DF92E53.50700@pws.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Is anybody able to explain the following behaviour?

Server is 8.4.7 RHEL5 build. Also happens on 8.4.8 Ubuntu x64 package.

mr-russ=# SELECT 'BU'::varchar = ANY ((select '{BU,CI}'::varchar[]));
ERROR: operator does not exist: character varying = character varying[]
LINE 1: SELECT 'BU'::varchar = ANY ((select '{BU,CI}'::varchar[]));
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
mr-russ=# SELECT 'BU'::varchar = ANY ((select '{BU,CI}'::varchar[])::varchar[]);
?column?
----------
t
(1 row)

mr-russ=#

What I don't understand is what happens to the single SELECT's type, is it because select returns a row? The error doesn't seem to match what I would expect?

Thanks

Russell

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Derrick Rice 2011-06-15 22:56:56 Re: { SELECT *->NOT(column1, column2) FROM table } syntax idea
Previous Message David Johnston 2011-06-15 22:08:06 { SELECT *->NOT(column1, column2) FROM table } syntax idea