aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/spi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor/spi.c')
-rw-r--r--src/backend/executor/spi.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 22dd55c3783..5756365c8f3 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -228,8 +228,13 @@ SPI_commit(void)
_SPI_current->internal_xact = true;
- if (ActiveSnapshotSet())
+ /*
+ * Before committing, pop all active snapshots to avoid error about
+ * "snapshot %p still active".
+ */
+ while (ActiveSnapshotSet())
PopActiveSnapshot();
+
CommitTransactionCommand();
MemoryContextSwitchTo(oldcontext);