Search Postgresql Archives

Re: COALESCE requires NULL from scalar subquery has a type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Geoff Winkless <pgsqladmin@xxxxxxxx> writes:
> SELECT COALESCE((SELECT 'Yes' FROM gwtest WHERE id=4), 'No') AS valid;
> gives an error

> I'm guessing this is because Postgres can't deduce the type of the
> string column from the source when the result isn't returned. Oddly,
> it also seems to cope when I do:
> SELECT COALESCE((SELECT 'Yes'::varchar FROM gwtest WHERE id=4), 'No') AS valid

Yup.  The output column type of the sub-SELECT is determined without
reference to its context, so there's nothing causing the unknown-type
literal to get assigned a definite type.

There's been occasional discussion of changing that behavior, but it's
not real clear that it wouldn't create as many problems as it solves.

			regards, tom lane


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux