1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

Quick-and-dirty fix for recursive plpgsql functions, per bug report from

Frank Miles 7-Sep-01.  This is really just sticking a finger in the dike.
Frank's case works now, but we still couldn't support a recursive function
returning a set.  Really need to restructure querytrees and execution
state so that the querytree is *read only*.  We've run into this over and
over and over again ... it has to happen sometime soon.
This commit is contained in:
Tom Lane
2001-09-21 00:11:31 +00:00
parent ac0c234c16
commit ae3129fd03
5 changed files with 123 additions and 92 deletions

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.39 2001/03/22 03:59:57 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.40 2001/09/21 00:11:31 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -17,11 +17,8 @@
#include "utils/fcache.h"
/*-----------------------------------------------------------------
*
/*
* Build a 'FunctionCache' struct given the PG_PROC oid.
*
*-----------------------------------------------------------------
*/
FunctionCachePtr
init_fcache(Oid foid, int nargs, MemoryContext fcacheCxt)
@ -29,6 +26,10 @@ init_fcache(Oid foid, int nargs, MemoryContext fcacheCxt)
MemoryContext oldcontext;
FunctionCachePtr retval;
/* Safety check (should never fail, as parser should check sooner) */
if (nargs > FUNC_MAX_ARGS)
elog(ERROR, "init_fcache: too many arguments");
/* Switch to a context long-lived enough for the fcache entry */
oldcontext = MemoryContextSwitchTo(fcacheCxt);
@ -38,25 +39,8 @@ init_fcache(Oid foid, int nargs, MemoryContext fcacheCxt)
/* Set up the primary fmgr lookup information */
fmgr_info(foid, &(retval->func));
/* Initialize unvarying fields of per-call info block */
retval->fcinfo.flinfo = &(retval->func);
retval->fcinfo.nargs = nargs;
if (nargs > FUNC_MAX_ARGS)
elog(ERROR, "init_fcache: too many arguments");
/*
* If function returns set, prepare a resultinfo node for
* communication
*/
if (retval->func.fn_retset)
{
retval->fcinfo.resultinfo = (Node *) &(retval->rsinfo);
retval->rsinfo.type = T_ReturnSetInfo;
}
retval->argsValid = false;
retval->hasSetArg = false;
/* Initialize additional info */
retval->setArgsValid = false;
MemoryContextSwitchTo(oldcontext);