PostgreSQL Source Code
git master
|
#include "postgres.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 2739 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 157 of file initsplan.c.
References build_simple_rel(), elog, ERROR, FromExpr::fromlist, IsA, j, JoinTreeItem::jtnode, lfirst, nodeTag, and root.
Referenced by query_planner().
void add_other_rels_to_query | ( | PlannerInfo * | root | ) |
Definition at line 195 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 352 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 281 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 234 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 3183 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 3560 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 3588 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 3523 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 2694 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 1807 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().
void create_lateral_join_info | ( | PlannerInfo * | root | ) |
Definition at line 604 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 1223 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 1985 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 843 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 925 of file initsplan.c.
References Assert, bms_add_member(), bms_add_members(), bms_copy(), bms_make_singleton(), bms_union(), 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().
|
static |
Definition at line 2304 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 2226 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 2954 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().
|
static |
Definition at line 2814 of file initsplan.c.
References bms_is_empty, bms_is_member(), find_base_rel(), IsA, RelOptInfo::notnullattnums, root, Var::varattno, and Var::varno.
Referenced by restriction_is_always_false(), and restriction_is_always_true().
|
static |
Definition at line 465 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 417 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 3252 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 1467 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 1425 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 3358 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 3039 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 1375 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 3286 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 566 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().
bool restriction_is_always_false | ( | PlannerInfo * | root, |
RestrictInfo * | restrictinfo | ||
) |
Definition at line 2899 of file initsplan.c.
References NullTest::arg, Assert, RestrictInfo::clause, expr_is_nonnullable(), if(), IS_NULL, is_orclause(), IsA, lfirst, NullTest::nulltesttype, restriction_is_or_clause(), and root.
Referenced by add_base_clause_to_rel(), add_join_clause_to_rels(), and apply_child_basequals().
bool restriction_is_always_true | ( | PlannerInfo * | root, |
RestrictInfo * | restrictinfo | ||
) |
Definition at line 2850 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_or_clause(), and root.
Referenced by add_base_clause_to_rel(), add_join_clause_to_rels(), and apply_child_basequals().
int from_collapse_limit |
Definition at line 38 of file initsplan.c.
Referenced by deconstruct_recurse().
int join_collapse_limit |
Definition at line 39 of file initsplan.c.
Referenced by deconstruct_recurse().