|
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/rewriteHandler.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.
Data Structures | |
| struct | NotnullHashEntry |
Typedefs | |
| typedef struct NotnullHashEntry | NotnullHashEntry |
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 2360 of file plancat.c.
References cpu_operator_cost, DatumGetPointer(), elog, ERROR, fb(), GETSTRUCT(), HeapTupleIsValid, ObjectIdGetDatum(), OidFunctionCall1, OidIsValid, QualCost::per_tuple, PointerGetDatum(), ReleaseSysCache(), root, SearchSysCache1(), QualCost::startup, and SupportRequestCost::type.
Referenced by cost_qual_eval_walker(), cost_windowagg(), and get_agg_clause_costs().
|
static |
Definition at line 2165 of file plancat.c.
References elog, ERROR, fb(), 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 2044 of file plancat.c.
References elog, ERROR, expandRTE(), fb(), IsA, lappend(), lfirst, makeTargetEntry(), makeVar(), makeVarFromTargetEntry(), NIL, NoLock, planner_rt_fetch, RelationData::rd_att, RelationGetNumberOfAttributes, RelOptInfo::relid, root, RTE_CTE, RTE_FUNCTION, RTE_NAMEDTUPLESTORE, RTE_RELATION, RTE_RESULT, RTE_SUBQUERY, RTE_TABLEFUNC, RTE_VALUES, table_close(), table_open(), Query::targetList, TupleDescAttr(), and VAR_RETURNING_DEFAULT.
Referenced by create_scan_plan().
| void estimate_rel_size | ( | Relation | rel, |
| int32 * | attr_widths, | ||
| BlockNumber * | pages, | ||
| double * | tuples, | ||
| double * | allvisfrac | ||
| ) |
Definition at line 1310 of file plancat.c.
References fb(), get_rel_data_width(), 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 2720 of file plancat.c.
References Assert, CurrentMemoryContext, fb(), fmgr_info_copy(), i, lappend(), lfirst, palloc0_object, palloc_array, RelationGetPartitionKey(), and root.
Referenced by set_relation_partition_info().
| Bitmapset * find_relation_notnullatts | ( | PlannerInfo * | root, |
| Oid | relid | ||
| ) |
Definition at line 777 of file plancat.c.
References fb(), HASH_FIND, hash_search(), NotnullHashEntry::notnullattnums, and root.
Referenced by get_relation_info(), and var_is_nonnullable().
| Selectivity function_selectivity | ( | PlannerInfo * | root, |
| Oid | funcid, | ||
| List * | args, | ||
| Oid | inputcollid, | ||
| bool | is_join, | ||
| int | varRelid, | ||
| JoinType | jointype, | ||
| SpecialJoinInfo * | sjinfo | ||
| ) |
Definition at line 2306 of file plancat.c.
References DatumGetPointer(), elog, ERROR, fb(), get_func_support(), OidFunctionCall1, PointerGetDatum(), root, and SupportRequestSelectivity::type.
Referenced by clause_selectivity_ext().
| Bitmapset * get_dependent_generated_columns | ( | PlannerInfo * | root, |
| Index | rti, | ||
| Bitmapset * | target_cols | ||
| ) |
Definition at line 2642 of file plancat.c.
References AttrDefault::adbin, AttrDefault::adnum, CompactAttribute::attgenerated, bms_add_member(), bms_overlap(), TupleDescData::constr, TupleConstr::defval, fb(), FirstLowInvalidHeapAttributeNumber, TupleConstr::has_generated_stored, i, NoLock, TupleConstr::num_defval, planner_rt_fetch, pull_varattnos(), RelationGetDescr, root, stringToNode(), table_close(), table_open(), and TupleDescCompactAttr().
Referenced by get_rel_all_updated_cols().
| double get_function_rows | ( | PlannerInfo * | root, |
| Oid | funcid, | ||
| Node * | node | ||
| ) |
Definition at line 2421 of file plancat.c.
References Assert, DatumGetPointer(), elog, ERROR, fb(), GETSTRUCT(), HeapTupleIsValid, ObjectIdGetDatum(), OidFunctionCall1, OidIsValid, PointerGetDatum(), ReleaseSysCache(), root, SearchSysCache1(), and SupportRequestRows::type.
Referenced by expression_returns_set_rows().
Definition at line 1435 of file plancat.c.
References Assert, clamp_width_est(), fb(), 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 1518 of file plancat.c.
References Assert, ATTNULLABLE_VALID, canonicalize_qual(), ConstrCheck::ccbin, ConstrCheck::ccenforced, ConstrCheck::ccnoinherit, ConstrCheck::ccvalid, ChangeVarNodes(), TupleConstr::check, TupleDescData::constr, eval_const_expressions(), expand_generated_columns_in_expr(), fb(), TupleConstr::has_not_null, i, IS_NOT_NULL, lappend(), list_concat(), Var::location, make_ands_implicit(), makeNode, makeVar(), TupleDescData::natts, NIL, NoLock, TupleConstr::num_check, RelOptInfo::partition_qual, RelationData::rd_att, RelationData::rd_rel, RelOptInfo::relid, root, set_baserel_partition_constraint(), stringToNode(), table_close(), table_open(), TupleDescAttr(), and TupleDescCompactAttr().
Referenced by relation_excluded_by_constraints().
Definition at line 1477 of file plancat.c.
References fb(), get_rel_data_width(), NoLock, table_close(), and table_open().
Referenced by plan_cluster_use_sort(), and set_rel_width().
|
static |
Definition at line 598 of file plancat.c.
References Assert, ForeignKeyOptInfo::con_relid, ForeignKeyOptInfo::eclass, fb(), ForeignKeyOptInfo::fk_eclass_member, lappend(), lfirst, list_length(), makeNode, ForeignKeyOptInfo::nconst_ec, ForeignKeyOptInfo::nkeys, ForeignKeyOptInfo::nmatched_ec, ForeignKeyOptInfo::nmatched_rcols, ForeignKeyOptInfo::nmatched_ri, ForeignKeyOptInfo::ref_relid, RelationGetFKeyList(), RelationGetRelid, RelOptInfo::relid, RELOPT_BASEREL, RelOptInfo::reloptkind, ForeignKeyOptInfo::rinfos, root, and RTE_RELATION.
Referenced by get_relation_info().
| void get_relation_info | ( | PlannerInfo * | root, |
| Oid | relationObjectId, | ||
| bool | inhparent, | ||
| RelOptInfo * | rel | ||
| ) |
Definition at line 124 of file plancat.c.
References RelOptInfo::allvisfrac, IndexOptInfo::amcanmarkpos, IndexOptInfo::amcanorderbyop, IndexOptInfo::amcanparallel, IndexOptInfo::amcostestimate, AMFLAG_HAS_TID_RANGE, RelOptInfo::amflags, IndexOptInfo::amhasgetbitmap, IndexOptInfo::amhasgettuple, IndexOptInfo::amoptionalkey, IndexOptInfo::amsearcharray, IndexOptInfo::amsearchnulls, Assert, build_index_tlist(), ChangeVarNodes(), COMPARE_LT, ereport, errcode(), errdetail_relkind_not_supported(), errmsg(), ERROR, estimate_rel_size(), eval_const_expressions(), fb(), find_relation_notnullatts(), FirstLowInvalidHeapAttributeNumber, FirstNormalObjectId, get_opfamily_member_for_cmptype(), 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(), make_ands_explicit(), make_ands_implicit(), makeNode, RelOptInfo::max_attr, RelOptInfo::min_attr, IndexOptInfo::ncolumns, NIL, IndexOptInfo::nkeycolumns, NoLock, RelOptInfo::notnullattnums, IndexOptInfo::nullsnotdistinct, OidIsValid, RelOptInfo::pages, IndexOptInfo::pages, palloc0(), palloc_array, IndexOptInfo::predOK, 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_tuple, 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, RelOptInfo::tuples, IndexOptInfo::tuples, IndexOptInfo::unique, and unlikely.
Referenced by build_simple_rel().
| void get_relation_notnullatts | ( | PlannerInfo * | root, |
| Relation | relation | ||
| ) |
Definition at line 704 of file plancat.c.
References Assert, CompactAttribute::attisdropped, CompactAttribute::attnullability, ATTNULLABLE_UNKNOWN, ATTNULLABLE_VALID, bms_add_member(), TupleDescData::constr, CurrentMemoryContext, fb(), TupleConstr::has_not_null, HASH_BLOBS, HASH_CONTEXT, hash_create(), HASH_ELEM, HASH_ENTER, hash_search(), i, HASHCTL::keysize, TupleDescData::natts, RelationData::rd_att, RelationGetRelid, root, and TupleDescCompactAttr().
Referenced by expand_single_inheritance_child(), and preprocess_relation_rtes().
|
static |
Definition at line 1743 of file plancat.c.
References bms_add_member(), bms_free(), ChangeVarNodes(), elog, ERROR, eval_const_expressions(), fb(), fix_opfuncids(), get_relation_statistics_worker(), GETSTRUCT(), HeapTupleIsValid, i, lfirst_oid, list_free(), NIL, ObjectIdGetDatum(), pfree(), RelationGetStatExtList(), ReleaseSysCache(), RelOptInfo::relid, root, SearchSysCache1(), stringToNode(), SysCacheGetAttr(), and TextDatumGetCString.
Referenced by get_relation_info().
|
static |
Definition at line 1660 of file plancat.c.
References bms_copy(), BoolGetDatum(), StatisticExtInfo::exprs, fb(), 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 2511 of file plancat.c.
References CMD_DELETE, CMD_INSERT, CMD_MERGE, CMD_UPDATE, elog, ERROR, fb(), NoLock, planner_rt_fetch, root, table_close(), table_open(), and RelationData::trigdesc.
Referenced by make_modifytable().
| bool has_stored_generated_columns | ( | PlannerInfo * | root, |
| Index | rti | ||
| ) |
Definition at line 2615 of file plancat.c.
References TupleDescData::constr, fb(), TupleConstr::has_generated_stored, NoLock, planner_rt_fetch, RelationGetDescr, root, table_close(), and table_open().
Referenced by make_modifytable().
| bool has_transition_tables | ( | PlannerInfo * | root, |
| Index | rti, | ||
| CmdType | event | ||
| ) |
Definition at line 2561 of file plancat.c.
References Assert, CMD_DELETE, CMD_INSERT, CMD_MERGE, CMD_UPDATE, elog, ERROR, fb(), NoLock, planner_rt_fetch, root, RTE_RELATION, table_close(), table_open(), and RelationData::trigdesc.
Referenced by make_modifytable().
| bool has_unique_index | ( | RelOptInfo * | rel, |
| AttrNumber | attno | ||
| ) |
Definition at line 2479 of file plancat.c.
References fb(), RelOptInfo::indexlist, lfirst, and NIL.
Referenced by examine_variable().
| List * infer_arbiter_indexes | ( | PlannerInfo * | root | ) |
Definition at line 816 of file plancat.c.
References OnConflictExpr::action, OnConflictExpr::arbiterElems, OnConflictExpr::arbiterWhere, Assert, bms_add_member(), bms_equal(), ChangeVarNodes(), OnConflictExpr::constraint, ereport, errcode(), errmsg(), ERROR, eval_const_expressions(), fb(), FirstLowInvalidHeapAttributeNumber, foreach_oid, foreach_ptr, get_constraint_index(), index_close(), index_open(), infer_collation_opclass_match(), InvalidAttrNumber, InvalidOid, IsA, lappend(), lappend_oid(), list_difference(), list_free(), list_member(), make_ands_explicit(), make_ands_implicit(), NIL, NoLock, OidIsValid, ONCONFLICT_UPDATE, predicate_implied_by(), RelationData::rd_rel, RelationGetIndexExpressions(), RelationGetIndexList(), RelationGetIndexPredicate(), root, rt_fetch, table_close(), table_open(), and Var::varattno.
Referenced by make_modifytable().
|
static |
Definition at line 1228 of file plancat.c.
References equal(), InferenceElem::expr, fb(), get_opclass_family(), get_opclass_input_type(), InferenceElem::infercollid, InferenceElem::inferopclass, InvalidOid, IsA, and list_nth().
Referenced by infer_arbiter_indexes().
| Selectivity join_selectivity | ( | PlannerInfo * | root, |
| Oid | operatorid, | ||
| List * | args, | ||
| Oid | inputcollid, | ||
| JoinType | jointype, | ||
| SpecialJoinInfo * | sjinfo | ||
| ) |
Definition at line 2266 of file plancat.c.
References DatumGetFloat8(), elog, ERROR, fb(), 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 1854 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(), fb(), get_relation_constraints(), IS_SIMPLE_REL, IsA, lappend(), lfirst, NIL, predicate_refuted_by(), RELOPT_BASEREL, RELOPT_OTHER_MEMBER_REL, RelOptInfo::reloptkind, root, and RTE_RELATION.
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 2227 of file plancat.c.
References DatumGetFloat8(), elog, ERROR, fb(), get_oprrest(), Int32GetDatum(), ObjectIdGetDatum(), OidFunctionCall4Coll(), PointerGetDatum(), and root.
Referenced by clause_selectivity_ext(), rowcomparesel(), and test_support_func().
|
static |
Definition at line 2894 of file plancat.c.
References ChangeVarNodes(), expression_planner(), fb(), RelOptInfo::partition_qual, RelationGetPartitionQual(), and RelOptInfo::relid.
Referenced by get_relation_constraints(), and set_relation_partition_info().
|
static |
Definition at line 2826 of file plancat.c.
References Assert, ChangeVarNodes(), copyObject, elog, ERROR, fb(), InvalidAttrNumber, IS_SIMPLE_REL, lfirst, list_head(), list_make1, lnext(), makeVar(), palloc0_array, palloc_array, RelationGetPartitionKey(), and RelOptInfo::relid.
Referenced by set_relation_partition_info().
|
static |
Definition at line 2690 of file plancat.c.
References Assert, PartitionDescData::boundinfo, CreatePartitionDirectory(), CurrentMemoryContext, fb(), 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 58 of file plancat.c.
Referenced by relation_excluded_by_constraints().
| get_relation_info_hook_type get_relation_info_hook = NULL |
Definition at line 61 of file plancat.c.
Referenced by get_relation_info().