Content-Length: 283321 | pFad | http://github.com/postgrespro/postgres/commit/21fb95da46bce8de3e149707c680d489b8a5ffb0

08 Use a fresh copy of query_list when making a second plan in GetCached… · postgrespro/postgres@21fb95d · GitHub
Skip to content

Commit 21fb95d

Browse files
committed
Use a fresh copy of query_list when making a second plan in GetCachedPlan.
The code path that tried a generic plan, didn't like it, and then made a custom plan was mistakenly passing the same copy of the query_list to the planner both times. This doesn't work too well for nontrivial queries, since the planner tends to scribble on its input. Diagnosis and fix by Yamamoto Takashi.
1 parent 2a571bc commit 21fb95d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/backend/utils/cache/plancache.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,8 @@ CheckCachedPlan(CachedPlanSource *plansource)
697697
/*
698698
* BuildCachedPlan: construct a new CachedPlan from a CachedPlanSource.
699699
*
700-
* qlist should be the result value from a previous RevalidateCachedQuery.
700+
* qlist should be the result value from a previous RevalidateCachedQuery,
701+
* or it can be set to NIL if we need to re-copy the plansource's query_list.
701702
*
702703
* To build a generic, parameter-value-independent plan, pass NULL for
703704
* boundParams. To build a custom plan, pass the actual parameter values via
@@ -980,6 +981,13 @@ GetCachedPlan(CachedPlanSource *plansource, ParamListInfo boundParams,
980981
* plan.
981982
*/
982983
customplan = choose_custom_plan(plansource, boundParams);
984+
985+
/*
986+
* If we choose to plan again, we need to re-copy the query_list,
987+
* since the planner probably scribbled on it. We can force
988+
* BuildCachedPlan to do that by passing NIL.
989+
*/
990+
qlist = NIL;
983991
}
984992
}
985993

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/21fb95da46bce8de3e149707c680d489b8a5ffb0

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy