aboutsummaryrefslogtreecommitdiff
path: root/src/include/executor
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2018-05-02 16:50:03 -0400
committerPeter Eisentraut <peter_e@gmx.net>2018-05-03 08:39:15 -0400
commit30c66e77be1d890c3cca766259c0bec80bcac1b5 (patch)
treea4b27230b6a9412e58786d483220cd02b9c9bca7 /src/include/executor
parenta365f52d58317e3b24e06564e1f6474ffa3221d4 (diff)
downloadpostgresql-30c66e77be1d890c3cca766259c0bec80bcac1b5.tar.gz
postgresql-30c66e77be1d890c3cca766259c0bec80bcac1b5.zip
Fix SPI error cleanup and memory leak
Since the SPI stack has been moved from TopTransactionContext to TopMemoryContext, setting _SPI_stack to NULL in AtEOXact_SPI() leaks memory. In fact, we don't need to do that anymore: We just leave the allocated stack around for the next SPI use. Also, refactor the SPI cleanup so that it is run both at transaction end and when returning to the main loop on an exception. The latter is necessary when a procedure calls a COMMIT or ROLLBACK command that itself causes an error.
Diffstat (limited to 'src/include/executor')
-rw-r--r--src/include/executor/spi.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/include/executor/spi.h b/src/include/executor/spi.h
index e5bdaecc4e3..143a89a16c4 100644
--- a/src/include/executor/spi.h
+++ b/src/include/executor/spi.h
@@ -163,6 +163,7 @@ extern void SPI_start_transaction(void);
extern void SPI_commit(void);
extern void SPI_rollback(void);
+extern void SPICleanup(void);
extern void AtEOXact_SPI(bool isCommit);
extern void AtEOSubXact_SPI(bool isCommit, SubTransactionId mySubid);