aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-03-17 03:16:03 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-03-17 03:16:03 +0000
commitadf06f6931f6c9ad6b3b0757e0fb75e03deb8f53 (patch)
treee5f3be85ae5aaed77d66f2c8dee4d94d98319b10 /src/backend
parent328df527d68665f0552b34d4ad917af673fa5c9d (diff)
downloadpostgresql-adf06f6931f6c9ad6b3b0757e0fb75e03deb8f53.tar.gz
postgresql-adf06f6931f6c9ad6b3b0757e0fb75e03deb8f53.zip
SPI_cursor_open failed to enforce that only read-only queries could be
executed in read_only mode. This could lead to various relatively-subtle failures, such as an allegedly stable function returning non-stable results. Bug goes all the way back to the introduction of read-only mode in 8.0. Per report from Gaetano Mendola.
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/executor/spi.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index dd1fcf8ec11..71e40ed25b4 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.133.4.1 2005/02/10 20:36:48 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.133.4.2 2007/03/17 03:16:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -862,6 +862,16 @@ SPI_cursor_open(const char *name, void *plan,
break;
}
+ /*
+ * If told to be read-only, we'd better check for read-only queries.
+ */
+ if (read_only && !QueryIsReadOnly(queryTree))
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ /* translator: %s is a SQL statement name */
+ errmsg("%s is not allowed in a non-volatile function",
+ CreateQueryTag(queryTree))));
+
/* Reset SPI result */
SPI_processed = 0;
SPI_tuptable = NULL;