102 List **group_clauses,
List **group_exprs);
122 root->simple_rel_array_size = size;
135 foreach(
lc,
root->parse->rtable)
139 root->simple_rte_array[rti++] =
rte;
143 if (
root->append_rel_list ==
NIL)
158 foreach(
lc,
root->append_rel_list)
161 int child_relid =
appinfo->child_relid;
164 Assert(child_relid < size);
166 if (
root->append_rel_array[child_relid])
167 elog(
ERROR,
"child relation already exists");
191 root->simple_rel_array =
194 root->simple_rte_array =
197 if (
root->append_rel_array)
198 root->append_rel_array =
201 root->append_rel_array =
219 if (
root->simple_rel_array[relid] !=
NULL)
220 elog(
ERROR,
"rel %d already exists", relid);
223 rte =
root->simple_rte_array[relid];
288 rel->fdwroutine =
NULL;
289 rel->fdw_private =
NULL;
304 rel->part_scheme =
NULL;
306 rel->boundinfo =
NULL;
309 rel->part_rels =
NULL;
312 rel->partexprs =
NULL;
313 rel->nullable_partexprs =
NULL;
321 rel->parent = parent;
322 rel->top_parent = parent->top_parent ? parent->top_parent : parent;
352 rel->top_parent =
NULL;
361 switch (
rte->rtekind)
382 rel->attr_needed = (
Relids *)
384 rel->attr_widths = (
int32 *)
391 rel->attr_needed =
NULL;
392 rel->attr_widths =
NULL;
410 (*build_simple_rel_hook) (
root, rel,
rte);
437 root->simple_rel_array[relid] = rel;
469 if (agg_info ==
NULL)
519 grouped_rel->part_scheme =
NULL;
521 grouped_rel->boundinfo =
NULL;
524 grouped_rel->part_rels =
NULL;
527 grouped_rel->partexprs =
NULL;
528 grouped_rel->nullable_partexprs =
NULL;
534 grouped_rel->
rows = 0;
551 rel =
root->simple_rel_array[relid];
556 elog(
ERROR,
"no relation entry for relid %d", relid);
570 return root->simple_rel_array[relid];
592 rel =
root->simple_rel_array[relid];
601 rte =
root->simple_rte_array[relid];
606 elog(
ERROR,
"no relation entry for relid %d", relid);
634 foreach(l,
root->join_rel_list)
648 root->join_rel_hash = hashtab;
674 if (
root->join_rel_hash)
690 foreach(l,
root->join_rel_list)
730 joinrel->fdwroutine =
outer_rel->fdwroutine;
738 joinrel->fdwroutine =
outer_rel->fdwroutine;
746 joinrel->fdwroutine =
outer_rel->fdwroutine;
763 if (
root->join_rel_hash)
773 hentry->join_rel = joinrel;
858 joinrel->attr_needed =
NULL;
859 joinrel->attr_widths =
NULL;
877 joinrel->fdwroutine =
NULL;
878 joinrel->fdw_private =
NULL;
893 joinrel->parent =
NULL;
894 joinrel->top_parent =
NULL;
896 joinrel->part_scheme =
NULL;
898 joinrel->boundinfo =
NULL;
901 joinrel->part_rels =
NULL;
904 joinrel->partexprs =
NULL;
905 joinrel->nullable_partexprs =
NULL;
957 sjinfo, restrictlist);
1000 if (
root->join_rel_level)
1004 root->join_rel_level[
root->join_cur_level] =
1041 nappinfos, appinfos);
1061 joinrel->attr_needed =
NULL;
1062 joinrel->attr_widths =
NULL;
1078 joinrel->fdwroutine =
NULL;
1079 joinrel->fdw_private =
NULL;
1094 joinrel->part_scheme =
NULL;
1096 joinrel->boundinfo =
NULL;
1099 joinrel->part_rels =
NULL;
1102 joinrel->partexprs =
NULL;
1103 joinrel->nullable_partexprs =
NULL;
1110 nappinfos, appinfos);
1136 sjinfo, restrictlist);
1166 nappinfos, appinfos,
1310 phv->phnullingrels =
1330 elog(
ERROR,
"unexpected node type in rel targetlist: %d",
1385 var->varnullingrels =
1630 foreach(
lc,
root->upper_rels[kind])
1644 upperrel->consider_startup = (
root->tuple_fraction > 0);
1645 upperrel->consider_param_startup =
false;
1646 upperrel->consider_parallel =
false;
1754#ifdef USE_ASSERT_CHECKING
1781 ppi->ppi_rows = rows;
1906 Assert(rinfo->left_ec == rinfo->right_ec);
1996 ppi->ppi_rows = rows;
2071 if (path->param_info ==
NULL)
2139 return path->param_info->ppi_serials;
2176 !
outer_rel->consider_partitionwise_join ||
2177 !
inner_rel->consider_partitionwise_join ||
2192 Assert(!joinrel->part_scheme && !joinrel->partexprs &&
2193 !joinrel->nullable_partexprs && !joinrel->part_rels &&
2194 !joinrel->boundinfo);
2245 foreach(
lc, restrictlist)
2261 if (!rinfo->can_join)
2265 if (!rinfo->mergeopfamilies && !
OidIsValid(rinfo->hashjoinoperator))
2303 root->outer_join_rels,
2307 root->outer_join_rels,
2334 if (
rel1->part_scheme->partcollation[
ipk1] != opexpr->inputcollid)
2431 rel2->part_scheme->partcollation[
ipk];
2475 Assert(rel->part_scheme);
2477 Assert(rel->nullable_partexprs);
2483 for (cnt = 0; cnt < rel->part_scheme->partnatts; cnt++)
2488 foreach(
lc, rel->partexprs[cnt])
2504 foreach(
lc, rel->nullable_partexprs[cnt])
2535 for (
int cnt = 0; cnt < partnatts; cnt++)
2649 elog(
ERROR,
"unrecognized join type: %d", (
int) jointype);
2652 joinrel->partexprs[cnt] =
partexpr;
2672 nappinfos, appinfos);
2719 if (grouped_rel ==
NULL)
2764 &group_clauses, &group_exprs))
2771 if (group_clauses ==
NIL)
2775 foreach(
lc,
root->agg_clause_list)
2867 foreach(
lc,
root->agg_clause_list)
2903 List **group_clauses,
List **group_exprs)
2911 foreach(
lc,
root->processed_tlist)
2943 if (sortgroupref > 0)
2969 *group_clauses =
lappend(*group_clauses,
sgc);
2970 *group_exprs =
lappend(*group_exprs, expr);
3004 tce->btree_opintype,
3005 tce->btree_opintype,
3030 *group_clauses =
lappend(*group_clauses,
sgc);
3031 *group_exprs =
lappend(*group_exprs, expr);
3069 target->
exprs, &deps))
3112 foreach(
lc,
root->agg_clause_list)
3178 foreach(
lc,
root->group_expr_list)
double min_eager_agg_group_size
Node * adjust_appendrel_attrs(PlannerInfo *root, Node *node, int nappinfos, AppendRelInfo **appinfos)
Node * adjust_appendrel_attrs_multilevel(PlannerInfo *root, Node *node, RelOptInfo *childrel, RelOptInfo *parentrel)
Relids adjust_child_relids(Relids relids, int nappinfos, AppendRelInfo **appinfos)
Bitmapset * bms_make_singleton(int x)
Bitmapset * bms_int_members(Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_intersect(const Bitmapset *a, const Bitmapset *b)
uint32 bitmap_hash(const void *key, Size keysize)
bool bms_equal(const Bitmapset *a, const Bitmapset *b)
int bms_next_member(const Bitmapset *a, int prevbit)
Bitmapset * bms_del_members(Bitmapset *a, const Bitmapset *b)
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
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)
int bitmap_match(const void *key1, const void *key2, Size keysize)
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_join(Bitmapset *a, Bitmapset *b)
bool bms_nonempty_difference(const Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_copy(const Bitmapset *a)
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
#define OidIsValid(objectId)
bool is_parallel_safe(PlannerInfo *root, Node *node)
double get_parameterized_baserel_size(PlannerInfo *root, RelOptInfo *rel, List *param_clauses)
double get_parameterized_joinrel_size(PlannerInfo *root, RelOptInfo *rel, Path *outer_path, Path *inner_path, SpecialJoinInfo *sjinfo, List *restrict_clauses)
void set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel, RelOptInfo *outer_rel, RelOptInfo *inner_rel, SpecialJoinInfo *sjinfo, List *restrictlist)
PathTarget * set_pathtarget_cost_width(PlannerInfo *root, PathTarget *target)
int32 clamp_width_est(int64 tuple_width)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, int64 nelem, const HASHCTL *info, int flags)
bool equal(const void *a, const void *b)
bool exprs_known_equal(PlannerInfo *root, Node *item1, Node *item2, Oid opfamily)
List * generate_join_implied_equalities_for_ecs(PlannerInfo *root, List *eclasses, Relids join_relids, Relids outer_relids, RelOptInfo *inner_rel)
void add_child_join_rel_equivalences(PlannerInfo *root, int nappinfos, AppendRelInfo **appinfos, RelOptInfo *parent_joinrel, RelOptInfo *child_joinrel)
List * generate_join_implied_equalities(PlannerInfo *root, Relids join_relids, Relids outer_relids, RelOptInfo *inner_rel, SpecialJoinInfo *sjinfo)
bool has_relevant_eclass_joinclause(PlannerInfo *root, RelOptInfo *rel1)
#define palloc0_array(type, count)
Datum OidFunctionCall1Coll(Oid functionId, Oid collation, Datum arg1)
bool apply_child_basequals(PlannerInfo *root, RelOptInfo *parentrel, RelOptInfo *childrel, RangeTblEntry *childRTE, AppendRelInfo *appinfo)
void mark_dummy_rel(RelOptInfo *rel)
List * lappend(List *list, void *datum)
List * list_concat(List *list1, const List *list2)
List * list_concat_copy(const List *list1, const List *list2)
List * list_copy(const List *oldlist)
void list_free(List *list)
bool list_member_oid(const List *list, Oid datum)
bool list_member(const List *list, const void *datum)
List * list_append_unique_ptr(List *list, void *datum)
Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
List * get_mergejoin_opfamilies(Oid opno)
bool op_in_opfamily(Oid opno, Oid opfamily)
Datum subpath(PG_FUNCTION_ARGS)
MemoryContext CurrentMemoryContext
#define BTEQUALIMAGE_PROC
Oid exprType(const Node *expr)
Oid exprCollation(const Node *expr)
#define IsA(nodeptr, _type_)
#define IS_OUTER_JOIN(jointype)
@ AGGSPLIT_INITIAL_SERIAL
#define castNode(_type_, nodeptr)
#define PVC_RECURSE_AGGREGATES
#define PVC_RECURSE_PLACEHOLDERS
#define PVC_RECURSE_WINDOWFUNCS
#define repalloc0_array(pointer, type, oldcount, count)
void get_sort_group_operators(Oid argtype, bool needLT, bool needEQ, bool needGT, Oid *ltOpr, Oid *eqOpr, Oid *gtOpr, bool *isHashable)
RTEPermissionInfo * getRTEPermissionInfo(List *rteperminfos, RangeTblEntry *rte)
@ PARTITION_STRATEGY_HASH
bool has_useful_pathkeys(PlannerInfo *root, RelOptInfo *rel)
void(* joinrel_setup_hook_type)(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *outer_rel, RelOptInfo *inner_rel, SpecialJoinInfo *sjinfo, List *restrictlist)
void(* build_simple_rel_hook_type)(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
#define RINFO_IS_PUSHED_DOWN(rinfo, joinrelids)
#define IS_PARTITIONED_REL(rel)
#define IS_GROUPED_REL(rel)
#define PATH_REQ_OUTER(path)
#define PGS_CONSIDER_PARTITIONWISE
@ RELOPT_OTHER_MEMBER_REL
#define IS_OTHER_REL(rel)
#define PARTITION_MAX_KEYS
bool check_functional_grouping(Oid relid, Index varno, Index varlevelsup, List *grouping_columns, List **constraintDeps)
#define lfirst_node(type, lc)
static int list_length(const List *l)
static void * list_nth(const List *list, int n)
static ListCell * list_head(const List *l)
#define list_make2(x1, x2)
PlaceHolderInfo * find_placeholder_info(PlannerInfo *root, PlaceHolderVar *phv)
void add_placeholders_to_joinrel(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *outer_rel, RelOptInfo *inner_rel, SpecialJoinInfo *sjinfo)
void get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent, RelOptInfo *rel)
void mark_partial_aggref(Aggref *agg, AggSplit aggsplit)
static bool DatumGetBool(Datum X)
static Datum ObjectIdGetDatum(Oid X)
static void build_joinrel_partition_info(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *outer_rel, RelOptInfo *inner_rel, SpecialJoinInfo *sjinfo, List *restrictlist)
RelOptInfo * find_base_rel(PlannerInfo *root, int relid)
void setup_simple_rel_arrays(PlannerInfo *root)
static void set_joinrel_partition_key_exprs(RelOptInfo *joinrel, RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinType jointype)
ParamPathInfo * get_appendrel_parampathinfo(RelOptInfo *appendrel, Relids required_outer)
static bool init_grouping_targets(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, PathTarget *agg_input, List **group_clauses, List **group_exprs)
static void build_joinrel_tlist(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *input_rel, SpecialJoinInfo *sjinfo, List *pushed_down_joins, bool can_null)
RelOptInfo * build_grouped_rel(PlannerInfo *root, RelOptInfo *rel)
joinrel_setup_hook_type joinrel_setup_hook
RelOptInfo * build_child_join_rel(PlannerInfo *root, RelOptInfo *outer_rel, RelOptInfo *inner_rel, RelOptInfo *parent_joinrel, List *restrictlist, SpecialJoinInfo *sjinfo, int nappinfos, AppendRelInfo **appinfos)
static bool have_partkey_equi_join(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *rel1, RelOptInfo *rel2, JoinType jointype, List *restrictlist)
RelOptInfo * find_base_rel_noerr(PlannerInfo *root, int relid)
Relids min_join_parameterization(PlannerInfo *root, Relids joinrelids, RelOptInfo *outer_rel, RelOptInfo *inner_rel)
RelOptInfo * find_join_rel(PlannerInfo *root, Relids relids)
static void build_join_rel_hash(PlannerInfo *root)
ParamPathInfo * get_joinrel_parampathinfo(PlannerInfo *root, RelOptInfo *joinrel, Path *outer_path, Path *inner_path, SpecialJoinInfo *sjinfo, Relids required_outer, List **restrict_clauses)
static bool eager_aggregation_possible_for_relation(PlannerInfo *root, RelOptInfo *rel)
Relids find_childrel_parents(PlannerInfo *root, RelOptInfo *rel)
void expand_planner_arrays(PlannerInfo *root, int add_size)
ParamPathInfo * get_baserel_parampathinfo(PlannerInfo *root, RelOptInfo *baserel, Relids required_outer)
RelOptInfo * build_simple_grouped_rel(PlannerInfo *root, RelOptInfo *rel)
RelOptInfo * fetch_upper_rel(PlannerInfo *root, UpperRelationKind kind, 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)
static void build_child_join_reltarget(PlannerInfo *root, RelOptInfo *parentrel, RelOptInfo *childrel, int nappinfos, AppendRelInfo **appinfos)
RelOptInfo * build_simple_rel(PlannerInfo *root, int relid, RelOptInfo *parent)
build_simple_rel_hook_type build_simple_rel_hook
static List * build_joinrel_restrictlist(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *outer_rel, RelOptInfo *inner_rel, SpecialJoinInfo *sjinfo)
RelAggInfo * create_rel_agg_info(PlannerInfo *root, RelOptInfo *rel, bool calculate_grouped_rows)
static int match_expr_to_partition_keys(Expr *expr, RelOptInfo *rel, bool strict_op)
ParamPathInfo * find_param_path_info(RelOptInfo *rel, Relids required_outer)
static void set_foreign_rel_properties(RelOptInfo *joinrel, RelOptInfo *outer_rel, RelOptInfo *inner_rel)
static void build_joinrel_joinlist(RelOptInfo *joinrel, RelOptInfo *outer_rel, RelOptInfo *inner_rel)
static Index get_expression_sortgroupref(PlannerInfo *root, Expr *expr)
Bitmapset * get_param_path_clause_serials(Path *path)
static void add_join_rel(PlannerInfo *root, RelOptInfo *joinrel)
RelOptInfo * find_base_rel_ignore_join(PlannerInfo *root, int relid)
static List * subbuild_joinrel_joinlist(RelOptInfo *joinrel, List *joininfo_list, List *new_joininfo)
static List * subbuild_joinrel_restrictlist(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *input_rel, Relids both_input_relids, List *new_restrictlist)
static bool is_var_in_aggref_only(PlannerInfo *root, Var *var)
static bool is_var_needed_by_join(PlannerInfo *root, Var *var, RelOptInfo *rel)
bool join_clause_is_movable_into(RestrictInfo *rinfo, Relids currentrelids, Relids current_and_outer)
Node * remove_nulling_relids(Node *node, const Bitmapset *removable_relids, const Bitmapset *except_relids)
double estimate_num_groups(PlannerInfo *root, List *groupExprs, double input_rows, List **pgset, EstimationInfo *estinfo)
Size add_size(Size s1, Size s2)
#define HTEqualStrategyNumber
struct PathTarget * agg_input
struct PathTarget * target
bool consider_param_startup
Bitmapset * notnullattnums
struct PathTarget * reltarget
struct RelAggInfo * agg_info
List * cheapest_parameterized_paths
Relids lateral_referencers
struct Path * cheapest_startup_path
QualCost baserestrictcost
struct Path * cheapest_total_path
List * unique_groupclause
struct RelOptInfo * grouped_rel
List * non_unique_for_rels
Bitmapset * eclass_indexes
Relids direct_lateral_relids
bool consider_partitionwise_join
Index baserestrict_min_security
struct RelOptInfo * unique_rel
Relids incompatible_relids
SortGroupClause * get_sortgroupref_clause(Index sortref, List *clauses)
PathTarget * create_empty_pathtarget(void)
void add_new_column_to_pathtarget(PathTarget *target, Expr *expr)
void add_column_to_pathtarget(PathTarget *target, Expr *expr, Index sortgroupref)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
#define TYPECACHE_BTREE_OPFAMILY
List * pull_var_clause(Node *node, int flags)