PostgreSQL Source Code git master
|
#include "postgres.h"
#include <limits.h>
#include <math.h>
#include "access/genam.h"
#include "access/parallel.h"
#include "access/sysattr.h"
#include "access/table.h"
#include "catalog/pg_aggregate.h"
#include "catalog/pg_inherits.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "executor/executor.h"
#include "foreign/fdwapi.h"
#include "jit/jit.h"
#include "lib/bipartite_match.h"
#include "lib/knapsack.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "nodes/supportnodes.h"
#include "optimizer/appendinfo.h"
#include "optimizer/clauses.h"
#include "optimizer/cost.h"
#include "optimizer/optimizer.h"
#include "optimizer/paramassign.h"
#include "optimizer/pathnode.h"
#include "optimizer/paths.h"
#include "optimizer/plancat.h"
#include "optimizer/planmain.h"
#include "optimizer/planner.h"
#include "optimizer/prep.h"
#include "optimizer/subselect.h"
#include "optimizer/tlist.h"
#include "parser/analyze.h"
#include "parser/parse_agg.h"
#include "parser/parse_clause.h"
#include "parser/parse_relation.h"
#include "parser/parsetree.h"
#include "partitioning/partdesc.h"
#include "rewrite/rewriteManip.h"
#include "utils/backend_status.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
#include "utils/selfuncs.h"
Go to the source code of this file.
Data Structures | |
struct | grouping_sets_data |
struct | WindowClauseSortData |
struct | standard_qp_extra |
Macros | |
#define | EXPRKIND_QUAL 0 |
#define | EXPRKIND_TARGET 1 |
#define | EXPRKIND_RTFUNC 2 |
#define | EXPRKIND_RTFUNC_LATERAL 3 |
#define | EXPRKIND_VALUES 4 |
#define | EXPRKIND_VALUES_LATERAL 5 |
#define | EXPRKIND_LIMIT 6 |
#define | EXPRKIND_APPINFO 7 |
#define | EXPRKIND_PHV 8 |
#define | EXPRKIND_TABLESAMPLE 9 |
#define | EXPRKIND_ARBITER_ELEM 10 |
#define | EXPRKIND_TABLEFUNC 11 |
#define | EXPRKIND_TABLEFUNC_LATERAL 12 |
#define | EXPRKIND_GROUPEXPR 13 |
Variables | |
double | cursor_tuple_fraction = DEFAULT_CURSOR_TUPLE_FRACTION |
int | debug_parallel_query = DEBUG_PARALLEL_OFF |
bool | parallel_leader_participation = true |
bool | enable_distinct_reordering = true |
planner_hook_type | planner_hook = NULL |
create_upper_paths_hook_type | create_upper_paths_hook = NULL |
|
static |
Definition at line 6980 of file planner.c.
References add_path(), GroupPathExtraData::agg_final_costs, AGG_HASHED, AGG_PLAIN, AGG_SORTED, AGGSPLIT_FINAL_DESERIAL, AGGSPLIT_SIMPLE, Assert(), RelOptInfo::cheapest_total_path, GroupByOrdering::clauses, consider_groupingsets_paths(), create_agg_path(), create_group_path(), GroupPathExtraData::flags, gather_grouping_paths(), get_useful_group_keys_orderings(), GROUPING_CAN_USE_HASH, GROUPING_CAN_USE_SORT, GroupPathExtraData::havingQual, if(), lfirst, list_length(), make_ordered_path(), NIL, parse(), RelOptInfo::partial_pathlist, GroupByOrdering::pathkeys, RelOptInfo::pathlist, RelOptInfo::reltarget, and root.
Referenced by create_ordinary_grouping_paths().
|
static |
Definition at line 3173 of file planner.c.
References Aggref::aggdistinct, Aggref::aggorder, AggInfo::aggrefs, append_pathkeys(), Aggref::args, Assert(), bms_add_member(), bms_del_member(), bms_del_members(), bms_next_member(), bms_num_members(), compare_pathkeys(), enable_presorted_aggregate, foreach_current_index, has_volatile_pathkey(), i, lfirst_node, linitial_node, list_copy(), list_nth_node, make_pathkeys_for_sortclauses(), NIL, PATHKEYS_BETTER1, PATHKEYS_BETTER2, PATHKEYS_DIFFERENT, PATHKEYS_EQUAL, and root.
Referenced by standard_qp_callback().
|
static |
Definition at line 6529 of file planner.c.
References apply_projection_to_path(), Assert(), RelOptInfo::cheapest_startup_path, RelOptInfo::cheapest_total_path, create_projection_path(), create_set_projection_path(), forboth, lfirst, lfirst_int, lfirst_node, linitial_int, list_length(), RelOptInfo::partial_pathlist, RelOptInfo::pathlist, root, and subpath().
Referenced by apply_scanjoin_target_to_paths(), and grouping_planner().
|
static |
Definition at line 7695 of file planner.c.
References add_paths_to_append_rel(), adjust_appendrel_attrs(), adjust_paths_for_srfs(), apply_scanjoin_target_to_paths(), Assert(), bms_next_member(), check_stack_depth(), RelOptInfo::consider_parallel, copy_pathtarget(), create_projection_path(), PathTarget::exprs, find_appinfos_by_relids(), generate_useful_gather_paths(), i, IS_DUMMY_REL, IS_OTHER_REL, IS_PARTITIONED_REL, lappend(), lfirst, lfirst_node, linitial_node, RelOptInfo::live_parts, llast_node, NIL, RelOptInfo::partial_pathlist, RelOptInfo::pathlist, pfree(), RelOptInfo::relids, RelOptInfo::reltarget, root, set_cheapest(), subpath(), and tlist_same_exprs().
Referenced by apply_scanjoin_target_to_paths(), and grouping_planner().
|
static |
Definition at line 7653 of file planner.c.
References NIL, parse(), and root.
Referenced by create_grouping_paths().
|
static |
Definition at line 5990 of file planner.c.
References a, b, forboth, lfirst_node, list_length(), SortGroupClause::nulls_first, SortGroupClause::sortop, SortGroupClause::tleSortGroupRef, and WindowClauseSortData::uniqueOrder.
Referenced by select_active_windows().
|
static |
Definition at line 4072 of file planner.c.
References add_path(), AGG_HASHED, AGG_MIXED, AGG_SORTED, grouping_sets_data::any_hashable, Assert(), bms_is_empty, bms_is_member(), create_groupingsets_path(), DiscreteKnapsack(), grouping_sets_data::dNumHashGroups, estimate_hashagg_tablesize(), for_each_cell, for_each_from, get_hash_memory_limit(), RollupData::groupClause, RollupData::gsets, RollupData::gsets_data, RollupData::hashable, i, RollupData::is_hashed, lappend(), lcons(), lfirst_node, linitial, list_concat(), list_copy(), list_head(), list_length(), list_make1, lnext(), makeNode, Max, Min, NIL, GroupingSetData::numGroups, RollupData::numGroups, palloc(), parse(), Path::pathkeys, pathkeys_contained_in(), preprocess_groupclause(), remap_to_groupclause_idx(), grouping_sets_data::rollups, root, scale, GroupingSetData::set, grouping_sets_data::tleref_to_colnum_map, and grouping_sets_data::unsortable_sets.
Referenced by add_paths_to_grouping_rel().
|
static |
Definition at line 3868 of file planner.c.
References add_path(), create_append_path(), create_group_result_path(), lappend(), list_length(), NIL, parse(), RelOptInfo::reltarget, and root.
Referenced by create_grouping_paths().
|
static |
Definition at line 4691 of file planner.c.
References RelOptInfo::consider_parallel, create_final_distinct_paths(), create_partial_distinct_paths(), create_upper_paths_hook, ereport, errcode(), errdetail(), errmsg(), ERROR, fetch_upper_rel(), NIL, RelOptInfo::pathlist, root, RelOptInfo::serverid, set_cheapest(), UPPERREL_DISTINCT, RelOptInfo::userid, and RelOptInfo::useridiscurrent.
Referenced by grouping_planner().
|
static |
Definition at line 4944 of file planner.c.
References add_path(), AGG_HASHED, AGGSPLIT_SIMPLE, Assert(), RelOptInfo::cheapest_total_path, create_agg_path(), create_limit_path(), create_upper_unique_path(), enable_hashagg, estimate_num_groups(), FLOAT8PASSBYVAL, foreach_node, get_sortgrouplist_exprs(), get_useful_pathkeys_for_distinct(), grouping_is_hashable(), grouping_is_sortable(), Int64GetDatum(), InvalidOid, lfirst, LIMIT_OPTION_COUNT, list_length(), make_ordered_path(), makeConst(), NIL, parse(), Path::pathkeys, RelOptInfo::pathlist, root, and Path::rows.
Referenced by create_distinct_paths(), and create_partial_distinct_paths().
|
static |
Definition at line 3681 of file planner.c.
References AGGSPLIT_SIMPLE, grouping_sets_data::any_hashable, can_partial_agg(), create_degenerate_grouping_paths(), create_ordinary_grouping_paths(), enable_partitionwise_aggregate, GroupPathExtraData::flags, get_agg_clause_costs(), GROUPING_CAN_PARTIAL_AGG, GROUPING_CAN_USE_HASH, GROUPING_CAN_USE_SORT, grouping_is_hashable(), grouping_is_sortable(), GroupPathExtraData::havingQual, is_degenerate_grouping(), make_grouping_rel(), MemSet, NIL, parse(), GroupPathExtraData::partial_costs_set, PARTITIONWISE_AGGREGATE_FULL, PARTITIONWISE_AGGREGATE_NONE, GroupPathExtraData::patype, grouping_sets_data::rollups, root, set_cheapest(), GroupPathExtraData::target_parallel_safe, and GroupPathExtraData::targetList.
Referenced by grouping_planner().
|
static |
Definition at line 4521 of file planner.c.
References add_column_to_pathtarget(), add_path(), WindowFuncRunCondition::arg, clamp_width_est(), copy_pathtarget(), copyObject, create_incremental_sort_path(), create_sort_path(), create_windowagg_path(), enable_incremental_sort, foreach_current_index, get_typavgwidth(), InvalidOid, lappend(), lfirst_node, list_length(), lnext(), make_opclause(), make_pathkeys_for_window(), NIL, WindowFuncRunCondition::opno, Path::pathkeys, pathkeys_count_contained_in(), root, WindowFuncRunCondition::wfunc_left, PathTarget::width, WindowFuncLists::windowFuncs, and WindowClause::winref.
Referenced by create_window_paths().
|
static |
Definition at line 5209 of file planner.c.
References add_path(), apply_projection_to_path(), Assert(), RelOptInfo::cheapest_total_path, compute_gather_rows(), RelOptInfo::consider_parallel, create_gather_merge_path(), create_incremental_sort_path(), create_sort_path(), create_upper_paths_hook, enable_incremental_sort, equal(), PathTarget::exprs, fetch_upper_rel(), lfirst, linitial, NIL, RelOptInfo::partial_pathlist, Path::pathkeys, pathkeys_count_contained_in(), RelOptInfo::pathlist, root, RelOptInfo::serverid, UPPERREL_ORDERED, RelOptInfo::userid, and RelOptInfo::useridiscurrent.
Referenced by grouping_planner().
|
static |
Definition at line 3932 of file planner.c.
References add_paths_to_grouping_rel(), Assert(), RelOptInfo::cheapest_total_path, create_partial_grouping_paths(), create_partitionwise_grouping_paths(), create_upper_paths_hook, ereport, errcode(), errdetail(), errmsg(), ERROR, GroupPathExtraData::flags, gather_grouping_paths(), get_number_of_groups(), group_by_has_partkey(), GROUPING_CAN_PARTIAL_AGG, IS_PARTITIONED_REL, NIL, RelOptInfo::partial_pathlist, PARTITIONWISE_AGGREGATE_FULL, PARTITIONWISE_AGGREGATE_NONE, PARTITIONWISE_AGGREGATE_PARTIAL, RelOptInfo::pathlist, GroupPathExtraData::patype, root, Path::rows, set_cheapest(), GroupPathExtraData::targetList, and UPPERREL_GROUP_AGG.
Referenced by create_grouping_paths(), and create_partitionwise_grouping_paths().
|
static |
Definition at line 4761 of file planner.c.
References add_partial_path(), AGG_HASHED, AGGSPLIT_SIMPLE, Assert(), RelOptInfo::consider_parallel, create_agg_path(), create_final_distinct_paths(), create_limit_path(), create_upper_paths_hook, create_upper_unique_path(), enable_hashagg, estimate_num_groups(), fetch_upper_rel(), FLOAT8PASSBYVAL, foreach_node, generate_useful_gather_paths(), get_sortgrouplist_exprs(), get_useful_pathkeys_for_distinct(), grouping_is_hashable(), grouping_is_sortable(), Int64GetDatum(), InvalidOid, lfirst, LIMIT_OPTION_COUNT, linitial, list_length(), make_ordered_path(), makeConst(), NIL, parse(), RelOptInfo::partial_pathlist, Path::pathkeys, RelOptInfo::reltarget, root, Path::rows, RelOptInfo::serverid, set_cheapest(), UPPERREL_PARTIAL_DISTINCT, RelOptInfo::userid, and RelOptInfo::useridiscurrent.
Referenced by create_distinct_paths().
|
static |
Definition at line 7217 of file planner.c.
References add_partial_path(), add_path(), GroupPathExtraData::agg_final_costs, AGG_HASHED, GroupPathExtraData::agg_partial_costs, AGG_PLAIN, AGG_SORTED, AGGSPLIT_FINAL_DESERIAL, AGGSPLIT_INITIAL_SERIAL, Assert(), RelOptInfo::cheapest_total_path, GroupByOrdering::clauses, RelOptInfo::consider_parallel, create_agg_path(), create_group_path(), fetch_upper_rel(), GroupPathExtraData::flags, get_agg_clause_costs(), get_number_of_groups(), get_useful_group_keys_orderings(), FdwRoutine::GetForeignUpperPaths, GROUPING_CAN_USE_HASH, GROUPING_CAN_USE_SORT, GroupPathExtraData::havingQual, lfirst, linitial, list_length(), make_ordered_path(), make_partial_grouping_target(), MemSet, NIL, parse(), GroupPathExtraData::partial_costs_set, RelOptInfo::partial_pathlist, PARTITIONWISE_AGGREGATE_PARTIAL, GroupByOrdering::pathkeys, RelOptInfo::pathlist, GroupPathExtraData::patype, RelOptInfo::relids, RelOptInfo::reloptkind, RelOptInfo::reltarget, root, Path::rows, RelOptInfo::serverid, GroupPathExtraData::targetList, UPPERREL_PARTIAL_GROUP_AGG, RelOptInfo::userid, and RelOptInfo::useridiscurrent.
Referenced by create_ordinary_grouping_paths().
|
static |
Definition at line 7930 of file planner.c.
References add_paths_to_append_rel(), adjust_appendrel_attrs(), Assert(), bms_next_member(), copy_pathtarget(), create_ordinary_grouping_paths(), PathTarget::exprs, find_appinfos_by_relids(), GroupPathExtraData::havingQual, i, IS_DUMMY_REL, lappend(), RelOptInfo::live_parts, make_grouping_rel(), NIL, PARTITIONWISE_AGGREGATE_FULL, PARTITIONWISE_AGGREGATE_NONE, PARTITIONWISE_AGGREGATE_PARTIAL, RelOptInfo::pathlist, GroupPathExtraData::patype, pfree(), RelOptInfo::relids, RelOptInfo::reltarget, root, set_cheapest(), GroupPathExtraData::target_parallel_safe, and GroupPathExtraData::targetList.
Referenced by create_ordinary_grouping_paths().
|
static |
Definition at line 4434 of file planner.c.
References RelOptInfo::cheapest_total_path, RelOptInfo::consider_parallel, create_one_window_path(), create_upper_paths_hook, fetch_upper_rel(), is_parallel_safe(), lfirst, Path::pathkeys, pathkeys_count_contained_in(), RelOptInfo::pathlist, root, RelOptInfo::serverid, set_cheapest(), UPPERREL_WINDOW, RelOptInfo::userid, and RelOptInfo::useridiscurrent.
Referenced by grouping_planner().
Definition at line 6645 of file planner.c.
References eval_const_expressions(), and fix_opfuncids().
Referenced by ATExecAddColumn(), ATExecSetExpression(), ATPrepAlterColumnType(), BeginCopyFrom(), ComputePartitionAttrs(), contain_mutable_functions_after_planning(), contain_volatile_functions_after_planning(), ExecPrepareCheck(), ExecPrepareExpr(), ExecPrepareQual(), load_domaintype_info(), set_baserel_partition_constraint(), slot_fill_defaults(), and transformPartitionBoundValue().
Definition at line 6672 of file planner.c.
References eval_const_expressions(), extract_query_dependencies_walker(), fix_opfuncids(), PlannerGlobal::invalItems, MemSet, NIL, PlannerGlobal::relationOids, and root.
Referenced by GetCachedExpression().
Definition at line 2868 of file planner.c.
References Assert(), BipartiteMatch(), BipartiteMatchFree(), bms_add_member(), bms_equal(), bms_free(), bms_is_subset(), for_each_cell, i, j, lappend(), lcons(), lfirst, lfirst_int, list_concat(), list_head(), list_length(), list_make1, lnext(), NIL, palloc(), palloc0(), and pfree().
Referenced by preprocess_grouping_sets().
|
static |
Definition at line 7570 of file planner.c.
References add_path(), compute_gather_rows(), create_gather_merge_path(), create_incremental_sort_path(), create_sort_path(), enable_incremental_sort, generate_useful_gather_paths(), lfirst, linitial, list_copy_head(), list_length(), RelOptInfo::partial_pathlist, Path::pathkeys, pathkeys_count_contained_in(), RelOptInfo::reltarget, and root.
Referenced by add_paths_to_grouping_rel(), and create_ordinary_grouping_paths().
|
static |
Definition at line 8161 of file planner.c.
References Assert(), assignSortGroupRef(), copyObject, TargetEntry::expr, exprType(), lfirst, lfirst_oid, list_head(), lnext(), NIL, and SortGroupClause::tleSortGroupRef.
Referenced by standard_qp_callback().
Path * get_cheapest_fractional_path | ( | RelOptInfo * | rel, |
double | tuple_fraction | ||
) |
Definition at line 6483 of file planner.c.
References RelOptInfo::cheapest_total_path, compare_fractional_path_costs(), lfirst, RelOptInfo::pathlist, and Path::rows.
Referenced by add_paths_to_append_rel(), make_subplan(), and standard_planner().
|
static |
Definition at line 3559 of file planner.c.
References Assert(), grouping_sets_data::dNumHashGroups, estimate_num_groups(), forboth, get_sortgrouplist_exprs(), RollupData::groupClause, RollupData::gsets, RollupData::gsets_data, grouping_sets_data::hash_sets_idx, lfirst, lfirst_node, list_length(), GroupingSetData::numGroups, RollupData::numGroups, parse(), grouping_sets_data::rollups, root, and grouping_sets_data::unsortable_sets.
Referenced by create_ordinary_grouping_paths(), and create_partial_grouping_paths().
|
static |
Definition at line 5124 of file planner.c.
References compare_pathkeys(), enable_distinct_reordering, enable_incremental_sort, foreach_node, lappend(), list_concat_unique_ptr(), list_length(), list_member_ptr(), NIL, PATHKEYS_EQUAL, and root.
Referenced by create_final_distinct_paths(), and create_partial_distinct_paths().
|
static |
Definition at line 8074 of file planner.c.
References Assert(), equal(), exprCollation(), get_sortgrouplist_exprs(), IsA, lfirst, and OidIsValid.
Referenced by create_ordinary_grouping_paths().
|
static |
Definition at line 1381 of file planner.c.
References generate_unaccent_rules::action, standard_qp_extra::activeWindows, add_partial_path(), add_path(), adjust_appendrel_attrs_multilevel(), adjust_inherited_attnums_multilevel(), adjust_paths_for_srfs(), apply_scanjoin_target_to_paths(), Assert(), assign_special_exec_param(), bms_membership(), BMS_MULTIPLE, bms_next_member(), RelOptInfo::cheapest_total_path, CMD_MERGE, CMD_SELECT, CMD_UPDATE, RelOptInfo::consider_parallel, copyObject, FinalPathExtraData::count_est, create_distinct_paths(), create_grouping_paths(), create_limit_path(), create_lockrows_path(), create_modifytable_path(), create_ordered_paths(), create_pathtarget, create_upper_paths_hook, create_window_paths(), equal(), ereport, errcode(), errmsg(), ERROR, PathTarget::exprs, fetch_upper_rel(), find_base_rel(), find_window_functions(), standard_qp_extra::gset_data, IS_DUMMY_REL, is_parallel_safe(), lappend(), lappend_int(), LCS_asString(), lfirst, limit_needed(), FinalPathExtraData::limit_needed, FinalPathExtraData::limit_tuples, linitial_int, linitial_node, list_length(), list_make1, list_make1_int, make_group_input_target(), make_pathkeys_for_sortclauses(), make_sort_input_target(), make_window_input_target(), name_active_windows(), NIL, WindowFuncLists::numWindowFuncs, FinalPathExtraData::offset_est, optimize_window_clauses(), parse(), RelOptInfo::partial_pathlist, RelOptInfo::pathlist, plan_set_operations(), postprocess_setop_tlist(), preprocess_aggrefs(), preprocess_groupclause(), preprocess_grouping_sets(), preprocess_limit(), preprocess_minmax_aggregates(), preprocess_targetlist(), query_planner(), RelOptInfo::relid, RelOptInfo::reltarget, root, select_active_windows(), RelOptInfo::serverid, standard_qp_extra::setop, split_pathtarget_at_srfs(), standard_qp_callback(), UPPERREL_DISTINCT, UPPERREL_FINAL, UPPERREL_GROUP_AGG, UPPERREL_ORDERED, UPPERREL_PARTIAL_DISTINCT, UPPERREL_WINDOW, RelOptInfo::userid, and RelOptInfo::useridiscurrent.
Referenced by subquery_planner().
|
static |
Definition at line 3128 of file planner.c.
References lfirst_node.
Referenced by adjust_group_pathkeys_for_groupagg().
|
static |
bool limit_needed | ( | Query * | parse | ) |
Definition at line 2706 of file planner.c.
References DatumGetInt64(), IsA, and parse().
Referenced by grouping_planner(), and set_rel_consider_parallel().
|
static |
Definition at line 5429 of file planner.c.
References add_column_to_pathtarget(), add_new_columns_to_pathtarget(), Assert(), bms_make_singleton(), create_empty_pathtarget(), PathTarget::exprs, get_pathtarget_sortgroupref, get_sortgroupref_clause_noerr(), i, lappend(), lfirst, list_free(), NIL, parse(), pull_var_clause(), PVC_INCLUDE_PLACEHOLDERS, PVC_RECURSE_AGGREGATES, PVC_RECURSE_WINDOWFUNCS, remove_nulling_relids(), root, and set_pathtarget_cost_width().
Referenced by grouping_planner().
|
static |
Definition at line 3794 of file planner.c.
References RelOptInfo::consider_parallel, fetch_upper_rel(), IS_OTHER_REL, is_parallel_safe(), RelOptInfo::relids, RELOPT_OTHER_UPPER_REL, RelOptInfo::reloptkind, RelOptInfo::reltarget, root, RelOptInfo::serverid, UPPERREL_GROUP_AGG, RelOptInfo::userid, and RelOptInfo::useridiscurrent.
Referenced by create_grouping_paths(), and create_partitionwise_grouping_paths().
|
static |
Definition at line 7511 of file planner.c.
References create_incremental_sort_path(), create_sort_path(), enable_incremental_sort, Path::pathkeys, pathkeys_count_contained_in(), and root.
Referenced by add_paths_to_grouping_rel(), create_final_distinct_paths(), create_partial_distinct_paths(), and create_partial_grouping_paths().
|
static |
Definition at line 5541 of file planner.c.
References add_column_to_pathtarget(), add_new_columns_to_pathtarget(), AGGSPLIT_INITIAL_SERIAL, create_empty_pathtarget(), PathTarget::exprs, get_pathtarget_sortgroupref, get_sortgroupref_clause_noerr(), i, IsA, lappend(), lfirst, list_free(), makeNode, mark_partial_aggref(), NIL, pull_var_clause(), PVC_INCLUDE_AGGREGATES, PVC_INCLUDE_PLACEHOLDERS, PVC_RECURSE_WINDOWFUNCS, root, and set_pathtarget_cost_width().
Referenced by create_partial_grouping_paths().
|
static |
Definition at line 6179 of file planner.c.
References append_pathkeys(), Assert(), ereport, errcode(), errdetail(), errmsg(), ERROR, grouping_is_sortable(), make_pathkeys_for_sortclauses(), make_pathkeys_for_sortclauses_extended(), NIL, WindowClause::orderClause, WindowClause::partitionClause, and root.
Referenced by create_one_window_path(), and standard_qp_callback().
|
static |
Definition at line 6307 of file planner.c.
References add_column_to_pathtarget(), add_new_columns_to_pathtarget(), Assert(), contain_volatile_functions(), cost_qual_eval_node(), cpu_operator_cost, create_empty_pathtarget(), expression_returns_set(), PathTarget::exprs, get_pathtarget_sortgroupref, i, lappend(), lfirst, list_free(), list_length(), NIL, palloc0(), parse(), QualCost::per_tuple, pull_var_clause(), PVC_INCLUDE_AGGREGATES, PVC_INCLUDE_PLACEHOLDERS, PVC_INCLUDE_WINDOWFUNCS, root, and set_pathtarget_cost_width().
Referenced by grouping_planner().
|
static |
Definition at line 6059 of file planner.c.
References add_column_to_pathtarget(), add_new_columns_to_pathtarget(), Assert(), bms_add_member(), bms_is_member(), create_empty_pathtarget(), PathTarget::exprs, get_pathtarget_sortgroupref, i, lappend(), lfirst, lfirst_node, list_free(), NIL, WindowClause::orderClause, WindowClause::partitionClause, pull_var_clause(), PVC_INCLUDE_AGGREGATES, PVC_INCLUDE_PLACEHOLDERS, PVC_RECURSE_WINDOWFUNCS, root, set_pathtarget_cost_width(), and SortGroupClause::tleSortGroupRef.
Referenced by grouping_planner().
Definition at line 5644 of file planner.c.
References AGGSPLIT_SIMPLE, Assert(), DO_AGGSPLIT_SERIALIZE, DO_AGGSPLIT_SKIPFINAL, and OidIsValid.
Referenced by convert_combining_aggrefs(), and make_partial_grouping_target().
|
static |
Definition at line 5939 of file planner.c.
References lfirst_node, pstrdup(), and snprintf.
Referenced by grouping_planner().
|
static |
Definition at line 5716 of file planner.c.
References Assert(), DatumGetPointer(), WindowClause::endOffset, equal(), foreach_current_index, WindowClause::frameOptions, SupportRequestOptimizeWindowClause::frameOptions, get_func_support(), if(), lfirst_node, list_concat(), list_length(), WindowFuncLists::maxWinRef, NIL, OidFunctionCall1, OidIsValid, WindowClause::orderClause, WindowClause::partitionClause, PointerGetDatum(), root, WindowClause::startOffset, SupportRequestOptimizeWindowClause::type, SupportRequestOptimizeWindowClause::window_clause, SupportRequestOptimizeWindowClause::window_func, WindowFuncLists::windowFuncs, WindowFunc::winfnoid, WindowClause::winref, and WindowFunc::winref.
Referenced by grouping_planner().
Definition at line 6725 of file planner.c.
References AccessShareLock, addRTEPermissionInfo(), build_simple_rel(), CMD_SELECT, Query::commandType, cost_qual_eval(), cost_sort(), create_index_path(), create_seqscan_path(), CurrentMemoryContext, Path::disabled_nodes, enable_indexscan, ForwardScanDirection, get_relation_data_width(), RelOptInfo::indexlist, IndexOptInfo::indexoid, RangeTblEntry::inh, lfirst_node, list_make1, maintenance_work_mem, makeNode, NIL, RelOptInfo::pages, IndexPath::path, QualCost::per_tuple, RelOptInfo::reltarget, root, RelOptInfo::rows, Query::rtable, RTE_RELATION, RangeTblEntry::rtekind, setup_simple_rel_arrays(), QualCost::startup, Path::total_cost, RelOptInfo::tuples, and PathTarget::width.
Referenced by copy_table_data().
Definition at line 6847 of file planner.c.
References AccessShareLock, addRTEPermissionInfo(), build_simple_rel(), CMD_SELECT, Query::commandType, compute_parallel_worker(), CurrentMemoryContext, estimate_rel_size(), index_close(), index_open(), RangeTblEntry::inh, is_parallel_safe(), IsUnderPostmaster, list_make1, maintenance_work_mem, makeNode, max_parallel_maintenance_workers, Min, NoLock, RelationData::rd_rel, RelOptInfo::rel_parallel_workers, RelationGetIndexExpressions(), RelationGetIndexPredicate(), root, Query::rtable, RTE_RELATION, RangeTblEntry::rtekind, setup_simple_rel_arrays(), table_close(), and table_open().
Referenced by index_build().
PlannedStmt * planner | ( | Query * | parse, |
const char * | query_string, | ||
int | cursorOptions, | ||
ParamListInfo | boundParams | ||
) |
Definition at line 286 of file planner.c.
References parse(), pgstat_report_plan_id(), PlannedStmt::planId, planner_hook, and standard_planner().
Referenced by pg_plan_query().
Definition at line 5679 of file planner.c.
References Assert(), elog, ERROR, lfirst_node, list_head(), lnext(), TargetEntry::resno, and TargetEntry::ressortgroupref.
Referenced by grouping_planner().
|
static |
Definition at line 1202 of file planner.c.
References canonicalize_qual(), convert_saop_to_hashed_saop(), eval_const_expressions(), EXPRKIND_QUAL, EXPRKIND_RTFUNC, EXPRKIND_TABLEFUNC, EXPRKIND_TABLESAMPLE, EXPRKIND_TARGET, EXPRKIND_VALUES, flatten_join_alias_vars(), make_ands_implicit(), pprint(), printf, root, SS_process_sublinks(), and SS_replace_correlation_vars().
Referenced by preprocess_phv_expression(), preprocess_qual_conditions(), and subquery_planner().
|
static |
Definition at line 2772 of file planner.c.
References Assert(), equal(), get_sortgroupref_clause(), lappend(), lfirst_int, lfirst_node, list_copy(), list_length(), list_member_ptr(), NIL, OidIsValid, parse(), root, and SortGroupClause::sortop.
Referenced by consider_groupingsets_paths(), grouping_planner(), and preprocess_grouping_sets().
|
static |
Definition at line 2125 of file planner.c.
References grouping_sets_data::any_hashable, bms_add_member(), bms_is_empty, bms_overlap_list(), ereport, errcode(), errdetail(), errmsg(), ERROR, expand_grouping_sets(), extract_rollup_sets(), RollupData::groupClause, RollupData::gsets, RollupData::gsets_data, grouping_sets_data::hash_sets_idx, RollupData::hashable, lappend(), lfirst, lfirst_node, linitial_node, list_length(), makeNode, NIL, OidIsValid, palloc(), palloc0(), parse(), preprocess_groupclause(), remap_to_groupclause_idx(), reorder_grouping_sets(), grouping_sets_data::rollups, root, GroupingSetData::set, SortGroupClause::sortop, grouping_sets_data::tleref_to_colnum_map, SortGroupClause::tleSortGroupRef, grouping_sets_data::unhashable_refs, grouping_sets_data::unsortable_refs, and grouping_sets_data::unsortable_sets.
Referenced by grouping_planner().
|
static |
Definition at line 2521 of file planner.c.
References Assert(), DatumGetInt64(), estimate_expression_value(), IsA, Min, parse(), and root.
Referenced by grouping_planner().
Expr * preprocess_phv_expression | ( | PlannerInfo * | root, |
Expr * | expr | ||
) |
Definition at line 1348 of file planner.c.
References EXPRKIND_PHV, preprocess_expression(), and root.
Referenced by extract_lateral_references().
|
static |
Definition at line 1304 of file planner.c.
References elog, ERROR, EXPRKIND_QUAL, FromExpr::fromlist, IsA, j, lfirst, nodeTag, preprocess_expression(), preprocess_qual_conditions(), FromExpr::quals, and root.
Referenced by preprocess_qual_conditions(), and subquery_planner().
|
static |
Definition at line 2343 of file planner.c.
References PlanRowMark::allMarkTypes, Assert(), bms_del_member(), bms_is_member(), CheckSelectLocking(), CMD_DELETE, CMD_MERGE, CMD_UPDATE, get_relids_in_jointree(), i, PlanRowMark::isParent, lappend(), LCS_NONE, lfirst_node, linitial_node, LockWaitBlock, makeNode, PlanRowMark::markType, NIL, parse(), PlanRowMark::prti, root, PlanRowMark::rowmarkId, rt_fetch, RTE_RELATION, RangeTblEntry::rtekind, RowMarkClause::rti, PlanRowMark::rti, select_rowmark_type(), RowMarkClause::strength, PlanRowMark::strength, RowMarkClause::waitPolicy, and PlanRowMark::waitPolicy.
Referenced by subquery_planner().
|
static |
Definition at line 2306 of file planner.c.
References lappend(), lappend_int(), lfirst_int, lfirst_node, NIL, GroupingSetData::set, and SortGroupClause::tleSortGroupRef.
Referenced by consider_groupingsets_paths(), and preprocess_grouping_sets().
Definition at line 3080 of file planner.c.
References lappend_int(), lcons(), lfirst, list_concat(), list_copy(), list_delete_int(), list_difference_int(), list_free(), list_length(), list_member_int(), list_nth(), makeNode, NIL, GroupingSetData::set, and SortGroupClause::tleSortGroupRef.
Referenced by preprocess_grouping_sets().
|
static |
Definition at line 5856 of file planner.c.
References Assert(), common_prefix_cmp(), i, lappend(), lfirst_node, list_concat_unique(), list_copy(), list_length(), WindowFuncLists::maxWinRef, NIL, WindowClause::orderClause, palloc(), WindowClause::partitionClause, pfree(), qsort, root, WindowClauseSortData::uniqueOrder, WindowClauseSortData::wc, WindowFuncLists::windowFuncs, and WindowClause::winref.
Referenced by grouping_planner().
RowMarkType select_rowmark_type | ( | RangeTblEntry * | rte, |
LockClauseStrength | strength | ||
) |
Definition at line 2455 of file planner.c.
References elog, ERROR, GetFdwRoutineByRelId(), FdwRoutine::GetForeignRowMarkType, LCS_FORKEYSHARE, LCS_FORNOKEYUPDATE, LCS_FORSHARE, LCS_FORUPDATE, LCS_NONE, ROW_MARK_COPY, ROW_MARK_EXCLUSIVE, ROW_MARK_KEYSHARE, ROW_MARK_NOKEYEXCLUSIVE, ROW_MARK_REFERENCE, ROW_MARK_SHARE, RTE_RELATION, and RangeTblEntry::rtekind.
Referenced by expand_single_inheritance_child(), and preprocess_rowmarks().
PlannedStmt * standard_planner | ( | Query * | parse, |
const char * | query_string, | ||
int | cursorOptions, | ||
ParamListInfo | boundParams | ||
) |
Definition at line 302 of file planner.c.
References PlannerGlobal::allRelids, PlannerGlobal::appendRelations, PlannedStmt::appendRelations, Assert(), bms_difference(), PlannedStmt::canSetTag, CMD_SELECT, PlannedStmt::commandType, create_plan(), CURSOR_OPT_FAST_PLAN, CURSOR_OPT_PARALLEL_OK, CURSOR_OPT_SCROLL, cursor_tuple_fraction, DEBUG_PARALLEL_OFF, debug_parallel_query, DEBUG_PARALLEL_REGRESS, PlannerGlobal::dependsOnRole, PlannedStmt::dependsOnRole, DestroyPartitionDirectory(), ExecSupportsBackwardScan(), fetch_upper_rel(), PlannerGlobal::finalrowmarks, PlannerGlobal::finalrtable, PlannerGlobal::finalrteperminfos, PlannerGlobal::firstResultRels, PlannedStmt::firstResultRels, forboth, get_cheapest_fractional_path(), PlannedStmt::hasModifyingCTE, PlannedStmt::hasReturning, Plan::initPlan, PlannerGlobal::invalItems, PlannedStmt::invalItems, Gather::invisible, IsParallelWorker, IsUnderPostmaster, jit_above_cost, jit_enabled, jit_expressions, jit_inline_above_cost, jit_optimize_above_cost, jit_tuple_deforming, PlannedStmt::jitFlags, PlannerGlobal::lastPHId, PlannerGlobal::lastPlanNodeId, PlannerGlobal::lastRowMarkId, Plan::lefttree, lfirst, lfirst_node, list_length(), makeNode, materialize_finished_plan(), max_parallel_hazard(), max_parallel_workers_per_gather, PlannerGlobal::maxParallelHazard, NIL, Gather::num_workers, Plan::parallel_aware, Plan::parallel_safe, parallel_setup_cost, parallel_tuple_cost, PlannerGlobal::parallelModeNeeded, PlannedStmt::parallelModeNeeded, PlannerGlobal::parallelModeOK, PlannerGlobal::paramExecTypes, PlannedStmt::paramExecTypes, parse(), PlannerGlobal::partPruneInfos, PlannedStmt::partPruneInfos, PlannedStmt::permInfos, PGJIT_DEFORM, PGJIT_EXPR, PGJIT_INLINE, PGJIT_NONE, PGJIT_OPT3, PGJIT_PERFORM, Gather::plan, Plan::plan_rows, Plan::plan_width, PlannedStmt::planTree, PlannerGlobal::prunableRelids, Plan::qual, PlannedStmt::queryId, PlannerGlobal::relationOids, PlannedStmt::relationOids, Gather::rescan_param, PlannerGlobal::resultRelations, PlannedStmt::resultRelations, PlannerGlobal::rewindPlanIDs, PlannedStmt::rewindPlanIDs, Plan::righttree, root, PlannedStmt::rowMarks, PlannedStmt::rtable, set_plan_references(), Gather::single_copy, SS_compute_initplan_cost(), SS_finalize_plan(), Plan::startup_cost, PlannedStmt::stmt_len, PlannedStmt::stmt_location, PlannerGlobal::subpaths, PlannerGlobal::subplans, PlannedStmt::subplans, subquery_planner(), Plan::targetlist, Plan::total_cost, PlannerGlobal::transientPlan, PlannedStmt::transientPlan, PlannedStmt::unprunableRelids, UPPERREL_FINAL, and PlannedStmt::utilityStmt.
Referenced by delay_execution_planner(), pgss_planner(), and planner().
|
static |
Definition at line 3354 of file planner.c.
References standard_qp_extra::activeWindows, adjust_group_pathkeys_for_groupagg(), Assert(), generate_setop_child_grouplist(), grouping_is_sortable(), standard_qp_extra::gset_data, linitial_node, list_copy(), list_length(), make_pathkeys_for_sortclauses(), make_pathkeys_for_sortclauses_extended(), make_pathkeys_for_window(), NIL, parse(), grouping_sets_data::rollups, root, and standard_qp_extra::setop.
Referenced by grouping_planner().
PlannerInfo * subquery_planner | ( | PlannerGlobal * | glob, |
Query * | parse, | ||
PlannerInfo * | parent_root, | ||
bool | hasRecursion, | ||
double | tuple_fraction, | ||
SetOperationStmt * | setops | ||
) |
Definition at line 647 of file planner.c.
References generate_unaccent_rules::action, Assert(), assign_special_exec_param(), bms_is_member(), bms_make_singleton(), contain_agg_clause(), contain_subplans(), contain_volatile_functions(), copyObject, CurrentMemoryContext, WindowClause::endOffset, expand_virtual_generated_columns(), expression_returns_set(), EXPRKIND_APPINFO, EXPRKIND_ARBITER_ELEM, EXPRKIND_GROUPEXPR, EXPRKIND_LIMIT, EXPRKIND_QUAL, EXPRKIND_RTFUNC, EXPRKIND_RTFUNC_LATERAL, EXPRKIND_TABLEFUNC, EXPRKIND_TABLEFUNC_LATERAL, EXPRKIND_TABLESAMPLE, EXPRKIND_TARGET, EXPRKIND_VALUES, EXPRKIND_VALUES_LATERAL, fetch_upper_rel(), flatten_group_exprs(), flatten_join_alias_vars(), flatten_simple_union_all(), RangeTblEntry::functions, grouping_planner(), has_subclass(), RangeTblEntry::inh, IS_OUTER_JOIN, RangeTblEntry::jointype, lappend(), lfirst, lfirst_node, list_cell_number(), list_concat(), list_length(), list_make1, makeNode, Max, NIL, parse(), preprocess_expression(), preprocess_function_rtes(), preprocess_qual_conditions(), preprocess_rowmarks(), pull_up_sublinks(), pull_up_subqueries(), pull_varnos(), WithCheckOption::qual, PlannerInfo::query_level, reduce_outer_joins(), remove_useless_result_rtes(), replace_empty_jointree(), root, rt_fetch, RTE_FUNCTION, RTE_GROUP, RTE_JOIN, RTE_RELATION, RTE_RESULT, RTE_SUBQUERY, RTE_TABLEFUNC, RTE_VALUES, RangeTblEntry::rtekind, set_cheapest(), SS_charge_for_initplans(), SS_identify_outer_params(), SS_process_ctes(), WindowClause::startOffset, RangeTblEntry::subquery, RangeTblEntry::tablefunc, RangeTblEntry::tablesample, transform_MERGE_to_join(), UPPERREL_FINAL, and RangeTblEntry::values_lists.
Referenced by make_subplan(), recurse_set_operations(), set_subquery_pathlist(), SS_process_ctes(), and standard_planner().
create_upper_paths_hook_type create_upper_paths_hook = NULL |
Definition at line 76 of file planner.c.
Referenced by create_distinct_paths(), create_ordered_paths(), create_ordinary_grouping_paths(), create_partial_distinct_paths(), create_window_paths(), grouping_planner(), and postprocess_setop_rel().
double cursor_tuple_fraction = DEFAULT_CURSOR_TUPLE_FRACTION |
Definition at line 67 of file planner.c.
Referenced by standard_planner().
int debug_parallel_query = DEBUG_PARALLEL_OFF |
Definition at line 68 of file planner.c.
Referenced by ProcessParallelMessage(), query_planner(), and standard_planner().
bool enable_distinct_reordering = true |
Definition at line 70 of file planner.c.
Referenced by get_useful_pathkeys_for_distinct().
bool parallel_leader_participation = true |
Definition at line 69 of file planner.c.
Referenced by ExecGather(), ExecGatherMerge(), ExecInitGather(), and get_parallel_divisor().
planner_hook_type planner_hook = NULL |
Definition at line 73 of file planner.c.
Referenced by _PG_init(), and planner().