PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/parallel.h"
#include "access/relscan.h"
#include "access/table.h"
#include "access/tableam.h"
#include "access/transam.h"
#include "executor/executor.h"
#include "executor/execPartition.h"
#include "jit/jit.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "parser/parsetree.h"
#include "partitioning/partdesc.h"
#include "storage/lmgr.h"
#include "utils/builtins.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/typcache.h"
Go to the source code of this file.
EState* CreateExecutorState | ( | void | ) |
Definition at line 90 of file execUtils.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, CurrentMemoryContext, EState::es_auxmodifytables, EState::es_crosscheck_snapshot, EState::es_direction, EState::es_exprcontexts, EState::es_finished, EState::es_instrument, EState::es_jit, EState::es_jit_flags, EState::es_junkFilter, EState::es_opened_result_relations, EState::es_output_cid, EState::es_param_exec_vals, EState::es_param_list_info, EState::es_per_tuple_exprcontext, EState::es_plannedstmt, EState::es_processed, EState::es_query_cxt, EState::es_queryEnv, EState::es_range_table, EState::es_range_table_size, EState::es_relations, EState::es_result_relations, EState::es_rowmarks, EState::es_snapshot, EState::es_sourceText, EState::es_subplanstates, EState::es_top_eflags, EState::es_trig_target_relations, EState::es_tuple_routing_result_relations, EState::es_tupleTable, EState::es_use_parallel_mode, ForwardScanDirection, InvalidSnapshot, makeNode, MemoryContextSwitchTo(), and NIL.
Referenced by afterTriggerInvokeEvents(), ATRewriteTable(), check_default_partition_contents(), compute_expr_stats(), compute_index_stats(), CopyFrom(), create_edata_for_relation(), create_estate_for_relation(), EvalPlanQualStart(), evaluate_expr(), ExecuteCallStmt(), ExecuteQuery(), ExecuteTruncateGuts(), ExplainExecuteQuery(), get_qual_for_range(), heapam_index_build_range_scan(), heapam_index_validate_scan(), IndexCheckExclusion(), make_build_data(), operator_predicate_proof(), plpgsql_create_econtext(), plpgsql_inline_handler(), standard_ExecutorStart(), StoreAttrDefault(), tuplesort_begin_cluster(), and validateDomainConstraint().
ExprContext* CreateExprContext | ( | EState * | estate | ) |
Definition at line 301 of file execUtils.c.
References ALLOCSET_DEFAULT_SIZES, and CreateExprContextInternal().
Referenced by ExecAssignExprContext(), ExecInitMergeJoin(), ExecInitSubPlan(), ExecuteCallStmt(), MakePerTupleExprContext(), and plpgsql_create_econtext().
|
static |
Definition at line 231 of file execUtils.c.
References AllocSetContextCreate, ExprContext::caseValue_datum, ExprContext::caseValue_isNull, ExprContext::domainValue_datum, ExprContext::domainValue_isNull, ExprContext::ecxt_aggnulls, ExprContext::ecxt_aggvalues, ExprContext::ecxt_callbacks, ExprContext::ecxt_estate, ExprContext::ecxt_innertuple, ExprContext::ecxt_outertuple, ExprContext::ecxt_param_exec_vals, ExprContext::ecxt_param_list_info, ExprContext::ecxt_per_query_memory, ExprContext::ecxt_per_tuple_memory, ExprContext::ecxt_scantuple, EState::es_exprcontexts, EState::es_param_exec_vals, EState::es_param_list_info, EState::es_query_cxt, lcons(), makeNode, and MemoryContextSwitchTo().
Referenced by CreateExprContext(), and CreateWorkExprContext().
ExprContext* CreateStandaloneExprContext | ( | void | ) |
Definition at line 352 of file execUtils.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, ExprContext::caseValue_datum, ExprContext::caseValue_isNull, CurrentMemoryContext, ExprContext::domainValue_datum, ExprContext::domainValue_isNull, ExprContext::ecxt_aggnulls, ExprContext::ecxt_aggvalues, ExprContext::ecxt_callbacks, ExprContext::ecxt_estate, ExprContext::ecxt_innertuple, ExprContext::ecxt_outertuple, ExprContext::ecxt_param_exec_vals, ExprContext::ecxt_param_list_info, ExprContext::ecxt_per_query_memory, ExprContext::ecxt_per_tuple_memory, ExprContext::ecxt_scantuple, and makeNode.
Referenced by BuildTupleHashTableExt(), domain_check_input(), and hypothetical_dense_rank_final().
ExprContext* CreateWorkExprContext | ( | EState * | estate | ) |
Definition at line 316 of file execUtils.c.
References ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE, ALLOCSET_DEFAULT_MINSIZE, CreateExprContextInternal(), and work_mem.
Referenced by ExecInitAgg().
Definition at line 480 of file execUtils.c.
References CreateExprContext(), and PlanState::ps_ExprContext.
Referenced by ExecInitAgg(), ExecInitBitmapHeapScan(), ExecInitBitmapIndexScan(), ExecInitCteScan(), ExecInitCustomScan(), ExecInitForeignScan(), ExecInitFunctionScan(), ExecInitGather(), ExecInitGatherMerge(), ExecInitGroup(), ExecInitHash(), ExecInitHashJoin(), ExecInitIndexOnlyScan(), ExecInitIndexScan(), ExecInitInsertProjection(), ExecInitLimit(), ExecInitMemoize(), ExecInitMerge(), ExecInitMergeJoin(), ExecInitModifyTable(), ExecInitNamedTuplestoreScan(), ExecInitNestLoop(), ExecInitPartitionPruning(), ExecInitProjectSet(), ExecInitResult(), ExecInitSampleScan(), ExecInitSeqScan(), ExecInitSetOp(), ExecInitSubqueryScan(), ExecInitTableFuncScan(), ExecInitTidRangeScan(), ExecInitTidScan(), ExecInitUnique(), ExecInitUpdateProjection(), ExecInitValuesScan(), ExecInitWindowAgg(), and ExecInitWorkTableScan().
Definition at line 535 of file execUtils.c.
References ExecBuildProjectionInfo(), PlanState::plan, PlanState::ps_ExprContext, PlanState::ps_ProjInfo, PlanState::ps_ResultTupleSlot, and Plan::targetlist.
Referenced by ExecConditionalAssignProjectionInfo(), ExecInitAgg(), ExecInitGroup(), ExecInitHashJoin(), ExecInitMergeJoin(), ExecInitNestLoop(), ExecInitResult(), and ExecInitWindowAgg().
Definition at line 670 of file execUtils.c.
References ExecSetSlotDescriptor(), and ScanState::ss_ScanTupleSlot.
Referenced by ExecWorkTableScan().
int ExecCleanTargetListLength | ( | List * | targetlist | ) |
Definition at line 1147 of file execUtils.c.
References len, lfirst_node, and TargetEntry::resjunk.
Referenced by check_sql_fn_retval(), and ExecTypeFromTLInternal().
Definition at line 555 of file execUtils.c.
References ExecAssignProjectionInfo(), ExecInitResultSlot(), PlanState::plan, PlanState::ps_ProjInfo, PlanState::ps_ResultTupleSlot, PlanState::resultops, PlanState::resultopsfixed, PlanState::resultopsset, PlanState::scanops, PlanState::scanopsfixed, PlanState::scanopsset, Plan::targetlist, tlist_matches_tupdesc(), and TTSOpsVirtual.
Referenced by ExecAssignScanProjectionInfo(), ExecAssignScanProjectionInfoWithVarno(), ExecInitGather(), and ExecInitGatherMerge().
void ExecCreateScanSlotFromOuterPlan | ( | EState * | estate, |
ScanState * | scanstate, | ||
const TupleTableSlotOps * | tts_ops | ||
) |
Definition at line 682 of file execUtils.c.
References ExecGetResultType(), ExecInitScanTupleSlot(), outerPlan, and outerPlanState.
Referenced by ExecInitAgg(), ExecInitGroup(), ExecInitIncrementalSort(), ExecInitMaterial(), ExecInitMemoize(), ExecInitSort(), and ExecInitWindowAgg().
void ExecFreeExprContext | ( | PlanState * | planstate | ) |
Definition at line 650 of file execUtils.c.
References PlanState::ps_ExprContext.
Referenced by ExecEndAgg(), ExecEndBitmapHeapScan(), ExecEndCteScan(), ExecEndCustomScan(), ExecEndForeignScan(), ExecEndFunctionScan(), ExecEndGather(), ExecEndGatherMerge(), ExecEndGroup(), ExecEndHash(), ExecEndHashJoin(), ExecEndIndexOnlyScan(), ExecEndIndexScan(), ExecEndLimit(), ExecEndMemoize(), ExecEndMergeJoin(), ExecEndModifyTable(), ExecEndNamedTuplestoreScan(), ExecEndNestLoop(), ExecEndProjectSet(), ExecEndResult(), ExecEndSampleScan(), ExecEndSeqScan(), ExecEndSetOp(), ExecEndSubqueryScan(), ExecEndTableFuncScan(), ExecEndTidRangeScan(), ExecEndTidScan(), ExecEndUnique(), ExecEndValuesScan(), ExecEndWindowAgg(), and ExecEndWorkTableScan().
Bitmapset* ExecGetAllUpdatedCols | ( | ResultRelInfo * | relinfo, |
EState * | estate | ||
) |
Definition at line 1347 of file execUtils.c.
References bms_union(), ExecGetExtraUpdatedCols(), and ExecGetUpdatedCols().
Referenced by ExecARUpdateTriggers(), ExecASUpdateTriggers(), ExecBRUpdateTriggers(), ExecBSUpdateTriggers(), and ExecUpdateLockMode().
TupleConversionMap* ExecGetChildToRootMap | ( | ResultRelInfo * | resultRelInfo | ) |
Definition at line 1234 of file execUtils.c.
References convert_tuples_by_name(), RelationGetDescr, ResultRelInfo::ri_ChildToRootMap, ResultRelInfo::ri_ChildToRootMapValid, ResultRelInfo::ri_RelationDesc, and ResultRelInfo::ri_RootResultRelInfo.
Referenced by adjust_partition_colnos(), AfterTriggerExecute(), AfterTriggerSaveEvent(), ExecCrossPartitionUpdate(), and TransitionTableAddTuple().
Bitmapset* ExecGetExtraUpdatedCols | ( | ResultRelInfo * | relinfo, |
EState * | estate | ||
) |
Definition at line 1321 of file execUtils.c.
References TupleConversionMap::attrMap, exec_rt_fetch(), execute_attr_map_cols(), RangeTblEntry::extraUpdatedCols, ResultRelInfo::ri_RangeTableIndex, ResultRelInfo::ri_RootResultRelInfo, and ResultRelInfo::ri_RootToPartitionMap.
Referenced by ExecComputeStoredGenerated(), ExecGetAllUpdatedCols(), and index_unchanged_by_update().
Bitmapset* ExecGetInsertedCols | ( | ResultRelInfo * | relinfo, |
EState * | estate | ||
) |
Definition at line 1256 of file execUtils.c.
References TupleConversionMap::attrMap, exec_rt_fetch(), execute_attr_map_cols(), RangeTblEntry::insertedCols, ResultRelInfo::ri_RangeTableIndex, ResultRelInfo::ri_RootResultRelInfo, and ResultRelInfo::ri_RootToPartitionMap.
Referenced by ExecConstraints(), ExecPartitionCheckEmitError(), and ExecWithCheckOptions().
Definition at line 782 of file execUtils.c.
References AccessShareLock, Assert(), CheckRelationLockedByMe(), EState::es_relations, exec_rt_fetch(), IsParallelWorker, NoLock, RangeTblEntry::relid, RangeTblEntry::rellockmode, RTE_RELATION, RangeTblEntry::rtekind, and table_open().
Referenced by CreatePartitionPruneState(), ExecInitResultRelation(), ExecOpenScanRelation(), and InitPlan().
const TupleTableSlotOps* ExecGetResultSlotOps | ( | PlanState * | planstate, |
bool * | isfixed | ||
) |
Definition at line 499 of file execUtils.c.
References PlanState::ps_ResultTupleSlot, PlanState::resultops, PlanState::resultopsfixed, PlanState::resultopsset, TTS_FIXED, TupleTableSlot::tts_ops, and TTSOpsVirtual.
Referenced by ExecComputeSlotInfo(), ExecInitAgg(), ExecInitGroup(), ExecInitHashJoin(), ExecInitLimit(), ExecInitLockRows(), ExecInitMergeJoin(), and ExecInitSubqueryScan().
Definition at line 490 of file execUtils.c.
References PlanState::ps_ResultTupleDesc.
Referenced by build_hash_table(), ExecComputeSlotInfo(), ExecCreateScanSlotFromOuterPlan(), ExecIncrementalSort(), ExecInitCteScan(), ExecInitGather(), ExecInitGatherMerge(), ExecInitGroup(), ExecInitHashJoin(), ExecInitIncrementalSort(), ExecInitLimit(), ExecInitMergeJoin(), ExecInitNestLoop(), ExecInitSetOp(), ExecInitSort(), ExecInitSubqueryScan(), ExecInitUnique(), ExecSort(), ExecWorkTableScan(), initialize_phase(), InitPlan(), and switchToPresortedPrefixMode().
TupleTableSlot* ExecGetReturningSlot | ( | EState * | estate, |
ResultRelInfo * | relInfo | ||
) |
Definition at line 1210 of file execUtils.c.
References EState::es_query_cxt, ExecInitExtraTupleSlot(), MemoryContextSwitchTo(), RelationGetDescr, ResultRelInfo::ri_RelationDesc, ResultRelInfo::ri_ReturningSlot, and table_slot_callbacks().
Referenced by apply_returning_filter(), ExecDelete(), and ExecInsert().
TupleTableSlot* ExecGetTriggerNewSlot | ( | EState * | estate, |
ResultRelInfo * | relInfo | ||
) |
Definition at line 1188 of file execUtils.c.
References EState::es_query_cxt, ExecInitExtraTupleSlot(), MemoryContextSwitchTo(), RelationGetDescr, ResultRelInfo::ri_RelationDesc, ResultRelInfo::ri_TrigNewSlot, and table_slot_callbacks().
Referenced by AfterTriggerExecute(), and AfterTriggerSaveEvent().
TupleTableSlot* ExecGetTriggerOldSlot | ( | EState * | estate, |
ResultRelInfo * | relInfo | ||
) |
Definition at line 1166 of file execUtils.c.
References EState::es_query_cxt, ExecInitExtraTupleSlot(), MemoryContextSwitchTo(), RelationGetDescr, ResultRelInfo::ri_RelationDesc, ResultRelInfo::ri_TrigOldSlot, and table_slot_callbacks().
Referenced by AfterTriggerExecute(), AfterTriggerSaveEvent(), ExecARDeleteTriggers(), ExecARUpdateTriggers(), ExecBRDeleteTriggers(), ExecBRUpdateTriggers(), ExecIRDeleteTriggers(), and ExecIRUpdateTriggers().
Bitmapset* ExecGetUpdatedCols | ( | ResultRelInfo * | relinfo, |
EState * | estate | ||
) |
Definition at line 1295 of file execUtils.c.
References TupleConversionMap::attrMap, exec_rt_fetch(), execute_attr_map_cols(), ResultRelInfo::ri_RangeTableIndex, ResultRelInfo::ri_RootResultRelInfo, ResultRelInfo::ri_RootToPartitionMap, and RangeTblEntry::updatedCols.
Referenced by ExecConstraints(), ExecGetAllUpdatedCols(), ExecPartitionCheckEmitError(), ExecWithCheckOptions(), and index_unchanged_by_update().
Definition at line 751 of file execUtils.c.
References EState::es_range_table, EState::es_range_table_size, EState::es_relations, EState::es_result_relations, EState::es_rowmarks, list_length(), and palloc0().
Referenced by CopyFrom(), create_edata_for_relation(), create_estate_for_relation(), and InitPlan().
void ExecInitResultRelation | ( | EState * | estate, |
ResultRelInfo * | resultRelInfo, | ||
Index | rti | ||
) |
Definition at line 834 of file execUtils.c.
References EState::es_instrument, EState::es_opened_result_relations, EState::es_range_table_size, EState::es_result_relations, ExecGetRangeTableRelation(), InitResultRelInfo(), lappend(), and palloc0().
Referenced by CopyFrom(), and ExecInitModifyTable().
Definition at line 720 of file execUtils.c.
References ereport, errcode(), errhint(), errmsg(), ERROR, EXEC_FLAG_EXPLAIN_ONLY, EXEC_FLAG_WITH_NO_DATA, ExecGetRangeTableRelation(), RelationGetRelationName, and RelationIsScannable.
Referenced by ExecInitBitmapHeapScan(), ExecInitCustomScan(), ExecInitForeignScan(), ExecInitIndexOnlyScan(), ExecInitIndexScan(), ExecInitSampleScan(), ExecInitSeqScan(), ExecInitTidRangeScan(), ExecInitTidScan(), and postgresBeginDirectModify().
Definition at line 707 of file execUtils.c.
References EState::es_plannedstmt, list_member_int(), and PlannedStmt::resultRelations.
int ExecTargetListLength | ( | List * | targetlist | ) |
Definition at line 1137 of file execUtils.c.
References list_length().
Referenced by ExecTypeFromTLInternal().
int executor_errposition | ( | EState * | estate, |
int | location | ||
) |
Definition at line 898 of file execUtils.c.
References errposition(), EState::es_sourceText, and pg_mbstrlen_with_len().
Referenced by ExecInitFunc(), ExecInitSubscriptingRef(), and init_sexpr().
void FreeExecutorState | ( | EState * | estate | ) |
Definition at line 186 of file execUtils.c.
References DestroyPartitionDirectory(), EState::es_exprcontexts, EState::es_jit, EState::es_partition_directory, EState::es_query_cxt, FreeExprContext(), jit_release_context(), linitial, and MemoryContextDelete().
Referenced by afterTriggerInvokeEvents(), ATRewriteTable(), check_default_partition_contents(), compute_expr_stats(), compute_index_stats(), CopyFrom(), EvalPlanQualEnd(), evaluate_expr(), ExecuteCallStmt(), ExecuteQuery(), ExecuteTruncateGuts(), ExplainExecuteQuery(), finish_edata(), get_qual_for_range(), heapam_index_build_range_scan(), heapam_index_validate_scan(), IndexCheckExclusion(), make_build_data(), operator_predicate_proof(), plpgsql_inline_handler(), plpgsql_xact_cb(), standard_ExecutorEnd(), StoreAttrDefault(), tuplesort_free(), and validateDomainConstraint().
void FreeExprContext | ( | ExprContext * | econtext, |
bool | isCommit | ||
) |
Definition at line 411 of file execUtils.c.
References ExprContext::ecxt_estate, ExprContext::ecxt_per_tuple_memory, EState::es_exprcontexts, list_delete_ptr(), MemoryContextDelete(), pfree(), and ShutdownExprContext().
Referenced by ExecEndBitmapIndexScan(), ExecEndIndexOnlyScan(), ExecEndIndexScan(), FreeExecutorState(), plpgsql_destroy_econtext(), and plpgsql_subxact_cb().
Datum GetAttributeByName | ( | HeapTupleHeader | tuple, |
const char * | attname, | ||
bool * | isNull | ||
) |
Definition at line 1023 of file execUtils.c.
References attname, elog(), ERROR, heap_getattr(), HeapTupleHeaderGetDatumLength, HeapTupleHeaderGetTypeId, HeapTupleHeaderGetTypMod, i, InvalidAttrNumber, InvalidOid, ItemPointerSetInvalid, lookup_rowtype_tupdesc(), namestrcmp(), TupleDescData::natts, ReleaseTupleDesc, HeapTupleData::t_data, HeapTupleData::t_len, HeapTupleData::t_self, HeapTupleData::t_tableOid, and TupleDescAttr.
Referenced by c_overpaid(), and overpaid().
Datum GetAttributeByNum | ( | HeapTupleHeader | tuple, |
AttrNumber | attrno, | ||
bool * | isNull | ||
) |
Definition at line 1086 of file execUtils.c.
References AttributeNumberIsValid, elog(), ERROR, heap_getattr(), HeapTupleHeaderGetDatumLength, HeapTupleHeaderGetTypeId, HeapTupleHeaderGetTypMod, InvalidOid, ItemPointerSetInvalid, lookup_rowtype_tupdesc(), ReleaseTupleDesc, HeapTupleData::t_data, HeapTupleData::t_len, HeapTupleData::t_self, and HeapTupleData::t_tableOid.
ExprContext* MakePerTupleExprContext | ( | EState * | estate | ) |
Definition at line 453 of file execUtils.c.
References CreateExprContext(), and EState::es_per_tuple_exprcontext.
void RegisterExprContextCallback | ( | ExprContext * | econtext, |
ExprContextCallbackFunction | function, | ||
Datum | arg | ||
) |
Definition at line 925 of file execUtils.c.
References arg, ExprContext_CB::arg, ExprContext::ecxt_callbacks, ExprContext::ecxt_per_query_memory, ExprContext_CB::function, MemoryContextAlloc(), and ExprContext_CB::next.
Referenced by AggRegisterCallback(), ExecMakeFunctionResultSet(), ExecPrepareTuplestoreResult(), fmgr_sql(), and init_MultiFuncCall().
void ReScanExprContext | ( | ExprContext * | econtext | ) |
Definition at line 438 of file execUtils.c.
References ExprContext::ecxt_per_tuple_memory, MemoryContextReset(), and ShutdownExprContext().
Referenced by agg_refill_hash_table(), agg_retrieve_direct(), domain_check_input(), ExecEndAgg(), ExecReScan(), ExecReScanAgg(), and ValuesNext().
|
static |
Definition at line 982 of file execUtils.c.
References ExprContext_CB::arg, ExprContext::ecxt_callbacks, ExprContext::ecxt_per_tuple_memory, ExprContext_CB::function, MemoryContextSwitchTo(), ExprContext_CB::next, and pfree().
Referenced by FreeExprContext(), and ReScanExprContext().
|
static |
Definition at line 582 of file execUtils.c.
References Assert(), IsA, lfirst, list_head(), lnext(), TupleDescData::natts, TupleDescAttr, Var::varattno, Var::varlevelsup, Var::varno, Var::vartype, and Var::vartypmod.
Referenced by ExecConditionalAssignProjectionInfo().
void UnregisterExprContextCallback | ( | ExprContext * | econtext, |
ExprContextCallbackFunction | function, | ||
Datum | arg | ||
) |
Definition at line 951 of file execUtils.c.
References arg, ExprContext_CB::arg, ExprContext::ecxt_callbacks, ExprContext_CB::function, ExprContext_CB::next, and pfree().
Referenced by end_MultiFuncCall(), and fmgr_sql().
Definition at line 864 of file execUtils.c.
References Plan::allParam, bms_free(), bms_intersect(), bms_is_empty(), bms_join(), PlanState::chgParam, and PlanState::plan.
Referenced by ExecReScan(), ExecReScanAppend(), ExecReScanBitmapAnd(), ExecReScanBitmapOr(), ExecReScanMergeAppend(), and ExecReScanSubqueryScan().