trim-append-rel-list-in-inheritance-planner.patch
text/x-diff
Filename: trim-append-rel-list-in-inheritance-planner.patch
Type: text/x-diff
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/optimizer/plan/planner.c | 0 | 0 |
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index b223972..fc0f08e 100644
*** a/src/backend/optimizer/plan/planner.c
--- b/src/backend/optimizer/plan/planner.c
*************** inheritance_planner(PlannerInfo *root)
*** 1307,1312 ****
--- 1307,1313 ----
RangeTblEntry *child_rte;
RelOptInfo *sub_final_rel;
Path *subpath;
+ ListCell *lc2;
/* append_rel_list contains all append rels; ignore others */
if (!bms_is_member(appinfo->parent_relid, parent_relids))
*************** inheritance_planner(PlannerInfo *root)
*** 1416,1439 ****
* want to copy items that actually contain such references; the rest
* can just get linked into the subroot's append_rel_list.
*
! * If we know there are no such references, we can just use the outer
! * append_rel_list unmodified.
*/
! if (modifiableARIindexes != NULL)
{
! ListCell *lc2;
! subroot->append_rel_list = NIL;
! foreach(lc2, parent_root->append_rel_list)
! {
! AppendRelInfo *appinfo2 = lfirst_node(AppendRelInfo, lc2);
! if (bms_is_member(appinfo2->child_relid, modifiableARIindexes))
! appinfo2 = copyObject(appinfo2);
! subroot->append_rel_list = lappend(subroot->append_rel_list,
! appinfo2);
! }
}
/*
--- 1417,1441 ----
* want to copy items that actually contain such references; the rest
* can just get linked into the subroot's append_rel_list.
*
! * While we're at it, drop the AppendRelInfo items that link the
! * current parent to its children from the subquery's append_rel_list.
! * Those items are irrelevant for the subquery, so keeping them just
! * wastes cycles during subquery planning, and could confuse code
! * elsewhere.
*/
! subroot->append_rel_list = NIL;
! foreach(lc2, parent_root->append_rel_list)
{
! AppendRelInfo *appinfo2 = lfirst_node(AppendRelInfo, lc2);
! if (appinfo2->parent_relid == appinfo->parent_relid)
! continue;
! if (bms_is_member(appinfo2->child_relid, modifiableARIindexes))
! appinfo2 = copyObject(appinfo2);
! subroot->append_rel_list = lappend(subroot->append_rel_list,
! appinfo2);
}
/*