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 add_base_rels_to_query(), build_simple_rel(), elog, ERROR, FromExpr::fromlist, IsA, j, JoinTreeItem::jtnode, lfirst, nodeTag, and root.
Referenced by add_base_rels_to_query(), and 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 root.
Referenced by query_planner().
void add_vars_to_attr_needed | ( | PlannerInfo * | root, |
List * | vars, | ||
Relids | where_needed | ||
) |
Definition at line 353 of file initsplan.c.
References Assert, bms_add_members(), bms_is_empty, bms_is_subset(), elog, ERROR, find_base_rel(), find_placeholder_info(), IsA, lfirst, RelOptInfo::min_attr, nodeTag, PlaceHolderInfo::ph_needed, RelOptInfo::relids, root, Var::varattno, and Var::varno.
Referenced by rebuild_eclass_attr_needed(), rebuild_joinclause_attr_needed(), rebuild_lateral_attr_needed(), and rebuild_placeholder_attr_needed().
void add_vars_to_targetlist | ( | PlannerInfo * | root, |
List * | vars, | ||
Relids | where_needed | ||
) |
Definition at line 282 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, root, 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(), list_free(), NIL, pull_var_clause(), PVC_INCLUDE_PLACEHOLDERS, PVC_RECURSE_AGGREGATES, PVC_RECURSE_WINDOWFUNCS, and root.
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 3424 of file initsplan.c.
References check_hashjoinable(), check_memoizable(), check_mergejoinable(), copyObject, InvalidOid, make_opclause(), make_restrictinfo(), JoinTreeItem::qualscope, and root.
Referenced by create_join_clause(), reconsider_full_join_clause(), and reconsider_outer_join_clause().
Definition at line 2151 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 845 of file initsplan.c.
References Assert, bms_add_member(), bms_add_members(), bms_copy(), bms_get_singleton_member(), bms_intersect(), bms_is_empty, bms_is_member(), bms_next_member(), RelOptInfo::direct_lateral_relids, find_base_rel(), find_base_rel_ignore_join(), find_placeholder_info(), IsA, RelOptInfo::lateral_referencers, RelOptInfo::lateral_relids, RelOptInfo::lateral_vars, lfirst, PlaceHolderInfo::ph_eval_at, PlaceHolderInfo::ph_lateral, RelOptInfo::relid, RELOPT_BASEREL, RelOptInfo::reloptkind, root, and Var::varno.
Referenced by query_planner().
Plan * create_plan | ( | PlannerInfo * | root, |
Path * | best_path | ||
) |
Definition at line 340 of file createplan.c.
References apply_tlist_labeling(), Assert, CP_EXACT_TLIST, create_plan_recurse(), elog, ERROR, IsA, NIL, plan, root, 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 1084 of file initsplan.c.
References Assert, bms_equal(), bms_union(), deconstruct_distribute(), deconstruct_distribute_oj_quals(), deconstruct_recurse(), IsA, JoinDomain::jd_relids, lfirst, linitial_node, list_free_deep(), NIL, JoinTreeItem::oj_joinclauses, and root.
Referenced by query_planner().
void distribute_restrictinfo_to_rels | ( | PlannerInfo * | root, |
RestrictInfo * | restrictinfo | ||
) |
Definition at line 3195 of file initsplan.c.
References add_base_clause_to_rel(), add_join_clause_to_rels(), bms_get_singleton_member(), bms_is_empty, check_hashjoinable(), check_memoizable(), elog, ERROR, RestrictInfo::required_relids, and root.
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 3593 of file setrefs.c.
References Assert, CMD_UTILITY, Query::commandType, PlannerGlobal::dependsOnRole, expression_tree_walker, extract_query_dependencies_walker(), fix_expr_common(), CallStmt::funcexpr, PlannerInfo::glob, IsA, lappend_oid(), lfirst, OidIsValid, CallStmt::outargs, 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(), extract_query_dependencies(), and extract_query_dependencies_walker().
void find_lateral_references | ( | PlannerInfo * | root | ) |
Definition at line 658 of file initsplan.c.
References Assert, extract_lateral_references(), RelOptInfo::relid, RELOPT_BASEREL, RelOptInfo::reloptkind, and root.
Referenced by query_planner().
Param * find_minmax_agg_replacement_param | ( | PlannerInfo * | root, |
Aggref * | aggref | ||
) |
Definition at line 3443 of file setrefs.c.
References MinMaxAggInfo::aggfnoid, Aggref::aggfnoid, Aggref::args, equal(), TargetEntry::expr, lfirst, linitial, list_length(), NIL, MinMaxAggInfo::param, root, and MinMaxAggInfo::target.
Referenced by finalize_primnode(), fix_scan_expr_mutator(), and fix_upper_expr_mutator().
bool innerrel_is_unique | ( | PlannerInfo * | root, |
Relids | joinrelids, | ||
Relids | outerrelids, | ||
RelOptInfo * | innerrel, | ||
JoinType | jointype, | ||
List * | restrictlist, | ||
bool | force_cache | ||
) |
Definition at line 1172 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(), root, and RelOptInfo::unique_for_rels.
Referenced by add_paths_to_joinrel(), and reduce_unique_semijoins().
bool is_projection_capable_path | ( | Path * | path | ) |
Definition at line 7303 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().
bool is_projection_capable_plan | ( | Plan * | plan | ) |
Definition at line 7353 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 6672 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 5898 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 7044 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 6492 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 3599 of file initsplan.c.
References OpExpr::args, RestrictInfo::clause, ForeignKeyOptInfo::con_relid, EquivalenceClass::ec_has_const, 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 root.
Referenced by query_planner().
Definition at line 6604 of file createplan.c.
References cost_material(), Plan::disabled_nodes, Plan::initPlan, make_material(), NIL, Plan::parallel_aware, Plan::parallel_safe, Plan::plan_rows, Plan::plan_width, SS_compute_initplan_cost(), 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(), NIL, OidIsValid, MinMaxAggInfo::param, parse(), planner_rt_fetch, root, 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 3280 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(), InvalidOid, IsA, list_free(), make_opclause(), make_restrictinfo(), pull_var_clause(), pull_varnos(), PVC_INCLUDE_PLACEHOLDERS, PVC_RECURSE_AGGREGATES, PVC_RECURSE_WINDOWFUNCS, JoinTreeItem::qualscope, and root.
Referenced by generate_base_implied_equalities_const(), and generate_base_implied_equalities_no_const().
Definition at line 983 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 54 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(), 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(), elog, ERROR, extract_restriction_or_clauses(), find_lateral_references(), find_placeholders_in_jointree(), fix_placeholder_input_needed_levels(), generate_base_implied_equalities(), is_parallel_safe(), IsA, linitial, list_length(), make_one_rel(), match_foreign_keys_to_quals(), NIL, parse(), reconsider_outer_join_clauses(), reduce_unique_semijoins(), RelOptInfo::reltarget, remove_useless_groupby_columns(), remove_useless_joins(), root, RTE_RESULT, RangeTblEntry::rtekind, set_cheapest(), and setup_simple_rel_arrays().
Referenced by build_minmax_path(), and grouping_planner().
bool query_supports_distinctness | ( | Query * | query | ) |
Definition at line 946 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 rebuild_joinclause_attr_needed | ( | PlannerInfo * | root | ) |
Definition at line 3527 of file initsplan.c.
References add_vars_to_attr_needed(), bms_add_member(), bms_intersect(), bms_is_member(), bms_membership(), BMS_MULTIPLE, RestrictInfo::clause, RestrictInfo::is_clone, RelOptInfo::joininfo, lfirst, list_free(), pull_var_clause(), PVC_INCLUDE_PLACEHOLDERS, PVC_RECURSE_AGGREGATES, PVC_RECURSE_WINDOWFUNCS, RELOPT_BASEREL, RelOptInfo::reloptkind, RestrictInfo::required_relids, RestrictInfo::rinfo_serial, and root.
Referenced by remove_rel_from_query().
void rebuild_lateral_attr_needed | ( | PlannerInfo * | root | ) |
Definition at line 807 of file initsplan.c.
References add_vars_to_attr_needed(), bms_make_singleton(), RelOptInfo::lateral_vars, NIL, RELOPT_BASEREL, RelOptInfo::reloptkind, and root.
Referenced by remove_rel_from_query().
void record_plan_function_dependency | ( | PlannerInfo * | root, |
Oid | funcid | ||
) |
Definition at line 3476 of file setrefs.c.
References PlanInvalItem::cacheId, FirstUnpinnedObjectId, GetSysCacheHashValue1, PlanInvalItem::hashValue, lappend(), makeNode, ObjectIdGetDatum(), and root.
Referenced by fix_expr_common(), inline_function(), and inline_set_returning_function().
void record_plan_type_dependency | ( | PlannerInfo * | root, |
Oid | typid | ||
) |
Definition at line 3516 of file setrefs.c.
References PlanInvalItem::cacheId, FirstUnpinnedObjectId, GetSysCacheHashValue1, PlanInvalItem::hashValue, lappend(), makeNode, ObjectIdGetDatum(), and root.
Referenced by eval_const_expressions_mutator().
void reduce_unique_semijoins | ( | PlannerInfo * | root | ) |
Definition at line 718 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(), JOIN_SEMI, RelOptInfo::joininfo, SpecialJoinInfo::jointype, lfirst, list_concat(), SpecialJoinInfo::min_lefthand, SpecialJoinInfo::min_righthand, SpecialJoinInfo::ojrelid, rel_supports_distinctness(), and root.
Referenced by query_planner().
void remove_useless_groupby_columns | ( | PlannerInfo * | root | ) |
Definition at line 412 of file initsplan.c.
References Assert, bms_add_member(), bms_difference(), bms_is_empty, bms_is_member(), bms_membership(), BMS_MULTIPLE, BMS_SUBSET1, bms_subset_compare(), TargetEntry::expr, FirstLowInvalidHeapAttributeNumber, foreach_node, get_sortgroupclause_tle(), i, if(), RelOptInfo::indexlist, RangeTblEntry::inh, IsA, lappend(), lfirst_node, list_length(), NIL, RelOptInfo::notnullattnums, palloc0(), parse(), PG_INT32_MAX, root, RTE_RELATION, RangeTblEntry::rtekind, Var::varattno, Var::varlevelsup, and Var::varno.
Referenced by query_planner().
List * remove_useless_joins | ( | PlannerInfo * | root, |
List * | joinlist | ||
) |
Definition at line 65 of file analyzejoins.c.
References bms_singleton_member(), elog, ERROR, join_is_removable(), lfirst, list_delete_cell(), SpecialJoinInfo::min_righthand, remove_rel_from_joinlist(), remove_rel_from_query(), and root.
Referenced by query_planner().
bool restriction_is_always_false | ( | PlannerInfo * | root, |
RestrictInfo * | restrictinfo | ||
) |
Definition at line 3140 of file initsplan.c.
References NullTest::arg, Assert, RestrictInfo::clause, expr_is_nonnullable(), if(), IS_NULL, is_orclause(), IsA, lfirst, NullTest::nulltesttype, restriction_is_always_false(), restriction_is_or_clause(), and root.
Referenced by add_base_clause_to_rel(), add_join_clause_to_rels(), apply_child_basequals(), and restriction_is_always_false().
bool restriction_is_always_true | ( | PlannerInfo * | root, |
RestrictInfo * | restrictinfo | ||
) |
Definition at line 3091 of file initsplan.c.
References NullTest::arg, Assert, RestrictInfo::clause, expr_is_nonnullable(), if(), IS_NOT_NULL, is_orclause(), IsA, lfirst, NullTest::nulltesttype, restriction_is_always_true(), restriction_is_or_clause(), and root.
Referenced by add_base_clause_to_rel(), add_join_clause_to_rels(), apply_child_basequals(), and restriction_is_always_true().
Plan * set_plan_references | ( | PlannerInfo * | root, |
Plan * | plan | ||
) |
Definition at line 288 of file setrefs.c.
References add_rtes_to_flat_rtable(), PlannerGlobal::appendRelations, AppendRelInfo::child_relid, PlannerGlobal::finalrowmarks, PlannerGlobal::finalrtable, foreach_current_index, lappend(), lfirst, lfirst_node, list_length(), NIL, palloc(), palloc0(), AppendRelInfo::parent_relid, plan, PlanRowMark::prti, root, 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 1465 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 66 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().