99 List **group_clauses,
List **group_exprs);
119 root->simple_rel_array_size = size;
132 foreach(
lc,
root->parse->rtable)
136 root->simple_rte_array[rti++] =
rte;
140 if (
root->append_rel_list ==
NIL)
155 foreach(
lc,
root->append_rel_list)
158 int child_relid =
appinfo->child_relid;
161 Assert(child_relid < size);
163 if (
root->append_rel_array[child_relid])
164 elog(
ERROR,
"child relation already exists");
188 root->simple_rel_array =
191 root->simple_rte_array =
194 if (
root->append_rel_array)
195 root->append_rel_array =
198 root->append_rel_array =
216 if (
root->simple_rel_array[relid] !=
NULL)
217 elog(
ERROR,
"rel %d already exists", relid);
220 rte =
root->simple_rte_array[relid];
285 rel->fdwroutine =
NULL;
286 rel->fdw_private =
NULL;
301 rel->part_scheme =
NULL;
303 rel->boundinfo =
NULL;
306 rel->part_rels =
NULL;
309 rel->partexprs =
NULL;
310 rel->nullable_partexprs =
NULL;
318 rel->parent = parent;
319 rel->top_parent = parent->top_parent ? parent->top_parent : parent;
349 rel->top_parent =
NULL;
358 switch (
rte->rtekind)
379 rel->attr_needed = (
Relids *)
381 rel->attr_widths = (
int32 *)
388 rel->attr_needed =
NULL;
389 rel->attr_widths =
NULL;
402 root->simple_rel_array[relid] = rel;
458 if (agg_info ==
NULL)
508 grouped_rel->part_scheme =
NULL;
510 grouped_rel->boundinfo =
NULL;
513 grouped_rel->part_rels =
NULL;
516 grouped_rel->partexprs =
NULL;
517 grouped_rel->nullable_partexprs =
NULL;
523 grouped_rel->
rows = 0;
540 rel =
root->simple_rel_array[relid];
545 elog(
ERROR,
"no relation entry for relid %d", relid);
559 return root->simple_rel_array[relid];
581 rel =
root->simple_rel_array[relid];
590 rte =
root->simple_rte_array[relid];
595 elog(
ERROR,
"no relation entry for relid %d", relid);
623 foreach(l,
root->join_rel_list)
637 root->join_rel_hash = hashtab;
663 if (
root->join_rel_hash)
679 foreach(l,
root->join_rel_list)
719 joinrel->fdwroutine =
outer_rel->fdwroutine;
727 joinrel->fdwroutine =
outer_rel->fdwroutine;
735 joinrel->fdwroutine =
outer_rel->fdwroutine;
752 if (
root->join_rel_hash)
762 hentry->join_rel = joinrel;
847 joinrel->attr_needed =
NULL;
848 joinrel->attr_widths =
NULL;
866 joinrel->fdwroutine =
NULL;
867 joinrel->fdw_private =
NULL;
882 joinrel->parent =
NULL;
883 joinrel->top_parent =
NULL;
885 joinrel->part_scheme =
NULL;
887 joinrel->boundinfo =
NULL;
890 joinrel->part_rels =
NULL;
893 joinrel->partexprs =
NULL;
894 joinrel->nullable_partexprs =
NULL;
946 sjinfo, restrictlist);
989 if (
root->join_rel_level)
993 root->join_rel_level[
root->join_cur_level] =
1030 nappinfos, appinfos);
1050 joinrel->attr_needed =
NULL;
1051 joinrel->attr_widths =
NULL;
1067 joinrel->fdwroutine =
NULL;
1068 joinrel->fdw_private =
NULL;
1083 joinrel->part_scheme =
NULL;
1085 joinrel->boundinfo =
NULL;
1088 joinrel->part_rels =
NULL;
1091 joinrel->partexprs =
NULL;
1092 joinrel->nullable_partexprs =
NULL;
1099 nappinfos, appinfos);
1125 sjinfo, restrictlist);
1155 nappinfos, appinfos,
1299 phv->phnullingrels =
1319 elog(
ERROR,
"unexpected node type in rel targetlist: %d",
1374 var->varnullingrels =
1619 foreach(
lc,
root->upper_rels[kind])
1633 upperrel->consider_startup = (
root->tuple_fraction > 0);
1634 upperrel->consider_param_startup =
false;
1635 upperrel->consider_parallel =
false;
1743#ifdef USE_ASSERT_CHECKING
1770 ppi->ppi_rows = rows;
1895 Assert(rinfo->left_ec == rinfo->right_ec);
1985 ppi->ppi_rows = rows;
2060 if (path->param_info ==
NULL)
2128 return path->param_info->ppi_serials;
2165 !
outer_rel->consider_partitionwise_join ||
2166 !
inner_rel->consider_partitionwise_join ||
2181 Assert(!joinrel->part_scheme && !joinrel->partexprs &&
2182 !joinrel->nullable_partexprs && !joinrel->part_rels &&
2183 !joinrel->boundinfo);
2234 foreach(
lc, restrictlist)
2250 if (!rinfo->can_join)
2254 if (!rinfo->mergeopfamilies && !
OidIsValid(rinfo->hashjoinoperator))
2292 root->outer_join_rels,
2296 root->outer_join_rels,
2323 if (
rel1->part_scheme->partcollation[
ipk1] != opexpr->inputcollid)
2420 rel2->part_scheme->partcollation[
ipk];
2464 Assert(rel->part_scheme);
2466 Assert(rel->nullable_partexprs);
2472 for (cnt = 0; cnt < rel->part_scheme->partnatts; cnt++)
2477 foreach(
lc, rel->partexprs[cnt])
2493 foreach(
lc, rel->nullable_partexprs[cnt])
2524 for (
int cnt = 0; cnt < partnatts; cnt++)
2638 elog(
ERROR,
"unrecognized join type: %d", (
int) jointype);
2641 joinrel->partexprs[cnt] =
partexpr;
2661 nappinfos, appinfos);
2708 if (grouped_rel ==
NULL)
2753 &group_clauses, &group_exprs))
2760 if (group_clauses ==
NIL)
2764 foreach(
lc,
root->agg_clause_list)
2856 foreach(
lc,
root->agg_clause_list)
2892 List **group_clauses,
List **group_exprs)
2900 foreach(
lc,
root->processed_tlist)
2932 if (sortgroupref > 0)
2958 *group_clauses =
lappend(*group_clauses,
sgc);
2959 *group_exprs =
lappend(*group_exprs, expr);
2993 tce->btree_opintype,
2994 tce->btree_opintype,
3019 *group_clauses =
lappend(*group_clauses,
sgc);
3020 *group_exprs =
lappend(*group_exprs, expr);
3058 target->
exprs, &deps))
3101 foreach(
lc,
root->agg_clause_list)
3167 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)
#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)
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)