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 "executor/nodeModifyTable.h"
#include "jit/jit.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "parser/parsetree.h"
#include "parser/parse_relation.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 93 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_insert_pending_modifytables, EState::es_insert_pending_result_relations, 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_rteperminfos, EState::es_snapshot, EState::es_sourceText, EState::es_subplanstates, EState::es_top_eflags, EState::es_total_processed, 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(), fileIterateForeignScan(), 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 309 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 239 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 360 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 324 of file execUtils.c.
References ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE, ALLOCSET_DEFAULT_MINSIZE, CreateExprContextInternal(), and work_mem.
Referenced by ExecInitAgg().
Definition at line 488 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 543 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 652 of file execUtils.c.
References ExecSetSlotDescriptor(), and ScanState::ss_ScanTupleSlot.
Referenced by ExecWorkTableScan().
int ExecCleanTargetListLength | ( | List * | targetlist | ) |
Definition at line 1124 of file execUtils.c.
References len, and lfirst_node.
Referenced by ApplyRetrieveRule(), check_sql_fn_retval(), and ExecTypeFromTLInternal().
Definition at line 563 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 664 of file execUtils.c.
References ExecGetResultType(), ExecInitScanTupleSlot(), outerPlan, and outerPlanState.
Referenced by ExecInitAgg(), ExecInitGroup(), ExecInitIncrementalSort(), ExecInitMaterial(), ExecInitMemoize(), ExecInitSort(), and ExecInitWindowAgg().
Bitmapset* ExecGetAllUpdatedCols | ( | ResultRelInfo * | relinfo, |
EState * | estate | ||
) |
Definition at line 1329 of file execUtils.c.
References bms_union(), ExecGetExtraUpdatedCols(), ExecGetUpdatedCols(), GetPerTupleMemoryContext, and MemoryContextSwitchTo().
Referenced by ExecARUpdateTriggers(), ExecASUpdateTriggers(), ExecBRUpdateTriggers(), ExecBSUpdateTriggers(), and ExecUpdateLockMode().
TupleConversionMap* ExecGetChildToRootMap | ( | ResultRelInfo * | resultRelInfo | ) |
Definition at line 1211 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 1314 of file execUtils.c.
References CMD_UPDATE, ExecInitStoredGenerated(), ResultRelInfo::ri_extraUpdatedCols, and ResultRelInfo::ri_GeneratedExprsU.
Referenced by ExecGetAllUpdatedCols(), and index_unchanged_by_update().
Bitmapset* ExecGetInsertedCols | ( | ResultRelInfo * | relinfo, |
EState * | estate | ||
) |
Definition at line 1272 of file execUtils.c.
References TupleConversionMap::attrMap, ExecGetRootToChildMap(), execute_attr_map_cols(), GetResultRTEPermissionInfo(), RTEPermissionInfo::insertedCols, and ResultRelInfo::ri_RootResultRelInfo.
Referenced by ExecConstraints(), ExecPartitionCheckEmitError(), and ExecWithCheckOptions().
Definition at line 767 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().
Oid ExecGetResultRelCheckAsUser | ( | ResultRelInfo * | relInfo, |
EState * | estate | ||
) |
Definition at line 1400 of file execUtils.c.
References RTEPermissionInfo::checkAsUser, elog(), ERROR, GetResultRTEPermissionInfo(), GetUserId(), RelationGetRelid, and ResultRelInfo::ri_RelationDesc.
Referenced by create_foreign_modify().
const TupleTableSlotOps* ExecGetResultSlotOps | ( | PlanState * | planstate, |
bool * | isfixed | ||
) |
Definition at line 507 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 498 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 1187 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().
TupleConversionMap* ExecGetRootToChildMap | ( | ResultRelInfo * | resultRelInfo, |
EState * | estate | ||
) |
Definition at line 1237 of file execUtils.c.
References Assert(), build_attrmap_by_name_if_req(), convert_tuples_by_name_attrmap(), EState::es_query_cxt, MemoryContextSwitchTo(), RelationData::rd_rel, RelationGetDescr, ResultRelInfo::ri_RelationDesc, ResultRelInfo::ri_RootResultRelInfo, ResultRelInfo::ri_RootToChildMap, and ResultRelInfo::ri_RootToChildMapValid.
Referenced by apply_handle_tuple_routing(), CopyFrom(), ExecFindPartition(), ExecGetInsertedCols(), ExecGetUpdatedCols(), ExecInitPartitionInfo(), ExecInitRoutingInfo(), and ExecPrepareTupleRouting().
TupleTableSlot* ExecGetTriggerNewSlot | ( | EState * | estate, |
ResultRelInfo * | relInfo | ||
) |
Definition at line 1165 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 1143 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 1293 of file execUtils.c.
References TupleConversionMap::attrMap, ExecGetRootToChildMap(), execute_attr_map_cols(), GetResultRTEPermissionInfo(), ResultRelInfo::ri_RootResultRelInfo, and RTEPermissionInfo::updatedCols.
Referenced by ExecConstraints(), ExecGetAllUpdatedCols(), ExecInitStoredGenerated(), ExecPartitionCheckEmitError(), ExecWithCheckOptions(), and index_unchanged_by_update().
Definition at line 733 of file execUtils.c.
References EState::es_range_table, EState::es_range_table_size, EState::es_relations, EState::es_result_relations, EState::es_rowmarks, EState::es_rteperminfos, 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 819 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 702 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 689 of file execUtils.c.
References EState::es_plannedstmt, list_member_int(), and PlannedStmt::resultRelations.
int ExecTargetListLength | ( | List * | targetlist | ) |
Definition at line 1114 of file execUtils.c.
References list_length().
Referenced by ExecTypeFromTLInternal().
int executor_errposition | ( | EState * | estate, |
int | location | ||
) |
Definition at line 875 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 194 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(), freestate_cluster(), 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(), and validateDomainConstraint().
void FreeExprContext | ( | ExprContext * | econtext, |
bool | isCommit | ||
) |
Definition at line 419 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 FreeExecutorState(), plpgsql_destroy_econtext(), and plpgsql_subxact_cb().
Datum GetAttributeByName | ( | HeapTupleHeader | tuple, |
const char * | attname, | ||
bool * | isNull | ||
) |
Definition at line 1000 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 1063 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.
|
static |
Definition at line 1349 of file execUtils.c.
References EState::es_rteperminfos, exec_rt_fetch(), getRTEPermissionInfo(), ResultRelInfo::ri_RangeTableIndex, and ResultRelInfo::ri_RootResultRelInfo.
Referenced by ExecGetInsertedCols(), ExecGetResultRelCheckAsUser(), and ExecGetUpdatedCols().
ExprContext* MakePerTupleExprContext | ( | EState * | estate | ) |
Definition at line 461 of file execUtils.c.
References CreateExprContext(), and EState::es_per_tuple_exprcontext.
void RegisterExprContextCallback | ( | ExprContext * | econtext, |
ExprContextCallbackFunction | function, | ||
Datum | arg | ||
) |
Definition at line 902 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 446 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 959 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 590 of file execUtils.c.
References Assert(), IsA, lfirst, list_head(), lnext(), TupleDescData::natts, TupleDescAttr, Var::varattno, Var::varlevelsup, and Var::varno.
Referenced by ExecConditionalAssignProjectionInfo().
void UnregisterExprContextCallback | ( | ExprContext * | econtext, |
ExprContextCallbackFunction | function, | ||
Datum | arg | ||
) |
Definition at line 928 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 849 of file execUtils.c.
References Plan::allParam, bms_intersect(), bms_join(), PlanState::chgParam, and PlanState::plan.
Referenced by ExecReScan(), ExecReScanAppend(), ExecReScanBitmapAnd(), ExecReScanBitmapOr(), ExecReScanMergeAppend(), and ExecReScanSubqueryScan().