execnodes.h
来自「PostgreSQL 8.2中增加了很多企业用户所需要的功能和性能上的提高,其开」· C头文件 代码 · 共 1,396 行 · 第 1/4 页
H
1,396 行
/*------------------------------------------------------------------------- * * execnodes.h * definitions for executor state nodes * * * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.161.2.2 2007/04/26 23:24:57 tgl Exp $ * *------------------------------------------------------------------------- */#ifndef EXECNODES_H#define EXECNODES_H#include "access/relscan.h"#include "nodes/params.h"#include "nodes/plannodes.h"#include "nodes/tidbitmap.h"#include "utils/hsearch.h"#include "utils/tuplestore.h"/* ---------------- * IndexInfo information * * this struct holds the information needed to construct new index * entries for a particular index. Used for both index_build and * retail creation of index entries. * * NumIndexAttrs number of columns in this index * KeyAttrNumbers underlying-rel attribute numbers used as keys * (zeroes indicate expressions) * Expressions expr trees for expression entries, or NIL if none * ExpressionsState exec state for expressions, or NIL if none * Predicate partial-index predicate, or NIL if none * PredicateState exec state for predicate, or NIL if none * Unique is it a unique index? * Concurrent are we doing a concurrent index build? * ---------------- */typedef struct IndexInfo{ NodeTag type; int ii_NumIndexAttrs; AttrNumber ii_KeyAttrNumbers[INDEX_MAX_KEYS]; List *ii_Expressions; /* list of Expr */ List *ii_ExpressionsState; /* list of ExprState */ List *ii_Predicate; /* list of Expr */ List *ii_PredicateState; /* list of ExprState */ bool ii_Unique; bool ii_Concurrent;} IndexInfo;/* ---------------- * ExprContext_CB * * List of callbacks to be called at ExprContext shutdown. * ---------------- */typedef void (*ExprContextCallbackFunction) (Datum arg);typedef struct ExprContext_CB{ struct ExprContext_CB *next; ExprContextCallbackFunction function; Datum arg;} ExprContext_CB;/* ---------------- * ExprContext * * This class holds the "current context" information * needed to evaluate expressions for doing tuple qualifications * and tuple projections. For example, if an expression refers * to an attribute in the current inner tuple then we need to know * what the current inner tuple is and so we look at the expression * context. * * There are two memory contexts associated with an ExprContext: * * ecxt_per_query_memory is a query-lifespan context, typically the same * context the ExprContext node itself is allocated in. This context * can be used for purposes such as storing function call cache info. * * ecxt_per_tuple_memory is a short-term context for expression results. * As the name suggests, it will typically be reset once per tuple, * before we begin to evaluate expressions for that tuple. Each * ExprContext normally has its very own per-tuple memory context. * * CurrentMemoryContext should be set to ecxt_per_tuple_memory before * calling ExecEvalExpr() --- see ExecEvalExprSwitchContext(). * ---------------- */typedef struct ExprContext{ NodeTag type; /* Tuples that Var nodes in expression may refer to */ TupleTableSlot *ecxt_scantuple; TupleTableSlot *ecxt_innertuple; TupleTableSlot *ecxt_outertuple; /* Memory contexts for expression evaluation --- see notes above */ MemoryContext ecxt_per_query_memory; MemoryContext ecxt_per_tuple_memory; /* Values to substitute for Param nodes in expression */ ParamExecData *ecxt_param_exec_vals; /* for PARAM_EXEC params */ ParamListInfo ecxt_param_list_info; /* for other param types */ /* Values to substitute for Aggref nodes in expression */ Datum *ecxt_aggvalues; /* precomputed values for Aggref nodes */ bool *ecxt_aggnulls; /* null flags for Aggref nodes */ /* Value to substitute for CaseTestExpr nodes in expression */ Datum caseValue_datum; bool caseValue_isNull; /* Value to substitute for CoerceToDomainValue nodes in expression */ Datum domainValue_datum; bool domainValue_isNull; /* Link to containing EState (NULL if a standalone ExprContext) */ struct EState *ecxt_estate; /* Functions to call back when ExprContext is shut down */ ExprContext_CB *ecxt_callbacks;} ExprContext;/* * Set-result status returned by ExecEvalExpr() */typedef enum{ ExprSingleResult, /* expression does not return a set */ ExprMultipleResult, /* this result is an element of a set */ ExprEndResult /* there are no more elements in the set */} ExprDoneCond;/* * Return modes for functions returning sets. Note values must be chosen * as separate bits so that a bitmask can be formed to indicate supported * modes. */typedef enum{ SFRM_ValuePerCall = 0x01, /* one value returned per call */ SFRM_Materialize = 0x02 /* result set instantiated in Tuplestore */} SetFunctionReturnMode;/* * When calling a function that might return a set (multiple rows), * a node of this type is passed as fcinfo->resultinfo to allow * return status to be passed back. A function returning set should * raise an error if no such resultinfo is provided. */typedef struct ReturnSetInfo{ NodeTag type; /* values set by caller: */ ExprContext *econtext; /* context function is being called in */ TupleDesc expectedDesc; /* tuple descriptor expected by caller */ int allowedModes; /* bitmask: return modes caller can handle */ /* result status from function (but pre-initialized by caller): */ SetFunctionReturnMode returnMode; /* actual return mode */ ExprDoneCond isDone; /* status for ValuePerCall mode */ /* fields filled by function in Materialize return mode: */ Tuplestorestate *setResult; /* holds the complete returned tuple set */ TupleDesc setDesc; /* actual descriptor for returned tuples */} ReturnSetInfo;/* ---------------- * ProjectionInfo node information * * This is all the information needed to perform projections --- * that is, form new tuples by evaluation of targetlist expressions. * Nodes which need to do projections create one of these. * * ExecProject() evaluates the tlist, forms a tuple, and stores it * in the given slot. Note that the result will be a "virtual" tuple * unless ExecMaterializeSlot() is then called to force it to be * converted to a physical tuple. The slot must have a tupledesc * that matches the output of the tlist! * * The planner very often produces tlists that consist entirely of * simple Var references (lower levels of a plan tree almost always * look like that). So we have an optimization to handle that case * with minimum overhead. * * targetlist target list for projection * exprContext expression context in which to evaluate targetlist * slot slot to place projection result in * itemIsDone workspace for ExecProject * isVarList TRUE if simple-Var-list optimization applies * varSlotOffsets array indicating which slot each simple Var is from * varNumbers array indicating attr numbers of simple Vars * lastInnerVar highest attnum from inner tuple slot (0 if none) * lastOuterVar highest attnum from outer tuple slot (0 if none) * lastScanVar highest attnum from scan tuple slot (0 if none) * ---------------- */typedef struct ProjectionInfo{ NodeTag type; List *pi_targetlist; ExprContext *pi_exprContext; TupleTableSlot *pi_slot; ExprDoneCond *pi_itemIsDone; bool pi_isVarList; int *pi_varSlotOffsets; int *pi_varNumbers; int pi_lastInnerVar; int pi_lastOuterVar; int pi_lastScanVar;} ProjectionInfo;/* ---------------- * JunkFilter * * This class is used to store information regarding junk attributes. * A junk attribute is an attribute in a tuple that is needed only for * storing intermediate information in the executor, and does not belong * in emitted tuples. For example, when we do an UPDATE query, * the planner adds a "junk" entry to the targetlist so that the tuples * returned to ExecutePlan() contain an extra attribute: the ctid of * the tuple to be updated. This is needed to do the update, but we * don't want the ctid to be part of the stored new tuple! So, we * apply a "junk filter" to remove the junk attributes and form the * real output tuple. * * targetList: the original target list (including junk attributes). * cleanTupType: the tuple descriptor for the "clean" tuple (with * junk attributes removed). * cleanMap: A map with the correspondence between the non-junk * attribute numbers of the "original" tuple and the * attribute numbers of the "clean" tuple. * resultSlot: tuple slot used to hold cleaned tuple. * ---------------- */typedef struct JunkFilter{ NodeTag type; List *jf_targetList; TupleDesc jf_cleanTupType; AttrNumber *jf_cleanMap; TupleTableSlot *jf_resultSlot;} JunkFilter;/* ---------------- * ResultRelInfo information * * Whenever we update an existing relation, we have to * update indices on the relation, and perhaps also fire triggers. * The ResultRelInfo class is used to hold all the information needed * about a result relation, including indices.. -cim 10/15/89 * * RangeTableIndex result relation's range table index * RelationDesc relation descriptor for result relation * NumIndices # of indices existing on result relation * IndexRelationDescs array of relation descriptors for indices * IndexRelationInfo array of key/attr info for indices * TrigDesc triggers to be fired, if any * TrigFunctions cached lookup info for trigger functions * TrigInstrument optional runtime measurements for triggers * ConstraintExprs array of constraint-checking expr states * junkFilter for removing junk attributes from tuples * projectReturning for computing a RETURNING list * ---------------- */typedef struct ResultRelInfo{ NodeTag type; Index ri_RangeTableIndex; Relation ri_RelationDesc; int ri_NumIndices; RelationPtr ri_IndexRelationDescs; IndexInfo **ri_IndexRelationInfo; TriggerDesc *ri_TrigDesc; FmgrInfo *ri_TrigFunctions; struct Instrumentation *ri_TrigInstrument; List **ri_ConstraintExprs; JunkFilter *ri_junkFilter; ProjectionInfo *ri_projectReturning;} ResultRelInfo;/* ---------------- * EState information * * Master working state for an Executor invocation * ---------------- */typedef struct EState{ NodeTag type; /* Basic state for all query types: */ ScanDirection es_direction; /* current scan direction */ Snapshot es_snapshot; /* time qual to use */ Snapshot es_crosscheck_snapshot; /* crosscheck time qual for RI */ List *es_range_table; /* List of RangeTableEntrys */ /* Info about target table for insert/update/delete queries: */ ResultRelInfo *es_result_relations; /* array of ResultRelInfos */ int es_num_result_relations; /* length of array */ ResultRelInfo *es_result_relation_info; /* currently active array elt */ JunkFilter *es_junkFilter; /* currently active junk filter */ TupleTableSlot *es_trig_tuple_slot; /* for trigger output tuples */ Relation es_into_relation_descriptor; /* for SELECT INTO */ bool es_into_relation_use_wal; /* Parameter info: */ ParamListInfo es_param_list_info; /* values of external params */ ParamExecData *es_param_exec_vals; /* values of internal params */ /* Other working state: */ MemoryContext es_query_cxt; /* per-query context in which EState lives */ TupleTable es_tupleTable; /* Array of TupleTableSlots */ uint32 es_processed; /* # of tuples processed */ Oid es_lastoid; /* last oid processed (by INSERT) */ List *es_rowMarks; /* not good place, but there is no other */ bool es_is_subquery; /* true if subquery (es_query_cxt not mine) */ bool es_instrument; /* true requests runtime instrumentation */ bool es_select_into; /* true if doing SELECT INTO */ bool es_into_oids; /* true to generate OIDs in SELECT INTO */ List *es_exprcontexts; /* List of ExprContexts within EState */ /* * this ExprContext is for per-output-tuple operations, such as constraint * checks and index-value computations. It will be reset for each output * tuple. Note that it will be created only if needed. */ ExprContext *es_per_tuple_exprcontext; /* Below is to re-evaluate plan qual in READ COMMITTED mode */ Plan *es_topPlan; /* link to top of plan tree */ struct evalPlanQual *es_evalPlanQual; /* chain of PlanQual states */ bool *es_evTupleNull; /* local array of EPQ status */ HeapTuple *es_evTuple; /* shared array of EPQ substitute tuples */ bool es_useEvalPlan; /* evaluating EPQ tuples? */} EState;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?