aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2013-05-12 13:08:12 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2013-05-12 13:08:12 -0400
commit904af8db8a99409257db1eed0b056c8098e9013c (patch)
treeb4533f0bd710f94509d62fda5370a9cc449ab9e6 /src/backend/executor
parentf0ed3a8a99b052d2d5e0b6153a8907b90c486636 (diff)
downloadpostgresql-904af8db8a99409257db1eed0b056c8098e9013c.tar.gz
postgresql-904af8db8a99409257db1eed0b056c8098e9013c.zip
Fix handling of strict non-set functions with NULLs in set-valued inputs.
In a construct like "select plain_function(set_returning_function(...))", the plain function is applied to each output row of the SRF successively. If some of the SRF outputs are NULL, and the plain function is strict, you'd expect to get NULL results for such rows ... but what actually happened was that such rows were omitted entirely from the result set. This was due to confusion of this case with what should happen for nested set-returning functions; a strict SRF is indeed supposed to yield an empty set for null input. Per bug #8150 from Erwin Brandstetter. Although this has been broken forever, we're not back-patching because of the possibility that some apps out there expect the incorrect behavior. This change should be listed as a possible incompatibility in the 9.3 release notes.
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/execQual.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c
index 4ea0cbadadb..494208a0320 100644
--- a/src/backend/executor/execQual.c
+++ b/src/backend/executor/execQual.c
@@ -1801,12 +1801,20 @@ restart:
pgstat_end_function_usage(&fcusage,
rsinfo.isDone != ExprMultipleResult);
}
- else
+ else if (fcache->func.fn_retset)
{
+ /* for a strict SRF, result for NULL is an empty set */
result = (Datum) 0;
*isNull = true;
*isDone = ExprEndResult;
}
+ else
+ {
+ /* for a strict non-SRF, result for NULL is a NULL */
+ result = (Datum) 0;
+ *isNull = true;
+ *isDone = ExprSingleResult;
+ }
/* Which protocol does function want to use? */
if (rsinfo.returnMode == SFRM_ValuePerCall)