mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
Make create_unique_path manage memory like mark_dummy_rel.
Put the unique path in the same context as the owning RelOptInfo, rather than the toplevel planner context. This is how this function worked originally, but commit f41803bb39bc2949db200116a609fd242d0ec221 changed it without explanation. mark_dummy_rel adopted the older (or newer?) technique in commit eca75a12a27d28b972fc269c1c8813cd8eb15441, which also featured a much better explanation of why it is correct. So, switch back to that technique here, with the same explanation given there. Although this fixes a possible memory leak when GEQO is in use, the leak is minor and probably nobody cares, so no back-patch. Ashutosh Bapat, reviewed by Tom Lane and by me Discussion: http://postgr.es/m/CAFjFpRcXkHHrXyD9BCvkgGJV4TnHG2SWJ0PhJfrDu3NAcQvh7g@mail.gmail.com
This commit is contained in:
parent
e21a556e13
commit
1761653bbb
@ -1462,10 +1462,16 @@ create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We must ensure path struct and subsidiary data are allocated in main
|
* When called during GEQO join planning, we are in a short-lived memory
|
||||||
* planning context; otherwise GEQO memory management causes trouble.
|
* context. We must make sure that the path and any subsidiary data
|
||||||
|
* structures created for a baserel survive the GEQO cycle, else the
|
||||||
|
* baserel is trashed for future GEQO cycles. On the other hand, when we
|
||||||
|
* are creating those for a joinrel during GEQO, we don't want them to
|
||||||
|
* clutter the main planning context. Upshot is that the best solution is
|
||||||
|
* to explicitly allocate memory in the same context the given RelOptInfo
|
||||||
|
* is in.
|
||||||
*/
|
*/
|
||||||
oldcontext = MemoryContextSwitchTo(root->planner_cxt);
|
oldcontext = MemoryContextSwitchTo(GetMemoryChunkContext(rel));
|
||||||
|
|
||||||
pathnode = makeNode(UniquePath);
|
pathnode = makeNode(UniquePath);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user