Skip to content

Commit 1198d63

Browse files
committed
Add some defenses against functions declared to return set that don't
actually follow the protocol; per example from Kris Jurka.
1 parent 4744c1a commit 1198d63

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/backend/executor/execQual.c

Lines changed: 4 additions & 3 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.177 2005/05/06 17:24:53 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.178 2005/05/09 14:28:39 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -948,7 +948,7 @@ ExecMakeFunctionResult(FuncExprState *fcache,
948948
* returns set, save the current argument values to re-use
949949
* on the next call.
950950
*/
951-
if (fcache->func.fn_retset)
951+
if (fcache->func.fn_retset && *isDone == ExprMultipleResult)
952952
{
953953
memcpy(&fcache->setArgs, &fcinfo, sizeof(fcinfo));
954954
fcache->setHasSetArg = hasSetArg;
@@ -967,7 +967,8 @@ ExecMakeFunctionResult(FuncExprState *fcache,
967967
* Make sure we say we are returning a set, even if the
968968
* function itself doesn't return sets.
969969
*/
970-
*isDone = ExprMultipleResult;
970+
if (hasSetArg)
971+
*isDone = ExprMultipleResult;
971972
break;
972973
}
973974

0 commit comments

Comments
 (0)