8.4 RC1 union/nested select cast bug?

Lists: pgsql-hackers
From: Eric Miller <eric_g_miller(at)yahoo(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: 8.4 RC1 union/nested select cast bug?
Date: 2009-06-25 23:44:05
Message-ID: 300814.4535.qm@web110404.mail.gq1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


With 8.4RC1, I get the following error with the SQL below.

ERROR: failed to find conversion function from unknown to character varying
SQL state: XX000

SELECT 0 AS "C1", cast('a' as varchar) AS "C2"
UNION ALL
SELECT 1 AS "C1", "X"."XX" AS "C2"
FROM ( SELECT NULL AS "XX" ) AS "X"
WHERE TRUE = FALSE

Compare that SQL to this:

SELECT 0 AS "C1", cast('a' as varchar) AS "C2"
UNION ALL
SELECT 1 AS "C1", NULL AS "C2"
WHERE TRUE = FALSE

The second works without the nested subquery.

I ran into SQL like the above when trying to use the Npgsql .Net driver 2.0.5 via Microsoft's Entity Framework (edmgen.exe). It happened against two different databases. Both have UTF-8 encoding and English, United States language.

--
Eric


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Eric Miller <eric_g_miller(at)yahoo(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.4 RC1 union/nested select cast bug?
Date: 2009-06-26 00:50:02
Message-ID: 19492.1245977402@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Eric Miller <eric_g_miller(at)yahoo(dot)com> writes:
> With 8.4RC1, I get the following error with the SQL below.
> ERROR: failed to find conversion function from unknown to character varying

Every PG version since 7.1 complains about that query, because it's
underspecified. Cast the NULL to something specific in the sub-SELECT.

regards, tom lane