|
3 | 3 | * spi.c
|
4 | 4 | * Server Programming Interface
|
5 | 5 | *
|
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 $ |
7 | 12 | *
|
8 | 13 | *-------------------------------------------------------------------------
|
9 | 14 | */
|
10 |
| -#include "executor/spi_priv.h" |
| 15 | +#include "postgres.h" |
| 16 | + |
11 | 17 | #include "access/printtup.h"
|
12 | 18 | #include "commands/command.h"
|
| 19 | +#include "executor/spi_priv.h" |
| 20 | + |
13 | 21 |
|
14 | 22 | uint32 SPI_processed = 0;
|
15 | 23 | Oid SPI_lastoid = InvalidOid;
|
@@ -786,10 +794,10 @@ spi_printtup(HeapTuple tuple, TupleDesc tupdesc, DestReceiver *self)
|
786 | 794 | if (tuptable == NULL)
|
787 | 795 | {
|
788 | 796 | 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); |
793 | 801 | MemoryContextSwitchTo(tuptabcxt);
|
794 | 802 |
|
795 | 803 | _SPI_current->tuptable = tuptable = (SPITupleTable *)
|
@@ -1253,29 +1261,28 @@ _SPI_copy_plan(_SPI_plan *plan, int location)
|
1253 | 1261 | _SPI_plan *newplan;
|
1254 | 1262 | MemoryContext oldcxt;
|
1255 | 1263 | MemoryContext plancxt;
|
1256 |
| - MemoryContext parentcxt = CurrentMemoryContext; |
| 1264 | + MemoryContext parentcxt; |
1257 | 1265 |
|
1258 |
| - /* Determine correct parent for the plans memory context */ |
| 1266 | + /* Determine correct parent for the plan's memory context */ |
1259 | 1267 | if (location == _SPI_CPLAN_PROCXT)
|
1260 | 1268 | parentcxt = _SPI_current->procCxt;
|
1261 |
| - /* |
1262 |
| - oldcxt = MemoryContextSwitchTo(_SPI_current->procCxt); |
1263 |
| - */ |
1264 | 1269 | else if (location == _SPI_CPLAN_TOPCXT)
|
1265 | 1270 | parentcxt = TopMemoryContext;
|
1266 |
| - /* |
1267 |
| - oldcxt = MemoryContextSwitchTo(TopMemoryContext); |
1268 |
| - */ |
| 1271 | + else |
| 1272 | + parentcxt = CurrentMemoryContext; |
1269 | 1273 |
|
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 | + */ |
1271 | 1278 | 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); |
1276 | 1283 | oldcxt = MemoryContextSwitchTo(plancxt);
|
1277 | 1284 |
|
1278 |
| - /* Copy the SPI plan into it's own context */ |
| 1285 | + /* Copy the SPI plan into its own context */ |
1279 | 1286 | newplan = (_SPI_plan *) palloc(sizeof(_SPI_plan));
|
1280 | 1287 | newplan->plancxt = plancxt;
|
1281 | 1288 | newplan->qtlist = (List *) copyObject(plan->qtlist);
|
|
0 commit comments