diff options
author | Robert Haas <rhaas@postgresql.org> | 2017-04-03 22:41:31 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2017-04-03 22:41:31 -0400 |
commit | 7a39b5e4d11229ece930a51fd7cb29e535db4494 (patch) | |
tree | 00bb00bac5129ead888147abec54bcd02f23273d /src/include | |
parent | 93cd7684ee2bba227fa371daa81b88f25456dcb2 (diff) |
Abstract logic to allow for multiple kinds of child rels.
Currently, the only type of child relation is an "other member rel",
which is the child of a baserel, but in the future joins and even
upper relations may have child rels. To facilitate that, introduce
macros that test to test for particular RelOptKind values, and use
them in various places where they help to clarify the sense of a test.
(For example, a test may allow RELOPT_OTHER_MEMBER_REL either because
it intends to allow child rels, or because it intends to allow simple
rels.)
Also, remove find_childrel_top_parent, which will not work for a
child rel that is not a baserel. Instead, add a new RelOptInfo
member top_parent_relids to track the same kind of information in a
more generic manner.
Ashutosh Bapat, slightly tweaked by me. Review and testing of the
patch set from which this was taken by Rajkumar Raghuwanshi and Rafia
Sabih.
Discussion: http://postgr.es/m/CA+TgmoagTnF2yqR3PT2rv=om=wJiZ4-A+ATwdnriTGku1CLYxA@mail.gmail.com
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/nodes/relation.h | 20 | ||||
-rw-r--r-- | src/include/optimizer/pathnode.h | 3 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index ebf9480f377..fc53eb171aa 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -484,6 +484,23 @@ typedef enum RelOptKind RELOPT_DEADREL } RelOptKind; +/* + * Is the given relation a simple relation i.e a base or "other" member + * relation? + */ +#define IS_SIMPLE_REL(rel) \ + ((rel)->reloptkind == RELOPT_BASEREL || \ + (rel)->reloptkind == RELOPT_OTHER_MEMBER_REL) + +/* Is the given relation a join relation? */ +#define IS_JOIN_REL(rel) ((rel)->reloptkind == RELOPT_JOINREL) + +/* Is the given relation an upper relation? */ +#define IS_UPPER_REL(rel) ((rel)->reloptkind == RELOPT_UPPER_REL) + +/* Is the given relation an "other" relation? */ +#define IS_OTHER_REL(rel) ((rel)->reloptkind == RELOPT_OTHER_MEMBER_REL) + typedef struct RelOptInfo { NodeTag type; @@ -554,6 +571,9 @@ typedef struct RelOptInfo List *joininfo; /* RestrictInfo structures for join clauses * involving this rel */ bool has_eclass_joins; /* T means joininfo is incomplete */ + + /* used by "other" relations. */ + Relids top_parent_relids; /* Relids of topmost parents. */ } RelOptInfo; /* diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h index 82d4e8701c8..2e712c6a35d 100644 --- a/src/include/optimizer/pathnode.h +++ b/src/include/optimizer/pathnode.h @@ -256,7 +256,7 @@ extern Path *reparameterize_path(PlannerInfo *root, Path *path, */ extern void setup_simple_rel_arrays(PlannerInfo *root); extern RelOptInfo *build_simple_rel(PlannerInfo *root, int relid, - RelOptKind reloptkind); + RelOptInfo *parent); extern RelOptInfo *find_base_rel(PlannerInfo *root, int relid); extern RelOptInfo *find_join_rel(PlannerInfo *root, Relids relids); extern RelOptInfo *build_join_rel(PlannerInfo *root, @@ -274,7 +274,6 @@ extern RelOptInfo *fetch_upper_rel(PlannerInfo *root, UpperRelationKind kind, Relids relids); extern AppendRelInfo *find_childrel_appendrelinfo(PlannerInfo *root, RelOptInfo *rel); -extern RelOptInfo *find_childrel_top_parent(PlannerInfo *root, RelOptInfo *rel); extern Relids find_childrel_parents(PlannerInfo *root, RelOptInfo *rel); extern ParamPathInfo *get_baserel_parampathinfo(PlannerInfo *root, RelOptInfo *baserel, |