aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop/postgres.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-10-08 17:17:19 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-10-08 17:17:19 +0000
commit56ece373848b5bef36f035a340bf4efe237c1099 (patch)
treeffeb967cf47776443c612ad168b70bdd0bd9a601 /src/backend/tcop/postgres.c
parent5fc32fbf8736acbf51893c6a15e8fcf10ee1817b (diff)
downloadpostgresql-56ece373848b5bef36f035a340bf4efe237c1099.tar.gz
postgresql-56ece373848b5bef36f035a340bf4efe237c1099.zip
Move responsibility for setting QuerySnapshot for utility statements
into postgres.c; make sure it happens for all cases that seem to need it. Perhaps it would be better to explicitly exclude just a few utility statement types from setting a snapshot?
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r--src/backend/tcop/postgres.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 2a78e38fe0c..f3bd34fde27 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.298 2002/10/06 03:56:03 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.299 2002/10/08 17:17:19 tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@@ -716,20 +716,33 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
/*
* process utility functions (create, destroy, etc..)
*/
+ Node *utilityStmt = querytree->utilityStmt;
+
elog(DEBUG2, "ProcessUtility");
+ /* set snapshot if utility stmt needs one */
+ /* XXX maybe cleaner to list those that shouldn't set one? */
+ if (IsA(utilityStmt, AlterTableStmt) ||
+ IsA(utilityStmt, ClusterStmt) ||
+ IsA(utilityStmt, CopyStmt) ||
+ IsA(utilityStmt, ExecuteStmt) ||
+ IsA(utilityStmt, ExplainStmt) ||
+ IsA(utilityStmt, IndexStmt) ||
+ IsA(utilityStmt, PrepareStmt) ||
+ IsA(utilityStmt, ReindexStmt))
+ SetQuerySnapshot();
+
if (querytree->originalQuery)
{
/* utility statement can override default tag string */
- ProcessUtility(querytree->utilityStmt, dest,
- completionTag);
+ ProcessUtility(utilityStmt, dest, completionTag);
if (completionTag[0])
commandTag = completionTag;
}
else
{
/* utility added by rewrite cannot override tag */
- ProcessUtility(querytree->utilityStmt, dest, NULL);
+ ProcessUtility(utilityStmt, dest, NULL);
}
}
else
@@ -739,14 +752,20 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
*/
Plan *plan;
+ /*
+ * Initialize snapshot state for query. This has to
+ * be done before running the planner, because it might
+ * try to evaluate immutable or stable functions, which
+ * in turn might run queries.
+ */
+ SetQuerySnapshot();
+
+ /* Make the plan */
plan = pg_plan_query(querytree);
/* if we got a cancel signal whilst planning, quit */
CHECK_FOR_INTERRUPTS();
- /* Initialize snapshot state for query */
- SetQuerySnapshot();
-
/*
* execute the plan
*/
@@ -1701,7 +1720,7 @@ PostgresMain(int argc, char *argv[], const char *username)
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.298 $ $Date: 2002/10/06 03:56:03 $\n");
+ puts("$Revision: 1.299 $ $Date: 2002/10/08 17:17:19 $\n");
}
/*
@@ -1886,6 +1905,9 @@ PostgresMain(int argc, char *argv[], const char *username)
/* start an xact for this function invocation */
start_xact_command();
+ /* assume it may need a snapshot */
+ SetQuerySnapshot();
+
if (HandleFunctionRequest() == EOF)
{
/* lost frontend connection during F message input */