execnodes.h

来自「PostgreSQL7.4.6 for Linux」· C头文件 代码 · 共 1,127 行 · 第 1/3 页

H
1,127
字号
 * Each executable expression tree has a parallel ExprState tree. * * Unlike PlanState, there is not an exact one-for-one correspondence between * ExprState node types and Expr node types.  Many Expr node types have no * need for node-type-specific run-time state, and so they can use plain * ExprState or GenericExprState as their associated ExprState node type. * ---------------------------------------------------------------- *//* ---------------- *		ExprState node * * ExprState is the common superclass for all ExprState-type nodes. * * It can also be instantiated directly for leaf Expr nodes that need no * local run-time state (such as Var, Const, or Param). * ---------------- */typedef struct ExprState{	NodeTag		type;	Expr	   *expr;			/* associated Expr node */} ExprState;/* ---------------- *		GenericExprState node * * This is used for Expr node types that need no local run-time state, * but have one child Expr node. * ---------------- */typedef struct GenericExprState{	ExprState	xprstate;	ExprState  *arg;			/* state of my child node */} GenericExprState;/* ---------------- *		AggrefExprState node * ---------------- */typedef struct AggrefExprState{	ExprState	xprstate;	ExprState  *target;			/* state of my child node */	int			aggno;			/* ID number for agg within its plan node */} AggrefExprState;/* ---------------- *		ArrayRefExprState node * * Note: array types can be fixed-length (typlen > 0), but only when the * element type is itself fixed-length.  Otherwise they are varlena structures * and have typlen = -1.  In any case, an array type is never pass-by-value. * ---------------- */typedef struct ArrayRefExprState{	ExprState	xprstate;	List	   *refupperindexpr;	/* states for child nodes */	List	   *reflowerindexpr;	ExprState  *refexpr;	ExprState  *refassgnexpr;	int16		refattrlength;	/* typlen of array type */	int16		refelemlength;	/* typlen of the array element type */	bool		refelembyval;	/* is the element type pass-by-value? */	char		refelemalign;	/* typalign of the element type */} ArrayRefExprState;/* ---------------- *		FuncExprState node * * Although named for FuncExpr, this is also used for OpExpr, DistinctExpr, * and NullIf nodes; be careful to check what xprstate.expr is actually * pointing at! * ---------------- */typedef struct FuncExprState{	ExprState	xprstate;	List	   *args;			/* states of argument expressions */	/*	 * Function manager's lookup info for the target function.  If	 * func.fn_oid is InvalidOid, we haven't initialized it yet.	 */	FmgrInfo	func;	/*	 * We also need to store argument values across calls when evaluating	 * a function-returning-set.	 *	 * setArgsValid is true when we are evaluating a set-valued function and	 * we are in the middle of a call series; we want to pass the same	 * argument values to the function again (and again, until it returns	 * ExprEndResult).	 */	bool		setArgsValid;	/*	 * Flag to remember whether we found a set-valued argument to the	 * function. This causes the function result to be a set as well.	 * Valid only when setArgsValid is true.	 */	bool		setHasSetArg;	/* some argument returns a set */	/*	 * Flag to remember whether we have registered a shutdown callback for	 * this FuncExprState.  We do so only if setArgsValid has been true at	 * least once (since all the callback is for is to clear setArgsValid).	 */	bool		shutdown_reg;	/* a shutdown callback is registered */	/*	 * Current argument data for a set-valued function; contains valid	 * data only if setArgsValid is true.	 */	FunctionCallInfoData setArgs;} FuncExprState;/* ---------------- *		ScalarArrayOpExprState node * * This is a FuncExprState plus some additional data. * ---------------- */typedef struct ScalarArrayOpExprState{	FuncExprState fxprstate;	/* Cached info about array element type */	Oid			element_type;	int16		typlen;	bool		typbyval;	char		typalign;} ScalarArrayOpExprState;/* ---------------- *		BoolExprState node * ---------------- */typedef struct BoolExprState{	ExprState	xprstate;	List	   *args;			/* states of argument expression(s) */} BoolExprState;/* ---------------- *		SubPlanState node * ---------------- */typedef struct SubPlanState{	ExprState	xprstate;	EState	   *sub_estate;		/* subselect plan has its own EState */	struct PlanState *planstate;	/* subselect plan's state tree */	List	   *exprs;			/* states of combining expression(s) */	List	   *args;			/* states of argument expression(s) */	bool		needShutdown;	/* TRUE = need to shutdown subplan */	HeapTuple	curTuple;		/* copy of most recent tuple from subplan */	/* these are used when hashing the subselect's output: */	ProjectionInfo *projLeft;	/* for projecting lefthand exprs */	ProjectionInfo *projRight;	/* for projecting subselect output */	TupleHashTable hashtable;	/* hash table for no-nulls subselect rows */	TupleHashTable hashnulls;	/* hash table for rows with null(s) */	bool		havehashrows;	/* TRUE if hashtable is not empty */	bool		havenullrows;	/* TRUE if hashnulls is not empty */	MemoryContext tablecxt;		/* memory context containing tables */	ExprContext *innerecontext; /* working context for comparisons */	AttrNumber *keyColIdx;		/* control data for hash tables */	FmgrInfo   *eqfunctions;	/* comparison functions for hash tables */	FmgrInfo   *hashfunctions;	/* lookup data for hash functions */} SubPlanState;/* ---------------- *		CaseExprState node * ---------------- */typedef struct CaseExprState{	ExprState	xprstate;	List	   *args;			/* the arguments (list of WHEN clauses) */	ExprState  *defresult;		/* the default result (ELSE clause) */} CaseExprState;/* ---------------- *		CaseWhenState node * ---------------- */typedef struct CaseWhenState{	ExprState	xprstate;	ExprState  *expr;			/* condition expression */	ExprState  *result;			/* substitution result */} CaseWhenState;/* ---------------- *		ArrayExprState node * * Note: ARRAY[] expressions always produce varlena arrays, never fixed-length * arrays. * ---------------- */typedef struct ArrayExprState{	ExprState	xprstate;	List	   *elements;		/* states for child nodes */	int16		elemlength;		/* typlen of the array element type */	bool		elembyval;		/* is the element type pass-by-value? */	char		elemalign;		/* typalign of the element type */} ArrayExprState;/* ---------------- *		CoalesceExprState node * ---------------- */typedef struct CoalesceExprState{	ExprState	xprstate;	List	   *args;			/* the arguments */} CoalesceExprState;/* ---------------- *		CoerceToDomainState node * ---------------- */typedef struct CoerceToDomainState{	ExprState	xprstate;	ExprState  *arg;			/* input expression */	/* Cached list of constraints that need to be checked */	List	   *constraints;	/* list of DomainConstraintState nodes */} CoerceToDomainState;/* * DomainConstraintState - one item to check during CoerceToDomain * * Note: this is just a Node, and not an ExprState, because it has no * corresponding Expr to link to.  Nonetheless it is part of an ExprState * tree, so we give it a name following the xxxState convention. */typedef enum DomainConstraintType{	DOM_CONSTRAINT_NOTNULL,	DOM_CONSTRAINT_CHECK} DomainConstraintType;typedef struct DomainConstraintState{	NodeTag		type;	DomainConstraintType constrainttype;		/* constraint type */	char	   *name;			/* name of constraint (for error msgs) */	ExprState  *check_expr;		/* for CHECK, a boolean expression */} DomainConstraintState;/* ---------------------------------------------------------------- *				 Executor State Trees * * An executing query has a PlanState tree paralleling the Plan tree * that describes the plan. * ---------------------------------------------------------------- *//* ---------------- *		PlanState node * * We never actually instantiate any PlanState nodes; this is just the common * abstract superclass for all PlanState-type nodes. * ---------------- */typedef struct PlanState{	NodeTag		type;	Plan	   *plan;			/* associated Plan node */	EState	   *state;			/* at execution time, state's of								 * individual nodes point to one EState								 * for the whole top-level plan */	struct Instrumentation *instrument; /* Optional runtime stats for this										 * plan node */	/*	 * Common structural data for all Plan types.  These links to	 * subsidiary state trees parallel links in the associated plan tree	 * (except for the subPlan list, which does not exist in the plan	 * tree).	 */	List	   *targetlist;		/* target list to be computed at this node */	List	   *qual;			/* implicitly-ANDed qual conditions */	struct PlanState *lefttree; /* input plan tree(s) */	struct PlanState *righttree;	List	   *initPlan;		/* Init SubPlanState nodes (un-correlated								 * expr subselects) */	List	   *subPlan;		/* SubPlanState nodes in my expressions */	/*	 * State for management of parameter-change-driven rescanning	 */	Bitmapset  *chgParam;		/* set of IDs of changed Params */	/*	 * Other run-time state needed by most if not all node types.	 */	TupleTableSlot *ps_OuterTupleSlot;	/* slot for current "outer" tuple */	TupleTableSlot *ps_ResultTupleSlot; /* slot for my result tuples */	ExprContext *ps_ExprContext;	/* node's expression-evaluation context */	ProjectionInfo *ps_ProjInfo;	/* info for doing tuple projection */	bool		ps_TupFromTlist;/* state flag for processing set-valued								 * functions in targetlist */} PlanState;/* ---------------- *	these are are defined to avoid confusion problems with "left" *	and "right" and "inner" and "outer".  The convention is that *	the "left" plan is the "outer" plan and the "right" plan is *	the inner plan, but these make the code more readable. * ---------------- */#define innerPlanState(node)		(((PlanState *)(node))->righttree)#define outerPlanState(node)		(((PlanState *)(node))->lefttree)/* ---------------- *	 ResultState information * ---------------- */typedef struct ResultState{	PlanState	ps;				/* its first field is NodeTag */	ExprState  *resconstantqual;	bool		rs_done;		/* are we done? */	bool		rs_checkqual;	/* do we need to check the qual? */} ResultState;/* ---------------- *	 AppendState information * *		nplans			how many plans are in the list *		whichplan		which plan is being executed (0 .. n-1) *		firstplan		first plan to execute (usually 0) *		lastplan		last plan to execute (usually n-1) * ---------------- */typedef struct AppendState{	PlanState	ps;				/* its first field is NodeTag */	PlanState **appendplans;	/* array of PlanStates for my inputs */	int			as_nplans;	int			as_whichplan;	int			as_firstplan;	int			as_lastplan;} AppendState;/* ---------------------------------------------------------------- *				 Scan State Information * ---------------------------------------------------------------- *//* ---------------- *	 ScanState information * *		ScanState extends PlanState for node types that represent *		scans of an underlying relation.  It can also be used for nodes *		that scan the output of an underlying plan node --- in that case, *		only ScanTupleSlot is actually useful, and it refers to the tuple *		retrieved from the subplan. * *		currentRelation    relation being scanned (NULL if none) *		currentScanDesc    current scan descriptor for scan (NULL if none) *		ScanTupleSlot	   pointer to slot in tuple table holding scan tuple * ---------------- */typedef struct ScanState{

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?