Commit ba4d223c authored by Tom Lane's avatar Tom Lane

Tweak memory context sizing for saved SPI plans.

parent ecaa2e01
...@@ -3,13 +3,21 @@ ...@@ -3,13 +3,21 @@
* spi.c * spi.c
* Server Programming Interface * Server Programming Interface
* *
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.55 2001/06/01 19:43:55 tgl Exp $ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.56 2001/08/02 16:05:23 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "executor/spi_priv.h" #include "postgres.h"
#include "access/printtup.h" #include "access/printtup.h"
#include "commands/command.h" #include "commands/command.h"
#include "executor/spi_priv.h"
uint32 SPI_processed = 0; uint32 SPI_processed = 0;
Oid SPI_lastoid = InvalidOid; Oid SPI_lastoid = InvalidOid;
...@@ -1253,29 +1261,28 @@ _SPI_copy_plan(_SPI_plan *plan, int location) ...@@ -1253,29 +1261,28 @@ _SPI_copy_plan(_SPI_plan *plan, int location)
_SPI_plan *newplan; _SPI_plan *newplan;
MemoryContext oldcxt; MemoryContext oldcxt;
MemoryContext plancxt; MemoryContext plancxt;
MemoryContext parentcxt = CurrentMemoryContext; MemoryContext parentcxt;
/* Determine correct parent for the plans memory context */ /* Determine correct parent for the plan's memory context */
if (location == _SPI_CPLAN_PROCXT) if (location == _SPI_CPLAN_PROCXT)
parentcxt = _SPI_current->procCxt; parentcxt = _SPI_current->procCxt;
/*
oldcxt = MemoryContextSwitchTo(_SPI_current->procCxt);
*/
else if (location == _SPI_CPLAN_TOPCXT) else if (location == _SPI_CPLAN_TOPCXT)
parentcxt = TopMemoryContext; parentcxt = TopMemoryContext;
else
parentcxt = CurrentMemoryContext;
/* /*
oldcxt = MemoryContextSwitchTo(TopMemoryContext); * Create a memory context for the plan. We don't expect the plan to
* be very large, so use smaller-than-default alloc parameters.
*/ */
/* Create a memory context for the plan */
plancxt = AllocSetContextCreate(parentcxt, plancxt = AllocSetContextCreate(parentcxt,
"SPI Plan", "SPI Plan",
ALLOCSET_DEFAULT_MINSIZE, 1024,
ALLOCSET_DEFAULT_INITSIZE, 1024,
ALLOCSET_DEFAULT_MAXSIZE); ALLOCSET_DEFAULT_MAXSIZE);
oldcxt = MemoryContextSwitchTo(plancxt); oldcxt = MemoryContextSwitchTo(plancxt);
/* Copy the SPI plan into it's own context */ /* Copy the SPI plan into its own context */
newplan = (_SPI_plan *) palloc(sizeof(_SPI_plan)); newplan = (_SPI_plan *) palloc(sizeof(_SPI_plan));
newplan->plancxt = plancxt; newplan->plancxt = plancxt;
newplan->qtlist = (List *) copyObject(plan->qtlist); newplan->qtlist = (List *) copyObject(plan->qtlist);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment