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

Commit ba4d223

Browse files
committed
Tweak memory context sizing for saved SPI plans.
1 parent ecaa2e0 commit ba4d223

File tree

1 file changed

+27
-20
lines changed
  • src/backend/executor

1 file changed

+27
-20
lines changed

src/backend/executor/spi.c

+27-20
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@
33
* spi.c
44
* Server Programming Interface
55
*
6-
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.55 2001/06/01 19:43:55 tgl Exp $
6+
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
7+
* Portions Copyright (c) 1994, Regents of the University of California
8+
*
9+
*
10+
* IDENTIFICATION
11+
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.56 2001/08/02 16:05:23 tgl Exp $
712
*
813
*-------------------------------------------------------------------------
914
*/
10-
#include "executor/spi_priv.h"
15+
#include "postgres.h"
16+
1117
#include "access/printtup.h"
1218
#include "commands/command.h"
19+
#include "executor/spi_priv.h"
20+
1321

1422
uint32 SPI_processed = 0;
1523
Oid SPI_lastoid = InvalidOid;
@@ -786,10 +794,10 @@ spi_printtup(HeapTuple tuple, TupleDesc tupdesc, DestReceiver *self)
786794
if (tuptable == NULL)
787795
{
788796
tuptabcxt = AllocSetContextCreate(CurrentMemoryContext,
789-
"SPI TupTable",
790-
ALLOCSET_DEFAULT_MINSIZE,
791-
ALLOCSET_DEFAULT_INITSIZE,
792-
ALLOCSET_DEFAULT_MAXSIZE);
797+
"SPI TupTable",
798+
ALLOCSET_DEFAULT_MINSIZE,
799+
ALLOCSET_DEFAULT_INITSIZE,
800+
ALLOCSET_DEFAULT_MAXSIZE);
793801
MemoryContextSwitchTo(tuptabcxt);
794802

795803
_SPI_current->tuptable = tuptable = (SPITupleTable *)
@@ -1253,29 +1261,28 @@ _SPI_copy_plan(_SPI_plan *plan, int location)
12531261
_SPI_plan *newplan;
12541262
MemoryContext oldcxt;
12551263
MemoryContext plancxt;
1256-
MemoryContext parentcxt = CurrentMemoryContext;
1264+
MemoryContext parentcxt;
12571265

1258-
/* Determine correct parent for the plans memory context */
1266+
/* Determine correct parent for the plan's memory context */
12591267
if (location == _SPI_CPLAN_PROCXT)
12601268
parentcxt = _SPI_current->procCxt;
1261-
/*
1262-
oldcxt = MemoryContextSwitchTo(_SPI_current->procCxt);
1263-
*/
12641269
else if (location == _SPI_CPLAN_TOPCXT)
12651270
parentcxt = TopMemoryContext;
1266-
/*
1267-
oldcxt = MemoryContextSwitchTo(TopMemoryContext);
1268-
*/
1271+
else
1272+
parentcxt = CurrentMemoryContext;
12691273

1270-
/* Create a memory context for the plan */
1274+
/*
1275+
* Create a memory context for the plan. We don't expect the plan to
1276+
* be very large, so use smaller-than-default alloc parameters.
1277+
*/
12711278
plancxt = AllocSetContextCreate(parentcxt,
1272-
"SPI Plan",
1273-
ALLOCSET_DEFAULT_MINSIZE,
1274-
ALLOCSET_DEFAULT_INITSIZE,
1275-
ALLOCSET_DEFAULT_MAXSIZE);
1279+
"SPI Plan",
1280+
1024,
1281+
1024,
1282+
ALLOCSET_DEFAULT_MAXSIZE);
12761283
oldcxt = MemoryContextSwitchTo(plancxt);
12771284

1278-
/* Copy the SPI plan into it's own context */
1285+
/* Copy the SPI plan into its own context */
12791286
newplan = (_SPI_plan *) palloc(sizeof(_SPI_plan));
12801287
newplan->plancxt = plancxt;
12811288
newplan->qtlist = (List *) copyObject(plan->qtlist);

0 commit comments

Comments
 (0)