提交 b69bde77 编写于 作者: T Tom Lane

Remove pg_plan_queries()'s now-useless needSnapshot parameter. It's useless

in 8.3, too, but I'm not back-patching this change since it would break any
extension modules that might be calling that function.
上级 c98a9237
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* Copyright (c) 2002-2008, PostgreSQL Global Development Group * Copyright (c) 2002-2008, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.92 2008/10/29 00:00:38 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.93 2008/12/13 02:29:21 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -144,8 +144,8 @@ PrepareQuery(PrepareStmt *stmt, const char *queryString) ...@@ -144,8 +144,8 @@ PrepareQuery(PrepareStmt *stmt, const char *queryString)
/* Rewrite the query. The result could be 0, 1, or many queries. */ /* Rewrite the query. The result could be 0, 1, or many queries. */
query_list = QueryRewrite(query); query_list = QueryRewrite(query);
/* Generate plans for queries. Snapshot is already set. */ /* Generate plans for queries. */
plan_list = pg_plan_queries(query_list, 0, NULL, false); plan_list = pg_plan_queries(query_list, 0, NULL);
/* /*
* Save the results. * Save the results.
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.201 2008/11/30 20:51:25 tgl Exp $ * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.202 2008/12/13 02:29:21 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1606,8 +1606,7 @@ _SPI_prepare_plan(const char *src, SPIPlanPtr plan, ParamListInfo boundParams) ...@@ -1606,8 +1606,7 @@ _SPI_prepare_plan(const char *src, SPIPlanPtr plan, ParamListInfo boundParams)
/* Need a copyObject here to keep parser from modifying raw tree */ /* Need a copyObject here to keep parser from modifying raw tree */
stmt_list = pg_analyze_and_rewrite(copyObject(parsetree), stmt_list = pg_analyze_and_rewrite(copyObject(parsetree),
src, argtypes, nargs); src, argtypes, nargs);
stmt_list = pg_plan_queries(stmt_list, cursor_options, stmt_list = pg_plan_queries(stmt_list, cursor_options, boundParams);
boundParams, false);
plansource = (CachedPlanSource *) palloc0(sizeof(CachedPlanSource)); plansource = (CachedPlanSource *) palloc0(sizeof(CachedPlanSource));
cplan = (CachedPlan *) palloc0(sizeof(CachedPlan)); cplan = (CachedPlan *) palloc0(sizeof(CachedPlan));
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.561 2008/12/13 02:00:19 tgl Exp $ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.562 2008/12/13 02:29:21 tgl Exp $
* *
* NOTES * NOTES
* this is the "main" module of the postgres backend and * this is the "main" module of the postgres backend and
...@@ -732,24 +732,14 @@ pg_plan_query(Query *querytree, int cursorOptions, ParamListInfo boundParams) ...@@ -732,24 +732,14 @@ pg_plan_query(Query *querytree, int cursorOptions, ParamListInfo boundParams)
/* /*
* Generate plans for a list of already-rewritten queries. * Generate plans for a list of already-rewritten queries.
* *
* If needSnapshot is TRUE, we haven't yet set a snapshot for the current
* query. A snapshot must be set before invoking the planner, since it
* might try to evaluate user-defined functions. But we must not set a
* snapshot if the list contains only utility statements, because some
* utility statements depend on not having frozen the snapshot yet.
* (We assume that such statements cannot appear together with plannable
* statements in the rewriter's output.)
*
* Normal optimizable statements generate PlannedStmt entries in the result * Normal optimizable statements generate PlannedStmt entries in the result
* list. Utility statements are simply represented by their statement nodes. * list. Utility statements are simply represented by their statement nodes.
*/ */
List * List *
pg_plan_queries(List *querytrees, int cursorOptions, ParamListInfo boundParams, pg_plan_queries(List *querytrees, int cursorOptions, ParamListInfo boundParams)
bool needSnapshot)
{ {
List *stmt_list = NIL; List *stmt_list = NIL;
ListCell *query_list; ListCell *query_list;
bool snapshot_set = false;
foreach(query_list, querytrees) foreach(query_list, querytrees)
{ {
...@@ -763,22 +753,12 @@ pg_plan_queries(List *querytrees, int cursorOptions, ParamListInfo boundParams, ...@@ -763,22 +753,12 @@ pg_plan_queries(List *querytrees, int cursorOptions, ParamListInfo boundParams,
} }
else else
{ {
if (needSnapshot && !snapshot_set) stmt = (Node *) pg_plan_query(query, cursorOptions, boundParams);
{
PushActiveSnapshot(GetTransactionSnapshot());
snapshot_set = true;
}
stmt = (Node *) pg_plan_query(query, cursorOptions,
boundParams);
} }
stmt_list = lappend(stmt_list, stmt); stmt_list = lappend(stmt_list, stmt);
} }
if (snapshot_set)
PopActiveSnapshot();
return stmt_list; return stmt_list;
} }
...@@ -937,7 +917,7 @@ exec_simple_query(const char *query_string) ...@@ -937,7 +917,7 @@ exec_simple_query(const char *query_string)
querytree_list = pg_analyze_and_rewrite(parsetree, query_string, querytree_list = pg_analyze_and_rewrite(parsetree, query_string,
NULL, 0); NULL, 0);
plantree_list = pg_plan_queries(querytree_list, 0, NULL, false); plantree_list = pg_plan_queries(querytree_list, 0, NULL);
/* Done with the snapshot used for parsing/planning */ /* Done with the snapshot used for parsing/planning */
if (snapshot_set) if (snapshot_set)
...@@ -1276,7 +1256,7 @@ exec_parse_message(const char *query_string, /* string to execute */ ...@@ -1276,7 +1256,7 @@ exec_parse_message(const char *query_string, /* string to execute */
} }
else else
{ {
stmt_list = pg_plan_queries(querytree_list, 0, NULL, false); stmt_list = pg_plan_queries(querytree_list, 0, NULL);
fully_planned = true; fully_planned = true;
} }
...@@ -1725,7 +1705,7 @@ exec_bind_message(StringInfo input_message) ...@@ -1725,7 +1705,7 @@ exec_bind_message(StringInfo input_message)
*/ */
oldContext = MemoryContextSwitchTo(PortalGetHeapMemory(portal)); oldContext = MemoryContextSwitchTo(PortalGetHeapMemory(portal));
query_list = copyObject(cplan->stmt_list); query_list = copyObject(cplan->stmt_list);
plan_list = pg_plan_queries(query_list, 0, params, false); plan_list = pg_plan_queries(query_list, 0, params);
MemoryContextSwitchTo(oldContext); MemoryContextSwitchTo(oldContext);
/* We no longer need the cached plan refcount ... */ /* We no longer need the cached plan refcount ... */
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.24 2008/12/13 02:00:20 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.25 2008/12/13 02:29:22 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -503,8 +503,7 @@ RevalidateCachedPlan(CachedPlanSource *plansource, bool useResOwner) ...@@ -503,8 +503,7 @@ RevalidateCachedPlan(CachedPlanSource *plansource, bool useResOwner)
/* /*
* Generate plans for queries. * Generate plans for queries.
*/ */
slist = pg_plan_queries(slist, plansource->cursor_options, slist = pg_plan_queries(slist, plansource->cursor_options, NULL);
NULL, false);
} }
/* /*
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/tcop/tcopprot.h,v 1.95 2008/12/09 15:59:39 heikki Exp $ * $PostgreSQL: pgsql/src/include/tcop/tcopprot.h,v 1.96 2008/12/13 02:29:22 tgl Exp $
* *
* OLD COMMENTS * OLD COMMENTS
* This file was created so that other c files could get the two * This file was created so that other c files could get the two
...@@ -52,7 +52,7 @@ extern List *pg_analyze_and_rewrite(Node *parsetree, const char *query_string, ...@@ -52,7 +52,7 @@ extern List *pg_analyze_and_rewrite(Node *parsetree, const char *query_string,
extern PlannedStmt *pg_plan_query(Query *querytree, int cursorOptions, extern PlannedStmt *pg_plan_query(Query *querytree, int cursorOptions,
ParamListInfo boundParams); ParamListInfo boundParams);
extern List *pg_plan_queries(List *querytrees, int cursorOptions, extern List *pg_plan_queries(List *querytrees, int cursorOptions,
ParamListInfo boundParams, bool needSnapshot); ParamListInfo boundParams);
extern bool assign_max_stack_depth(int newval, bool doit, GucSource source); extern bool assign_max_stack_depth(int newval, bool doit, GucSource source);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册