Unix Technical Forum

Re: NULL value in subselect in UNION causes error

This is a discussion on Re: NULL value in subselect in UNION causes error within the pgsql Hackers forums, part of the PostgreSQL category; --> Jan Wieck <JanWieck@Yahoo.com> writes: > Checked it against HEAD and 8.2: > postgres=# select 1, 1, 1 union select ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008, 06:43 AM
Tom Lane
 
Posts: n/a
Default Re: NULL value in subselect in UNION causes error

Jan Wieck <JanWieck@Yahoo.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

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-12-2008, 06:43 AM
Jan Wieck
 
Posts: n/a
Default Re: NULL value in subselect in UNION causes error

On 1/26/2007 3:41 PM, Tom Lane wrote:
> Jan Wieck <JanWieck@Yahoo.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@Yahoo.com #

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:14 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com