primnodes.h

来自「PostgreSQL 8.2中增加了很多企业用户所需要的功能和性能上的提高,其开」· C头文件 代码 · 共 973 行 · 第 1/3 页

H
973
字号
 */typedef enum BoolExprType{	AND_EXPR, OR_EXPR, NOT_EXPR} BoolExprType;typedef struct BoolExpr{	Expr		xpr;	BoolExprType boolop;	List	   *args;			/* arguments to this expression */} BoolExpr;/* * SubLink * * A SubLink represents a subselect appearing in an expression, and in some * cases also the combining operator(s) just above it.	The subLinkType * indicates the form of the expression represented: *	EXISTS_SUBLINK		EXISTS(SELECT ...) *	ALL_SUBLINK			(lefthand) op ALL (SELECT ...) *	ANY_SUBLINK			(lefthand) op ANY (SELECT ...) *	ROWCOMPARE_SUBLINK	(lefthand) op (SELECT ...) *	EXPR_SUBLINK		(SELECT with single targetlist item ...) *	ARRAY_SUBLINK		ARRAY(SELECT with single targetlist item ...) * For ALL, ANY, and ROWCOMPARE, the lefthand is a list of expressions of the * same length as the subselect's targetlist.  ROWCOMPARE will *always* have * a list with more than one entry; if the subselect has just one target * then the parser will create an EXPR_SUBLINK instead (and any operator * above the subselect will be represented separately).  Note that both * ROWCOMPARE and EXPR require the subselect to deliver only one row. * ALL, ANY, and ROWCOMPARE require the combining operators to deliver boolean * results.  ALL and ANY combine the per-row results using AND and OR * semantics respectively. * ARRAY requires just one target column, and creates an array of the target * column's type using one or more rows resulting from the subselect. * * SubLink is classed as an Expr node, but it is not actually executable; * it must be replaced in the expression tree by a SubPlan node during * planning. * * NOTE: in the raw output of gram.y, testexpr contains just the raw form * of the lefthand expression (if any), and operName is the String name of * the combining operator.	Also, subselect is a raw parsetree.  During parse * analysis, the parser transforms testexpr into a complete boolean expression * that compares the lefthand value(s) to PARAM_SUBLINK nodes representing the * output columns of the subselect.  And subselect is transformed to a Query. * This is the representation seen in saved rules and in the rewriter. * * In EXISTS, EXPR, and ARRAY SubLinks, testexpr and operName are unused and * are always null. */typedef enum SubLinkType{	EXISTS_SUBLINK,	ALL_SUBLINK,	ANY_SUBLINK,	ROWCOMPARE_SUBLINK,	EXPR_SUBLINK,	ARRAY_SUBLINK} SubLinkType;typedef struct SubLink{	Expr		xpr;	SubLinkType subLinkType;	/* see above */	Node	   *testexpr;		/* outer-query test for ALL/ANY/ROWCOMPARE */	List	   *operName;		/* originally specified operator name */	Node	   *subselect;		/* subselect as Query* or parsetree */} SubLink;/* * SubPlan - executable expression node for a subplan (sub-SELECT) * * The planner replaces SubLink nodes in expression trees with SubPlan * nodes after it has finished planning the subquery.  SubPlan contains * a sub-plantree and rtable instead of a sub-Query. * * In an ordinary subplan, testexpr points to an executable expression * (OpExpr, an AND/OR tree of OpExprs, or RowCompareExpr) for the combining * operator(s); the left-hand arguments are the original lefthand expressions, * and the right-hand arguments are PARAM_EXEC Param nodes representing the * outputs of the sub-select.  (NOTE: runtime coercion functions may be * inserted as well.)  This is just the same expression tree as testexpr in * the original SubLink node, but the PARAM_SUBLINK nodes are replaced by * suitably numbered PARAM_EXEC nodes. * * If the sub-select becomes an initplan rather than a subplan, the executable * expression is part of the outer plan's expression tree (and the SubPlan * node itself is not).  In this case testexpr is NULL to avoid duplication. * * The planner also derives lists of the values that need to be passed into * and out of the subplan.	Input values are represented as a list "args" of * expressions to be evaluated in the outer-query context (currently these * args are always just Vars, but in principle they could be any expression). * The values are assigned to the global PARAM_EXEC params indexed by parParam * (the parParam and args lists must have the same ordering).  setParam is a * list of the PARAM_EXEC params that are computed by the sub-select, if it * is an initplan; they are listed in order by sub-select output column * position.  (parParam and setParam are integer Lists, not Bitmapsets, * because their ordering is significant.) */typedef struct SubPlan{	Expr		xpr;	/* Fields copied from original SubLink: */	SubLinkType subLinkType;	/* see above */	/* The combining operators, transformed to an executable expression: */	Node	   *testexpr;		/* OpExpr or RowCompareExpr expression tree */	List	   *paramIds;		/* IDs of Params embedded in the above */	/* The subselect, transformed to a Plan: */	struct Plan *plan;			/* subselect plan itself */	int			plan_id;		/* dummy thing because of we haven't equal								 * funcs for plan nodes... actually, we could								 * put *plan itself somewhere else (TopPlan								 * node ?)... */	List	   *rtable;			/* range table for subselect */	/* Information about execution strategy: */	bool		useHashTable;	/* TRUE to store subselect output in a hash								 * table (implies we are doing "IN") */	bool		unknownEqFalse; /* TRUE if it's okay to return FALSE when the								 * spec result is UNKNOWN; this allows much								 * simpler handling of null values */	/* Information for passing params into and out of the subselect: */	/* setParam and parParam are lists of integers (param IDs) */	List	   *setParam;		/* initplan subqueries have to set these								 * Params for parent plan */	List	   *parParam;		/* indices of input Params from parent plan */	List	   *args;			/* exprs to pass as parParam values */} SubPlan;/* ---------------- * FieldSelect * * FieldSelect represents the operation of extracting one field from a tuple * value.  At runtime, the input expression is expected to yield a rowtype * Datum.  The specified field number is extracted and returned as a Datum. * ---------------- */typedef struct FieldSelect{	Expr		xpr;	Expr	   *arg;			/* input expression */	AttrNumber	fieldnum;		/* attribute number of field to extract */	Oid			resulttype;		/* type of the field (result type of this								 * node) */	int32		resulttypmod;	/* output typmod (usually -1) */} FieldSelect;/* ---------------- * FieldStore * * FieldStore represents the operation of modifying one field in a tuple * value, yielding a new tuple value (the input is not touched!).  Like * the assign case of ArrayRef, this is used to implement UPDATE of a * portion of a column. * * A single FieldStore can actually represent updates of several different * fields.	The parser only generates FieldStores with single-element lists, * but the planner will collapse multiple updates of the same base column * into one FieldStore. * ---------------- */typedef struct FieldStore{	Expr		xpr;	Expr	   *arg;			/* input tuple value */	List	   *newvals;		/* new value(s) for field(s) */	List	   *fieldnums;		/* integer list of field attnums */	Oid			resulttype;		/* type of result (same as type of arg) */	/* Like RowExpr, we deliberately omit a typmod here */} FieldStore;/* ---------------- * RelabelType * * RelabelType represents a "dummy" type coercion between two binary- * compatible datatypes, such as reinterpreting the result of an OID * expression as an int4.  It is a no-op at runtime; we only need it * to provide a place to store the correct type to be attributed to * the expression result during type resolution.  (We can't get away * with just overwriting the type field of the input expression node, * so we need a separate node to show the coercion's result type.) * ---------------- */typedef struct RelabelType{	Expr		xpr;	Expr	   *arg;			/* input expression */	Oid			resulttype;		/* output type of coercion expression */	int32		resulttypmod;	/* output typmod (usually -1) */	CoercionForm relabelformat; /* how to display this node */} RelabelType;/* ---------------- * ConvertRowtypeExpr * * ConvertRowtypeExpr represents a type coercion from one composite type * to another, where the source type is guaranteed to contain all the columns * needed for the destination type plus possibly others; the columns need not * be in the same positions, but are matched up by name.  This is primarily * used to convert a whole-row value of an inheritance child table into a * valid whole-row value of its parent table's rowtype. * ---------------- */typedef struct ConvertRowtypeExpr{	Expr		xpr;	Expr	   *arg;			/* input expression */	Oid			resulttype;		/* output type (always a composite type) */	/* result typmod is not stored, but must be -1; see RowExpr comments */	CoercionForm convertformat; /* how to display this node */} ConvertRowtypeExpr;/*---------- * CaseExpr - a CASE expression * * We support two distinct forms of CASE expression: *		CASE WHEN boolexpr THEN expr [ WHEN boolexpr THEN expr ... ] *		CASE testexpr WHEN compexpr THEN expr [ WHEN compexpr THEN expr ... ] * These are distinguishable by the "arg" field being NULL in the first case * and the testexpr in the second case. * * In the raw grammar output for the second form, the condition expressions * of the WHEN clauses are just the comparison values.	Parse analysis * converts these to valid boolean expressions of the form *		CaseTestExpr '=' compexpr * where the CaseTestExpr node is a placeholder that emits the correct * value at runtime.  This structure is used so that the testexpr need be * evaluated only once.  Note that after parse analysis, the condition * expressions always yield boolean. * * Note: we can test whether a CaseExpr has been through parse analysis * yet by checking whether casetype is InvalidOid or not. *---------- */typedef struct CaseExpr{	Expr		xpr;	Oid			casetype;		/* type of expression result */	Expr	   *arg;			/* implicit equality comparison argument */	List	   *args;			/* the arguments (list of WHEN clauses) */	Expr	   *defresult;		/* the default result (ELSE clause) */} CaseExpr;/* * CaseWhen - one arm of a CASE expression */typedef struct CaseWhen{	Expr		xpr;	Expr	   *expr;			/* condition expression */	Expr	   *result;			/* substitution result */} CaseWhen;/* * Placeholder node for the test value to be processed by a CASE expression. * This is effectively like a Param, but can be implemented more simply * since we need only one replacement value at a time. * * We also use this in nested UPDATE expressions. * See transformAssignmentIndirection(). */typedef struct CaseTestExpr{	Expr		xpr;	Oid			typeId;			/* type for substituted value */	int32		typeMod;		/* typemod for substituted value */} CaseTestExpr;/* * ArrayExpr - an ARRAY[] expression * * Note: if multidims is false, the constituent expressions all yield the * scalar type identified by element_typeid.  If multidims is true, the * constituent expressions all yield arrays of element_typeid (ie, the same * type as array_typeid); at runtime we must check for compatible subscripts. */typedef struct ArrayExpr{	Expr		xpr;	Oid			array_typeid;	/* type of expression result */	Oid			element_typeid; /* common type of array elements */	List	   *elements;		/* the array elements or sub-arrays */	bool		multidims;		/* true if elements are sub-arrays */} ArrayExpr;/* * RowExpr - a ROW() expression * * Note: the list of fields must have a one-for-one correspondence with * physical fields of the associated rowtype, although it is okay for it * to be shorter than the rowtype.	That is, the N'th list element must * match up with the N'th physical field.  When the N'th physical field * is a dropped column (attisdropped) then the N'th list element can just * be a NULL constant.	(This case can only occur for named composite types, * not RECORD types, since those are built from the RowExpr itself rather * than vice versa.)  It is important not to assume that length(args) is * the same as the number of columns logically present in the rowtype. */typedef struct RowExpr{	Expr		xpr;	List	   *args;			/* the fields */	Oid			row_typeid;		/* RECORDOID or a composite type's ID */	/*	 * Note: we deliberately do NOT store a typmod.  Although a typmod will be	 * associated with specific RECORD types at runtime, it will differ for	 * different backends, and so cannot safely be stored in stored	 * parsetrees.	We must assume typmod -1 for a RowExpr node.	 */	CoercionForm row_format;	/* how to display this node */} RowExpr;/* * RowCompareExpr - row-wise comparison, such as (a, b) <= (1, 2) * * We support row comparison for any operator that can be determined to * act like =, <>, <, <=, >, or >= (we determine this by looking for the

⌨️ 快捷键说明

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