Commit 480f1f43 authored by Robert Haas's avatar Robert Haas

Teach adjust_appendrel_attrs(_multilevel) to do multiple translations.

Currently, child relations are always base relations, so when we
translate parent relids to child relids, we only need to translate
a singler relid.  However, the proposed partition-wise join feature
will create child joins, which will mean we need to translate a set
of parent relids to the corresponding child relids.  This is
preliminary refactoring to make that possible.

Ashutosh Bapat.  Review and testing of the larger patch set of which
this is a part by Amit Langote, Rajkumar Raghuwanshi, Rafia Sabih,
Thomas Munro, Dilip Kumar, and me.  Some adjustments, mostly
cosmetic, by me.

Discussion: http://postgr.es/m/CA+TgmobQK80vtXjAsPZWWXd7c8u13G86gmuLupN+uUJjA+i4nA@mail.gmail.com
parent d57929af
...@@ -942,7 +942,7 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel, ...@@ -942,7 +942,7 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
Assert(IsA(rinfo, RestrictInfo)); Assert(IsA(rinfo, RestrictInfo));
childqual = adjust_appendrel_attrs(root, childqual = adjust_appendrel_attrs(root,
(Node *) rinfo->clause, (Node *) rinfo->clause,
appinfo); 1, &appinfo);
childqual = eval_const_expressions(root, childqual); childqual = eval_const_expressions(root, childqual);
/* check for flat-out constant */ /* check for flat-out constant */
if (childqual && IsA(childqual, Const)) if (childqual && IsA(childqual, Const))
...@@ -1061,11 +1061,11 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel, ...@@ -1061,11 +1061,11 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
childrel->joininfo = (List *) childrel->joininfo = (List *)
adjust_appendrel_attrs(root, adjust_appendrel_attrs(root,
(Node *) rel->joininfo, (Node *) rel->joininfo,
appinfo); 1, &appinfo);
childrel->reltarget->exprs = (List *) childrel->reltarget->exprs = (List *)
adjust_appendrel_attrs(root, adjust_appendrel_attrs(root,
(Node *) rel->reltarget->exprs, (Node *) rel->reltarget->exprs,
appinfo); 1, &appinfo);
/* /*
* We have to make child entries in the EquivalenceClass data * We have to make child entries in the EquivalenceClass data
......
...@@ -1329,7 +1329,8 @@ generate_join_implied_equalities_broken(PlannerInfo *root, ...@@ -1329,7 +1329,8 @@ generate_join_implied_equalities_broken(PlannerInfo *root,
if (IS_OTHER_REL(inner_rel) && result != NIL) if (IS_OTHER_REL(inner_rel) && result != NIL)
result = (List *) adjust_appendrel_attrs_multilevel(root, result = (List *) adjust_appendrel_attrs_multilevel(root,
(Node *) result, (Node *) result,
inner_rel); inner_rel->relids,
inner_rel->top_parent_relids);
return result; return result;
} }
...@@ -2112,7 +2113,7 @@ add_child_rel_equivalences(PlannerInfo *root, ...@@ -2112,7 +2113,7 @@ add_child_rel_equivalences(PlannerInfo *root,
child_expr = (Expr *) child_expr = (Expr *)
adjust_appendrel_attrs(root, adjust_appendrel_attrs(root,
(Node *) cur_em->em_expr, (Node *) cur_em->em_expr,
appinfo); 1, &appinfo);
/* /*
* Transform em_relids to match. Note we do *not* do * Transform em_relids to match. Note we do *not* do
......
...@@ -1142,7 +1142,7 @@ inheritance_planner(PlannerInfo *root) ...@@ -1142,7 +1142,7 @@ inheritance_planner(PlannerInfo *root)
subroot->parse = (Query *) subroot->parse = (Query *)
adjust_appendrel_attrs(root, adjust_appendrel_attrs(root,
(Node *) parse, (Node *) parse,
appinfo); 1, &appinfo);
/* /*
* If there are securityQuals attached to the parent, move them to the * If there are securityQuals attached to the parent, move them to the
......
This diff is collapsed.
...@@ -53,9 +53,13 @@ extern RelOptInfo *plan_set_operations(PlannerInfo *root); ...@@ -53,9 +53,13 @@ extern RelOptInfo *plan_set_operations(PlannerInfo *root);
extern void expand_inherited_tables(PlannerInfo *root); extern void expand_inherited_tables(PlannerInfo *root);
extern Node *adjust_appendrel_attrs(PlannerInfo *root, Node *node, extern Node *adjust_appendrel_attrs(PlannerInfo *root, Node *node,
AppendRelInfo *appinfo); int nappinfos, AppendRelInfo **appinfos);
extern Node *adjust_appendrel_attrs_multilevel(PlannerInfo *root, Node *node, extern Node *adjust_appendrel_attrs_multilevel(PlannerInfo *root, Node *node,
RelOptInfo *child_rel); Relids child_relids,
Relids top_parent_relids);
extern AppendRelInfo **find_appinfos_by_relids(PlannerInfo *root,
Relids relids, int *nappinfos);
#endif /* PREP_H */ #endif /* PREP_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment