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) |
Variables | |
PGDLLIMPORT double | cursor_tuple_fraction |
PGDLLIMPORT int | from_collapse_limit |
PGDLLIMPORT int | join_collapse_limit |
#define DEFAULT_CURSOR_TUPLE_FRACTION 0.1 |
Definition at line 21 of file planmain.h.
typedef void(* query_pathkeys_callback) (PlannerInfo *root, void *extra) |
Definition at line 25 of file planmain.h.
void add_base_rels_to_query | ( | PlannerInfo * | root, |
Node * | jtnode | ||
) |
Definition at line 158 of file initsplan.c.
References build_simple_rel(), elog(), ERROR, FromExpr::fromlist, IsA, j, JoinTreeItem::jtnode, lfirst, and nodeTag.
Referenced by query_planner().
void add_other_rels_to_query | ( | PlannerInfo * | root | ) |
Definition at line 196 of file initsplan.c.
References expand_inherited_rtentry(), RangeTblEntry::inh, RELOPT_BASEREL, RelOptInfo::reloptkind, and PlannerInfo::simple_rel_array_size.
Referenced by query_planner().
void add_vars_to_targetlist | ( | PlannerInfo * | root, |
List * | vars, | ||
Relids | where_needed | ||
) |
Definition at line 280 of file initsplan.c.
References Assert(), 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(), expand_inherited_rtentry(), extract_lateral_references(), fix_placeholder_input_needed_levels(), generate_base_implied_equalities_no_const(), and process_implied_equality().
void build_base_rel_tlists | ( | PlannerInfo * | root, |
List * | final_tlist | ||
) |
Definition at line 235 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 distribute_row_identity_vars(), and query_planner().
RestrictInfo* build_implied_join_equality | ( | PlannerInfo * | root, |
Oid | opno, | ||
Oid | collation, | ||
Expr * | item1, | ||
Expr * | item2, | ||
Relids | qualscope, | ||
Index | security_level | ||
) |
Definition at line 2851 of file initsplan.c.
References check_hashjoinable(), check_memoizable(), check_mergejoinable(), copyObject, InvalidOid, make_opclause(), make_restrictinfo(), and JoinTreeItem::qualscope.
Referenced by create_join_clause(), reconsider_full_join_clause(), and reconsider_outer_join_clause().
Definition at line 2131 of file createplan.c.
References inject_projection_plan(), is_projection_capable_plan(), Plan::parallel_safe, Plan::targetlist, and tlist_same_exprs().
Referenced by create_unique_plan(), and postgresGetForeignPlan().
void create_lateral_join_info | ( | PlannerInfo * | root | ) |
Definition at line 502 of file initsplan.c.
References Assert(), bms_add_member(), bms_add_members(), bms_copy(), bms_get_singleton_member(), bms_is_empty, bms_is_member(), bms_next_member(), RelOptInfo::direct_lateral_relids, find_base_rel(), find_base_rel_ignore_join(), find_placeholder_info(), PlannerInfo::hasLateralRTEs, IsA, RelOptInfo::lateral_referencers, RelOptInfo::lateral_relids, RelOptInfo::lateral_vars, lfirst, PlaceHolderInfo::ph_eval_at, PlaceHolderInfo::ph_lateral, PlannerInfo::placeholder_list, PlannerInfo::placeholdersFrozen, RelOptInfo::relid, RELOPT_BASEREL, RelOptInfo::reloptkind, PlannerInfo::simple_rel_array_size, and Var::varno.
Referenced by query_planner().
Plan* create_plan | ( | PlannerInfo * | root, |
Path * | best_path | ||
) |
Definition at line 335 of file createplan.c.
References apply_tlist_labeling(), Assert(), CP_EXACT_TLIST, create_plan_recurse(), PlannerInfo::curOuterParams, PlannerInfo::curOuterRels, elog(), ERROR, IsA, NIL, plan, PlannerInfo::plan_params, PlannerInfo::processed_tlist, and SS_attach_initplans().
Referenced by create_minmaxagg_plan(), create_subqueryscan_plan(), make_subplan(), SS_process_ctes(), and standard_planner().
List* deconstruct_jointree | ( | PlannerInfo * | root | ) |
Definition at line 731 of file initsplan.c.
References PlannerInfo::all_baserels, PlannerInfo::all_query_rels, Assert(), bms_equal(), bms_union(), deconstruct_distribute(), deconstruct_distribute_oj_quals(), deconstruct_recurse(), IsA, JoinDomain::jd_relids, PlannerInfo::join_domains, PlannerInfo::join_info_list, Query::jointree, lfirst, linitial_node, list_free_deep(), NIL, JoinTreeItem::oj_joinclauses, PlannerInfo::outer_join_rels, PlannerInfo::parse, and PlannerInfo::placeholdersFrozen.
Referenced by query_planner().
void distribute_restrictinfo_to_rels | ( | PlannerInfo * | root, |
RestrictInfo * | restrictinfo | ||
) |
Definition at line 2621 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(), check_memoizable(), elog(), ERROR, find_base_rel(), lappend(), Min, RestrictInfo::required_relids, and RestrictInfo::security_level.
Referenced by distribute_qual_to_rels(), generate_base_implied_equalities_broken(), generate_base_implied_equalities_const(), process_implied_equality(), reconsider_outer_join_clauses(), and remove_rel_from_query().
bool extract_query_dependencies_walker | ( | Node * | node, |
PlannerInfo * | context | ||
) |
Definition at line 3525 of file setrefs.c.
References Assert(), CMD_UTILITY, Query::commandType, PlannerGlobal::dependsOnRole, expression_tree_walker, fix_expr_common(), PlannerInfo::glob, IsA, lappend_oid(), lfirst, OidIsValid, query_tree_walker, PlannerGlobal::relationOids, RangeTblEntry::relid, Query::rtable, RTE_NAMEDTUPLESTORE, RTE_RELATION, RTE_SUBQUERY, RangeTblEntry::rtekind, UtilityContainsQuery(), and Query::utilityStmt.
Referenced by expression_planner_with_deps(), and extract_query_dependencies().
void find_lateral_references | ( | PlannerInfo * | root | ) |
Definition at line 359 of file initsplan.c.
References Assert(), extract_lateral_references(), PlannerInfo::hasLateralRTEs, RelOptInfo::relid, RELOPT_BASEREL, RelOptInfo::reloptkind, 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 1104 of file analyzejoins.c.
References bms_copy(), bms_is_subset(), is_innerrel_unique_for(), lappend(), lfirst, MemoryContextSwitchTo(), NIL, RelOptInfo::non_unique_for_rels, rel_supports_distinctness(), and RelOptInfo::unique_for_rels.
Referenced by add_paths_to_joinrel(), and reduce_unique_semijoins().
Definition at line 7156 of file createplan.c.
References castNode, CUSTOMPATH_SUPPORT_PROJECTION, IS_DUMMY_APPEND, and Path::pathtype.
Referenced by add_paths_with_pathkeys_for_rel(), apply_projection_to_path(), create_projection_path(), and create_projection_plan().
Definition at line 7206 of file createplan.c.
References CUSTOMPATH_SUPPORT_PROJECTION, nodeTag, and plan.
Referenced by change_plan_targetlist(), create_projection_plan(), and prepare_sort_from_pathkeys().
Agg* make_agg | ( | List * | tlist, |
List * | qual, | ||
AggStrategy | aggstrategy, | ||
AggSplit | aggsplit, | ||
int | numGroupCols, | ||
AttrNumber * | grpColIdx, | ||
Oid * | grpOperators, | ||
Oid * | grpCollations, | ||
List * | groupingSets, | ||
List * | chain, | ||
double | dNumGroups, | ||
Size | transitionSpace, | ||
Plan * | lefttree | ||
) |
Definition at line 6544 of file createplan.c.
References Agg::aggParams, Agg::aggsplit, Agg::aggstrategy, Agg::chain, clamp_cardinality_to_long(), Agg::groupingSets, makeNode, Agg::numCols, Agg::numGroups, Agg::plan, plan, and Agg::transitionSpace.
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 5780 of file createplan.c.
References ForeignScan::checkAsUser, CMD_SELECT, ForeignScan::fdw_exprs, ForeignScan::fdw_private, ForeignScan::fdw_recheck_quals, ForeignScan::fdw_scan_tlist, ForeignScan::fs_base_relids, ForeignScan::fs_relids, ForeignScan::fs_server, ForeignScan::fsSystemCol, InvalidOid, makeNode, ForeignScan::operation, plan, ForeignScan::resultRelation, ForeignScan::scan, and Scan::scanrelid.
Referenced by fileGetForeignPlan(), and postgresGetForeignPlan().
Limit* make_limit | ( | Plan * | lefttree, |
Node * | limitOffset, | ||
Node * | limitCount, | ||
LimitOption | limitOption, | ||
int | uniqNumCols, | ||
AttrNumber * | uniqColIdx, | ||
Oid * | uniqOperators, | ||
Oid * | uniqCollations | ||
) |
Definition at line 6911 of file createplan.c.
References Limit::limitCount, Limit::limitOffset, Limit::limitOption, makeNode, NIL, Limit::plan, plan, Plan::targetlist, and Limit::uniqNumCols.
Referenced by create_limit_plan(), and create_minmaxagg_plan().
Definition at line 6373 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 2960 of file initsplan.c.
References OpExpr::args, RestrictInfo::clause, ForeignKeyOptInfo::con_relid, EquivalenceClass::ec_has_const, PlannerInfo::fkey_list, get_commutator(), get_leftop(), get_rightop(), if(), InvalidOid, IsA, RelOptInfo::joininfo, lappend(), lfirst, list_length(), match_eclasses_to_foreign_key_col(), ForeignKeyOptInfo::nconst_ec, NIL, ForeignKeyOptInfo::nkeys, ForeignKeyOptInfo::nmatched_ec, ForeignKeyOptInfo::nmatched_rcols, ForeignKeyOptInfo::nmatched_ri, OidIsValid, OpExpr::opno, ForeignKeyOptInfo::ref_relid, RELOPT_BASEREL, RelOptInfo::reloptkind, ForeignKeyOptInfo::rinfos, and PlannerInfo::simple_rel_array_size.
Referenced by query_planner().
Definition at line 6485 of file createplan.c.
References cost_material(), Plan::initPlan, make_material(), NIL, Plan::parallel_aware, Plan::parallel_safe, Plan::plan_rows, Plan::plan_width, Path::startup_cost, Plan::startup_cost, Path::total_cost, and Plan::total_cost.
Referenced by build_subplan(), and standard_planner().
void preprocess_minmax_aggregates | ( | PlannerInfo * | root | ) |
Definition at line 73 of file planagg.c.
References add_path(), MinMaxAggInfo::aggsortop, Assert(), build_minmax_path(), can_minmax_aggs(), create_minmaxagg_path(), create_pathtarget, elog(), ERROR, exprCollation(), exprType(), fetch_upper_rel(), FromExpr::fromlist, get_equality_op_for_ordering_op(), RangeTblEntry::inh, IsA, lfirst, linitial, list_length(), PlannerInfo::minmax_aggs, NIL, OidIsValid, MinMaxAggInfo::param, parse(), PlannerInfo::parse, planner_rt_fetch, PlannerInfo::processed_tlist, RTE_RELATION, RTE_SUBQUERY, RangeTblEntry::rtekind, RangeTblRef::rtindex, SS_make_initplan_output_param(), MinMaxAggInfo::target, and UPPERREL_GROUP_AGG.
Referenced by grouping_planner().
RestrictInfo* process_implied_equality | ( | PlannerInfo * | root, |
Oid | opno, | ||
Oid | collation, | ||
Expr * | item1, | ||
Expr * | item2, | ||
Relids | qualscope, | ||
Index | security_level, | ||
bool | both_const | ||
) |
Definition at line 2712 of file initsplan.c.
References add_vars_to_targetlist(), Assert(), bms_is_empty, bms_is_subset(), bms_membership(), BMS_MULTIPLE, check_mergejoinable(), Const::consttype, copyObject, DatumGetBool(), distribute_restrictinfo_to_rels(), eval_const_expressions(), get_join_domain_min_rels(), PlannerInfo::hasPseudoConstantQuals, InvalidOid, IsA, list_free(), make_opclause(), make_restrictinfo(), pull_var_clause(), pull_varnos(), PVC_INCLUDE_PLACEHOLDERS, PVC_RECURSE_AGGREGATES, PVC_RECURSE_WINDOWFUNCS, and JoinTreeItem::qualscope.
Referenced by generate_base_implied_equalities_const(), and generate_base_implied_equalities_no_const().
Definition at line 915 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, GROUPING_SET_EMPTY, Query::groupingSets, Query::havingQual, lfirst, linitial, list_head(), list_length(), lnext(), OidIsValid, SetOperationStmt::op, TargetEntry::resno, SETOP_NONE, Query::setOperations, and Query::targetList.
Referenced by create_unique_path(), and rel_is_distinct_for().
RelOptInfo* query_planner | ( | PlannerInfo * | root, |
query_pathkeys_callback | qp_callback, | ||
void * | qp_extra | ||
) |
Definition at line 55 of file planmain.c.
References add_base_rels_to_query(), add_other_rels_to_query(), add_path(), add_placeholders_to_base_rels(), Assert(), build_base_rel_tlists(), build_simple_rel(), PlannerInfo::canon_pathkeys, RelOptInfo::cheapest_total_path, RelOptInfo::consider_parallel, create_group_result_path(), create_lateral_join_info(), DEBUG_PARALLEL_OFF, debug_parallel_query, deconstruct_jointree(), distribute_row_identity_vars(), PlannerInfo::ec_merging_done, elog(), ERROR, extract_restriction_or_clauses(), find_lateral_references(), find_placeholders_in_jointree(), fix_placeholder_input_needed_levels(), PlannerInfo::fkey_list, PlannerInfo::full_join_clauses, generate_base_implied_equalities(), PlannerInfo::glob, is_parallel_safe(), IsA, PlannerInfo::join_cur_level, PlannerInfo::join_info_list, PlannerInfo::join_rel_list, PlannerInfo::left_join_clauses, linitial, list_length(), make_one_rel(), match_foreign_keys_to_quals(), NIL, PlannerGlobal::parallelModeOK, parse(), PlannerInfo::parse, PlannerInfo::placeholder_list, PlannerInfo::processed_tlist, reconsider_outer_join_clauses(), reduce_unique_semijoins(), RelOptInfo::reltarget, remove_useless_joins(), PlannerInfo::right_join_clauses, RTE_RESULT, RangeTblEntry::rtekind, set_cheapest(), and setup_simple_rel_arrays().
Referenced by build_minmax_path(), and grouping_planner().
Definition at line 878 of file analyzejoins.c.
References Query::distinctClause, Query::groupClause, Query::groupingSets, 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 3408 of file setrefs.c.
References PlanInvalItem::cacheId, FirstUnpinnedObjectId, 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 record_plan_type_dependency | ( | PlannerInfo * | root, |
Oid | typid | ||
) |
Definition at line 3448 of file setrefs.c.
References PlanInvalItem::cacheId, FirstUnpinnedObjectId, GetSysCacheHashValue1, PlannerInfo::glob, PlanInvalItem::hashValue, PlannerGlobal::invalItems, lappend(), makeNode, ObjectIdGetDatum(), and TYPEOID.
Referenced by eval_const_expressions_mutator().
void reduce_unique_semijoins | ( | PlannerInfo * | root | ) |
Definition at line 649 of file analyzejoins.c.
References Assert(), bms_get_singleton_member(), bms_union(), find_base_rel(), foreach_delete_current, generate_join_implied_equalities(), innerrel_is_unique(), PlannerInfo::join_info_list, JOIN_SEMI, RelOptInfo::joininfo, SpecialJoinInfo::jointype, lfirst, list_concat(), SpecialJoinInfo::min_lefthand, SpecialJoinInfo::min_righthand, SpecialJoinInfo::ojrelid, and rel_supports_distinctness().
Referenced by query_planner().
List* remove_useless_joins | ( | PlannerInfo * | root, |
List * | joinlist | ||
) |
Definition at line 64 of file analyzejoins.c.
References bms_singleton_member(), elog(), ERROR, PlannerInfo::join_info_list, join_is_removable(), lfirst, list_delete_cell(), 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 287 of file setrefs.c.
References add_rtes_to_flat_rtable(), PlannerInfo::append_rel_list, PlannerGlobal::appendRelations, AppendRelInfo::child_relid, PlannerGlobal::finalrowmarks, PlannerGlobal::finalrtable, foreach_current_index, PlannerInfo::glob, PlannerInfo::hasAlternativeSubPlans, lappend(), lfirst, lfirst_node, list_length(), NIL, palloc(), palloc0(), AppendRelInfo::parent_relid, plan, PlanRowMark::prti, PlannerInfo::rowMarks, PlanRowMark::rti, set_plan_refs(), PlannerGlobal::subplans, and AppendRelInfo::translated_vars.
Referenced by set_subqueryscan_references(), and standard_planner().
bool trivial_subqueryscan | ( | SubqueryScan * | plan | ) |
Definition at line 1448 of file setrefs.c.
References Assert(), equal(), TargetEntry::expr, forboth, IsA, lfirst, list_length(), NIL, plan, SUBQUERY_SCAN_NONTRIVIAL, SUBQUERY_SCAN_TRIVIAL, SUBQUERY_SCAN_UNKNOWN, Var::varattno, Var::varlevelsup, and Var::varno.
Referenced by mark_async_capable_plan(), and set_subqueryscan_references().
|
extern |
Definition at line 72 of file planner.c.
Referenced by standard_planner().
|
extern |
Definition at line 39 of file initsplan.c.
Referenced by deconstruct_recurse().
|
extern |
Definition at line 40 of file initsplan.c.
Referenced by deconstruct_recurse().