diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-11-16 18:10:16 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-11-16 18:10:16 +0000 |
commit | 7efa8411cc56383a9b7ac2203f310d0db81f0580 (patch) | |
tree | a205f416cfee9d6c54864d06c72a2aa6f686f9e6 /src/backend/executor/spi.c | |
parent | 2bb3bcfcf9edb57d7bd3635b2201688defee6676 (diff) | |
download | postgresql-7efa8411cc56383a9b7ac2203f310d0db81f0580.tar.gz postgresql-7efa8411cc56383a9b7ac2203f310d0db81f0580.zip |
Rethink plpgsql's way of handling SPI execution during an exception block.
We don't really want to start a new SPI connection, just keep using the old
one; otherwise we have memory management problems as illustrated by
John Kennedy's bug report of today. This requires a bit of a hack to
ensure the SPI stack state is properly restored, but then again what we
were doing before was a hack too, strictly speaking. Add a regression
test to cover this case.
Diffstat (limited to 'src/backend/executor/spi.c')
-rw-r--r-- | src/backend/executor/spi.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index b533470e1d5..4549ba00080 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.131 2004/10/13 01:25:10 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.132 2004/11/16 18:10:13 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -270,6 +270,14 @@ SPI_pop(void) _SPI_curid--; } +/* Restore state of SPI stack after aborting a subtransaction */ +void +SPI_restore_connection(void) +{ + Assert(_SPI_connected >= 0); + _SPI_curid = _SPI_connected - 1; +} + /* Parse, plan, and execute a querystring */ int SPI_execute(const char *src, bool read_only, int tcount) |