mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Avoid unnecessary snapshot-acquisitions in BuildCachedPlan.
I had copied-and-pasted a claim that we couldn't reach this point when dealing with utility statements, but that was a leftover from when the caller was required to supply a plan to start with. We now will go through here at least once when handling a utility statement, so it seems worth a check to see whether a snapshot is actually needed. (Note that analyze_requires_snapshot is quite a cheap test.) Per suggestion from Yamamoto Takashi. I don't think I believe that this resolves his reported assertion failure; but it's worth changing anyway, just to save a cycle or two.
This commit is contained in:
parent
2594ad7436
commit
d5aa7a9fe6
11
src/backend/utils/cache/plancache.c
vendored
11
src/backend/utils/cache/plancache.c
vendored
@ -54,6 +54,7 @@
|
|||||||
#include "nodes/nodeFuncs.h"
|
#include "nodes/nodeFuncs.h"
|
||||||
#include "optimizer/planmain.h"
|
#include "optimizer/planmain.h"
|
||||||
#include "optimizer/prep.h"
|
#include "optimizer/prep.h"
|
||||||
|
#include "parser/analyze.h"
|
||||||
#include "parser/parsetree.h"
|
#include "parser/parsetree.h"
|
||||||
#include "storage/lmgr.h"
|
#include "storage/lmgr.h"
|
||||||
#include "tcop/pquery.h"
|
#include "tcop/pquery.h"
|
||||||
@ -756,14 +757,12 @@ BuildCachedPlan(CachedPlanSource *plansource, List *qlist,
|
|||||||
PushOverrideSearchPath(plansource->search_path);
|
PushOverrideSearchPath(plansource->search_path);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If a snapshot is already set (the normal case), we can just use
|
* If a snapshot is already set (the normal case), we can just use that
|
||||||
* that for parsing/planning. But if it isn't, install one. Note: no
|
* for planning. But if it isn't, and we need one, install one.
|
||||||
* point in checking whether parse analysis requires a snapshot;
|
|
||||||
* utility commands don't have invalidatable plans, so we'd not get
|
|
||||||
* here for such a command.
|
|
||||||
*/
|
*/
|
||||||
snapshot_set = false;
|
snapshot_set = false;
|
||||||
if (!ActiveSnapshotSet())
|
if (!ActiveSnapshotSet() &&
|
||||||
|
analyze_requires_snapshot(plansource->raw_parse_tree))
|
||||||
{
|
{
|
||||||
PushActiveSnapshot(GetTransactionSnapshot());
|
PushActiveSnapshot(GetTransactionSnapshot());
|
||||||
snapshot_set = true;
|
snapshot_set = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user