@@ -137,6 +137,10 @@ PullPlanInLRU(CachedPlanSource *plansource)
137
137
if (plan_cache_lru_size <= 0 )
138
138
return ;
139
139
140
+ /* We don't cache oneshot plans */
141
+ if (plansource -> is_oneshot )
142
+ return ;
143
+
140
144
/* Remove from current place in LRU (if any) */
141
145
DeletePlanFromLRU (plansource );
142
146
@@ -175,6 +179,8 @@ PullPlanInLRU(CachedPlanSource *plansource)
175
179
{
176
180
MemoryContext qcxt = ps -> query_context ;
177
181
182
+ Assert (qcxt != ps -> context );
183
+
178
184
ps -> query_context = NULL ;
179
185
MemoryContextDelete (qcxt );
180
186
}
@@ -193,6 +199,10 @@ PullPlanInLRU(CachedPlanSource *plansource)
193
199
static void
194
200
DeletePlanFromLRU (CachedPlanSource * plansource )
195
201
{
202
+ /* We don't cache oneshot plans */
203
+ if (plansource -> is_oneshot )
204
+ return ;
205
+
196
206
if (plansource -> lru_prev || plansource -> lru_next )
197
207
{
198
208
plan_cache_lru_cur_size -- ;
@@ -430,8 +440,6 @@ CreateOneShotCachedPlan(RawStmt *raw_parse_tree,
430
440
431
441
PlanSourceContextRegisterCallback (CurrentMemoryContext , plansource );
432
442
433
- PullPlanInLRU (plansource );
434
-
435
443
return plansource ;
436
444
}
437
445
@@ -806,6 +814,8 @@ RevalidateCachedQuery(CachedPlanSource *plansource,
806
814
{
807
815
MemoryContext qcxt = plansource -> query_context ;
808
816
817
+ Assert (qcxt != plansource -> context );
818
+
809
819
plansource -> query_context = NULL ;
810
820
MemoryContextDelete (qcxt );
811
821
}
0 commit comments