|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.164 2006/10/04 00:29:53 momjian Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.165 2006/11/21 22:35:29 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -254,6 +254,19 @@ AtEOSubXact_SPI(bool isCommit, SubTransactionId mySubid)
|
254 | 254 | (errcode(ERRCODE_WARNING),
|
255 | 255 | errmsg("subtransaction left non-empty SPI stack"),
|
256 | 256 | errhint("Check for missing \"SPI_finish\" calls.")));
|
| 257 | + |
| 258 | +/* |
| 259 | + * If we are aborting a subtransaction and there is an open SPI context |
| 260 | + * surrounding the subxact, clean up to prevent memory leakage. |
| 261 | + */ |
| 262 | +if (_SPI_current&& !isCommit) |
| 263 | +{ |
| 264 | +/* free Executor memory the same as _SPI_end_call would do */ |
| 265 | +MemoryContextResetAndDeleteChildren(_SPI_current->execCxt); |
| 266 | +/* throw away any partially created tuple-table */ |
| 267 | +SPI_freetuptable(_SPI_current->tuptable); |
| 268 | +_SPI_current->tuptable=NULL; |
| 269 | +} |
257 | 270 | }
|
258 | 271 |
|
259 | 272 |
|
|