PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <math.h>
#include "access/genam.h"
#include "access/htup_details.h"
#include "access/nbtree.h"
#include "access/sysattr.h"
#include "access/table.h"
#include "access/tableam.h"
#include "access/transam.h"
#include "access/xlog.h"
#include "catalog/catalog.h"
#include "catalog/heap.h"
#include "catalog/pg_am.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_statistic_ext.h"
#include "catalog/pg_statistic_ext_data.h"
#include "foreign/fdwapi.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "nodes/supportnodes.h"
#include "optimizer/cost.h"
#include "optimizer/optimizer.h"
#include "optimizer/plancat.h"
#include "parser/parse_relation.h"
#include "parser/parsetree.h"
#include "partitioning/partdesc.h"
#include "rewrite/rewriteManip.h"
#include "statistics/statistics.h"
#include "storage/bufmgr.h"
#include "tcop/tcopprot.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/partcache.h"
#include "utils/rel.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
Go to the source code of this file.
Variables | |
int | constraint_exclusion = CONSTRAINT_EXCLUSION_PARTITION |
get_relation_info_hook_type | get_relation_info_hook = NULL |
void add_function_cost | ( | PlannerInfo * | root, |
Oid | funcid, | ||
Node * | node, | ||
QualCost * | cost | ||
) |
Definition at line 2097 of file plancat.c.
References cpu_operator_cost, DatumGetPointer(), elog, ERROR, SupportRequestCost::funcid, GETSTRUCT, HeapTupleIsValid, SupportRequestCost::node, ObjectIdGetDatum(), OidFunctionCall1, OidIsValid, QualCost::per_tuple, SupportRequestCost::per_tuple, PointerGetDatum(), ReleaseSysCache(), root, SupportRequestCost::root, SearchSysCache1(), QualCost::startup, SupportRequestCost::startup, and SupportRequestCost::type.
Referenced by cost_qual_eval_walker(), cost_windowagg(), and get_agg_clause_costs().
|
static |
Definition at line 1893 of file plancat.c.
References elog, ERROR, FormData_pg_attribute, i, lappend(), lfirst, list_head(), lnext(), makeTargetEntry(), makeVar(), NIL, RelationData::rd_att, SystemAttributeDefinition(), and TupleDescAttr.
Referenced by get_relation_info().
List* build_physical_tlist | ( | PlannerInfo * | root, |
RelOptInfo * | rel | ||
) |
Definition at line 1772 of file plancat.c.
References elog, ERROR, expandRTE(), IsA, lappend(), lfirst, makeTargetEntry(), makeVar(), makeVarFromTargetEntry(), NIL, NoLock, planner_rt_fetch, RelationData::rd_att, RelationGetNumberOfAttributes, RangeTblEntry::relid, RelOptInfo::relid, TargetEntry::resno, root, RTE_CTE, RTE_FUNCTION, RTE_NAMEDTUPLESTORE, RTE_RELATION, RTE_RESULT, RTE_SUBQUERY, RTE_TABLEFUNC, RTE_VALUES, RangeTblEntry::rtekind, RangeTblEntry::subquery, table_close(), table_open(), Query::targetList, and TupleDescAttr.
Referenced by create_scan_plan().
void estimate_rel_size | ( | Relation | rel, |
int32 * | attr_widths, | ||
BlockNumber * | pages, | ||
double * | tuples, | ||
double * | allvisfrac | ||
) |
Definition at line 1066 of file plancat.c.
References get_rel_data_width(), if(), MAXALIGN, RelationData::rd_rel, RelationGetNumberOfBlocks, SizeofHeapTupleHeader, SizeOfPageHeaderData, and table_relation_estimate_size().
Referenced by get_relation_info(), hashbuild(), and plan_create_index_workers().
|
static |
Definition at line 2403 of file plancat.c.
References Assert, CurrentMemoryContext, fmgr_info_copy(), FmgrInfo::fn_oid, i, lappend(), lfirst, palloc(), palloc0(), PartitionSchemeData::partcollation, PartitionKeyData::partcollation, PartitionSchemeData::partnatts, PartitionKeyData::partnatts, PartitionSchemeData::partopcintype, PartitionKeyData::partopcintype, PartitionSchemeData::partopfamily, PartitionKeyData::partopfamily, PartitionSchemeData::partsupfunc, PartitionKeyData::partsupfunc, PartitionSchemeData::parttypbyval, PartitionKeyData::parttypbyval, PartitionSchemeData::parttyplen, PartitionKeyData::parttyplen, RelationGetPartitionKey(), root, PartitionSchemeData::strategy, and PartitionKeyData::strategy.
Referenced by set_relation_partition_info().
Selectivity function_selectivity | ( | PlannerInfo * | root, |
Oid | funcid, | ||
List * | args, | ||
Oid | inputcollid, | ||
bool | is_join, | ||
int | varRelid, | ||
JoinType | jointype, | ||
SpecialJoinInfo * | sjinfo | ||
) |
Definition at line 2035 of file plancat.c.
References generate_unaccent_rules::args, SupportRequestSelectivity::args, DatumGetPointer(), elog, ERROR, SupportRequestSelectivity::funcid, get_func_support(), SupportRequestSelectivity::inputcollid, SupportRequestSelectivity::is_join, SupportRequestSelectivity::jointype, OidFunctionCall1, PointerGetDatum(), root, SupportRequestSelectivity::root, SupportRequestSelectivity::selectivity, SupportRequestSelectivity::sjinfo, SupportRequestSelectivity::type, and SupportRequestSelectivity::varRelid.
Referenced by clause_selectivity_ext().
Bitmapset* get_dependent_generated_columns | ( | PlannerInfo * | root, |
Index | rti, | ||
Bitmapset * | target_cols | ||
) |
Definition at line 2325 of file plancat.c.
References AttrDefault::adbin, AttrDefault::adnum, bms_add_member(), bms_overlap(), TupleDescData::constr, TupleConstr::defval, FirstLowInvalidHeapAttributeNumber, TupleConstr::has_generated_stored, i, NoLock, TupleConstr::num_defval, planner_rt_fetch, pull_varattnos(), RelationGetDescr, RangeTblEntry::relid, root, stringToNode(), table_close(), table_open(), and TupleDescAttr.
Referenced by get_rel_all_updated_cols().
double get_function_rows | ( | PlannerInfo * | root, |
Oid | funcid, | ||
Node * | node | ||
) |
Definition at line 2158 of file plancat.c.
References Assert, DatumGetPointer(), elog, ERROR, SupportRequestRows::funcid, GETSTRUCT, HeapTupleIsValid, SupportRequestRows::node, ObjectIdGetDatum(), OidFunctionCall1, OidIsValid, PointerGetDatum(), ReleaseSysCache(), root, SupportRequestRows::root, SupportRequestRows::rows, SearchSysCache1(), and SupportRequestRows::type.
Referenced by expression_returns_set_rows().
Definition at line 1191 of file plancat.c.
References Assert, clamp_width_est(), get_attavgwidth(), get_typavgwidth(), i, RelationData::rd_att, RelationGetNumberOfAttributes, RelationGetRelid, and TupleDescAttr.
Referenced by estimate_rel_size(), get_relation_data_width(), and table_block_relation_estimate_size().
|
static |
Definition at line 1273 of file plancat.c.
References NullTest::arg, canonicalize_qual(), ConstrCheck::ccbin, ConstrCheck::ccnoinherit, ConstrCheck::ccvalid, ChangeVarNodes(), TupleConstr::check, TupleDescData::constr, eval_const_expressions(), TupleConstr::has_not_null, i, IS_NOT_NULL, lappend(), list_concat(), NullTest::location, make_ands_implicit(), makeNode, makeVar(), TupleDescData::natts, NIL, NoLock, NullTest::nulltesttype, TupleConstr::num_check, RelOptInfo::partition_qual, RelationData::rd_att, RelationData::rd_rel, RelOptInfo::relid, root, set_baserel_partition_constraint(), stringToNode(), table_close(), table_open(), and TupleDescAttr.
Referenced by relation_excluded_by_constraints().
Definition at line 1233 of file plancat.c.
References get_rel_data_width(), NoLock, table_close(), and table_open().
Referenced by plan_cluster_use_sort(), and set_rel_width().
|
static |
Definition at line 589 of file plancat.c.
References Assert, ForeignKeyOptInfo::con_relid, ForeignKeyCacheInfo::confrelid, ForeignKeyCacheInfo::conrelid, ForeignKeyOptInfo::eclass, ForeignKeyOptInfo::fk_eclass_member, RangeTblEntry::inh, lappend(), lfirst, list_length(), makeNode, ForeignKeyOptInfo::nconst_ec, ForeignKeyOptInfo::nkeys, ForeignKeyCacheInfo::nkeys, ForeignKeyOptInfo::nmatched_ec, ForeignKeyOptInfo::nmatched_rcols, ForeignKeyOptInfo::nmatched_ri, ForeignKeyOptInfo::ref_relid, RelationGetFKeyList(), RelationGetRelid, RangeTblEntry::relid, RelOptInfo::relid, RELOPT_BASEREL, RelOptInfo::reloptkind, ForeignKeyOptInfo::rinfos, root, RTE_RELATION, and RangeTblEntry::rtekind.
Referenced by get_relation_info().
void get_relation_info | ( | PlannerInfo * | root, |
Oid | relationObjectId, | ||
bool | inhparent, | ||
RelOptInfo * | rel | ||
) |
Definition at line 116 of file plancat.c.
References RelOptInfo::allvisfrac, IndexOptInfo::amcanmarkpos, IndexAmRoutine::amcanorder, IndexAmRoutine::amcanorderbyop, IndexOptInfo::amcanorderbyop, IndexAmRoutine::amcanparallel, IndexOptInfo::amcanparallel, IndexAmRoutine::amcostestimate, IndexOptInfo::amcostestimate, AMFLAG_HAS_TID_RANGE, RelOptInfo::amflags, IndexAmRoutine::amgetbitmap, IndexAmRoutine::amgettreeheight, IndexAmRoutine::amgettuple, IndexOptInfo::amhasgetbitmap, IndexOptInfo::amhasgettuple, IndexAmRoutine::ammarkpos, IndexAmRoutine::amoptionalkey, IndexOptInfo::amoptionalkey, IndexAmRoutine::amrestrpos, IndexAmRoutine::amsearcharray, IndexOptInfo::amsearcharray, IndexAmRoutine::amsearchnulls, IndexOptInfo::amsearchnulls, Assert, bms_add_member(), BTLessStrategyNumber, build_index_tlist(), ChangeVarNodes(), ereport, errcode(), errdetail_relkind_not_supported(), errmsg(), ERROR, estimate_rel_size(), FirstLowInvalidHeapAttributeNumber, FirstNormalObjectId, get_opfamily_member(), get_ordering_op_properties(), get_relation_foreign_keys(), get_relation_info_hook, get_relation_statistics(), GetFdwRoutineForRelation(), GetForeignServerIdByRelId(), HeapTupleHeaderGetXmin, IndexOptInfo::hypothetical, i, IgnoreSystemIndexes, IndexOptInfo::immediate, index_can_return(), index_close(), index_open(), RelOptInfo::indexlist, IndexOptInfo::indexoid, IndexOptInfo::indextlist, IndexOptInfo::indpred, IndexOptInfo::indrestrictinfo, InvalidOid, IsSystemRelation(), lcons(), lfirst_oid, list_free(), makeNode, RelOptInfo::max_attr, RelOptInfo::min_attr, TupleDescData::natts, IndexOptInfo::ncolumns, NIL, IndexOptInfo::nkeycolumns, NoLock, RelOptInfo::notnullattnums, OidIsValid, RelOptInfo::pages, IndexOptInfo::pages, palloc(), palloc0(), IndexOptInfo::predOK, RelationData::rd_att, RelationData::rd_indam, RelationData::rd_indcollation, RelationData::rd_index, RelationData::rd_indextuple, RelationData::rd_indoption, RelationData::rd_opcintype, RelationData::rd_opfamily, RelationData::rd_rel, RelationData::rd_tableam, RecoveryInProgress(), RelOptInfo::rel_parallel_workers, IndexOptInfo::relam, RelationGetForm, RelationGetIndexAttOptions(), RelationGetIndexExpressions(), RelationGetIndexList(), RelationGetIndexPredicate(), RelationGetNumberOfAttributes, RelationGetNumberOfBlocks, RelationGetParallelWorkers, RelationGetRelationName, RelationGetRelid, RelationIsPermanent, RelOptInfo::relid, RelOptInfo::reltablespace, IndexOptInfo::reltablespace, restrict_nonsystem_relation_kind, RESTRICT_RELKIND_FOREIGN_TABLE, root, TableAmRoutine::scan_bitmap_next_block, TableAmRoutine::scan_getnextslot_tidrange, TableAmRoutine::scan_set_tidrange, RelOptInfo::serverid, set_relation_partition_info(), RelOptInfo::statlist, HeapTupleData::t_data, table_close(), table_open(), TransactionIdPrecedes(), TransactionXmin, IndexOptInfo::tree_height, TupleDescAttr, RelOptInfo::tuples, IndexOptInfo::tuples, IndexOptInfo::unique, and unlikely.
Referenced by build_simple_rel().
|
static |
Definition at line 1476 of file plancat.c.
References bms_add_member(), bms_free(), ChangeVarNodes(), elog, ERROR, eval_const_expressions(), fix_opfuncids(), get_relation_statistics_worker(), GETSTRUCT, HeapTupleIsValid, i, lfirst_oid, list_free(), NIL, ObjectIdGetDatum(), pfree(), RelationGetStatExtList(), ReleaseSysCache(), RelOptInfo::relid, SearchSysCache1(), stringToNode(), SysCacheGetAttr(), and TextDatumGetCString.
Referenced by get_relation_info().
|
static |
Definition at line 1393 of file plancat.c.
References bms_copy(), BoolGetDatum(), StatisticExtInfo::exprs, GETSTRUCT, HeapTupleIsValid, StatisticExtInfo::inherit, StatisticExtInfo::keys, StatisticExtInfo::kind, lappend(), makeNode, ObjectIdGetDatum(), ReleaseSysCache(), SearchSysCache2(), statext_is_kind_built(), and StatisticExtInfo::statOid.
Referenced by get_relation_statistics().
bool has_row_triggers | ( | PlannerInfo * | root, |
Index | rti, | ||
CmdType | event | ||
) |
Definition at line 2248 of file plancat.c.
References CMD_DELETE, CMD_INSERT, CMD_MERGE, CMD_UPDATE, elog, ERROR, NoLock, planner_rt_fetch, RangeTblEntry::relid, root, table_close(), table_open(), TriggerDesc::trig_delete_after_row, TriggerDesc::trig_delete_before_row, TriggerDesc::trig_insert_after_row, TriggerDesc::trig_insert_before_row, TriggerDesc::trig_update_after_row, TriggerDesc::trig_update_before_row, and RelationData::trigdesc.
Referenced by make_modifytable().
bool has_stored_generated_columns | ( | PlannerInfo * | root, |
Index | rti | ||
) |
Definition at line 2298 of file plancat.c.
References TupleDescData::constr, TupleConstr::has_generated_stored, NoLock, planner_rt_fetch, RelationGetDescr, RangeTblEntry::relid, root, table_close(), and table_open().
Referenced by make_modifytable().
bool has_unique_index | ( | RelOptInfo * | rel, |
AttrNumber | attno | ||
) |
Definition at line 2216 of file plancat.c.
References RelOptInfo::indexlist, lfirst, and NIL.
Referenced by examine_variable().
List* infer_arbiter_indexes | ( | PlannerInfo * | root | ) |
Definition at line 704 of file plancat.c.
References OnConflictExpr::action, OnConflictExpr::arbiterElems, OnConflictExpr::arbiterWhere, bms_add_member(), bms_equal(), ChangeVarNodes(), OnConflictExpr::constraint, ereport, errcode(), errmsg(), ERROR, InferenceElem::expr, FirstLowInvalidHeapAttributeNumber, get_constraint_index(), if(), index_close(), index_open(), infer_collation_opclass_match(), InferenceElem::infercollid, InferenceElem::inferopclass, InvalidOid, IsA, lappend(), lappend_oid(), lfirst, lfirst_oid, list_difference(), list_free(), list_member(), next, NIL, NoLock, ONCONFLICT_UPDATE, predicate_implied_by(), RelationData::rd_index, RelationGetIndexExpressions(), RelationGetIndexList(), RelationGetIndexPredicate(), RangeTblEntry::relid, root, rt_fetch, table_close(), table_open(), and Var::varattno.
Referenced by make_modifytable().
|
static |
Definition at line 984 of file plancat.c.
References equal(), InferenceElem::expr, get_opclass_family(), get_opclass_input_type(), InferenceElem::infercollid, InferenceElem::inferopclass, InvalidOid, IsA, list_nth(), TupleDescData::natts, RelationData::rd_att, RelationData::rd_indcollation, RelationData::rd_index, RelationData::rd_opcintype, and RelationData::rd_opfamily.
Referenced by infer_arbiter_indexes().
Selectivity join_selectivity | ( | PlannerInfo * | root, |
Oid | operatorid, | ||
List * | args, | ||
Oid | inputcollid, | ||
JoinType | jointype, | ||
SpecialJoinInfo * | sjinfo | ||
) |
Definition at line 1994 of file plancat.c.
References generate_unaccent_rules::args, DatumGetFloat8(), elog, ERROR, get_oprjoin(), Int16GetDatum(), ObjectIdGetDatum(), OidFunctionCall5Coll(), PointerGetDatum(), and root.
Referenced by clause_selectivity_ext(), rowcomparesel(), and test_support_func().
bool relation_excluded_by_constraints | ( | PlannerInfo * | root, |
RelOptInfo * | rel, | ||
RangeTblEntry * | rte | ||
) |
Definition at line 1582 of file plancat.c.
References Assert, RelOptInfo::baserestrictinfo, RestrictInfo::clause, constraint_exclusion, CONSTRAINT_EXCLUSION_OFF, CONSTRAINT_EXCLUSION_ON, CONSTRAINT_EXCLUSION_PARTITION, contain_mutable_functions(), DatumGetBool(), get_relation_constraints(), RangeTblEntry::inh, IS_SIMPLE_REL, IsA, lappend(), lfirst, NIL, predicate_refuted_by(), RangeTblEntry::relid, RELOPT_BASEREL, RELOPT_OTHER_MEMBER_REL, RelOptInfo::reloptkind, root, RTE_RELATION, and RangeTblEntry::rtekind.
Referenced by set_append_rel_size(), and set_rel_size().
Selectivity restriction_selectivity | ( | PlannerInfo * | root, |
Oid | operatorid, | ||
List * | args, | ||
Oid | inputcollid, | ||
int | varRelid | ||
) |
Definition at line 1955 of file plancat.c.
References generate_unaccent_rules::args, DatumGetFloat8(), elog, ERROR, get_oprrest(), Int32GetDatum(), ObjectIdGetDatum(), OidFunctionCall4Coll(), PointerGetDatum(), and root.
Referenced by clause_selectivity_ext(), rowcomparesel(), and test_support_func().
|
static |
Definition at line 2578 of file plancat.c.
References ChangeVarNodes(), expression_planner(), RelOptInfo::partition_qual, RelationGetPartitionQual(), and RelOptInfo::relid.
Referenced by get_relation_constraints(), and set_relation_partition_info().
|
static |
Definition at line 2510 of file plancat.c.
References Assert, ChangeVarNodes(), copyObject, elog, ERROR, InvalidAttrNumber, IS_SIMPLE_REL, lfirst, list_head(), list_make1, lnext(), makeVar(), palloc(), palloc0(), PartitionKeyData::partattrs, PartitionKeyData::partexprs, PartitionKeyData::partnatts, PartitionKeyData::parttypcoll, PartitionKeyData::parttypid, PartitionKeyData::parttypmod, RelationGetPartitionKey(), and RelOptInfo::relid.
Referenced by set_relation_partition_info().
|
static |
Definition at line 2373 of file plancat.c.
References Assert, PartitionDescData::boundinfo, CreatePartitionDirectory(), CurrentMemoryContext, find_partition_scheme(), RelOptInfo::nparts, PartitionDescData::nparts, PartitionDirectoryLookup(), root, set_baserel_partition_constraint(), and set_baserel_partition_key_exprs().
Referenced by get_relation_info().
int constraint_exclusion = CONSTRAINT_EXCLUSION_PARTITION |
Definition at line 57 of file plancat.c.
Referenced by relation_excluded_by_constraints().
get_relation_info_hook_type get_relation_info_hook = NULL |
Definition at line 60 of file plancat.c.
Referenced by get_relation_info().