From bf8236526be85bc3f061a918dbf49a28bc9bc220 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 25 Mar 2007 23:27:59 +0000 Subject: [PATCH] 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. --- doc/src/sgml/spi.sgml | 14 ++------------ src/backend/executor/spi.c | 11 +---------- src/include/executor/spi.h | 4 ++-- src/pl/plpgsql/src/pl_exec.c | 12 +----------- 4 files changed, 6 insertions(+), 35 deletions(-) diff --git a/doc/src/sgml/spi.sgml b/doc/src/sgml/spi.sgml index c7c4304b3a..14e975b5fc 100644 --- a/doc/src/sgml/spi.sgml +++ b/doc/src/sgml/spi.sgml @@ -1,4 +1,4 @@ - + Server Programming Interface @@ -555,20 +555,10 @@ typedef struct - SPI_ERROR_CURSOR - - - if DECLARE, CLOSE, or FETCH - was attempted - - - - - SPI_ERROR_TRANSACTION - if any command involving transaction manipulation was attempted + if a transaction manipulation command was attempted (BEGIN, COMMIT, ROLLBACK, diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index e0856a3d8f..d6127c19d8 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -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; diff --git a/src/include/executor/spi.h b/src/include/executor/spi.h index c041726a45..80c8993c7c 100644 --- a/src/include/executor/spi.h +++ b/src/include/executor/spi.h @@ -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) diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index eb29d7333a..165ce0426e 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -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), -- 2.11.0