pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: brandstetter@falter.at
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #8150: NULL emements lost when casting result of unnest()
Date: Sat, 11 May 2013 11:13:44 -0400
Message-ID: <16834.1368285224@sss.pgh.pa.us> (raw)
In-Reply-To: <E1Ub8p6-0006NC-Ja@wrigleys.postgresql.org>
References: <E1Ub8p6-0006NC-Ja@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

brandstetter@falter.at writes:
> SELECT unnest('{1,NULL,4}'::int[])::int8;
>  i
> ---
>  1
>  4

Hm ... this seems to be a very old oversight in ExecMakeFunctionResult:
when it's dealing with a set-valued function argument, if the function
is strict and the particular input value is NULL, it sets the isDone
flag to ExprEndResult, ie, empty-set result.  I think this is the right
thing if the current function returns set; but for a non-set-returning
function, what we ought to get is a scalar NULL result not an empty set.
Various other code paths including ExecMakeTableFunctionResult appear to
get this right.

The attached patch fixes it.

This is another case where I'm not too sure if we ought to back-patch.
The current behavior is clearly wrong, but perhaps some application
out there will be unhappy if we change it in back branches?

			regards, tom lane

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

view thread (3+ messages)  latest in thread

Message-ID: <16834.1368285224@sss.pgh.pa.us>
Permalink:  ../16834.1368285224@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/16834.1368285224@sss.pgh.pa.us

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, brandstetter@falter.at
  Subject: Re: BUG #8150: NULL emements lost when casting result of unnest()
  In-Reply-To: <16834.1368285224@sss.pgh.pa.us>
  References: <E1Ub8p6-0006NC-Ja@wrigleys.postgresql.org> <16834.1368285224@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox