Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd5aa7a9

Browse files
committed
Avoid unnecessary snapshot-acquisitions in BuildCachedPlan.
I had copied-and-pasted a claim that we couldn't reach this point whendealing with utility statements, but that was a leftover from when thecaller was required to supply a plan to start with. We now will gothrough here at least once when handling a utility statement, so itseems 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 thisresolves his reported assertion failure; but it's worth changing anyway,just to save a cycle or two.
1 parent2594ad7 commitd5aa7a9

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

‎src/backend/utils/cache/plancache.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#include"nodes/nodeFuncs.h"
5555
#include"optimizer/planmain.h"
5656
#include"optimizer/prep.h"
57+
#include"parser/analyze.h"
5758
#include"parser/parsetree.h"
5859
#include"storage/lmgr.h"
5960
#include"tcop/pquery.h"
@@ -756,14 +757,12 @@ BuildCachedPlan(CachedPlanSource *plansource, List *qlist,
756757
PushOverrideSearchPath(plansource->search_path);
757758

758759
/*
759-
* If a snapshot is already set (the normal case), we can just use
760-
* that for parsing/planning. But if it isn't, install one. Note: no
761-
* point in checking whether parse analysis requires a snapshot;
762-
* utility commands don't have invalidatable plans, so we'd not get
763-
* here for such a command.
760+
* If a snapshot is already set (the normal case), we can just use that
761+
* for planning. But if it isn't, and we need one, install one.
764762
*/
765763
snapshot_set= false;
766-
if (!ActiveSnapshotSet())
764+
if (!ActiveSnapshotSet()&&
765+
analyze_requires_snapshot(plansource->raw_parse_tree))
767766
{
768767
PushActiveSnapshot(GetTransactionSnapshot());
769768
snapshot_set= true;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp