_SPI_cursor_operation forgot to check for failure return from
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 23 Sep 2003 15:11:41 +0000 (15:11 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 23 Sep 2003 15:11:41 +0000 (15:11 +0000)
_SPI_begin_call.  Per gripe from Tomasz Myrta.

src/backend/executor/spi.c

index 0a17c727e9d7099fda968d1a384ecb9d734b13f4..135a848aa9a584de61849fbbdf5c015d718d7d91 100644 (file)
@@ -1270,7 +1270,8 @@ _SPI_cursor_operation(Portal portal, bool forward, int count,
                elog(ERROR, "invalid portal in SPI cursor operation");
 
        /* Push the SPI stack */
-       _SPI_begin_call(true);
+       if (_SPI_begin_call(true) < 0)
+               elog(ERROR, "SPI cursor operation called while not connected");
 
        /* Reset the SPI result */
        SPI_processed = 0;
@@ -1320,8 +1321,7 @@ _SPI_procmem()
 }
 
 /*
- * _SPI_begin_call
- *
+ * _SPI_begin_call: begin a SPI operation within a connected procedure
  */
 static int
 _SPI_begin_call(bool execmem)
@@ -1338,6 +1338,11 @@ _SPI_begin_call(bool execmem)
        return 0;
 }
 
+/*
+ * _SPI_end_call: end a SPI operation within a connected procedure
+ *
+ * Note: this currently has no failure return cases, so callers don't check
+ */
 static int
 _SPI_end_call(bool procmem)
 {