diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-01-29 15:24:57 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-01-29 15:24:57 +0000 |
commit | d6242b373b5fd1c0bc1b27ab759a6df24fffc5c5 (patch) | |
tree | 7bd00669e96f58b8eb8b78253473c6cff1aa39e1 | |
parent | 726b7f3b3cc067de053f7d7c0aa488e9c6c211f8 (diff) | |
download | postgresql-d6242b373b5fd1c0bc1b27ab759a6df24fffc5c5.tar.gz postgresql-d6242b373b5fd1c0bc1b27ab759a6df24fffc5c5.zip |
SPI_exec shouldn't return SPI_OK_SELECT if it hasn't actually returned
a tuple table. Fixes core dump in pltcl (and probably other PLs) when
executing a query rewritten by a rule. Per bug report from Wolfgang Walter.
-rw-r--r-- | src/backend/executor/spi.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index 41f04fbb521..c237a126e86 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.75.2.1 2003/01/21 22:06:36 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.75.2.2 2003/01/29 15:24:57 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -125,6 +125,14 @@ SPI_finish(void) MemoryContextDelete(_SPI_current->procCxt); /* + * Reset result variables, especially SPI_tuptable which is probably + * pointing at a just-deleted tuptable + */ + SPI_processed = 0; + SPI_lastoid = InvalidOid; + SPI_tuptable = NULL; + + /* * After _SPI_begin_call _SPI_connected == _SPI_curid. Now we are * closing connection to SPI and returning to upper Executor and so * _SPI_connected must be equal to _SPI_curid. @@ -1330,6 +1338,11 @@ _SPI_pquery(QueryDesc *queryDesc, EState *state, int tcount) SPI_lastoid = save_lastoid; SPI_tuptable = _SPI_current->tuptable; } + else if (res == SPI_OK_SELECT) + { + /* Don't return SPI_OK_SELECT if we discarded the result */ + res = SPI_OK_UTILITY; + } queryDesc->dest = dest; return res; |