⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 primnodes.h

📁 PostgreSQL 8.1.4的源码 适用于Linux下的开源数据库系统
💻 H
📖 第 1 页 / 共 3 页
字号:
 * Notice the arguments are given as a List.  For NOT, of course the list * must always have exactly one element.  For AND and OR, the executor can * handle any number of arguments.	The parser treats AND and OR as binary * and so it only produces two-element lists, but the optimizer will flatten * trees of AND and OR nodes to produce longer lists when possible. */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 ...) *	MULTIEXPR_SUBLINK	(lefthand) op (SELECT ...) *	EXPR_SUBLINK		(SELECT with single targetlist item ...) *	ARRAY_SUBLINK		ARRAY(SELECT with single targetlist item ...) * For ALL, ANY, and MULTIEXPR, the lefthand is a list of expressions of the * same length as the subselect's targetlist.  MULTIEXPR 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 * MULTIEXPR and EXPR require the subselect to deliver only one row. * 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. * ALL, ANY, and MULTIEXPR require the combining operators to deliver boolean * results.  These are reduced to one result per row using OR or AND semantics * depending on the "useOr" flag.  ALL and ANY combine the per-row results * using AND and OR semantics respectively. * * 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, lefthand contains a list of raw * expressions; useOr and operOids are not filled in yet.  Also, subselect * is a raw parsetree.	During parse analysis, the parser transforms the * lefthand expression list using normal expression transformation rules. * It fills operOids with the OIDs representing the specific operator(s) * to apply to each pair of lefthand and targetlist expressions. * 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, lefthand, operName, and operOids are * unused and are always NIL.  useOr is not significant either for these * sublink types. * ---------------- */typedef enum SubLinkType{	EXISTS_SUBLINK,	ALL_SUBLINK,	ANY_SUBLINK,	MULTIEXPR_SUBLINK,	EXPR_SUBLINK,	ARRAY_SUBLINK} SubLinkType;typedef struct SubLink{	Expr		xpr;	SubLinkType subLinkType;	/* EXISTS, ALL, ANY, MULTIEXPR, EXPR */	bool		useOr;			/* TRUE to combine column results with "OR"								 * not "AND" */	List	   *lefthand;		/* list of outer-query expressions on the left */	List	   *operName;		/* originally specified operator name */	List	   *operOids;		/* OIDs of actual combining operators */	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, "exprs" points to a list of executable expressions * (OpExpr trees) for the combining operators; their left-hand arguments are * the original lefthand expressions, and their right-hand arguments are * PARAM_EXEC Param nodes representing the outputs of the sub-select. * (NOTE: runtime coercion functions may be inserted as well.)	But if the * sub-select becomes an initplan rather than a subplan, these executable * expressions are part of the outer plan's expression tree (and the SubPlan * node itself is not).  In this case "exprs" is NIL 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;	/* EXISTS, ALL, ANY, MULTIEXPR, EXPR */	bool		useOr;			/* TRUE to combine column results with "OR"								 * not "AND" */	/* The combining operators, transformed to executable expressions: */	List	   *exprs;			/* list of OpExpr expression trees */	List	   *paramIds;		/* IDs of Params embedded in the above */	/* Note: paramIds has a one-to-one correspondence to the exprs list */	/* 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

⌨️ 快捷键说明

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