Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4669dd7

Browse files
committed
Merge branch 'PGPROEE10_lru_fix' into PGPROEE10
2 parents 9bf5abb + 548b0c3 commit 4669dd7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/backend/utils/cache/plancache.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ PullPlanInLRU(CachedPlanSource *plansource)
137137
if (plan_cache_lru_size <= 0)
138138
return;
139139

140+
/* We don't cache oneshot plans */
141+
if (plansource->is_oneshot)
142+
return;
143+
140144
/* Remove from current place in LRU (if any) */
141145
DeletePlanFromLRU(plansource);
142146

@@ -175,6 +179,8 @@ PullPlanInLRU(CachedPlanSource *plansource)
175179
{
176180
MemoryContext qcxt = ps->query_context;
177181

182+
Assert(qcxt != ps->context);
183+
178184
ps->query_context = NULL;
179185
MemoryContextDelete(qcxt);
180186
}
@@ -193,6 +199,10 @@ PullPlanInLRU(CachedPlanSource *plansource)
193199
static void
194200
DeletePlanFromLRU(CachedPlanSource *plansource)
195201
{
202+
/* We don't cache oneshot plans */
203+
if (plansource->is_oneshot)
204+
return;
205+
196206
if (plansource->lru_prev || plansource->lru_next)
197207
{
198208
plan_cache_lru_cur_size--;
@@ -430,8 +440,6 @@ CreateOneShotCachedPlan(RawStmt *raw_parse_tree,
430440

431441
PlanSourceContextRegisterCallback(CurrentMemoryContext, plansource);
432442

433-
PullPlanInLRU(plansource);
434-
435443
return plansource;
436444
}
437445

@@ -806,6 +814,8 @@ RevalidateCachedQuery(CachedPlanSource *plansource,
806814
{
807815
MemoryContext qcxt = plansource->query_context;
808816

817+
Assert(qcxt != plansource->context);
818+
809819
plansource->query_context = NULL;
810820
MemoryContextDelete(qcxt);
811821
}

0 commit comments

Comments
 (0)