Skip to content

Commit cc2fc4a

Browse files
committed
Fix SQL function executor for case where last command of a function is
not a SELECT. We didn't use to allow that, but we do now.
1 parent ccd99a5 commit cc2fc4a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/backend/executor/functions.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.65 2003/05/08 18:16:36 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.66 2003/06/12 17:29:26 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -262,17 +262,19 @@ postquel_getnext(execution_state *es)
262262

263263
if (es->qd->operation == CMD_UTILITY)
264264
{
265-
/*
266-
* Process a utility command. (create, destroy...) DZ - 30-8-1996
267-
*/
268265
ProcessUtility(es->qd->parsetree->utilityStmt, es->qd->dest, NULL);
269-
if (!LAST_POSTQUEL_COMMAND(es))
270-
CommandCounterIncrement();
271266
return (TupleTableSlot *) NULL;
272267
}
273268

274-
/* If it's not the last command, just run it to completion */
275-
count = (LAST_POSTQUEL_COMMAND(es)) ? 1L : 0L;
269+
/*
270+
* If it's the function's last command, and it's a SELECT, fetch one
271+
* row at a time so we can return the results. Otherwise just run it
272+
* to completion.
273+
*/
274+
if (LAST_POSTQUEL_COMMAND(es) && es->qd->operation == CMD_SELECT)
275+
count = 1L;
276+
else
277+
count = 0L;
276278

277279
return ExecutorRun(es->qd, ForwardScanDirection, count);
278280
}

0 commit comments

Comments
 (0)