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

Commite2605c8

Browse files
committed
Add a warning to AtEOXact_SPI() to catch cases where the current
transaction has been committed without SPI_finish() being calledfirst. Per recent discussion here:http://archives.postgresql.org/pgsql-patches/2003-11/msg00286.php
1 parent0fd336c commite2605c8

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

‎src/backend/access/transam/xact.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.157 2003/11/29 19:51:40 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.158 2003/12/02 19:26:47 joe Exp $
1212
*
1313
* NOTES
1414
*Transaction aborts can now occur two ways:
@@ -977,7 +977,7 @@ CommitTransaction(void)
977977

978978
CallEOXactCallbacks(true);
979979
AtEOXact_GUC(true);
980-
AtEOXact_SPI();
980+
AtEOXact_SPI(true);
981981
AtEOXact_gist();
982982
AtEOXact_hash();
983983
AtEOXact_nbtree();
@@ -1087,7 +1087,7 @@ AbortTransaction(void)
10871087

10881088
CallEOXactCallbacks(false);
10891089
AtEOXact_GUC(false);
1090-
AtEOXact_SPI();
1090+
AtEOXact_SPI(false);
10911091
AtEOXact_gist();
10921092
AtEOXact_hash();
10931093
AtEOXact_nbtree();

‎src/backend/executor/spi.c

Lines changed: 12 additions & 4 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.108 2003/11/29 19:51:48 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.109 2003/12/02 19:26:47 joe Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -174,18 +174,26 @@ SPI_finish(void)
174174
}
175175

176176
/*
177-
* Clean up SPI state at transaction commit or abort (we don't care which).
177+
* Clean up SPI state at transaction commit or abort.
178178
*/
179179
void
180-
AtEOXact_SPI(void)
180+
AtEOXact_SPI(boolisCommit)
181181
{
182182
/*
183183
* Note that memory contexts belonging to SPI stack entries will be
184184
* freed automatically, so we can ignore them here. We just need to
185185
* restore our static variables to initial state.
186186
*/
187-
if (_SPI_stack!=NULL)/* there was abort */
187+
if (_SPI_stack!=NULL)
188+
{
188189
free(_SPI_stack);
190+
if (isCommit)
191+
ereport(WARNING,
192+
(errcode(ERRCODE_WARNING),
193+
errmsg("freeing non-empty SPI stack"),
194+
errhint("Check for missing \"SPI_finish\" calls")));
195+
}
196+
189197
_SPI_current=_SPI_stack=NULL;
190198
_SPI_connected=_SPI_curid=-1;
191199
SPI_processed=0;

‎src/include/executor/spi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* spi.h
44
*
5-
* $PostgreSQL: pgsql/src/include/executor/spi.h,v 1.40 2003/11/29 22:41:01 pgsql Exp $
5+
* $PostgreSQL: pgsql/src/include/executor/spi.h,v 1.41 2003/12/02 19:26:47 joe Exp $
66
*
77
*-------------------------------------------------------------------------
88
*/
@@ -116,6 +116,6 @@ extern void SPI_cursor_fetch(Portal portal, bool forward, int count);
116116
externvoidSPI_cursor_move(Portalportal,boolforward,intcount);
117117
externvoidSPI_cursor_close(Portalportal);
118118

119-
externvoidAtEOXact_SPI(void);
119+
externvoidAtEOXact_SPI(boolisCommit);
120120

121121
#endif/* SPI_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp