PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/transam.h"
#include "catalog/pg_type.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/optimizer.h"
#include "optimizer/pathnode.h"
#include "optimizer/planmain.h"
#include "optimizer/planner.h"
#include "optimizer/tlist.h"
#include "parser/parse_relation.h"
#include "tcop/utility.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
Go to the source code of this file.
Data Structures | |
struct | tlist_vinfo |
struct | indexed_tlist |
struct | fix_scan_expr_context |
struct | fix_join_expr_context |
struct | fix_upper_expr_context |
struct | fix_windowagg_cond_context |
struct | flatten_rtes_walker_context |
Macros | |
#define | NUM_EXEC_TLIST(parentplan) ((parentplan)->plan_rows) |
#define | NUM_EXEC_QUAL(parentplan) ((parentplan)->plan_rows * 2.0) |
#define | ISREGCLASSCONST(con) |
#define | fix_scan_list(root, lst, rtoffset, num_exec) ((List *) fix_scan_expr(root, (Node *) (lst), rtoffset, num_exec)) |
Enumerations | |
enum | NullingRelsMatch { NRM_EQUAL , NRM_SUBSET , NRM_SUPERSET } |
#define fix_scan_list | ( | root, | |
lst, | |||
rtoffset, | |||
num_exec | |||
) | ((List *) fix_scan_expr(root, (Node *) (lst), rtoffset, num_exec)) |
#define ISREGCLASSCONST | ( | con | ) |
#define NUM_EXEC_QUAL | ( | parentplan | ) | ((parentplan)->plan_rows * 2.0) |
#define NUM_EXEC_TLIST | ( | parentplan | ) | ((parentplan)->plan_rows) |
enum NullingRelsMatch |
|
static |
Definition at line 565 of file setrefs.c.
References addRTEPermissionInfo(), RangeTblEntry::colcollations, RangeTblEntry::coltypes, RangeTblEntry::coltypmods, PlannerGlobal::finalrtable, PlannerGlobal::finalrteperminfos, RangeTblEntry::functions, getRTEPermissionInfo(), RangeTblEntry::join_using_alias, RangeTblEntry::joinaliasvars, RangeTblEntry::joinleftcols, RangeTblEntry::joinrightcols, lappend(), lappend_oid(), NIL, OidIsValid, palloc(), RangeTblEntry::perminfoindex, PlannerGlobal::relationOids, RangeTblEntry::relid, RTE_RELATION, RTE_SUBQUERY, RangeTblEntry::rtekind, RangeTblEntry::securityQuals, RangeTblEntry::subquery, RangeTblEntry::tablefunc, RangeTblEntry::tablesample, and RangeTblEntry::values_lists.
Referenced by add_rtes_to_flat_rtable(), and flatten_rtes_walker().
|
static |
Definition at line 418 of file setrefs.c.
References add_rte_to_flat_rtable(), Assert(), fetch_upper_rel(), flatten_unplanned_rtes(), PlannerInfo::glob, RangeTblEntry::inh, IS_DUMMY_REL, lfirst, OidIsValid, PlannerInfo::parse, RangeTblEntry::relid, RelOptInfo::relid, Query::rtable, RTE_RELATION, RTE_SUBQUERY, RangeTblEntry::rtekind, RelOptInfo::subroot, and UPPERREL_FINAL.
Referenced by set_plan_references().
|
static |
Definition at line 2652 of file setrefs.c.
References TargetEntry::expr, indexed_tlist::has_non_vars, indexed_tlist::has_ph_vars, IsA, lfirst, list_length(), indexed_tlist::num_vars, palloc(), tlist_vinfo::resno, TargetEntry::resno, indexed_tlist::tlist, tlist_vinfo::varattno, Var::varattno, tlist_vinfo::varno, Var::varno, and indexed_tlist::vars.
Referenced by set_customscan_references(), set_foreignscan_references(), set_hash_references(), set_indexonlyscan_references(), set_join_references(), set_plan_refs(), set_upper_references(), and set_windowagg_runcondition_references().
|
static |
Definition at line 2705 of file setrefs.c.
References TargetEntry::expr, indexed_tlist::has_non_vars, indexed_tlist::has_ph_vars, if(), IsA, lfirst, list_length(), indexed_tlist::num_vars, palloc(), tlist_vinfo::resno, TargetEntry::resno, indexed_tlist::tlist, tlist_vinfo::varattno, Var::varattno, tlist_vinfo::varno, Var::varno, and indexed_tlist::vars.
Referenced by set_returning_clause_references().
Definition at line 1545 of file setrefs.c.
References apply_tlist_labeling(), Plan::initPlan, list_concat(), and Plan::targetlist.
Referenced by set_append_references(), set_mergeappend_references(), and set_subqueryscan_references().
Definition at line 2516 of file setrefs.c.
References Aggref::aggdistinct, Aggref::aggfilter, Aggref::aggorder, AGGSPLIT_FINAL_DESERIAL, AGGSPLIT_INITIAL_SERIAL, Aggref::args, Assert(), copyObject, expression_tree_mutator, IsA, list_make1, makeNode, makeTargetEntry(), mark_partial_aggref(), and NIL.
Referenced by set_plan_refs().
Definition at line 1914 of file setrefs.c.
References palloc().
Referenced by fix_join_expr_mutator(), fix_scan_expr_mutator(), and search_indexed_tlist_for_var().
void extract_query_dependencies | ( | Node * | query, |
List ** | relationOids, | ||
List ** | invalItems, | ||
bool * | hasRowSecurity | ||
) |
Definition at line 3482 of file setrefs.c.
References PlannerGlobal::dependsOnRole, extract_query_dependencies_walker(), PlannerInfo::glob, PlannerGlobal::invalItems, MemSet, NIL, and PlannerGlobal::relationOids.
Referenced by CompleteCachedPlan(), and RevalidateCachedQuery().
bool extract_query_dependencies_walker | ( | Node * | node, |
PlannerInfo * | context | ||
) |
Definition at line 3518 of file setrefs.c.
References Assert(), CMD_UTILITY, Query::commandType, PlannerGlobal::dependsOnRole, expression_tree_walker, fix_expr_common(), PlannerInfo::glob, IsA, lappend_oid(), lfirst, OidIsValid, query_tree_walker, PlannerGlobal::relationOids, RangeTblEntry::relid, Query::rtable, RTE_NAMEDTUPLESTORE, RTE_RELATION, RTE_SUBQUERY, RangeTblEntry::rtekind, UtilityContainsQuery(), and Query::utilityStmt.
Referenced by expression_planner_with_deps(), and extract_query_dependencies().
|
static |
Definition at line 2062 of file setrefs.c.
References Assert(), lfirst, NIL, SubPlan::per_call_cost, SubPlan::plan_id, SubPlan::startup_cost, and AlternativeSubPlan::subplans.
Referenced by fix_join_expr_mutator(), fix_scan_expr_mutator(), and fix_upper_expr_mutator().
|
static |
Definition at line 1936 of file setrefs.c.
References Assert(), DatumGetObjectId(), equal(), PlannerInfo::glob, IsA, ISREGCLASSCONST, lappend_int(), lappend_oid(), lfirst_int, NIL, OidIsValid, record_plan_function_dependency(), PlannerGlobal::relationOids, set_opfuncid(), and set_sa_opfuncid().
Referenced by extract_query_dependencies_walker(), fix_join_expr_mutator(), fix_scan_expr_mutator(), fix_scan_expr_walker(), and fix_upper_expr_mutator().
|
static |
Definition at line 2986 of file setrefs.c.
References fix_join_expr_context::acceptable_rel, fix_join_expr_mutator(), fix_join_expr_context::inner_itlist, fix_join_expr_context::nrm_match, fix_join_expr_context::num_exec, fix_join_expr_context::outer_itlist, fix_join_expr_context::root, and fix_join_expr_context::rtoffset.
Referenced by set_join_references(), set_plan_refs(), and set_returning_clause_references().
|
static |
Definition at line 3008 of file setrefs.c.
References fix_join_expr_context::acceptable_rel, copyVar(), elog(), ERROR, expression_tree_mutator, fix_alternative_subplan(), fix_expr_common(), fix_param_node(), indexed_tlist::has_non_vars, indexed_tlist::has_ph_vars, fix_join_expr_context::inner_itlist, INNER_VAR, IsA, fix_join_expr_context::nrm_match, fix_join_expr_context::num_exec, fix_join_expr_context::outer_itlist, OUTER_VAR, fix_join_expr_context::root, fix_join_expr_context::rtoffset, search_indexed_tlist_for_non_var(), search_indexed_tlist_for_phv(), search_indexed_tlist_for_var(), and Var::varno.
Referenced by fix_join_expr().
|
static |
Definition at line 2031 of file setrefs.c.
References copyObject, elog(), ERROR, list_length(), list_nth(), PlannerInfo::multiexpr_params, PARAM_MULTIEXPR, Param::paramid, and Param::paramkind.
Referenced by fix_join_expr_mutator(), fix_scan_expr_mutator(), and fix_upper_expr_mutator().
|
static |
Definition at line 2118 of file setrefs.c.
References fix_scan_expr_mutator(), fix_scan_expr_walker(), PlannerInfo::glob, PlannerInfo::hasAlternativeSubPlans, PlannerGlobal::lastPHId, PlannerInfo::minmax_aggs, PlannerInfo::multiexpr_params, NIL, fix_scan_expr_context::num_exec, fix_scan_expr_context::root, and fix_scan_expr_context::rtoffset.
Referenced by set_plan_refs().
|
static |
Definition at line 2153 of file setrefs.c.
References MinMaxAggInfo::aggfnoid, Aggref::aggfnoid, Aggref::args, Assert(), copyObject, copyVar(), CurrentOfExpr::cvarno, equal(), TargetEntry::expr, expression_tree_mutator, fix_alternative_subplan(), fix_expr_common(), fix_param_node(), INNER_VAR, IS_SPECIAL_VARNO, IsA, lfirst, linitial, list_length(), PlannerInfo::minmax_aggs, NIL, fix_scan_expr_context::num_exec, OUTER_VAR, MinMaxAggInfo::param, fix_scan_expr_context::root, ROWID_VAR, fix_scan_expr_context::rtoffset, MinMaxAggInfo::target, Var::varlevelsup, and Var::varno.
Referenced by fix_scan_expr().
|
static |
Definition at line 2227 of file setrefs.c.
References Assert(), expression_tree_walker, fix_expr_common(), IsA, fix_scan_expr_context::root, and ROWID_VAR.
Referenced by fix_scan_expr().
|
static |
Definition at line 3147 of file setrefs.c.
References fix_upper_expr_mutator(), fix_upper_expr_context::newvarno, fix_upper_expr_context::nrm_match, fix_upper_expr_context::num_exec, fix_upper_expr_context::root, fix_upper_expr_context::rtoffset, and fix_upper_expr_context::subplan_itlist.
Referenced by set_customscan_references(), set_foreignscan_references(), set_hash_references(), set_indexonlyscan_references(), set_join_references(), and set_upper_references().
|
static |
Definition at line 3167 of file setrefs.c.
References MinMaxAggInfo::aggfnoid, Aggref::aggfnoid, Aggref::args, copyObject, elog(), equal(), ERROR, TargetEntry::expr, expression_tree_mutator, fix_alternative_subplan(), fix_expr_common(), fix_param_node(), indexed_tlist::has_non_vars, indexed_tlist::has_ph_vars, IsA, lfirst, linitial, list_length(), PlannerInfo::minmax_aggs, fix_upper_expr_context::newvarno, NIL, fix_upper_expr_context::nrm_match, fix_upper_expr_context::num_exec, MinMaxAggInfo::param, fix_upper_expr_context::root, fix_upper_expr_context::rtoffset, search_indexed_tlist_for_non_var(), search_indexed_tlist_for_phv(), search_indexed_tlist_for_var(), fix_upper_expr_context::subplan_itlist, and MinMaxAggInfo::target.
Referenced by fix_upper_expr().
|
static |
Definition at line 3352 of file setrefs.c.
References fix_windowagg_condition_expr_mutator(), fix_windowagg_cond_context::newvarno, fix_windowagg_cond_context::root, and fix_windowagg_cond_context::subplan_itlist.
Referenced by set_windowagg_runcondition_references().
|
static |
Definition at line 3322 of file setrefs.c.
References elog(), ERROR, expression_tree_mutator, IsA, fix_windowagg_cond_context::newvarno, search_indexed_tlist_for_non_var(), and fix_windowagg_cond_context::subplan_itlist.
Referenced by fix_windowagg_condition_expr().
|
static |
Definition at line 519 of file setrefs.c.
References add_rte_to_flat_rtable(), expression_tree_walker, flatten_rtes_walker_context::glob, IsA, OidIsValid, QTW_EXAMINE_RTES_BEFORE, flatten_rtes_walker_context::query, query_tree_walker, RangeTblEntry::relid, RTE_RELATION, RTE_SUBQUERY, and RangeTblEntry::rtekind.
Referenced by flatten_unplanned_rtes().
|
static |
Definition at line 507 of file setrefs.c.
References flatten_rtes_walker(), QTW_EXAMINE_RTES_BEFORE, query_tree_walker, and RangeTblEntry::subquery.
Referenced by add_rtes_to_flat_rtable().
Definition at line 1892 of file setrefs.c.
References bms_add_member(), and bms_next_member().
Referenced by set_append_references(), set_customscan_references(), set_foreignscan_references(), set_mergeappend_references(), and set_plan_references().
void record_plan_function_dependency | ( | PlannerInfo * | root, |
Oid | funcid | ||
) |
Definition at line 3401 of file setrefs.c.
References PlanInvalItem::cacheId, FirstUnpinnedObjectId, GetSysCacheHashValue1, PlannerInfo::glob, PlanInvalItem::hashValue, PlannerGlobal::invalItems, lappend(), makeNode, ObjectIdGetDatum(), and PROCOID.
Referenced by fix_expr_common(), inline_function(), and inline_set_returning_function().
void record_plan_type_dependency | ( | PlannerInfo * | root, |
Oid | typid | ||
) |
Definition at line 3441 of file setrefs.c.
References PlanInvalItem::cacheId, FirstUnpinnedObjectId, GetSysCacheHashValue1, PlannerInfo::glob, PlanInvalItem::hashValue, PlannerGlobal::invalItems, lappend(), makeNode, ObjectIdGetDatum(), and TYPEOID.
Referenced by eval_const_expressions_mutator().
|
static |
Definition at line 2875 of file setrefs.c.
References IsA, makeVarFromTargetEntry(), indexed_tlist::tlist, and tlist_member().
Referenced by fix_join_expr_mutator(), fix_upper_expr_mutator(), and fix_windowagg_condition_expr_mutator().
|
static |
Definition at line 2826 of file setrefs.c.
References Assert(), bms_equal(), bms_is_subset(), TargetEntry::expr, if(), IsA, lfirst, makeVarFromTargetEntry(), NRM_SUBSET, NRM_SUPERSET, PlaceHolderVar::phid, PlaceHolderVar::phnullingrels, and indexed_tlist::tlist.
Referenced by fix_join_expr_mutator(), and fix_upper_expr_mutator().
|
static |
Definition at line 2915 of file setrefs.c.
References equal(), TargetEntry::expr, lfirst, makeVarFromTargetEntry(), TargetEntry::ressortgroupref, and indexed_tlist::tlist.
Referenced by set_upper_references().
|
static |
Definition at line 2765 of file setrefs.c.
References Assert(), bms_equal(), bms_is_subset(), copyVar(), i, NRM_SUBSET, NRM_SUPERSET, indexed_tlist::num_vars, tlist_vinfo::resno, tlist_vinfo::varattno, Var::varattno, tlist_vinfo::varno, Var::varno, and indexed_tlist::vars.
Referenced by fix_join_expr_mutator(), and fix_upper_expr_mutator().
|
static |
Definition at line 1729 of file setrefs.c.
References Append::appendplans, Append::apprelids, Assert(), clean_up_removed_plan_level(), PlannerInfo::glob, Plan::lefttree, lfirst, linitial, list_length(), NIL, offset_relid_set(), Plan::parallel_aware, Append::part_prune_index, PlannerGlobal::partPruneInfos, Append::plan, Plan::qual, Plan::righttree, set_dummy_tlist_references(), and set_plan_refs().
Referenced by set_plan_refs().
|
static |
Definition at line 1653 of file setrefs.c.
References build_tlist_index(), CustomScan::custom_plans, CustomScan::custom_relids, CustomScan::custom_scan_tlist, fix_scan_list, fix_upper_expr(), INDEX_VAR, lfirst, NIL, NRM_EQUAL, NUM_EXEC_QUAL, NUM_EXEC_TLIST, offset_relid_set(), pfree(), Plan::qual, CustomScan::scan, Scan::scanrelid, and set_plan_refs().
Referenced by set_plan_refs().
|
static |
Definition at line 2585 of file setrefs.c.
References TargetEntry::expr, exprCollation(), exprType(), exprTypmod(), flatCopyTargetEntry(), if(), IsA, lappend(), lfirst, makeVar(), NIL, OUTER_VAR, TargetEntry::resno, and Plan::targetlist.
Referenced by set_append_references(), set_hash_references(), set_mergeappend_references(), and set_plan_refs().
|
static |
Definition at line 1566 of file setrefs.c.
References build_tlist_index(), ForeignScan::fdw_scan_tlist, fix_scan_list, fix_upper_expr(), ForeignScan::fs_base_relids, ForeignScan::fs_relids, INDEX_VAR, NIL, NRM_EQUAL, NUM_EXEC_QUAL, NUM_EXEC_TLIST, offset_relid_set(), pfree(), Plan::qual, ForeignScan::resultRelation, ForeignScan::scan, and Scan::scanrelid.
Referenced by set_plan_refs().
|
static |
Definition at line 1859 of file setrefs.c.
References Assert(), build_tlist_index(), fix_upper_expr(), Hash::hashkeys, Plan::lefttree, NIL, NRM_EQUAL, NUM_EXEC_QUAL, OUTER_VAR, Plan::qual, set_dummy_tlist_references(), and Plan::targetlist.
Referenced by set_plan_refs().
|
static |
Definition at line 1332 of file setrefs.c.
References build_tlist_index(), fix_scan_list, fix_upper_expr(), INDEX_VAR, IndexOnlyScan::indexorderby, IndexOnlyScan::indexqual, IndexOnlyScan::indextlist, lappend(), lfirst, NIL, NRM_EQUAL, NUM_EXEC_QUAL, NUM_EXEC_TLIST, pfree(), IndexOnlyScan::recheckqual, IndexOnlyScan::scan, and Scan::scanrelid.
Referenced by set_plan_refs().
|
static |
Definition at line 2248 of file setrefs.c.
References build_tlist_index(), elog(), ERROR, fix_join_expr(), fix_upper_expr(), HashJoin::hashclauses, HashJoin::hashkeys, IsA, JOIN_INNER, Join::joinqual, Join::jointype, lfirst, MergeJoin::mergeclauses, NestLoop::nestParams, NRM_EQUAL, NRM_SUBSET, NRM_SUPERSET, NUM_EXEC_QUAL, NUM_EXEC_TLIST, OUTER_VAR, NestLoopParam::paramval, pfree(), Plan::targetlist, and Var::varno.
Referenced by set_plan_refs().
|
static |
Definition at line 1795 of file setrefs.c.
References MergeAppend::apprelids, Assert(), clean_up_removed_plan_level(), PlannerInfo::glob, Plan::lefttree, lfirst, linitial, list_length(), MergeAppend::mergeplans, NIL, offset_relid_set(), Plan::parallel_aware, MergeAppend::part_prune_index, PlannerGlobal::partPruneInfos, MergeAppend::plan, Plan::qual, Plan::righttree, set_dummy_tlist_references(), and set_plan_refs().
Referenced by set_plan_refs().
|
static |
Definition at line 2461 of file setrefs.c.
References Assert(), bms_add_member(), bms_intersect(), Plan::extParam, PlannerInfo::init_plans, IsA, Plan::lefttree, lfirst, lfirst_int, and SubPlan::setParam.
Referenced by set_plan_refs().
Plan* set_plan_references | ( | PlannerInfo * | root, |
Plan * | plan | ||
) |
Definition at line 289 of file setrefs.c.
References add_rtes_to_flat_rtable(), PlannerInfo::append_rel_list, PlannerGlobal::appendRelations, AppendRelInfo::child_relid, PlannerGlobal::finalrowmarks, PlannerGlobal::finalrtable, foreach_current_index, PlannerInfo::glob, PlannerInfo::hasAlternativeSubPlans, lappend(), lfirst, lfirst_node, list_length(), NIL, offset_relid_set(), palloc(), palloc0(), AppendRelInfo::parent_relid, PlannerGlobal::partPruneInfos, PlannerInfo::partPruneInfos, PlanRowMark::prti, PartitionPruneInfo::prune_infos, PartitionPruneInfo::root_parent_relids, PlannerInfo::rowMarks, PlanRowMark::rti, PartitionedRelPruneInfo::rtindex, set_plan_refs(), PlannerGlobal::subplans, and AppendRelInfo::translated_vars.
Referenced by set_subqueryscan_references(), and standard_planner().
|
static |
Definition at line 635 of file setrefs.c.
References generate_unaccent_rules::action, Agg::aggsplit, Assert(), build_tlist_index(), convert_combining_aggrefs(), copyObject, DO_AGGSPLIT_COMBINE, elog(), WindowAgg::endOffset, ERROR, TargetEntry::expr, fix_join_expr(), fix_scan_expr(), fix_scan_list, forboth, PlannerInfo::glob, if(), IsA, lappend(), lappend_int(), PlannerGlobal::lastPlanNodeId, lca(), Plan::lefttree, lfirst, lfirst_int, linitial, linitial_int, list_concat(), list_length(), makeNullConst(), NIL, nodeTag, NRM_EQUAL, NUM_EXEC_QUAL, NUM_EXEC_TLIST, outerPlan, Memoize::param_exprs, pfree(), Plan::plan_node_id, PlanRowMark::prti, PlannerGlobal::resultRelations, Plan::righttree, ROWID_VAR, PlanRowMark::rti, WindowAgg::runCondition, WindowAgg::runConditionOrig, set_append_references(), set_customscan_references(), set_dummy_tlist_references(), set_foreignscan_references(), set_hash_references(), set_indexonlyscan_references(), set_join_references(), set_mergeappend_references(), set_param_references(), set_returning_clause_references(), set_subqueryscan_references(), set_upper_references(), set_windowagg_runcondition_references(), splan, WindowAgg::startOffset, Plan::targetlist, and Var::varno.
Referenced by set_append_references(), set_customscan_references(), set_mergeappend_references(), and set_plan_references().
|
static |
Definition at line 3278 of file setrefs.c.
References build_tlist_index_other_vars(), fix_join_expr(), NRM_EQUAL, NUM_EXEC_TLIST, pfree(), and Plan::targetlist.
Referenced by set_plan_refs().
|
static |
Definition at line 1406 of file setrefs.c.
References clean_up_removed_plan_level(), find_base_rel(), fix_scan_list, NUM_EXEC_QUAL, NUM_EXEC_TLIST, Plan::qual, SubqueryScan::scan, Scan::scanrelid, set_plan_references(), SubqueryScan::subplan, RelOptInfo::subroot, and trivial_subqueryscan().
Referenced by set_plan_refs().
|
static |
Definition at line 2395 of file setrefs.c.
References build_tlist_index(), TargetEntry::expr, fix_upper_expr(), flatCopyTargetEntry(), lappend(), Plan::lefttree, lfirst, NIL, NRM_EQUAL, NUM_EXEC_QUAL, NUM_EXEC_TLIST, OUTER_VAR, pfree(), Plan::qual, TargetEntry::ressortgroupref, search_indexed_tlist_for_sortgroupref(), and Plan::targetlist.
Referenced by set_plan_refs().
|
static |
Definition at line 3373 of file setrefs.c.
References build_tlist_index(), fix_windowagg_condition_expr(), pfree(), and Plan::targetlist.
Referenced by set_plan_refs().
bool trivial_subqueryscan | ( | SubqueryScan * | plan | ) |
Definition at line 1475 of file setrefs.c.
References Assert(), equal(), TargetEntry::expr, forboth, IsA, lfirst, list_length(), NIL, SubqueryScan::scan, Scan::scanrelid, SubqueryScan::scanstatus, SubqueryScan::subplan, SUBQUERY_SCAN_NONTRIVIAL, SUBQUERY_SCAN_TRIVIAL, SUBQUERY_SCAN_UNKNOWN, Plan::targetlist, Var::varattno, Var::varlevelsup, and Var::varno.
Referenced by mark_async_capable_plan(), and set_subqueryscan_references().