PostgreSQL Source Code
git master
|
Go to the source code of this file.
Macros | |
#define | DEFAULT_CURSOR_TUPLE_FRACTION 0.1 |
Typedefs | |
typedef void(* | query_pathkeys_callback) (PlannerInfo *root, void *extra) |
Enumerations | |
enum | ForceParallelMode { FORCE_PARALLEL_OFF, FORCE_PARALLEL_ON, FORCE_PARALLEL_REGRESS } |
Variables | |
double | cursor_tuple_fraction |
int | force_parallel_mode |
bool | parallel_leader_participation |
int | from_collapse_limit |
int | join_collapse_limit |
#define DEFAULT_CURSOR_TUPLE_FRACTION 0.1 |
Definition at line 29 of file planmain.h.
typedef void(* query_pathkeys_callback) (PlannerInfo *root, void *extra) |
Definition at line 35 of file planmain.h.
enum ForceParallelMode |
Enumerator | |
---|---|
FORCE_PARALLEL_OFF | |
FORCE_PARALLEL_ON | |
FORCE_PARALLEL_REGRESS |
Definition at line 21 of file planmain.h.
void add_base_rels_to_query | ( | PlannerInfo * | root, |
Node * | jtnode | ||
) |
Definition at line 105 of file initsplan.c.
References add_base_rels_to_query(), build_simple_rel(), elog, ERROR, FromExpr::fromlist, IsA, JoinExpr::larg, lfirst, nodeTag, and JoinExpr::rarg.
Referenced by add_base_rels_to_query(), and query_planner().
void add_vars_to_targetlist | ( | PlannerInfo * | root, |
List * | vars, | ||
Relids | where_needed, | ||
bool | create_new_ph | ||
) |
Definition at line 198 of file initsplan.c.
References Assert, RelOptInfo::attr_needed, bms_add_members(), bms_is_empty(), bms_is_subset(), copyObject, elog, ERROR, PathTarget::exprs, find_base_rel(), find_placeholder_info(), IsA, lappend(), lfirst, RelOptInfo::min_attr, nodeTag, PlaceHolderInfo::ph_needed, RelOptInfo::relids, RelOptInfo::reltarget, Var::varattno, and Var::varno.
Referenced by build_base_rel_tlists(), distribute_qual_to_rels(), extract_lateral_references(), fix_placeholder_input_needed_levels(), and generate_base_implied_equalities_no_const().
void build_base_rel_tlists | ( | PlannerInfo * | root, |
List * | final_tlist | ||
) |
Definition at line 151 of file initsplan.c.
References add_vars_to_targetlist(), bms_make_singleton(), Query::havingQual, list_free(), NIL, PlannerInfo::parse, pull_var_clause(), PVC_INCLUDE_PLACEHOLDERS, PVC_RECURSE_AGGREGATES, and PVC_RECURSE_WINDOWFUNCS.
Referenced by query_planner().
RestrictInfo* build_implied_join_equality | ( | Oid | opno, |
Oid | collation, | ||
Expr * | item1, | ||
Expr * | item2, | ||
Relids | qualscope, | ||
Relids | nullable_relids, | ||
Index | security_level | ||
) |
Definition at line 2381 of file initsplan.c.
References check_hashjoinable(), check_mergejoinable(), copyObject, InvalidOid, make_opclause(), and make_restrictinfo().
Referenced by create_join_clause(), reconsider_full_join_clause(), and reconsider_outer_join_clause().
void create_lateral_join_info | ( | PlannerInfo * | root | ) |
Definition at line 418 of file initsplan.c.
References PlannerInfo::append_rel_list, Assert, bms_add_member(), bms_add_members(), bms_copy(), bms_get_singleton_member(), bms_is_empty(), bms_is_member(), bms_next_member(), AppendRelInfo::child_relid, RelOptInfo::direct_lateral_relids, find_base_rel(), find_placeholder_info(), PlannerInfo::hasLateralRTEs, RangeTblEntry::inh, IS_SIMPLE_REL, IsA, RelOptInfo::lateral_referencers, RelOptInfo::lateral_relids, RelOptInfo::lateral_vars, lfirst, AppendRelInfo::parent_relid, PlaceHolderInfo::ph_eval_at, PlaceHolderInfo::ph_lateral, PlannerInfo::placeholder_list, RelOptInfo::relid, RangeTblEntry::relkind, RELOPT_BASEREL, RELOPT_OTHER_MEMBER_REL, RelOptInfo::reloptkind, RTE_RELATION, RangeTblEntry::rtekind, PlannerInfo::simple_rel_array, PlannerInfo::simple_rel_array_size, PlannerInfo::simple_rte_array, and Var::varno.
Referenced by query_planner().
Plan* create_plan | ( | PlannerInfo * | root, |
Path * | best_path | ||
) |
Definition at line 315 of file createplan.c.
References apply_tlist_labeling(), Assert, CP_EXACT_TLIST, create_plan_recurse(), PlannerInfo::curOuterParams, PlannerInfo::curOuterRels, elog, ERROR, IsA, NIL, PlannerInfo::plan_params, PlannerInfo::processed_tlist, SS_attach_initplans(), and Plan::targetlist.
Referenced by create_minmaxagg_plan(), create_subqueryscan_plan(), make_subplan(), SS_process_ctes(), and standard_planner().
List* deconstruct_jointree | ( | PlannerInfo * | root | ) |
Definition at line 713 of file initsplan.c.
References Assert, deconstruct_recurse(), IsA, Query::jointree, NIL, PlannerInfo::nullable_baserels, and PlannerInfo::parse.
Referenced by query_planner().
void distribute_restrictinfo_to_rels | ( | PlannerInfo * | root, |
RestrictInfo * | restrictinfo | ||
) |
Definition at line 2232 of file initsplan.c.
References add_join_clause_to_rels(), RelOptInfo::baserestrict_min_security, RelOptInfo::baserestrictinfo, bms_membership(), BMS_MULTIPLE, BMS_SINGLETON, bms_singleton_member(), check_hashjoinable(), elog, ERROR, find_base_rel(), lappend(), Min, PostponedQual::relids, RestrictInfo::required_relids, and RestrictInfo::security_level.
Referenced by distribute_qual_to_rels(), generate_base_implied_equalities_broken(), generate_base_implied_equalities_const(), reconsider_outer_join_clauses(), and remove_rel_from_query().
void extract_query_dependencies | ( | Node * | query, |
List ** | relationOids, | ||
List ** | invalItems, | ||
bool * | hasRowSecurity | ||
) |
Definition at line 2596 of file setrefs.c.
References PlannerGlobal::dependsOnRole, extract_query_dependencies_walker(), PlannerInfo::glob, PlannerGlobal::invalItems, MemSet, NIL, PlannerGlobal::relationOids, T_PlannerGlobal, T_PlannerInfo, PlannerGlobal::type, and PlannerInfo::type.
Referenced by CompleteCachedPlan(), and RevalidateCachedQuery().
void find_lateral_references | ( | PlannerInfo * | root | ) |
Definition at line 272 of file initsplan.c.
References Assert, extract_lateral_references(), PlannerInfo::hasLateralRTEs, RelOptInfo::relid, RELOPT_BASEREL, RelOptInfo::reloptkind, PlannerInfo::simple_rel_array, and PlannerInfo::simple_rel_array_size.
Referenced by query_planner().
bool innerrel_is_unique | ( | PlannerInfo * | root, |
Relids | joinrelids, | ||
Relids | outerrelids, | ||
RelOptInfo * | innerrel, | ||
JoinType | jointype, | ||
List * | restrictlist, | ||
bool | force_cache | ||
) |
Definition at line 971 of file analyzejoins.c.
References bms_copy(), bms_is_subset(), is_innerrel_unique_for(), PlannerInfo::join_search_private, lappend(), lfirst, MemoryContextSwitchTo(), NIL, RelOptInfo::non_unique_for_rels, PlannerInfo::planner_cxt, rel_supports_distinctness(), and RelOptInfo::unique_for_rels.
Referenced by add_paths_to_joinrel(), and reduce_unique_semijoins().
Definition at line 6700 of file createplan.c.
References IS_DUMMY_PATH, Path::pathtype, T_Append, T_Hash, T_Limit, T_LockRows, T_Material, T_MergeAppend, T_ModifyTable, T_ProjectSet, T_RecursiveUnion, T_SetOp, T_Sort, and T_Unique.
Referenced by apply_projection_to_path(), create_projection_path(), and create_projection_plan().
Definition at line 6745 of file createplan.c.
References nodeTag, T_Append, T_Hash, T_Limit, T_LockRows, T_Material, T_MergeAppend, T_ModifyTable, T_ProjectSet, T_RecursiveUnion, T_SetOp, T_Sort, and T_Unique.
Referenced by create_unique_plan(), and prepare_sort_from_pathkeys().
Agg* make_agg | ( | List * | tlist, |
List * | qual, | ||
AggStrategy | aggstrategy, | ||
AggSplit | aggsplit, | ||
int | numGroupCols, | ||
AttrNumber * | grpColIdx, | ||
Oid * | grpOperators, | ||
List * | groupingSets, | ||
List * | chain, | ||
double | dNumGroups, | ||
Plan * | lefttree | ||
) |
Definition at line 6150 of file createplan.c.
References Agg::aggParams, Agg::aggsplit, Agg::aggstrategy, Agg::chain, Agg::groupingSets, Agg::grpColIdx, Agg::grpOperators, Plan::lefttree, makeNode, Min, Agg::numCols, Agg::numGroups, Agg::plan, Plan::qual, Plan::righttree, and Plan::targetlist.
Referenced by create_agg_plan(), create_groupingsets_plan(), and create_unique_plan().
ForeignScan* make_foreignscan | ( | List * | qptlist, |
List * | qpqual, | ||
Index | scanrelid, | ||
List * | fdw_exprs, | ||
List * | fdw_private, | ||
List * | fdw_scan_tlist, | ||
List * | fdw_recheck_quals, | ||
Plan * | outer_plan | ||
) |
Definition at line 5383 of file createplan.c.
References CMD_SELECT, ForeignScan::fdw_exprs, ForeignScan::fdw_private, ForeignScan::fdw_recheck_quals, ForeignScan::fdw_scan_tlist, ForeignScan::fs_relids, ForeignScan::fs_server, ForeignScan::fsSystemCol, InvalidOid, Plan::lefttree, makeNode, ForeignScan::operation, Scan::plan, Plan::qual, Plan::righttree, ForeignScan::scan, Scan::scanrelid, and Plan::targetlist.
Referenced by fileGetForeignPlan(), and postgresGetForeignPlan().
Definition at line 6496 of file createplan.c.
References Plan::lefttree, Limit::limitCount, Limit::limitOffset, makeNode, NIL, Limit::plan, Plan::qual, Plan::righttree, and Plan::targetlist.
Referenced by create_limit_plan(), and create_minmaxagg_plan().
Definition at line 6004 of file createplan.c.
References TargetEntry::expr, exprCollation(), get_sortgroupclause_tle(), lfirst, list_length(), make_sort(), SortGroupClause::nulls_first, palloc(), TargetEntry::resno, SortGroupClause::sortop, and Plan::targetlist.
Referenced by create_unique_plan().
void match_foreign_keys_to_quals | ( | PlannerInfo * | root | ) |
Definition at line 2439 of file initsplan.c.
References OpExpr::args, RestrictInfo::clause, ForeignKeyOptInfo::con_relid, ForeignKeyOptInfo::confkey, ForeignKeyOptInfo::conkey, ForeignKeyOptInfo::conpfeqop, ForeignKeyOptInfo::eclass, PlannerInfo::fkey_list, get_commutator(), get_leftop(), get_rightop(), InvalidOid, IsA, RelOptInfo::joininfo, lappend(), lfirst, list_length(), match_eclasses_to_foreign_key_col(), NIL, ForeignKeyOptInfo::nkeys, ForeignKeyOptInfo::nmatched_ec, ForeignKeyOptInfo::nmatched_rcols, ForeignKeyOptInfo::nmatched_ri, OidIsValid, OpExpr::opno, RestrictInfo::outerjoin_delayed, ForeignKeyOptInfo::ref_relid, RELOPT_BASEREL, RelOptInfo::reloptkind, ForeignKeyOptInfo::rinfos, PlannerInfo::simple_rel_array, and PlannerInfo::simple_rel_array_size.
Referenced by query_planner().
Definition at line 6116 of file createplan.c.
References cost_material(), Plan::initPlan, make_material(), NIL, Plan::parallel_aware, Plan::parallel_safe, Plan::plan_rows, Plan::plan_width, Plan::startup_cost, Path::startup_cost, Plan::total_cost, and Path::total_cost.
Referenced by build_subplan(), and standard_planner().
void preprocess_minmax_aggregates | ( | PlannerInfo * | root, |
List * | tlist | ||
) |
Definition at line 75 of file planagg.c.
References add_path(), MinMaxAggInfo::aggsortop, Assert, build_minmax_path(), create_minmaxagg_path(), create_pathtarget, Query::cteList, elog, ERROR, exprCollation(), exprType(), fetch_upper_rel(), find_minmax_aggs_walker(), FromExpr::fromlist, get_equality_op_for_ordering_op(), Query::groupClause, Query::groupingSets, Query::hasAggs, Query::hasWindowFuncs, Query::havingQual, RangeTblEntry::inh, IsA, Query::jointree, lfirst, linitial, list_length(), PlannerInfo::minmax_aggs, NIL, OidIsValid, MinMaxAggInfo::param, parse(), PlannerInfo::parse, planner_rt_fetch, Query::rowMarks, RTE_RELATION, RTE_SUBQUERY, RangeTblEntry::rtekind, RangeTblRef::rtindex, Query::setOperations, SS_make_initplan_output_param(), MinMaxAggInfo::target, and UPPERREL_GROUP_AGG.
Referenced by grouping_planner().
void process_implied_equality | ( | PlannerInfo * | root, |
Oid | opno, | ||
Oid | collation, | ||
Expr * | item1, | ||
Expr * | item2, | ||
Relids | qualscope, | ||
Relids | nullable_relids, | ||
Index | security_level, | ||
bool | below_outer_join, | ||
bool | both_const | ||
) |
Definition at line 2316 of file initsplan.c.
References Assert, Const::constisnull, Const::consttype, Const::constvalue, copyObject, DatumGetBool, distribute_qual_to_rels(), eval_const_expressions(), InvalidOid, IsA, JOIN_INNER, and make_opclause().
Referenced by generate_base_implied_equalities_const(), and generate_base_implied_equalities_no_const().
Definition at line 782 of file analyzejoins.c.
References SetOperationStmt::all, Assert, castNode, distinct_col_search(), Query::distinctClause, SortGroupClause::eqop, equality_ops_are_compatible(), get_sortgroupclause_tle(), Query::groupClause, SetOperationStmt::groupClauses, GROUPING_SET_EMPTY, Query::groupingSets, Query::hasAggs, Query::hasTargetSRFs, Query::havingQual, lfirst, linitial, list_head(), list_length(), lnext, OidIsValid, SetOperationStmt::op, TargetEntry::resjunk, TargetEntry::resno, SETOP_NONE, Query::setOperations, and Query::targetList.
Referenced by create_unique_path(), and rel_is_distinct_for().
RelOptInfo* query_planner | ( | PlannerInfo * | root, |
List * | tlist, | ||
query_pathkeys_callback | qp_callback, | ||
void * | qp_extra | ||
) |
Definition at line 54 of file planmain.c.
References add_base_rels_to_query(), add_path(), add_placeholders_to_base_rels(), Assert, build_base_rel_tlists(), build_empty_join_rel(), PlannerInfo::canon_pathkeys, RelOptInfo::cheapest_total_path, RelOptInfo::consider_parallel, create_lateral_join_info(), create_result_path(), deconstruct_jointree(), elog, ERROR, extract_restriction_or_clauses(), find_lateral_references(), find_placeholders_in_jointree(), fix_placeholder_input_needed_levels(), PlannerInfo::fkey_list, FromExpr::fromlist, PlannerInfo::full_join_clauses, generate_base_implied_equalities(), PlannerInfo::glob, PlannerInfo::initial_rels, is_parallel_safe(), IS_SIMPLE_REL, PlannerInfo::join_cur_level, PlannerInfo::join_info_list, PlannerInfo::join_rel_hash, PlannerInfo::join_rel_level, PlannerInfo::join_rel_list, Query::jointree, PlannerInfo::left_join_clauses, make_one_rel(), match_foreign_keys_to_quals(), NIL, RelOptInfo::pages, PlannerGlobal::parallelModeOK, Path::param_info, parse(), PlannerInfo::parse, PlannerInfo::placeholder_list, FromExpr::quals, reconsider_outer_join_clauses(), reduce_unique_semijoins(), RelOptInfo::relid, RelOptInfo::reltarget, remove_useless_joins(), PlannerInfo::right_join_clauses, set_cheapest(), and setup_simple_rel_arrays().
Referenced by build_minmax_path(), and grouping_planner().
Definition at line 745 of file analyzejoins.c.
References Query::distinctClause, Query::groupClause, Query::groupingSets, Query::hasAggs, Query::hasTargetSRFs, Query::havingQual, NIL, and Query::setOperations.
Referenced by create_unique_path(), and rel_supports_distinctness().
void record_plan_function_dependency | ( | PlannerInfo * | root, |
Oid | funcid | ||
) |
Definition at line 2558 of file setrefs.c.
References PlanInvalItem::cacheId, FirstBootstrapObjectId, GetSysCacheHashValue1, PlannerInfo::glob, PlanInvalItem::hashValue, PlannerGlobal::invalItems, lappend(), makeNode, ObjectIdGetDatum, and PROCOID.
Referenced by fix_expr_common(), inline_function(), and inline_set_returning_function().
void reduce_unique_semijoins | ( | PlannerInfo * | root | ) |
Definition at line 511 of file analyzejoins.c.
References bms_get_singleton_member(), bms_union(), SpecialJoinInfo::delay_upper_joins, find_base_rel(), generate_join_implied_equalities(), innerrel_is_unique(), PlannerInfo::join_info_list, JOIN_SEMI, RelOptInfo::joininfo, SpecialJoinInfo::jointype, lfirst, list_concat(), list_delete_ptr(), list_head(), lnext, SpecialJoinInfo::min_lefthand, SpecialJoinInfo::min_righthand, next, and rel_supports_distinctness().
Referenced by query_planner().
List* remove_useless_joins | ( | PlannerInfo * | root, |
List * | joinlist | ||
) |
Definition at line 61 of file analyzejoins.c.
References bms_singleton_member(), bms_union(), elog, ERROR, PlannerInfo::join_info_list, join_is_removable(), lfirst, list_delete_ptr(), SpecialJoinInfo::min_lefthand, SpecialJoinInfo::min_righthand, remove_rel_from_joinlist(), and remove_rel_from_query().
Referenced by query_planner().
Plan* set_plan_references | ( | PlannerInfo * | root, |
Plan * | plan | ||
) |
Definition at line 214 of file setrefs.c.
References add_rtes_to_flat_rtable(), PlannerGlobal::finalrowmarks, PlannerGlobal::finalrtable, PlannerInfo::glob, lappend(), lfirst_node, list_length(), palloc(), PlanRowMark::prti, PlannerInfo::rowMarks, PlanRowMark::rti, and set_plan_refs().
Referenced by set_subqueryscan_references(), and standard_planner().
double cursor_tuple_fraction |
Definition at line 63 of file planner.c.
Referenced by standard_planner().
int force_parallel_mode |
Definition at line 64 of file planner.c.
Referenced by HandleParallelMessage(), and standard_planner().
int from_collapse_limit |
Definition at line 37 of file initsplan.c.
Referenced by deconstruct_recurse().
int join_collapse_limit |
Definition at line 38 of file initsplan.c.
Referenced by deconstruct_recurse().
bool parallel_leader_participation |
Definition at line 65 of file planner.c.
Referenced by ExecGather(), ExecGatherMerge(), ExecInitGather(), and get_parallel_divisor().