Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7ec1c5a

Browse files
committed
Prevent intratransaction memory leak when a subtransaction is aborted
in the middle of executing a SPI query. This doesn't entirely fix theproblem of memory leakage in plpgsql exception handling, but it shouldget rid of the lion's share of leakage.
1 parent5fc2d7e commit7ec1c5a

File tree

1 file changed

+14
-1
lines changed
  • src/backend/executor

1 file changed

+14
-1
lines changed

‎src/backend/executor/spi.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* 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 $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -254,6 +254,19 @@ AtEOSubXact_SPI(bool isCommit, SubTransactionId mySubid)
254254
(errcode(ERRCODE_WARNING),
255255
errmsg("subtransaction left non-empty SPI stack"),
256256
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+
}
257270
}
258271

259272

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp