Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4ac592b

Browse files
committed
Fix oversight in my recent patch to allow ExecMakeFunctionResult to handle
materialize-mode set results. Since it now uses the ReturnSetInfo node to hold internal state, we need to be sure to set up the node even when the immediately called function doesn't return set (but does have a set-valued argument). Per report from Anupama Aherrao.
1 parent 517ae40 commit 4ac592b

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/backend/executor/execQual.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.237 2008/11/15 20:52:35 petere Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.238 2008/12/18 19:38:22 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1433,23 +1433,6 @@ ExecMakeFunctionResult(FuncExprState *fcache,
14331433
fcache->setArgsValid = false;
14341434
}
14351435

1436-
/*
1437-
* If function returns set, prepare a resultinfo node for communication
1438-
*/
1439-
if (fcache->func.fn_retset)
1440-
{
1441-
fcinfo->resultinfo = (Node *) &rsinfo;
1442-
rsinfo.type = T_ReturnSetInfo;
1443-
rsinfo.econtext = econtext;
1444-
rsinfo.expectedDesc = fcache->funcResultDesc;
1445-
rsinfo.allowedModes = (int) (SFRM_ValuePerCall | SFRM_Materialize);
1446-
/* note we do not set SFRM_Materialize_Random or _Preferred */
1447-
rsinfo.returnMode = SFRM_ValuePerCall;
1448-
/* isDone is filled below */
1449-
rsinfo.setResult = NULL;
1450-
rsinfo.setDesc = NULL;
1451-
}
1452-
14531436
/*
14541437
* Now call the function, passing the evaluated parameter values.
14551438
*/
@@ -1464,6 +1447,23 @@ ExecMakeFunctionResult(FuncExprState *fcache,
14641447
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
14651448
errmsg("set-valued function called in context that cannot accept a set")));
14661449

1450+
/*
1451+
* Prepare a resultinfo node for communication. If the function
1452+
* doesn't itself return set, we don't pass the resultinfo to the
1453+
* function, but we need to fill it in anyway for internal use.
1454+
*/
1455+
if (fcache->func.fn_retset)
1456+
fcinfo->resultinfo = (Node *) &rsinfo;
1457+
rsinfo.type = T_ReturnSetInfo;
1458+
rsinfo.econtext = econtext;
1459+
rsinfo.expectedDesc = fcache->funcResultDesc;
1460+
rsinfo.allowedModes = (int) (SFRM_ValuePerCall | SFRM_Materialize);
1461+
/* note we do not set SFRM_Materialize_Random or _Preferred */
1462+
rsinfo.returnMode = SFRM_ValuePerCall;
1463+
/* isDone is filled below */
1464+
rsinfo.setResult = NULL;
1465+
rsinfo.setDesc = NULL;
1466+
14671467
/*
14681468
* This loop handles the situation where we have both a set argument
14691469
* and a set-valued function. Once we have exhausted the function's

0 commit comments

Comments
 (0)