From 2dde90ad8dbe9d973a15804e44b0e01ca4d2ac30 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 14 Feb 2003 21:12:45 +0000 Subject: [PATCH] Fix SPI result logic for case where there are multiple statements of the same type in a rule. Per bug report from Pavel Hanak. --- src/backend/executor/spi.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index 193bd08b4d..d94e12cde5 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.85 2003/01/29 15:24:46 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.86 2003/02/14 21:12:45 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1088,6 +1088,15 @@ _SPI_execute(const char *src, int tcount, _SPI_plan *plan) else canSetResult = false; + /* Reset state if can set result */ + if (canSetResult) + { + SPI_processed = 0; + SPI_lastoid = InvalidOid; + SPI_tuptable = NULL; + _SPI_current->tuptable = NULL; + } + if (queryTree->commandType == CMD_UTILITY) { if (IsA(queryTree->utilityStmt, CopyStmt)) @@ -1199,6 +1208,15 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls, else canSetResult = false; + /* Reset state if can set result */ + if (canSetResult) + { + SPI_processed = 0; + SPI_lastoid = InvalidOid; + SPI_tuptable = NULL; + _SPI_current->tuptable = NULL; + } + if (queryTree->commandType == CMD_UTILITY) { res = SPI_OK_UTILITY; -- 2.11.0