37 bool only_pushed_down);
44 List *parent_restrictlist);
75 List **joinrels =
root->join_rel_level;
82 root->join_cur_level = level;
91 foreach(r, joinrels[level - 1])
150 int other_level = level - k;
159 foreach(r, joinrels[k])
174 if (k == other_level)
219 if (joinrels[level] ==
NIL)
225 foreach(r, joinrels[level - 1])
252 if (joinrels[level] ==
NIL &&
254 !
root->hasLateralRTEs)
255 elog(
ERROR,
"failed to build any %d-way joins", level);
320 foreach(l, other_rels)
357 bool must_be_leftjoin;
374 unique_ified =
false;
375 must_be_leftjoin =
false;
377 foreach(l,
root->join_info_list)
434 match_sjinfo = sjinfo;
442 match_sjinfo = sjinfo;
474 match_sjinfo = sjinfo;
486 match_sjinfo = sjinfo;
529 must_be_leftjoin =
true;
542 if (must_be_leftjoin &&
543 (match_sjinfo == NULL ||
551 if (
root->hasLateralRTEs)
574 if (lateral_fwd && lateral_rev)
591 else if (lateral_rev)
622 if (join_lateral_rels)
630 foreach(l,
root->join_info_list)
653 *sjinfo_p = match_sjinfo;
654 *reversed_p = reversed;
673 sjinfo->type = T_SpecialJoinInfo;
753 sjinfo = &sjinfo_data;
762 sjinfo, pushed_down_joins,
804 List **pushed_down_joins)
807 if (sjinfo == NULL || sjinfo->
ojrelid == 0)
849 foreach(lc,
root->join_info_list)
853 if (othersj == sjinfo ||
868 if (pushed_down_joins != NULL)
869 *pushed_down_joins =
lappend(*pushed_down_joins, othersj);
972 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
973 errmsg(
"FULL JOIN is only supported with merge-joinable or hash-joinable join conditions")));
1078 bool result =
false;
1096 foreach(l,
root->placeholder_list)
1113 foreach(l,
root->join_info_list)
1195 foreach(l,
root->placeholder_list)
1204 foreach(l,
root->join_info_list)
1248 foreach(lc,
root->initial_rels)
1266 &sjinfo, &reversed))
1313 foreach(lc,
root->placeholder_list)
1430 bool only_pushed_down)
1440 foreach(lc, restrictlist)
1452 if (con->constisnull)
1484 List *parent_restrictlist)
1498 if (joinrel->part_scheme == NULL || joinrel->
nparts == 0)
1521 Assert(joinrel->part_scheme == rel1->part_scheme &&
1522 joinrel->part_scheme == rel2->part_scheme);
1540 for (cnt_parts = 0; cnt_parts < joinrel->
nparts; cnt_parts++)
1547 List *child_restrictlist;
1557 lcr1 =
lnext(parts1, lcr1);
1558 lcr2 =
lnext(parts2, lcr2);
1562 child_rel1 = rel1->part_rels[cnt_parts];
1563 child_rel2 = rel2->part_rels[cnt_parts];
1566 rel1_empty = (child_rel1 == NULL ||
IS_DUMMY_REL(child_rel1));
1567 rel2_empty = (child_rel2 == NULL ||
IS_DUMMY_REL(child_rel2));
1580 if (rel1_empty || rel2_empty)
1589 if (rel1_empty && rel2_empty)
1594 elog(
ERROR,
"unrecognized join type: %d",
1604 if (child_rel1 == NULL || child_rel2 == NULL)
1655 child_restrictlist =
1657 (
Node *) parent_restrictlist,
1658 nappinfos, appinfos);
1661 child_joinrel = joinrel->part_rels[cnt_parts];
1665 joinrel, child_restrictlist,
1666 child_sjinfo, nappinfos, appinfos);
1667 joinrel->part_rels[cnt_parts] = child_joinrel;
1676 nappinfos, appinfos)));
1680 child_joinrel, child_sjinfo,
1681 child_restrictlist);
1711 int right_nappinfos;
1728 left_nappinfos, left_appinfos);
1733 left_nappinfos, left_appinfos);
1743 pfree(left_appinfos);
1744 pfree(right_appinfos);
1792 pfree(child_sjinfo);
1809 if (joinrel->
nparts == -1)
1815 Assert(joinrel->boundinfo == NULL);
1816 Assert(joinrel->part_rels == NULL);
1834 rel1->boundinfo, rel2->boundinfo))
1836 boundinfo = rel1->boundinfo;
1848 if (boundinfo == NULL)
1858 joinrel->boundinfo = boundinfo;
1859 joinrel->
nparts = nparts;
1860 joinrel->part_rels =
1866 Assert(joinrel->boundinfo);
1867 Assert(joinrel->part_rels);
1902 for (cnt_parts = 0; cnt_parts < joinrel->
nparts; cnt_parts++)
1904 RelOptInfo *child_joinrel = joinrel->part_rels[cnt_parts];
1920 *parts1 =
lappend(*parts1, NULL);
1921 *parts2 =
lappend(*parts2, NULL);
1978 *parts1 =
lappend(*parts1, child_rel1);
1979 *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)
Bitmapset * bms_intersect(const Bitmapset *a, const Bitmapset *b)
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_add_members(Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_copy(const Bitmapset *a)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
Assert(PointerIsAligned(start, uint64))
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)
RelOptInfo * make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
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)
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)
void init_dummy_sjinfo(SpecialJoinInfo *sjinfo, Relids left_relids, Relids right_relids)
static void free_child_join_sjinfo(SpecialJoinInfo *child_sjinfo, SpecialJoinInfo *parent_sjinfo)
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)
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)
UniquePath * create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, SpecialJoinInfo *sjinfo)
void set_cheapest(RelOptInfo *parent_rel)
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)
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)
#define foreach_current_index(var_or_cell)
#define for_each_from(cell, lst, N)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
static bool DatumGetBool(Datum X)
RelOptInfo * find_base_rel(PlannerInfo *root, int relid)
RelOptInfo * build_child_join_rel(PlannerInfo *root, RelOptInfo *outer_rel, RelOptInfo *inner_rel, RelOptInfo *parent_joinrel, List *restrictlist, SpecialJoinInfo *sjinfo, int nappinfos, AppendRelInfo **appinfos)
Relids min_join_parameterization(PlannerInfo *root, Relids joinrelids, RelOptInfo *outer_rel, RelOptInfo *inner_rel)
RelOptInfo * find_join_rel(PlannerInfo *root, Relids relids)
RelOptInfo * build_join_rel(PlannerInfo *root, Relids joinrelids, RelOptInfo *outer_rel, RelOptInfo *inner_rel, SpecialJoinInfo *sjinfo, List *pushed_down_joins, List **restrictlist_ptr)
void check_stack_depth(void)
struct FmgrInfo * partsupfunc
Relids lateral_referencers
struct Path * cheapest_total_path
Relids direct_lateral_relids
bool consider_partitionwise_join