*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
MemoryContextDelete(_SPI_current->execCxt);
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_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;