diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index 0ab4014..4d3a87a 100644 --- a/src/backend/optimizer/prep/prepunion.c +++ b/src/backend/optimizer/prep/prepunion.c @@ -56,8 +56,8 @@ typedef struct { PlannerInfo *root; - int nappinfos; - AppendRelInfo **appinfos; + int nappinfos; /* # of entries in appinfos array. */ + AppendRelInfo **appinfos; /* AppendRelInfo detecting the adjustment. */ } adjust_appendrel_attrs_context; static RelOptInfo *recurse_set_operations(Node *setOp, PlannerInfo *root, @@ -2037,6 +2037,9 @@ translate_col_privs(const Bitmapset *parent_privs, * update rtindexes appearing outside Vars, such as resultRelation and * jointree relids. * + * appinfos is an array of nappinfos AppendRelInfos indicating parent-child + * pairs. + * * Note: this is only applied after conversion of sublinks to subplans, * so we don't need to cope with recursion into sub-queries. * @@ -2613,6 +2616,9 @@ build_child_join_sjinfo(PlannerInfo *root, SpecialJoinInfo *parent_sjinfo, * * The AppendRelInfos are returned in an array, which can be pfree'd by the * caller. *nappinfos is set to the number of entries in the array. + * + * The returned array and *nappinfos is usually passed down to + * adjust_appendrel_attrs(). See prologue of that function for more details. */ AppendRelInfo ** find_appinfos_by_relids(PlannerInfo *root, Relids relids, int *nappinfos) diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index 3b28d19..0d17999 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -2096,6 +2096,13 @@ typedef struct SpecialJoinInfo * will not have many different append parents, it doesn't seem worthwhile * to complicate things. * + * We expand multi-level partitioning hierarchy into corresponding inheritance + * hierarchy level by level. An intermediate partitioned partition acts as + * both, a parent (of its partitions) and a child (to the partitioned table + * whose partition it is). Per expand_single_inheritance_child() the + * AppendRelInfo of an intermediate parent appears before that of any of its + * children. + * * Note: after completion of the planner prep phase, any given RTE is an * append parent having entries in append_rel_list if and only if its * "inh" flag is set. We clear "inh" for plain tables that turn out not