]> granicus.if.org Git - postgresql/commitdiff
Remove the prohibition on executing cursor commands through SPI_execute.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 25 Mar 2007 23:27:59 +0000 (23:27 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 25 Mar 2007 23:27:59 +0000 (23:27 +0000)
Vadim had included this restriction in the original design of the SPI code,
but I'm darned if I can see a reason for it.

I left the macro definition of SPI_ERROR_CURSOR in place, so as not to
needlessly break any SPI callers that are checking for it, but that code
will never actually be returned anymore.

doc/src/sgml/spi.sgml
src/backend/executor/spi.c
src/include/executor/spi.h
src/pl/plpgsql/src/pl_exec.c

index c7c4304b3a7dd557565f2dcbf2afafb306616c5c..14e975b5fc9263dffaeaea19ee95419e90959fdd 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/spi.sgml,v 1.54 2007/03/15 23:12:06 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/spi.sgml,v 1.55 2007/03/25 23:27:59 tgl Exp $ -->
 
 <chapter id="spi">
  <title>Server Programming Interface</title>
@@ -554,21 +554,11 @@ typedef struct
      </listitem>
     </varlistentry>
 
-    <varlistentry>
-     <term><symbol>SPI_ERROR_CURSOR</symbol></term>
-     <listitem>
-      <para>
-       if <command>DECLARE</>, <command>CLOSE</>, or <command>FETCH</>
-       was attempted
-      </para>
-     </listitem>
-    </varlistentry>
-
     <varlistentry>
      <term><symbol>SPI_ERROR_TRANSACTION</symbol></term>
      <listitem>
       <para>
-       if any command involving transaction manipulation was attempted
+       if a transaction manipulation command was attempted
        (<command>BEGIN</>,
        <command>COMMIT</>,
        <command>ROLLBACK</>,
index e0856a3d8f2bcc93fb029da301db2b8ceb275890..d6127c19d84e98a44c4aa1140c67689038eebf89 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.173 2007/03/17 03:15:38 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.174 2007/03/25 23:27:59 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1155,8 +1155,6 @@ SPI_result_code_string(int code)
                        return "SPI_ERROR_OPUNKNOWN";
                case SPI_ERROR_UNCONNECTED:
                        return "SPI_ERROR_UNCONNECTED";
-               case SPI_ERROR_CURSOR:
-                       return "SPI_ERROR_CURSOR";
                case SPI_ERROR_ARGUMENT:
                        return "SPI_ERROR_ARGUMENT";
                case SPI_ERROR_PARAM:
@@ -1490,13 +1488,6 @@ _SPI_execute_plan(SPIPlanPtr plan, Datum *Values, const char *Nulls,
                                                        goto fail;
                                                }
                                        }
-                                       else if (IsA(stmt, DeclareCursorStmt) ||
-                                                        IsA(stmt, ClosePortalStmt) ||
-                                                        IsA(stmt, FetchStmt))
-                                       {
-                                               my_res = SPI_ERROR_CURSOR;
-                                               goto fail;
-                                       }
                                        else if (IsA(stmt, TransactionStmt))
                                        {
                                                my_res = SPI_ERROR_TRANSACTION;
index c041726a45a3aab0bfb06560df8f8a18173cf19d..80c8993c7c3cba70a7904e547d94fe8da23f1e37 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/executor/spi.h,v 1.59 2007/03/15 23:12:06 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/executor/spi.h,v 1.60 2007/03/25 23:27:59 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -61,7 +61,7 @@ typedef struct _SPI_plan *SPIPlanPtr;
 #define SPI_ERROR_COPY                 (-2)
 #define SPI_ERROR_OPUNKNOWN            (-3)
 #define SPI_ERROR_UNCONNECTED  (-4)
-#define SPI_ERROR_CURSOR               (-5)
+#define SPI_ERROR_CURSOR               (-5)                    /* not used anymore */
 #define SPI_ERROR_ARGUMENT             (-6)
 #define SPI_ERROR_PARAM                        (-7)
 #define SPI_ERROR_TRANSACTION  (-8)
index eb29d7333a8299fb4869554ea1efe9b2907c32d7..165ce0426ec1784f34cd909cba65a8d07d28f2c5 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.190 2007/03/15 23:12:07 tgl Exp $
+ *       $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.191 2007/03/25 23:27:59 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2327,11 +2327,6 @@ exec_prepare_plan(PLpgSQL_execstate *estate,
                                ereport(ERROR,
                                                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                                                 errmsg("cannot COPY to/from client in PL/pgSQL")));
-                       case SPI_ERROR_CURSOR:
-                               ereport(ERROR,
-                                               (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                                       errmsg("cannot manipulate cursors directly in PL/pgSQL"),
-                                                errhint("Use PL/pgSQL's cursor features instead.")));
                        case SPI_ERROR_TRANSACTION:
                                ereport(ERROR,
                                                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
@@ -2631,11 +2626,6 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate,
                        ereport(ERROR,
                                        (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                                         errmsg("cannot COPY to/from client in PL/pgSQL")));
-               case SPI_ERROR_CURSOR:
-                       ereport(ERROR,
-                                       (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                                        errmsg("cannot manipulate cursors directly in PL/pgSQL"),
-                                        errhint("Use PL/pgSQL's cursor features instead.")));
                case SPI_ERROR_TRANSACTION:
                        ereport(ERROR,
                                        (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),