diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-03-17 03:15:47 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-03-17 03:15:47 +0000 |
commit | 32311dfaa0c6a22b1e7268710167d6a8b7f41181 (patch) | |
tree | 4916bf254d23ee938492a699807c6d2ca4fccf98 /src/backend/executor | |
parent | 009dac8ed49ee256d94bc65df9316e49469bf5fb (diff) | |
download | postgresql-32311dfaa0c6a22b1e7268710167d6a8b7f41181.tar.gz postgresql-32311dfaa0c6a22b1e7268710167d6a8b7f41181.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/executor')
-rw-r--r-- | src/backend/executor/spi.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index a444cb882a3..07f312e8a26 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.165.2.2 2006/12/26 16:56:22 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.165.2.3 2007/03/17 03:15:47 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -870,6 +870,26 @@ SPI_cursor_open(const char *name, void *plan, if (list_length(qtlist) != list_length(ptlist)) elog(ERROR, "corrupted SPI plan lists"); + /* + * If told to be read-only, we'd better check for read-only queries. + */ + if (read_only) + { + ListCell *lc; + + foreach(lc, qtlist) + { + Query *qry = (Query *) lfirst(lc); + + if (!QueryIsReadOnly(qry)) + 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(qry)))); + } + } + /* Reset SPI result (note we deliberately don't touch lastoid) */ SPI_processed = 0; SPI_tuptable = NULL; |