Commit bf823652 authored by Tom Lane's avatar Tom Lane

Remove the prohibition on executing cursor commands through SPI_execute.

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.
parent e85a01df
<!-- $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"> <chapter id="spi">
<title>Server Programming Interface</title> <title>Server Programming Interface</title>
...@@ -554,21 +554,11 @@ typedef struct ...@@ -554,21 +554,11 @@ typedef struct
</listitem> </listitem>
</varlistentry> </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> <varlistentry>
<term><symbol>SPI_ERROR_TRANSACTION</symbol></term> <term><symbol>SPI_ERROR_TRANSACTION</symbol></term>
<listitem> <listitem>
<para> <para>
if any command involving transaction manipulation was attempted if a transaction manipulation command was attempted
(<command>BEGIN</>, (<command>BEGIN</>,
<command>COMMIT</>, <command>COMMIT</>,
<command>ROLLBACK</>, <command>ROLLBACK</>,
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -1155,8 +1155,6 @@ SPI_result_code_string(int code)
return "SPI_ERROR_OPUNKNOWN"; return "SPI_ERROR_OPUNKNOWN";
case SPI_ERROR_UNCONNECTED: case SPI_ERROR_UNCONNECTED:
return "SPI_ERROR_UNCONNECTED"; return "SPI_ERROR_UNCONNECTED";
case SPI_ERROR_CURSOR:
return "SPI_ERROR_CURSOR";
case SPI_ERROR_ARGUMENT: case SPI_ERROR_ARGUMENT:
return "SPI_ERROR_ARGUMENT"; return "SPI_ERROR_ARGUMENT";
case SPI_ERROR_PARAM: case SPI_ERROR_PARAM:
...@@ -1490,13 +1488,6 @@ _SPI_execute_plan(SPIPlanPtr plan, Datum *Values, const char *Nulls, ...@@ -1490,13 +1488,6 @@ _SPI_execute_plan(SPIPlanPtr plan, Datum *Values, const char *Nulls,
goto fail; 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)) else if (IsA(stmt, TransactionStmt))
{ {
my_res = SPI_ERROR_TRANSACTION; my_res = SPI_ERROR_TRANSACTION;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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; ...@@ -61,7 +61,7 @@ typedef struct _SPI_plan *SPIPlanPtr;
#define SPI_ERROR_COPY (-2) #define SPI_ERROR_COPY (-2)
#define SPI_ERROR_OPUNKNOWN (-3) #define SPI_ERROR_OPUNKNOWN (-3)
#define SPI_ERROR_UNCONNECTED (-4) #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_ARGUMENT (-6)
#define SPI_ERROR_PARAM (-7) #define SPI_ERROR_PARAM (-7)
#define SPI_ERROR_TRANSACTION (-8) #define SPI_ERROR_TRANSACTION (-8)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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, ...@@ -2327,11 +2327,6 @@ exec_prepare_plan(PLpgSQL_execstate *estate,
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot COPY to/from client in PL/pgSQL"))); 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: case SPI_ERROR_TRANSACTION:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
...@@ -2631,11 +2626,6 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate, ...@@ -2631,11 +2626,6 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate,
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot COPY to/from client in PL/pgSQL"))); 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: case SPI_ERROR_TRANSACTION:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment