aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-03-17 03:15:55 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-03-17 03:15:55 +0000
commit6c156225954b18ae2827a759907343357508d54c (patch)
treeb9fe559acab72d549966bc53eba56e738ecc2a0c
parent5f41ad2ccfaf5befe70d6214c9d073ecf6459251 (diff)
downloadpostgresql-6c156225954b18ae2827a759907343357508d54c.tar.gz
postgresql-6c156225954b18ae2827a759907343357508d54c.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.
-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 e8ba1f5f292..61dd6a6d0a7 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.144.2.1 2005/11/22 18:23:09 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.144.2.2 2007/03/17 03:15:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -860,6 +860,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 (note we deliberately don't touch lastoid) */
SPI_processed = 0;
SPI_tuptable = NULL;