Re: NULL value in subselect in UNION causes error

Lists: pgsql-hackers
From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: NULL value in subselect in UNION causes error
Date: 2007-01-26 19:58:53
Message-ID: 45BA5D7D.8040608@Yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Checked it against HEAD and 8.2:

postgres=# select 1, 1, 1 union select * from (select 2, null, 2) two;
ERROR: failed to find conversion function from "unknown" to integer

Jan

--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jan Wieck <JanWieck(at)Yahoo(dot)com>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: NULL value in subselect in UNION causes error
Date: 2007-01-26 20:41:24
Message-ID: 28688.1169844084@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Jan Wieck <JanWieck(at)Yahoo(dot)com> writes:
> Checked it against HEAD and 8.2:
> postgres=# select 1, 1, 1 union select * from (select 2, null, 2) two;
> ERROR: failed to find conversion function from "unknown" to integer

It's always done that. The SQL spec would tell you that you have to
cast the null to some specific type. We allow untyped nulls in contexts
where we can derive a type from reasonably nearby context, but an
integer two levels up and over in another union arm isn't very nearby
IMHO. So I'm not particularly concerned about making this work ...

regards, tom lane


From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: NULL value in subselect in UNION causes error
Date: 2007-01-26 20:46:50
Message-ID: 45BA68BA.2080204@Yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 1/26/2007 3:41 PM, Tom Lane wrote:
> Jan Wieck <JanWieck(at)Yahoo(dot)com> writes:
>> Checked it against HEAD and 8.2:
>> postgres=# select 1, 1, 1 union select * from (select 2, null, 2) two;
>> ERROR: failed to find conversion function from "unknown" to integer
>
> It's always done that. The SQL spec would tell you that you have to
> cast the null to some specific type. We allow untyped nulls in contexts
> where we can derive a type from reasonably nearby context, but an
> integer two levels up and over in another union arm isn't very nearby
> IMHO. So I'm not particularly concerned about making this work ...

That explains. Thanks.

Jan

--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #