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/subselect.h"
#include "optimizer/tlist.h"
#include "parser/parse_relation.h"
#include "rewrite/rewriteManip.h"
#include "tcop/utility.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 538 of file setrefs.c.
References addRTEPermissionInfo(), PlannerGlobal::finalrtable, PlannerGlobal::finalrteperminfos, RangeTblEntry::functions, getRTEPermissionInfo(), lappend(), lappend_oid(), NIL, OidIsValid, palloc(), PlannerGlobal::relationOids, RangeTblEntry::relid, RTE_RELATION, RTE_SUBQUERY, RangeTblEntry::rtekind, 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 392 of file setrefs.c.
References add_rte_to_flat_rtable(), Assert, fetch_upper_rel(), flatten_unplanned_rtes(), RangeTblEntry::inh, IS_DUMMY_REL, lfirst, OidIsValid, RangeTblEntry::relid, RelOptInfo::relid, root, RTE_RELATION, RTE_SUBQUERY, RangeTblEntry::rtekind, RelOptInfo::subroot, and UPPERREL_FINAL.
Referenced by set_plan_references().
|
static |
Definition at line 2696 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, tlist_vinfo::varnullingrels, 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 2747 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, tlist_vinfo::varnullingrels, and indexed_tlist::vars.
Referenced by set_returning_clause_references().
Definition at line 1535 of file setrefs.c.
References apply_tlist_labeling(), Plan::initPlan, list_concat(), Plan::parallel_safe, SS_compute_initplan_cost(), Plan::startup_cost, Plan::targetlist, and Plan::total_cost.
Referenced by set_append_references(), set_mergeappend_references(), and set_subqueryscan_references().
Definition at line 2561 of file setrefs.c.
References Aggref::aggdistinct, Aggref::aggfilter, Aggref::aggorder, AGGSPLIT_FINAL_DESERIAL, AGGSPLIT_INITIAL_SERIAL, Aggref::args, Assert, context, copyObject, expression_tree_mutator, IsA, list_make1, makeNode, makeTargetEntry(), mark_partial_aggref(), and NIL.
Referenced by set_plan_refs().
Definition at line 1945 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 3557 of file setrefs.c.
References PlannerGlobal::dependsOnRole, extract_query_dependencies_walker(), PlannerGlobal::invalItems, MemSet, NIL, PlannerGlobal::relationOids, and root.
Referenced by CompleteCachedPlan(), and RevalidateCachedQuery().
bool extract_query_dependencies_walker | ( | Node * | node, |
PlannerInfo * | context | ||
) |
Definition at line 3593 of file setrefs.c.
References Assert, CMD_UTILITY, Query::commandType, context, expression_tree_walker, fix_expr_common(), CallStmt::funcexpr, IsA, lappend_oid(), lfirst, OidIsValid, CallStmt::outargs, query_tree_walker, 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().
Param* find_minmax_agg_replacement_param | ( | PlannerInfo * | root, |
Aggref * | aggref | ||
) |
Definition at line 3443 of file setrefs.c.
References MinMaxAggInfo::aggfnoid, Aggref::aggfnoid, Aggref::args, equal(), TargetEntry::expr, lfirst, linitial, list_length(), NIL, MinMaxAggInfo::param, root, and MinMaxAggInfo::target.
Referenced by finalize_primnode(), fix_scan_expr_mutator(), and fix_upper_expr_mutator().
|
static |
Definition at line 2093 of file setrefs.c.
References Assert, lfirst, NIL, SubPlan::per_call_cost, SubPlan::plan_id, root, 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 1967 of file setrefs.c.
References Assert, DatumGetObjectId(), equal(), IsA, ISREGCLASSCONST, lappend_int(), lappend_oid(), lfirst_int, NIL, OidIsValid, record_plan_function_dependency(), root, 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 3041 of file setrefs.c.
References context, fix_join_expr_mutator(), and root.
Referenced by set_join_references(), set_plan_refs(), and set_returning_clause_references().
|
static |
Definition at line 3063 of file setrefs.c.
References context, copyVar(), elog, ERROR, expression_tree_mutator, fix_alternative_subplan(), fix_expr_common(), fix_param_node(), INNER_VAR, IsA, OUTER_VAR, 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 2062 of file setrefs.c.
References copyObject, elog, ERROR, list_length(), list_nth(), PARAM_MULTIEXPR, Param::paramid, Param::paramkind, and root.
Referenced by fix_join_expr_mutator(), fix_scan_expr_mutator(), and fix_upper_expr_mutator().
|
static |
Definition at line 2149 of file setrefs.c.
References context, fix_scan_expr_mutator(), fix_scan_expr_walker(), NIL, and root.
Referenced by set_plan_refs().
|
static |
Definition at line 2184 of file setrefs.c.
References Assert, context, copyObject, copyVar(), CurrentOfExpr::cvarno, expression_tree_mutator, find_minmax_agg_replacement_param(), fix_alternative_subplan(), fix_expr_common(), fix_param_node(), INNER_VAR, IS_SPECIAL_VARNO, IsA, OUTER_VAR, ROWID_VAR, Var::varlevelsup, and Var::varno.
Referenced by fix_scan_expr().
|
static |
Definition at line 2249 of file setrefs.c.
References Assert, context, expression_tree_walker, fix_expr_common(), IsA, and ROWID_VAR.
Referenced by fix_scan_expr().
|
static |
Definition at line 3200 of file setrefs.c.
References context, fix_upper_expr_mutator(), and root.
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 3220 of file setrefs.c.
References context, copyObject, elog, ERROR, expression_tree_mutator, find_minmax_agg_replacement_param(), fix_alternative_subplan(), fix_expr_common(), fix_param_node(), IsA, search_indexed_tlist_for_non_var(), search_indexed_tlist_for_phv(), and search_indexed_tlist_for_var().
Referenced by fix_upper_expr().
|
static |
Definition at line 3395 of file setrefs.c.
References context, fix_windowagg_condition_expr_mutator(), and root.
Referenced by set_windowagg_runcondition_references().
|
static |
Definition at line 3365 of file setrefs.c.
References context, elog, ERROR, expression_tree_mutator, IsA, and search_indexed_tlist_for_non_var().
Referenced by fix_windowagg_condition_expr().
|
static |
Definition at line 493 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 481 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 1923 of file setrefs.c.
References bms_add_member(), and bms_next_member().
Referenced by set_append_references(), set_customscan_references(), set_foreignscan_references(), and set_mergeappend_references().
void record_plan_function_dependency | ( | PlannerInfo * | root, |
Oid | funcid | ||
) |
Definition at line 3476 of file setrefs.c.
References PlanInvalItem::cacheId, FirstUnpinnedObjectId, GetSysCacheHashValue1, PlanInvalItem::hashValue, lappend(), makeNode, ObjectIdGetDatum(), and root.
Referenced by fix_expr_common(), inline_function(), and inline_set_returning_function().
void record_plan_type_dependency | ( | PlannerInfo * | root, |
Oid | typid | ||
) |
Definition at line 3516 of file setrefs.c.
References PlanInvalItem::cacheId, FirstUnpinnedObjectId, GetSysCacheHashValue1, PlanInvalItem::hashValue, lappend(), makeNode, ObjectIdGetDatum(), and root.
Referenced by eval_const_expressions_mutator().
|
static |
Definition at line 2923 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 2870 of file setrefs.c.
References bms_equal(), bms_is_subset(), bmsToString(), elog, ERROR, 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 2963 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 2805 of file setrefs.c.
References bms_equal(), bms_is_subset(), bmsToString(), copyVar(), elog, ERROR, i, NRM_SUBSET, NRM_SUPERSET, indexed_tlist::num_vars, tlist_vinfo::resno, tlist_vinfo::varattno, Var::varattno, tlist_vinfo::varno, Var::varno, tlist_vinfo::varnullingrels, and indexed_tlist::vars.
Referenced by fix_join_expr_mutator(), and fix_upper_expr_mutator().
|
static |
Definition at line 1742 of file setrefs.c.
References Append::appendplans, Append::apprelids, Assert, clean_up_removed_plan_level(), Plan::lefttree, lfirst, linitial, list_length(), NIL, offset_relid_set(), Plan::parallel_aware, Append::part_prune_info, Append::plan, PartitionPruneInfo::prune_infos, Plan::qual, Plan::righttree, root, PartitionedRelPruneInfo::rtindex, set_dummy_tlist_references(), and set_plan_refs().
Referenced by set_plan_refs().
|
static |
Definition at line 1666 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, root, CustomScan::scan, Scan::scanrelid, and set_plan_refs().
Referenced by set_plan_refs().
|
static |
Definition at line 2629 of file setrefs.c.
References TargetEntry::expr, exprCollation(), exprType(), exprTypmod(), flatCopyTargetEntry(), if(), IsA, lappend(), lfirst, makeVar(), NIL, OUTER_VAR, plan, and TargetEntry::resno.
Referenced by set_append_references(), set_hash_references(), set_mergeappend_references(), and set_plan_refs().
|
static |
Definition at line 1579 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, root, ForeignScan::scan, and Scan::scanrelid.
Referenced by set_plan_refs().
|
static |
Definition at line 1890 of file setrefs.c.
References Assert, build_tlist_index(), fix_upper_expr(), Hash::hashkeys, NIL, NRM_EQUAL, NUM_EXEC_QUAL, OUTER_VAR, plan, root, set_dummy_tlist_references(), and Plan::targetlist.
Referenced by set_plan_refs().
|
static |
Definition at line 1322 of file setrefs.c.
References build_tlist_index(), fix_scan_list, fix_upper_expr(), INDEX_VAR, lappend(), lfirst, NIL, NRM_EQUAL, NUM_EXEC_QUAL, NUM_EXEC_TLIST, pfree(), plan, and root.
Referenced by set_plan_refs().
|
static |
Definition at line 2269 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(), root, Plan::targetlist, and Var::varno.
Referenced by set_plan_refs().
|
static |
Definition at line 1817 of file setrefs.c.
References MergeAppend::apprelids, Assert, clean_up_removed_plan_level(), Plan::lefttree, lfirst, linitial, list_length(), MergeAppend::mergeplans, NIL, offset_relid_set(), Plan::parallel_aware, MergeAppend::part_prune_info, MergeAppend::plan, PartitionPruneInfo::prune_infos, Plan::qual, Plan::righttree, root, PartitionedRelPruneInfo::rtindex, set_dummy_tlist_references(), and set_plan_refs().
Referenced by set_plan_refs().
|
static |
Definition at line 2506 of file setrefs.c.
References Assert, bms_add_member(), bms_intersect(), PlannerInfo::init_plans, IsA, lfirst, lfirst_int, plan, root, and SubPlan::setParam.
Referenced by set_plan_refs().
Plan* set_plan_references | ( | PlannerInfo * | root, |
Plan * | plan | ||
) |
Definition at line 288 of file setrefs.c.
References add_rtes_to_flat_rtable(), PlannerGlobal::appendRelations, AppendRelInfo::child_relid, PlannerGlobal::finalrowmarks, PlannerGlobal::finalrtable, foreach_current_index, lappend(), lfirst, lfirst_node, list_length(), NIL, palloc(), palloc0(), AppendRelInfo::parent_relid, plan, PlanRowMark::prti, root, PlanRowMark::rti, set_plan_refs(), PlannerGlobal::subplans, and AppendRelInfo::translated_vars.
Referenced by set_subqueryscan_references(), and standard_planner().
|
static |
Definition at line 609 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, forthree, if(), IsA, lappend(), lappend_int(), lca(), 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, PlanRowMark::prti, root, 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 3321 of file setrefs.c.
References build_tlist_index_other_vars(), fix_join_expr(), NRM_EQUAL, NUM_EXEC_TLIST, pfree(), root, and Plan::targetlist.
Referenced by set_plan_refs().
|
static |
Definition at line 1396 of file setrefs.c.
References clean_up_removed_plan_level(), find_base_rel(), fix_scan_list, NUM_EXEC_QUAL, NUM_EXEC_TLIST, plan, root, set_plan_references(), RelOptInfo::subroot, and trivial_subqueryscan().
Referenced by set_plan_refs().
|
static |
Definition at line 2418 of file setrefs.c.
References bms_make_singleton(), build_tlist_index(), TargetEntry::expr, fix_upper_expr(), flatCopyTargetEntry(), IsA, lappend(), lfirst, NIL, NRM_EQUAL, NUM_EXEC_QUAL, NUM_EXEC_TLIST, OUTER_VAR, pfree(), plan, remove_nulling_relids(), TargetEntry::ressortgroupref, root, search_indexed_tlist_for_sortgroupref(), and Plan::targetlist.
Referenced by set_plan_refs().
|
static |
Definition at line 3416 of file setrefs.c.
References build_tlist_index(), fix_windowagg_condition_expr(), pfree(), plan, and root.
Referenced by set_plan_refs().
bool trivial_subqueryscan | ( | SubqueryScan * | plan | ) |
Definition at line 1465 of file setrefs.c.
References Assert, equal(), TargetEntry::expr, forboth, IsA, lfirst, list_length(), NIL, plan, SUBQUERY_SCAN_NONTRIVIAL, SUBQUERY_SCAN_TRIVIAL, SUBQUERY_SCAN_UNKNOWN, Var::varattno, Var::varlevelsup, and Var::varno.
Referenced by mark_async_capable_plan(), and set_subqueryscan_references().