|
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 |
|
static |
Definition at line 3347 of file initsplan.c.
References Assert, RelOptInfo::baserestrict_min_security, RelOptInfo::baserestrictinfo, bms_membership(), BMS_SINGLETON, fb(), find_base_rel(), lappend(), make_restrictinfo(), makeBoolConst(), Min, restriction_is_always_false(), restriction_is_always_true(), and root.
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, fb(), 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(), fb(), 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, fb(), find_base_rel(), find_placeholder_info(), IsA, lfirst, RelOptInfo::min_attr, nodeTag, 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, fb(), find_base_rel(), find_placeholder_info(), IsA, lappend(), lfirst, RelOptInfo::min_attr, nodeTag, 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(), fb(), 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 3787 of file initsplan.c.
References check_hashjoinable(), check_memoizable(), check_mergejoinable(), copyObject, fb(), 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 4164 of file initsplan.c.
References contain_volatile_functions(), exprType(), fb(), is_opclause(), linitial, list_length(), and op_hashjoinable().
Referenced by build_implied_join_equality(), and distribute_restrictinfo_to_rels().
|
static |
Definition at line 4192 of file initsplan.c.
References TypeCacheEntry::eq_opr, exprType(), fb(), 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 4127 of file initsplan.c.
References contain_volatile_functions(), exprType(), fb(), 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 3302 of file initsplan.c.
References bms_is_member(), fb(), 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 2415 of file initsplan.c.
References OpExpr::args, bms_is_empty, bms_is_subset(), bms_overlap(), bms_union(), contain_volatile_functions(), copyObject, enable_hashagg, exprType(), fb(), 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 750 of file initsplan.c.
References Aggref::aggdistinct, Aggref::aggfnoid, Aggref::aggorder, Assert, bms_add_members(), bms_is_subset(), castNode, fb(), 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 868 of file initsplan.c.
References Assert, BTEQUALIMAGE_PROC, copyObject, DatumGetBool(), exprType(), fb(), 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, root, and TYPECACHE_BTREE_OPFAMILY.
Referenced by setup_eager_aggregation().
| void create_lateral_join_info | ( | PlannerInfo * | root | ) |
Definition at line 1212 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(), fb(), find_base_rel(), find_base_rel_ignore_join(), find_placeholder_info(), IsA, RelOptInfo::lateral_relids, lfirst, RELOPT_BASEREL, root, and Var::varno.
Referenced by query_planner().
|
static |
Definition at line 1831 of file initsplan.c.
References bms_add_members(), bms_union(), SpecialJoinInfo::commute_below_l, SpecialJoinInfo::commute_below_r, distribute_quals_to_rels(), elog, ERROR, fb(), IsA, j, JOIN_INNER, JOIN_LEFT, JOIN_SEMI, JoinTreeItem::jtnode, lappend(), SpecialJoinInfo::lhs_strict, list_concat(), make_outerjoininfo(), SpecialJoinInfo::min_lefthand, SpecialJoinInfo::min_righthand, nodeTag, process_security_barrier_quals(), FromExpr::quals, root, and JoinTreeItem::sjinfo.
Referenced by deconstruct_jointree().
|
static |
Definition at line 2593 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(), fb(), lfirst, SpecialJoinInfo::lhs_strict, SpecialJoinInfo::min_lefthand, SpecialJoinInfo::min_righthand, JoinTreeItem::nonnullable_rels, 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 1451 of file initsplan.c.
References Assert, bms_equal(), bms_union(), deconstruct_distribute(), deconstruct_distribute_oj_quals(), deconstruct_recurse(), fb(), IsA, lfirst, linitial_node, list_free_deep(), NIL, and root.
Referenced by query_planner().
|
static |
Definition at line 1533 of file initsplan.c.
References Assert, bms_add_member(), bms_add_members(), bms_copy(), bms_make_singleton(), bms_union(), deconstruct_recurse(), elog, ERROR, fb(), from_collapse_limit, FromExpr::fromlist, IsA, j, JOIN_ANTI, join_collapse_limit, JOIN_FULL, JOIN_INNER, JOIN_LEFT, JOIN_SEMI, JoinTreeItem::jtnode, lappend(), lfirst, linitial, list_concat(), list_length(), list_make1, list_make2, llast, makeNode, mark_rels_nulled_by_join(), NIL, nodeTag, palloc0_object, remaining, and root.
Referenced by deconstruct_jointree(), and deconstruct_recurse().
|
static |
Definition at line 2912 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, fb(), initialize_mergeclause_eclasses(), JOIN_FULL, SpecialJoinInfo::jointype, lappend(), linitial, list_free(), make_restrictinfo(), makeNode, process_equivalence(), pull_var_clause(), pull_varnos(), PVC_INCLUDE_PLACEHOLDERS, PVC_RECURSE_AGGREGATES, PVC_RECURSE_WINDOWFUNCS, JoinTreeItem::qualscope, root, and JoinTreeItem::sjinfo.
Referenced by distribute_quals_to_rels().
|
static |
Definition at line 2834 of file initsplan.c.
References distribute_qual_to_rels(), fb(), 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 3558 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, fb(), 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 1073 of file initsplan.c.
References add_vars_to_targetlist(), Assert, bms_make_singleton(), copyObject, fb(), IncrementVarSublevelsUp(), IsA, lappend(), lfirst, list_free(), NIL, preprocess_phv_expression(), pull_vars_of_level(), root, RTE_FUNCTION, RTE_RELATION, RTE_SUBQUERY, RTE_TABLEFUNC, RTE_VALUES, and Var::varlevelsup.
Referenced by find_lateral_references().
| void find_lateral_references | ( | PlannerInfo * | root | ) |
Definition at line 1025 of file initsplan.c.
References Assert, extract_lateral_references(), fb(), RELOPT_BASEREL, and root.
Referenced by query_planner().
|
static |
Definition at line 951 of file initsplan.c.
References COMPARE_EQ, elog, ERROR, exprCollation(), fb(), get_eclass_for_sort_expr(), get_mergejoin_opfamilies(), get_opfamily_member_for_cmptype(), get_ordering_op_properties(), OidIsValid, and root.
Referenced by create_grouping_expr_infos().
|
static |
Definition at line 3856 of file initsplan.c.
References bms_copy(), bms_del_member(), bms_del_members(), bms_equal(), bms_is_member(), fb(), JOIN_LEFT, SpecialJoinInfo::jointype, lfirst, SpecialJoinInfo::ojrelid, root, JoinTreeItem::sjinfo, and SpecialJoinInfo::syn_righthand.
Referenced by process_implied_equality().
|
static |
Definition at line 729 of file initsplan.c.
References fb(), lfirst_node, and root.
Referenced by setup_eager_aggregation().
|
static |
Definition at line 2075 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, fb(), 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, 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 2033 of file initsplan.c.
References Assert, bms_add_member(), bms_is_member(), bms_next_member(), fb(), RelOptInfo::nulling_relids, and root.
Referenced by deconstruct_recurse().
| void match_foreign_keys_to_quals | ( | PlannerInfo * | root | ) |
Definition at line 3962 of file initsplan.c.
References OpExpr::args, RestrictInfo::clause, EquivalenceClass::ec_has_const, fb(), get_commutator(), get_leftop(), get_rightop(), InvalidOid, IsA, lappend(), lfirst, list_length(), match_eclasses_to_foreign_key_col(), NIL, OidIsValid, OpExpr::opno, RELOPT_BASEREL, 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 3643 of file initsplan.c.
References add_vars_to_targetlist(), Assert, bms_is_empty, bms_is_subset(), bms_membership(), BMS_MULTIPLE, check_mergejoinable(), copyObject, DatumGetBool(), distribute_restrictinfo_to_rels(), eval_const_expressions(), fb(), 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 1983 of file initsplan.c.
References Assert, distribute_quals_to_rels(), fb(), lfirst, and root.
Referenced by deconstruct_distribute().
| void rebuild_joinclause_attr_needed | ( | PlannerInfo * | root | ) |
Definition at line 3890 of file initsplan.c.
References add_vars_to_attr_needed(), bms_add_member(), bms_intersect(), bms_is_member(), bms_membership(), BMS_MULTIPLE, RestrictInfo::clause, fb(), RestrictInfo::is_clone, lfirst, list_free(), pull_var_clause(), PVC_INCLUDE_PLACEHOLDERS, PVC_RECURSE_AGGREGATES, PVC_RECURSE_WINDOWFUNCS, RELOPT_BASEREL, 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 1174 of file initsplan.c.
References add_vars_to_attr_needed(), bms_make_singleton(), fb(), NIL, RELOPT_BASEREL, 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(), fb(), FirstLowInvalidHeapAttributeNumber, foreach_node, get_sortgroupclause_tle(), i, RelOptInfo::indexlist, IsA, lappend(), lfirst_node, list_length(), NIL, RelOptInfo::notnullattnums, palloc0_array, parse(), PG_INT32_MAX, root, RTE_RELATION, Var::varattno, Var::varlevelsup, and Var::varno.
Referenced by query_planner().
| bool restriction_is_always_false | ( | PlannerInfo * | root, |
| RestrictInfo * | restrictinfo | ||
| ) |
Definition at line 3487 of file initsplan.c.
References Assert, expr_is_nonnullable(), fb(), IS_NULL, is_orclause(), IsA, lfirst, 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 3422 of file initsplan.c.
References Assert, expr_is_nonnullable(), fb(), IS_NOT_NULL, is_orclause(), IsA, lfirst, 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 642 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().