mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
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?
This commit is contained in:
parent
5fc32fbf87
commit
56ece37384
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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
|
* NOTES
|
||||||
* this is the "main" module of the postgres backend and
|
* 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..)
|
* process utility functions (create, destroy, etc..)
|
||||||
*/
|
*/
|
||||||
|
Node *utilityStmt = querytree->utilityStmt;
|
||||||
|
|
||||||
elog(DEBUG2, "ProcessUtility");
|
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)
|
if (querytree->originalQuery)
|
||||||
{
|
{
|
||||||
/* utility statement can override default tag string */
|
/* utility statement can override default tag string */
|
||||||
ProcessUtility(querytree->utilityStmt, dest,
|
ProcessUtility(utilityStmt, dest, completionTag);
|
||||||
completionTag);
|
|
||||||
if (completionTag[0])
|
if (completionTag[0])
|
||||||
commandTag = completionTag;
|
commandTag = completionTag;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* utility added by rewrite cannot override tag */
|
/* utility added by rewrite cannot override tag */
|
||||||
ProcessUtility(querytree->utilityStmt, dest, NULL);
|
ProcessUtility(utilityStmt, dest, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -739,14 +752,20 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
|
|||||||
*/
|
*/
|
||||||
Plan *plan;
|
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);
|
plan = pg_plan_query(querytree);
|
||||||
|
|
||||||
/* if we got a cancel signal whilst planning, quit */
|
/* if we got a cancel signal whilst planning, quit */
|
||||||
CHECK_FOR_INTERRUPTS();
|
CHECK_FOR_INTERRUPTS();
|
||||||
|
|
||||||
/* Initialize snapshot state for query */
|
|
||||||
SetQuerySnapshot();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* execute the plan
|
* execute the plan
|
||||||
*/
|
*/
|
||||||
@ -1701,7 +1720,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
|||||||
if (!IsUnderPostmaster)
|
if (!IsUnderPostmaster)
|
||||||
{
|
{
|
||||||
puts("\nPOSTGRES backend interactive interface ");
|
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 an xact for this function invocation */
|
||||||
start_xact_command();
|
start_xact_command();
|
||||||
|
|
||||||
|
/* assume it may need a snapshot */
|
||||||
|
SetQuerySnapshot();
|
||||||
|
|
||||||
if (HandleFunctionRequest() == EOF)
|
if (HandleFunctionRequest() == EOF)
|
||||||
{
|
{
|
||||||
/* lost frontend connection during F message input */
|
/* lost frontend connection during F message input */
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.178 2002/09/26 22:58:33 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.179 2002/10/08 17:17:19 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -380,14 +380,7 @@ ProcessUtility(Node *parsetree,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case T_CopyStmt:
|
case T_CopyStmt:
|
||||||
{
|
DoCopy((CopyStmt *) parsetree);
|
||||||
CopyStmt *stmt = (CopyStmt *) parsetree;
|
|
||||||
|
|
||||||
if (!stmt->is_from)
|
|
||||||
SetQuerySnapshot();
|
|
||||||
|
|
||||||
DoCopy(stmt);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_PrepareStmt:
|
case T_PrepareStmt:
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.60 2002/09/04 20:31:33 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.61 2002/10/08 17:17:19 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -977,8 +977,8 @@ CopyQuerySnapshot(void)
|
|||||||
{
|
{
|
||||||
Snapshot snapshot;
|
Snapshot snapshot;
|
||||||
|
|
||||||
if (QuerySnapshot == NULL) /* should be set already, but... */
|
if (QuerySnapshot == NULL) /* should be set beforehand */
|
||||||
SetQuerySnapshot();
|
elog(ERROR, "CopyQuerySnapshot: no snapshot has been set");
|
||||||
|
|
||||||
snapshot = (Snapshot) palloc(sizeof(SnapshotData));
|
snapshot = (Snapshot) palloc(sizeof(SnapshotData));
|
||||||
memcpy(snapshot, QuerySnapshot, sizeof(SnapshotData));
|
memcpy(snapshot, QuerySnapshot, sizeof(SnapshotData));
|
||||||
|
Loading…
Reference in New Issue
Block a user