Re: Problems with insert rule called from plpython - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Problems with insert rule called from plpython
Date
Msg-id 11090.1045257253@sss.pgh.pa.us
Whole thread Raw
In response to Problems with insert rule called from plpython  (Pavel Hanak <hanak@brailcom.cz>)
List pgsql-bugs
Pavel Hanak <hanak@brailcom.cz> writes:
> Now calling "select testfun()" shows this fatal error:
>    FATAL:  SPI: improper call to spi_dest_setup

Hm, I'm glad I put in that test --- it exposed a problem.  Here is
the patch for 7.3.

            regards, tom lane


*** src/backend/executor/spi.c.orig    Wed Jan 29 10:24:57 2003
--- src/backend/executor/spi.c    Fri Feb 14 16:09:38 2003
***************
*** 1097,1102 ****
--- 1097,1111 ----
              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))
***************
*** 1206,1211 ****
--- 1215,1229 ----
                  canSetResult = true;
              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)
              {

pgsql-bugs by date:

Previous
From: Josh Berkus
Date:
Subject: Function will not back up on 7.2.3
Next
From: Tom Lane
Date:
Subject: Re: Function will not back up on 7.2.3