37 bool only_pushed_down);
44 List *parent_restrictlist);
73 List **joinrels = root->join_rel_level;
89 foreach(r, joinrels[level - 1])
148 int other_level = level - k;
157 foreach(r, joinrels[k])
172 if (k == other_level)
217 if (joinrels[level] ==
NIL)
223 foreach(r, joinrels[level - 1])
250 if (joinrels[level] ==
NIL &&
253 elog(
ERROR,
"failed to build any %d-way joins", level);
318 foreach(l, other_rels)
355 bool must_be_leftjoin;
372 unique_ified =
false;
373 must_be_leftjoin =
false;
432 match_sjinfo = sjinfo;
440 match_sjinfo = sjinfo;
472 match_sjinfo = sjinfo;
484 match_sjinfo = sjinfo;
527 must_be_leftjoin =
true;
540 if (must_be_leftjoin &&
541 (match_sjinfo == NULL ||
572 if (lateral_fwd && lateral_rev)
589 else if (lateral_rev)
620 if (join_lateral_rels)
651 *sjinfo_p = match_sjinfo;
652 *reversed_p = reversed;
718 sjinfo = &sjinfo_data;
719 sjinfo->type = T_SpecialJoinInfo;
743 sjinfo, pushed_down_joins,
785 List **pushed_down_joins)
788 if (sjinfo == NULL || sjinfo->
ojrelid == 0)
834 if (othersj == sjinfo ||
849 if (pushed_down_joins != NULL)
850 *pushed_down_joins =
lappend(*pushed_down_joins, othersj);
953 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
954 errmsg(
"FULL JOIN is only supported with merge-joinable or hash-joinable join conditions")));
1056 bool result =
false;
1226 foreach(lc, root->initial_rels)
1244 &sjinfo, &reversed))
1408 bool only_pushed_down)
1418 foreach(lc, restrictlist)
1430 if (con->constisnull)
1462 List *parent_restrictlist)
1476 if (joinrel->part_scheme == NULL || joinrel->
nparts == 0)
1499 Assert(joinrel->part_scheme == rel1->part_scheme &&
1500 joinrel->part_scheme == rel2->part_scheme);
1518 for (cnt_parts = 0; cnt_parts < joinrel->
nparts; cnt_parts++)
1525 List *child_restrictlist;
1534 lcr1 =
lnext(parts1, lcr1);
1535 lcr2 =
lnext(parts2, lcr2);
1539 child_rel1 = rel1->part_rels[cnt_parts];
1540 child_rel2 = rel2->part_rels[cnt_parts];
1543 rel1_empty = (child_rel1 == NULL ||
IS_DUMMY_REL(child_rel1));
1544 rel2_empty = (child_rel2 == NULL ||
IS_DUMMY_REL(child_rel2));
1557 if (rel1_empty || rel2_empty)
1566 if (rel1_empty && rel2_empty)
1571 elog(
ERROR,
"unrecognized join type: %d",
1581 if (child_rel1 == NULL || child_rel2 == NULL)
1633 child_restrictlist =
1635 (
Node *) parent_restrictlist,
1636 nappinfos, appinfos);
1639 child_joinrel = joinrel->part_rels[cnt_parts];
1643 joinrel, child_restrictlist,
1645 joinrel->part_rels[cnt_parts] = child_joinrel;
1654 nappinfos, appinfos)));
1658 child_joinrel, child_sjinfo,
1659 child_restrictlist);
1678 int right_nappinfos;
1687 left_nappinfos, left_appinfos);
1692 left_nappinfos, left_appinfos);
1702 pfree(left_appinfos);
1703 pfree(right_appinfos);
1722 if (joinrel->
nparts == -1)
1728 Assert(joinrel->boundinfo == NULL);
1729 Assert(joinrel->part_rels == NULL);
1747 rel1->boundinfo, rel2->boundinfo))
1749 boundinfo = rel1->boundinfo;
1761 if (boundinfo == NULL)
1771 joinrel->boundinfo = boundinfo;
1772 joinrel->
nparts = nparts;
1773 joinrel->part_rels =
1779 Assert(joinrel->boundinfo);
1780 Assert(joinrel->part_rels);
1815 for (cnt_parts = 0; cnt_parts < joinrel->
nparts; cnt_parts++)
1817 RelOptInfo *child_joinrel = joinrel->part_rels[cnt_parts];
1833 *parts1 =
lappend(*parts1, NULL);
1834 *parts2 =
lappend(*parts2, NULL);
1891 *parts1 =
lappend(*parts1, child_rel1);
1892 *parts2 =
lappend(*parts2, child_rel2);
AppendRelInfo ** find_appinfos_by_relids(PlannerInfo *root, Relids relids, int *nappinfos)
Node * adjust_appendrel_attrs(PlannerInfo *root, Node *node, int nappinfos, AppendRelInfo **appinfos)
Relids adjust_child_relids(Relids relids, int nappinfos, AppendRelInfo **appinfos)
bool bms_equal(const Bitmapset *a, const Bitmapset *b)
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
int bms_singleton_member(const Bitmapset *a)
void bms_free(Bitmapset *a)
int bms_num_members(const Bitmapset *a)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_intersect(const Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_add_members(Bitmapset *a, const Bitmapset *b)
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_copy(const Bitmapset *a)
elog(ERROR, "%s: %s", p2, msg)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
if(TABLE==NULL||TABLE_index==NULL)
bool have_relevant_joinclause(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
void add_paths_to_joinrel(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel, JoinType jointype, SpecialJoinInfo *sjinfo, List *restrictlist)
static void populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2, RelOptInfo *joinrel, SpecialJoinInfo *sjinfo, List *restrictlist)
static void try_partitionwise_join(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2, RelOptInfo *joinrel, SpecialJoinInfo *parent_sjinfo, List *parent_restrictlist)
static void make_rels_by_clauseless_joins(PlannerInfo *root, RelOptInfo *old_rel, List *other_rels)
bool is_dummy_rel(RelOptInfo *rel)
void join_search_one_level(PlannerInfo *root, int level)
static bool restriction_is_constant_false(List *restrictlist, RelOptInfo *joinrel, bool only_pushed_down)
static void get_matching_part_pairs(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *rel1, RelOptInfo *rel2, List **parts1, List **parts2)
static bool has_legal_joinclause(PlannerInfo *root, RelOptInfo *rel)
static void compute_partition_bounds(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2, RelOptInfo *joinrel, SpecialJoinInfo *parent_sjinfo, List **parts1, List **parts2)
Relids add_outer_joins_to_relids(PlannerInfo *root, Relids input_relids, SpecialJoinInfo *sjinfo, List **pushed_down_joins)
static SpecialJoinInfo * build_child_join_sjinfo(PlannerInfo *root, SpecialJoinInfo *parent_sjinfo, Relids left_relids, Relids right_relids)
RelOptInfo * make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
void mark_dummy_rel(RelOptInfo *rel)
bool have_dangerous_phv(PlannerInfo *root, Relids outer_relids, Relids inner_params)
bool have_join_order_restriction(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
static bool has_join_restriction(PlannerInfo *root, RelOptInfo *rel)
static bool join_is_legal(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2, Relids joinrelids, SpecialJoinInfo **sjinfo_p, bool *reversed_p)
static void make_rels_by_clause_joins(PlannerInfo *root, RelOptInfo *old_rel, List *other_rels, int first_rel_idx)
Assert(fmt[strlen(fmt) - 1] !='\n')
List * lappend(List *list, void *datum)
Datum subpath(PG_FUNCTION_ARGS)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext GetMemoryChunkContext(void *pointer)
#define IsA(nodeptr, _type_)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
bool partition_bounds_equal(int partnatts, int16 *parttyplen, bool *parttypbyval, PartitionBoundInfo b1, PartitionBoundInfo b2)
PartitionBoundInfo partition_bounds_merge(int partnatts, FmgrInfo *partsupfunc, Oid *partcollation, RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinType jointype, List **outer_parts, List **inner_parts)
AppendPath * create_append_path(PlannerInfo *root, RelOptInfo *rel, List *subpaths, List *partial_subpaths, List *pathkeys, Relids required_outer, int parallel_workers, bool parallel_aware, double rows)
UniquePath * create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, SpecialJoinInfo *sjinfo)
void set_cheapest(RelOptInfo *parent_rel)
void add_path(RelOptInfo *parent_rel, Path *new_path)
#define IS_DUMMY_APPEND(p)
#define RINFO_IS_PUSHED_DOWN(rinfo, joinrelids)
#define IS_SIMPLE_REL(rel)
#define IS_PARTITIONED_REL(rel)
#define REL_HAS_ALL_PART_PROPS(rel)
@ RELOPT_OTHER_MEMBER_REL
#define lfirst_node(type, lc)
static int list_length(const List *l)
static ListCell * list_head(const List *l)
#define for_each_from(cell, lst, N)
static ListCell * lnext(const List *l, const ListCell *c)
#define foreach_current_index(cell)
void check_stack_depth(void)
static bool DatumGetBool(Datum X)
RelOptInfo * build_join_rel(PlannerInfo *root, Relids joinrelids, RelOptInfo *outer_rel, RelOptInfo *inner_rel, SpecialJoinInfo *sjinfo, List *pushed_down_joins, List **restrictlist_ptr)
Relids min_join_parameterization(PlannerInfo *root, Relids joinrelids, RelOptInfo *outer_rel, RelOptInfo *inner_rel)
RelOptInfo * find_base_rel(PlannerInfo *root, int relid)
RelOptInfo * find_join_rel(PlannerInfo *root, Relids relids)
RelOptInfo * build_child_join_rel(PlannerInfo *root, RelOptInfo *outer_rel, RelOptInfo *inner_rel, RelOptInfo *parent_joinrel, List *restrictlist, SpecialJoinInfo *sjinfo)
struct FmgrInfo * partsupfunc
Relids lateral_referencers
struct Path * cheapest_total_path
Relids direct_lateral_relids
bool consider_partitionwise_join