aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop/postgres.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-03-22 19:55:04 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-03-22 19:55:04 +0000
commit4f896dac17f7015b34347e278fc3db4047b86e43 (patch)
tree7eea59672726c94e3314b4847a5cabfe8d53f3d5 /src/backend/tcop/postgres.c
parent686956375a84f4ac9f214e402e9922b49813784a (diff)
downloadpostgresql-4f896dac17f7015b34347e278fc3db4047b86e43.tar.gz
postgresql-4f896dac17f7015b34347e278fc3db4047b86e43.zip
Arrange for PreventTransactionChain to reject commands submitted as part
of a multi-statement simple-Query message. This bug goes all the way back, but unfortunately is not nearly so easy to fix in existing releases; it is only the recent ProcessUtility API change that makes it fixable in HEAD. Per report from William Garrison.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r--src/backend/tcop/postgres.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index f997d524101..9f55ba2e387 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.528 2007/03/13 00:33:42 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.529 2007/03/22 19:55:04 tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@@ -765,6 +765,7 @@ exec_simple_query(const char *query_string)
ListCell *parsetree_item;
bool save_log_statement_stats = log_statement_stats;
bool was_logged = false;
+ bool isTopLevel;
char msec_str[32];
/*
@@ -825,6 +826,15 @@ exec_simple_query(const char *query_string)
MemoryContextSwitchTo(oldcontext);
/*
+ * We'll tell PortalRun it's a top-level command iff there's exactly
+ * one raw parsetree. If more than one, it's effectively a transaction
+ * block and we want PreventTransactionChain to reject unsafe commands.
+ * (Note: we're assuming that query rewrite cannot add commands that are
+ * significant to PreventTransactionChain.)
+ */
+ isTopLevel = (list_length(parsetree_list) == 1);
+
+ /*
* Run through the raw parsetree(s) and process each one.
*/
foreach(parsetree_item, parsetree_list)
@@ -944,7 +954,7 @@ exec_simple_query(const char *query_string)
*/
(void) PortalRun(portal,
FETCH_ALL,
- true, /* top level */
+ isTopLevel,
receiver,
receiver,
completionTag);
@@ -1810,7 +1820,7 @@ exec_execute_message(const char *portal_name, long max_rows)
completed = PortalRun(portal,
max_rows,
- true, /* top level */
+ true, /* always top level */
receiver,
receiver,
completionTag);