@@ -249,10 +249,14 @@ append_child_relation(PlannerInfo *root, Relation parent_relation,
249249 child_rte = copyObject (parent_rte );
250250 child_rte -> relid = child_oid ;
251251 child_rte -> relkind = child_relation -> rd_rel -> relkind ;
252- // child_rte->inh = false; /* relation has no children */
252+ child_rte -> requiredPerms = 0 ; /* perform all checks on parent */
253+ /*
254+ * If it is the parent relation, then set inh flag to false to prevent
255+ * further recursive unrolling. Else if relation is a child and has subclass
256+ * then we will need to check if there are subpartitions
257+ */
253258 child_rte -> inh = (child_oid != parent_rte -> relid ) ?
254259 child_relation -> rd_rel -> relhassubclass : false;
255- child_rte -> requiredPerms = 0 ; /* perform all checks on parent */
256260
257261 /* Add 'child_rte' to rtable and 'root->simple_rte_array' */
258262 root -> parse -> rtable = lappend (root -> parse -> rtable , child_rte );
@@ -394,7 +398,7 @@ append_child_relation(PlannerInfo *root, Relation parent_relation,
394398 }
395399
396400 /*
397- * TODO: new!!!
401+ * Recursively expand child partition if it has subpartitions
398402 */
399403 if (child_rte -> inh )
400404 {
@@ -1660,29 +1664,36 @@ set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, Index rti,
16601664 set_rel_consider_parallel_compat (root , childrel , childRTE );
16611665#endif
16621666
1663- /* Compute child's access paths & sizes */
1664- if (childRTE -> relkind == RELKIND_FOREIGN_TABLE )
1667+ /*
1668+ * If inh is True and pathlist is not null then it is a partitioned
1669+ * table and we've already filled it, skip it. Otherwise build a
1670+ * pathlist for it
1671+ */
1672+ if (!childRTE -> inh || childrel -> pathlist == NIL )
16651673 {
1666- /* childrel->rows should be >= 1 */
1667- set_foreign_size (root , childrel , childRTE );
1674+ /* Compute child's access paths & sizes */
1675+ if (childRTE -> relkind == RELKIND_FOREIGN_TABLE )
1676+ {
1677+ /* childrel->rows should be >= 1 */
1678+ set_foreign_size (root , childrel , childRTE );
16681679
1669- /* If child IS dummy, ignore it */
1670- if (IS_DUMMY_REL (childrel ))
1671- continue ;
1680+ /* If child IS dummy, ignore it */
1681+ if (IS_DUMMY_REL (childrel ))
1682+ continue ;
16721683
1673- set_foreign_pathlist (root , childrel , childRTE );
1674- }
1675- /* TODO: temporary!!! */
1676- else if (!childRTE -> inh || childrel -> pathlist == NIL )
1677- {
1678- /* childrel->rows should be >= 1 */
1679- set_plain_rel_size (root , childrel , childRTE );
1684+ set_foreign_pathlist (root , childrel , childRTE );
1685+ }
1686+ else
1687+ {
1688+ /* childrel->rows should be >= 1 */
1689+ set_plain_rel_size (root , childrel , childRTE );
16801690
1681- /* If child IS dummy, ignore it */
1682- if (IS_DUMMY_REL (childrel ))
1683- continue ;
1691+ /* If child IS dummy, ignore it */
1692+ if (IS_DUMMY_REL (childrel ))
1693+ continue ;
16841694
1685- set_plain_rel_pathlist (root , childrel , childRTE );
1695+ set_plain_rel_pathlist (root , childrel , childRTE );
1696+ }
16861697 }
16871698
16881699 /* Set cheapest path for child */
0 commit comments