|
PostgreSQL Source Code git master
|
#include "postgres.h"#include "access/nbtree.h"#include "catalog/pg_constraint.h"#include "catalog/pg_type.h"#include "nodes/makefuncs.h"#include "nodes/nodeFuncs.h"#include "optimizer/clauses.h"#include "optimizer/cost.h"#include "optimizer/inherit.h"#include "optimizer/joininfo.h"#include "optimizer/optimizer.h"#include "optimizer/pathnode.h"#include "optimizer/paths.h"#include "optimizer/placeholder.h"#include "optimizer/planmain.h"#include "optimizer/planner.h"#include "optimizer/restrictinfo.h"#include "parser/analyze.h"#include "rewrite/rewriteManip.h"#include "utils/lsyscache.h"#include "utils/rel.h"#include "utils/typcache.h"
Go to the source code of this file.
Data Structures | |
| struct | JoinTreeItem |
Typedefs | |
| typedef struct JoinTreeItem | JoinTreeItem |
Variables | |
| int | from_collapse_limit |
| int | join_collapse_limit |
| typedef struct JoinTreeItem JoinTreeItem |
|
static |
Definition at line 3349 of file initsplan.c.
References Assert(), RelOptInfo::baserestrict_min_security, RelOptInfo::baserestrictinfo, bms_membership(), BMS_SINGLETON, find_base_rel(), RestrictInfo::has_clone, RestrictInfo::incompatible_relids, RangeTblEntry::inh, RestrictInfo::is_clone, RestrictInfo::is_pushed_down, lappend(), make_restrictinfo(), makeBoolConst(), Min, RestrictInfo::outer_relids, RestrictInfo::required_relids, restriction_is_always_false(), restriction_is_always_true(), RestrictInfo::rinfo_serial, root, and RestrictInfo::security_level.
Referenced by distribute_restrictinfo_to_rels().
| void add_base_rels_to_query | ( | PlannerInfo * | root, |
| Node * | jtnode | ||
| ) |
Definition at line 165 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 203 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 360 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 289 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 242 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 3789 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().
|
static |
Definition at line 4166 of file initsplan.c.
References generate_unaccent_rules::args, RestrictInfo::clause, contain_volatile_functions(), exprType(), is_opclause(), linitial, list_length(), and op_hashjoinable().
Referenced by build_implied_join_equality(), and distribute_restrictinfo_to_rels().
|
static |
Definition at line 4194 of file initsplan.c.
References generate_unaccent_rules::args, RestrictInfo::clause, TypeCacheEntry::eq_opr, exprType(), TypeCacheEntry::hash_proc, is_opclause(), linitial, list_length(), lookup_type_cache(), lsecond, OidIsValid, TYPECACHE_EQ_OPR, and TYPECACHE_HASH_PROC.
Referenced by build_implied_join_equality(), and distribute_restrictinfo_to_rels().
|
static |
Definition at line 4129 of file initsplan.c.
References generate_unaccent_rules::args, RestrictInfo::clause, contain_volatile_functions(), exprType(), get_mergejoin_opfamilies(), is_opclause(), linitial, list_length(), and op_mergejoinable().
Referenced by build_implied_join_equality(), distribute_qual_to_rels(), and process_implied_equality().
|
static |
Definition at line 3304 of file initsplan.c.
References bms_is_member(), find_forced_null_var(), JOIN_ANTI, SpecialJoinInfo::jointype, lfirst, SpecialJoinInfo::ojrelid, root, and JoinTreeItem::sjinfo.
Referenced by distribute_qual_to_rels().
|
static |
Definition at line 2417 of file initsplan.c.
References OpExpr::args, bms_is_empty, bms_is_subset(), bms_overlap(), bms_union(), contain_volatile_functions(), copyObject, enable_hashagg, exprType(), get_commutator(), get_mergejoin_opfamilies(), IsA, JOIN_SEMI, SpecialJoinInfo::jointype, lappend(), lappend_oid(), lfirst, linitial, list_length(), lsecond, NIL, OidIsValid, op_hashjoinable(), op_mergejoinable(), OpExpr::opno, pull_varnos(), root, SpecialJoinInfo::semi_can_btree, SpecialJoinInfo::semi_can_hash, SpecialJoinInfo::semi_operators, SpecialJoinInfo::semi_rhs_exprs, JoinTreeItem::sjinfo, and SpecialJoinInfo::syn_righthand.
Referenced by make_outerjoininfo().
|
static |
Definition at line 752 of file initsplan.c.
References AggClauseInfo::agg_eval_at, Aggref::aggdistinct, Aggref::aggfnoid, Aggref::aggorder, AggClauseInfo::aggref, Assert(), bms_add_members(), bms_is_subset(), castNode, get_func_leakproof(), IsA, lfirst, list_append_unique(), list_concat(), list_free(), list_free_deep(), makeNode, NIL, pull_var_clause(), pull_varnos(), PVC_INCLUDE_AGGREGATES, PVC_RECURSE_PLACEHOLDERS, PVC_RECURSE_WINDOWFUNCS, and root.
Referenced by setup_eager_aggregation().
|
static |
Definition at line 870 of file initsplan.c.
References Assert(), BTEQUALIMAGE_PROC, TypeCacheEntry::btree_opf, TypeCacheEntry::btree_opintype, copyObject, DatumGetBool(), GroupingExprInfo::expr, TargetEntry::expr, exprType(), forthree, get_eclass_for_sortgroupclause(), get_opfamily_proc(), get_sortgroupclause_tle(), IsA, lappend(), lappend_int(), lfirst, lfirst_int, lfirst_node, lookup_type_cache(), makeNode, NIL, ObjectIdGetDatum(), OidFunctionCall1Coll(), OidIsValid, TargetEntry::ressortgroupref, root, GroupingExprInfo::sortgroupref, TypeCacheEntry::typcollation, and TYPECACHE_BTREE_OPFAMILY.
Referenced by setup_eager_aggregation().
| void create_lateral_join_info | ( | PlannerInfo * | root | ) |
Definition at line 1214 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().
|
static |
Definition at line 1833 of file initsplan.c.
References bms_add_members(), bms_union(), SpecialJoinInfo::commute_below_l, SpecialJoinInfo::commute_below_r, distribute_quals_to_rels(), elog, ERROR, JoinTreeItem::inner_join_rels, IsA, j, JOIN_INNER, JOIN_LEFT, JOIN_SEMI, JoinTreeItem::jtnode, lappend(), JoinTreeItem::lateral_clauses, JoinTreeItem::left_rels, SpecialJoinInfo::lhs_strict, list_concat(), make_outerjoininfo(), SpecialJoinInfo::min_lefthand, SpecialJoinInfo::min_righthand, nodeTag, JoinTreeItem::nonnullable_rels, JoinTreeItem::oj_joinclauses, process_security_barrier_quals(), FromExpr::quals, JoinTreeItem::qualscope, JoinTreeItem::right_rels, root, and JoinTreeItem::sjinfo.
Referenced by deconstruct_jointree().
|
static |
Definition at line 2595 of file initsplan.c.
References add_nulling_relids(), Assert(), bms_add_member(), bms_copy(), bms_del_member(), bms_equal(), bms_is_empty, bms_is_member(), bms_make_singleton(), bms_union(), SpecialJoinInfo::commute_above_r, SpecialJoinInfo::commute_below_l, distribute_quals_to_rels(), lfirst, SpecialJoinInfo::lhs_strict, SpecialJoinInfo::min_lefthand, SpecialJoinInfo::min_righthand, JoinTreeItem::nonnullable_rels, JoinTreeItem::oj_joinclauses, SpecialJoinInfo::ojrelid, JoinTreeItem::qualscope, remove_nulling_relids(), root, JoinTreeItem::sjinfo, SpecialJoinInfo::syn_lefthand, and SpecialJoinInfo::syn_righthand.
Referenced by deconstruct_jointree().
| List * deconstruct_jointree | ( | PlannerInfo * | root | ) |
Definition at line 1453 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().
|
static |
Definition at line 1535 of file initsplan.c.
References Assert(), bms_add_member(), bms_add_members(), bms_copy(), bms_make_singleton(), bms_union(), deconstruct_recurse(), elog, ERROR, from_collapse_limit, FromExpr::fromlist, JoinTreeItem::inner_join_rels, IsA, j, JoinDomain::jd_relids, JoinTreeItem::jdomain, JOIN_ANTI, join_collapse_limit, JOIN_FULL, JOIN_INNER, JOIN_LEFT, JOIN_SEMI, JoinTreeItem::jti_parent, JoinTreeItem::jtnode, lappend(), JoinTreeItem::left_rels, lfirst, linitial, list_concat(), list_length(), list_make1, list_make2, llast, makeNode, mark_rels_nulled_by_join(), NIL, nodeTag, JoinTreeItem::nonnullable_rels, palloc0_object, JoinTreeItem::qualscope, remaining, JoinTreeItem::right_rels, and root.
Referenced by deconstruct_jointree(), and deconstruct_recurse().
|
static |
Definition at line 2914 of file initsplan.c.
References add_vars_to_targetlist(), Assert(), bms_copy(), bms_intersect(), bms_is_empty, bms_is_subset(), bms_membership(), BMS_MULTIPLE, bms_overlap(), check_mergejoinable(), check_redundant_nullability_qual(), contain_volatile_functions(), distribute_restrictinfo_to_rels(), elog, ERROR, initialize_mergeclause_eclasses(), JoinDomain::jd_relids, JoinTreeItem::jdomain, JOIN_FULL, SpecialJoinInfo::jointype, JoinTreeItem::jti_parent, lappend(), JoinTreeItem::lateral_clauses, linitial, list_free(), make_restrictinfo(), makeNode, process_equivalence(), pull_var_clause(), pull_varnos(), PVC_INCLUDE_PLACEHOLDERS, PVC_RECURSE_AGGREGATES, PVC_RECURSE_WINDOWFUNCS, JoinTreeItem::qualscope, OuterJoinClauseInfo::rinfo, root, JoinTreeItem::sjinfo, and OuterJoinClauseInfo::sjinfo.
Referenced by distribute_quals_to_rels().
|
static |
Definition at line 2836 of file initsplan.c.
References distribute_qual_to_rels(), lfirst, JoinTreeItem::qualscope, root, and JoinTreeItem::sjinfo.
Referenced by deconstruct_distribute(), deconstruct_distribute_oj_quals(), and process_security_barrier_quals().
| void distribute_restrictinfo_to_rels | ( | PlannerInfo * | root, |
| RestrictInfo * | restrictinfo | ||
| ) |
Definition at line 3560 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 add_non_redundant_clauses(), distribute_qual_to_rels(), generate_base_implied_equalities_broken(), generate_base_implied_equalities_const(), process_implied_equality(), reconsider_outer_join_clauses(), and remove_leftjoinrel_from_query().
|
static |
Definition at line 1075 of file initsplan.c.
References add_vars_to_targetlist(), Assert(), bms_make_singleton(), copyObject, RangeTblEntry::functions, IncrementVarSublevelsUp(), IsA, lappend(), RelOptInfo::lateral_vars, lfirst, list_free(), NIL, PlaceHolderVar::phlevelsup, preprocess_phv_expression(), pull_vars_of_level(), root, RTE_FUNCTION, RTE_RELATION, RTE_SUBQUERY, RTE_TABLEFUNC, RTE_VALUES, RangeTblEntry::rtekind, RangeTblEntry::subquery, RangeTblEntry::tablefunc, RangeTblEntry::tablesample, RangeTblEntry::values_lists, and Var::varlevelsup.
Referenced by find_lateral_references().
| void find_lateral_references | ( | PlannerInfo * | root | ) |
Definition at line 1027 of file initsplan.c.
References Assert(), extract_lateral_references(), RelOptInfo::relid, RELOPT_BASEREL, RelOptInfo::reloptkind, and root.
Referenced by query_planner().
|
static |
Definition at line 953 of file initsplan.c.
References COMPARE_EQ, elog, ERROR, exprCollation(), get_eclass_for_sort_expr(), get_mergejoin_opfamilies(), get_opfamily_member_for_cmptype(), get_ordering_op_properties(), OidIsValid, root, SortGroupClause::sortop, and SortGroupClause::tleSortGroupRef.
Referenced by create_grouping_expr_infos().
|
static |
Definition at line 3858 of file initsplan.c.
References bms_copy(), bms_del_member(), bms_del_members(), bms_equal(), bms_is_member(), JOIN_LEFT, SpecialJoinInfo::jointype, lfirst, SpecialJoinInfo::ojrelid, root, JoinTreeItem::sjinfo, and SpecialJoinInfo::syn_righthand.
Referenced by process_implied_equality().
|
static |
Definition at line 731 of file initsplan.c.
References AggTransInfo::aggtransspace, lfirst_node, and root.
Referenced by setup_eager_aggregation().
|
static |
Definition at line 2077 of file initsplan.c.
References Assert(), bms_add_member(), bms_add_members(), bms_copy(), bms_del_member(), bms_del_members(), bms_int_members(), bms_intersect(), bms_is_empty, bms_is_member(), bms_is_subset(), bms_overlap(), bms_union(), SpecialJoinInfo::commute_above_l, SpecialJoinInfo::commute_above_r, SpecialJoinInfo::commute_below_l, SpecialJoinInfo::commute_below_r, compute_semijoin_info(), contain_placeholder_references_to(), ereport, errcode(), errmsg(), ERROR, find_nonnullable_rels(), JoinTreeItem::inner_join_rels, JOIN_ANTI, JOIN_FULL, JOIN_INNER, JOIN_LEFT, JOIN_RIGHT, JOIN_SEMI, SpecialJoinInfo::jointype, LCS_asString(), JoinTreeItem::left_rels, lfirst, SpecialJoinInfo::lhs_strict, makeNode, SpecialJoinInfo::min_lefthand, SpecialJoinInfo::min_righthand, SpecialJoinInfo::ojrelid, PlaceHolderInfo::ph_eval_at, PlaceHolderInfo::ph_var, pull_varnos(), JoinTreeItem::right_rels, root, RowMarkClause::rti, JoinTreeItem::sjinfo, RowMarkClause::strength, SpecialJoinInfo::syn_lefthand, and SpecialJoinInfo::syn_righthand.
Referenced by deconstruct_distribute().
|
static |
Definition at line 2035 of file initsplan.c.
References Assert(), bms_add_member(), bms_is_member(), bms_next_member(), RelOptInfo::nulling_relids, and root.
Referenced by deconstruct_recurse().
| void match_foreign_keys_to_quals | ( | PlannerInfo * | root | ) |
Definition at line 3964 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().
| 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 3645 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().
|
static |
Definition at line 1985 of file initsplan.c.
References Assert(), distribute_quals_to_rels(), lfirst, JoinTreeItem::qualscope, and root.
Referenced by deconstruct_distribute().
| void rebuild_joinclause_attr_needed | ( | PlannerInfo * | root | ) |
Definition at line 3892 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_leftjoinrel_from_query(), and remove_self_join_rel().
| void rebuild_lateral_attr_needed | ( | PlannerInfo * | root | ) |
Definition at line 1176 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_leftjoinrel_from_query(), and remove_self_join_rel().
| void remove_useless_groupby_columns | ( | PlannerInfo * | root | ) |
Definition at line 419 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().
| bool restriction_is_always_false | ( | PlannerInfo * | root, |
| RestrictInfo * | restrictinfo | ||
| ) |
Definition at line 3489 of file initsplan.c.
References NullTest::arg, Assert(), RestrictInfo::clause, expr_is_nonnullable(), RestrictInfo::has_clone, if(), RestrictInfo::is_clone, 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 3424 of file initsplan.c.
References NullTest::arg, Assert(), RestrictInfo::clause, expr_is_nonnullable(), RestrictInfo::has_clone, if(), RestrictInfo::is_clone, 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().
| void setup_eager_aggregation | ( | PlannerInfo * | root | ) |
Definition at line 644 of file initsplan.c.
References bms_membership(), BMS_MULTIPLE, create_agg_clause_infos(), create_grouping_expr_infos(), enable_eager_aggregate, is_partial_agg_memory_risky(), NIL, and root.
Referenced by query_planner().
| int from_collapse_limit |
Definition at line 40 of file initsplan.c.
Referenced by deconstruct_recurse().
| int join_collapse_limit |
Definition at line 41 of file initsplan.c.
Referenced by deconstruct_recurse().