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

Commit1761653

Browse files
committed
Make create_unique_path manage memory like mark_dummy_rel.
Put the unique path in the same context as the owning RelOptInfo, ratherthan the toplevel planner context. This is how this function workedoriginally, but commitf41803bchanged it without explanation. mark_dummy_rel adopted the older (ornewer?) technique in commiteca75a1,which also featured a much better explanation of why it is correct.So, switch back to that technique here, with the same explanationgiven there.Although this fixes a possible memory leak when GEQO is in use, theleak is minor and probably nobody cares, so no back-patch.Ashutosh Bapat, reviewed by Tom Lane and by meDiscussion:http://postgr.es/m/CAFjFpRcXkHHrXyD9BCvkgGJV4TnHG2SWJ0PhJfrDu3NAcQvh7g@mail.gmail.com
1 parente21a556 commit1761653

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

‎src/backend/optimizer/util/pathnode.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,10 +1462,16 @@ create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath,
14621462
returnNULL;
14631463

14641464
/*
1465-
* We must ensure path struct and subsidiary data are allocated in main
1466-
* planning context; otherwise GEQO memory management causes trouble.
1465+
* When called during GEQO join planning, we are in a short-lived memory
1466+
* context. We must make sure that the path and any subsidiary data
1467+
* structures created for a baserel survive the GEQO cycle, else the
1468+
* baserel is trashed for future GEQO cycles. On the other hand, when we
1469+
* are creating those for a joinrel during GEQO, we don't want them to
1470+
* clutter the main planning context. Upshot is that the best solution is
1471+
* to explicitly allocate memory in the same context the given RelOptInfo
1472+
* is in.
14671473
*/
1468-
oldcontext=MemoryContextSwitchTo(root->planner_cxt);
1474+
oldcontext=MemoryContextSwitchTo(GetMemoryChunkContext(rel));
14691475

14701476
pathnode=makeNode(UniquePath);
14711477

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp