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

Commit25ee160

Browse files
committed
More paranoia in AtEOSubXact_SPI: don't assume we can safely use SPI_finish
for cleaning up. It seems possible that the memory contexts SPI_finishwould try to touch are already gone; and there's no need for SPI itselfto delete them, since the containing contexts will surely be going awayanyway at transaction end.
1 parent1732cb0 commit25ee160

File tree

1 file changed

+16
-5
lines changed
  • src/backend/executor

1 file changed

+16
-5
lines changed

‎src/backend/executor/spi.c

Lines changed: 16 additions & 5 deletions
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.119 2004/07/0100:50:26 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.120 2004/07/0121:17:13 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -206,16 +206,27 @@ AtEOSubXact_SPI(bool isCommit, TransactionId childXid)
206206
while (_SPI_connected >=0)
207207
{
208208
_SPI_connection*connection=&(_SPI_stack[_SPI_connected]);
209-
intres;
210209

211210
if (connection->connectXid!=childXid)
212211
break;/* couldn't be any underneath it either */
213212

214213
found= true;
215214

216-
_SPI_curid=_SPI_connected-1;/* avoid begin_call error */
217-
res=SPI_finish();
218-
Assert(res==SPI_OK_FINISH);
215+
/*
216+
* Pop the stack entry and reset global variables. Unlike
217+
* SPI_finish(), we don't risk switching to memory contexts that
218+
* might be already gone, or deleting memory contexts that have been
219+
* or will be thrown away anyway.
220+
*/
221+
_SPI_connected--;
222+
_SPI_curid=_SPI_connected;
223+
if (_SPI_connected==-1)
224+
_SPI_current=NULL;
225+
else
226+
_SPI_current=&(_SPI_stack[_SPI_connected]);
227+
SPI_processed=0;
228+
SPI_lastoid=InvalidOid;
229+
SPI_tuptable=NULL;
219230
}
220231

221232
if (found&&isCommit)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp