aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
authorJoe Conway <mail@joeconway.com>2003-12-02 19:26:47 +0000
committerJoe Conway <mail@joeconway.com>2003-12-02 19:26:47 +0000
commite2605c8311948e479b742ebbd81cdff400cb70c3 (patch)
tree3c98a9f4564580767070f27739e4d82bab539746 /src/backend/executor
parent0fd336c61dba7877f7d24dc55e855f1bc478ee7d (diff)
downloadpostgresql-e2605c8311948e479b742ebbd81cdff400cb70c3.tar.gz
postgresql-e2605c8311948e479b742ebbd81cdff400cb70c3.zip
Add a warning to AtEOXact_SPI() to catch cases where the current
transaction has been committed without SPI_finish() being called first. Per recent discussion here: http://archives.postgresql.org/pgsql-patches/2003-11/msg00286.php
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/spi.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 3dee4246af3..5b4d92124d7 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.108 2003/11/29 19:51:48 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.109 2003/12/02 19:26:47 joe Exp $
*
*-------------------------------------------------------------------------
*/
@@ -174,18 +174,26 @@ SPI_finish(void)
}
/*
- * Clean up SPI state at transaction commit or abort (we don't care which).
+ * Clean up SPI state at transaction commit or abort.
*/
void
-AtEOXact_SPI(void)
+AtEOXact_SPI(bool isCommit)
{
/*
* Note that memory contexts belonging to SPI stack entries will be
* freed automatically, so we can ignore them here. We just need to
* restore our static variables to initial state.
*/
- if (_SPI_stack != NULL) /* there was abort */
+ if (_SPI_stack != NULL)
+ {
free(_SPI_stack);
+ if (isCommit)
+ ereport(WARNING,
+ (errcode(ERRCODE_WARNING),
+ errmsg("freeing non-empty SPI stack"),
+ errhint("Check for missing \"SPI_finish\" calls")));
+ }
+
_SPI_current = _SPI_stack = NULL;
_SPI_connected = _SPI_curid = -1;
SPI_processed = 0;