Hackaround attached.
This hack makes SPI_pusn()/SPI_pop() wrapper optional.
--- src/backend/executor/spi.c.orig Fri Jan 26 13:12:50 2007
+++ src/backend/executor/spi.c Tue Jan 30 12:42:56 2007
@@ -64,16 +64,6 @@
{
int newdepth;
- /*
- * When procedure called by Executor _SPI_curid expected to be equal to
- * _SPI_connected
- */
- if (_SPI_curid != _SPI_connected)
- {
- SPI_logid("SPI_connect");
- return SPI_ERROR_CONNECT;
- }
-
if (_SPI_stack == NULL)
{
if (_SPI_connected != -1 || _SPI_stack_depth != 0)
@@ -105,6 +95,8 @@
Assert(_SPI_connected >= 0 && _SPI_connected < _SPI_stack_depth);
_SPI_current = &(_SPI_stack[_SPI_connected]);
+ _SPI_current->saved_SPI_curid=_SPI_curid;
+ _SPI_curid=_SPI_connected-1; /* XXX Hack */
_SPI_current->processed = 0;
_SPI_current->lastoid = InvalidOid;
_SPI_current->tuptable = NULL;
@@ -168,7 +160,7 @@
* must be equal to _SPI_curid.
*/
_SPI_connected--;
- _SPI_curid--;
+ _SPI_curid=_SPI_current->saved_SPI_curid; /* XXX Hack */
if (_SPI_connected == -1)
_SPI_current = NULL;
else
--- src/include/executor/spi_priv.h.orig Mon Jan 29 18:28:18 2007
+++ src/include/executor/spi_priv.h Mon Jan 29 18:35:38 2007
@@ -27,6 +27,7 @@
MemoryContext execCxt; /* executor context */
MemoryContext savedcxt;
SubTransactionId connectSubid; /* ID of connecting subtransaction */
+ int saved_SPI_curid; /* XXX Hack. Saved difference between _SPI_connected and _SPI_curid */
} _SPI_connection;
typedef struct
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq