aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/spi.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 875e4da2914..6d59401d0fb 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.181 2007/09/20 17:56:31 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.182 2007/10/24 23:27:08 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -975,6 +975,7 @@ SPI_cursor_open(const char *name, SPIPlanPtr plan,
{
if (list_length(stmt_list) == 1 &&
IsA((Node *) linitial(stmt_list), PlannedStmt) &&
+ ((PlannedStmt *) linitial(stmt_list))->rowMarks == NIL &&
ExecSupportsBackwardScan(((PlannedStmt *) linitial(stmt_list))->planTree))
portal->cursorOptions |= CURSOR_OPT_SCROLL;
else
@@ -982,6 +983,22 @@ SPI_cursor_open(const char *name, SPIPlanPtr plan,
}
/*
+ * Disallow SCROLL with SELECT FOR UPDATE. This is not redundant with
+ * the check in transformDeclareCursorStmt because the cursor options
+ * might not have come through there.
+ */
+ if (portal->cursorOptions & CURSOR_OPT_SCROLL)
+ {
+ if (list_length(stmt_list) == 1 &&
+ IsA((Node *) linitial(stmt_list), PlannedStmt) &&
+ ((PlannedStmt *) linitial(stmt_list))->rowMarks != NIL)
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("DECLARE CURSOR SCROLL ... FOR UPDATE/SHARE is not supported"),
+ errdetail("Scrollable cursors must be READ ONLY.")));
+ }
+
+ /*
* If told to be read-only, we'd better check for read-only queries.
* This can't be done earlier because we need to look at the finished,
* planned queries. (In particular, we don't want to do it between