primnodes.h

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

H
973
字号
 * operator in btree opclasses).  Note that the same operator name might * map to a different operator for each pair of row elements, since the * element datatypes can vary. * * A RowCompareExpr node is only generated for the < <= > >= cases; * the = and <> cases are translated to simple AND or OR combinations * of the pairwise comparisons.  However, we include = and <> in the * RowCompareType enum for the convenience of parser logic. */typedef enum RowCompareType{	/* Values of this enum are chosen to match btree strategy numbers */	ROWCOMPARE_LT = 1,			/* BTLessStrategyNumber */	ROWCOMPARE_LE = 2,			/* BTLessEqualStrategyNumber */	ROWCOMPARE_EQ = 3,			/* BTEqualStrategyNumber */	ROWCOMPARE_GE = 4,			/* BTGreaterEqualStrategyNumber */	ROWCOMPARE_GT = 5,			/* BTGreaterStrategyNumber */	ROWCOMPARE_NE = 6			/* no such btree strategy */} RowCompareType;typedef struct RowCompareExpr{	Expr		xpr;	RowCompareType rctype;		/* LT LE GE or GT, never EQ or NE */	List	   *opnos;			/* OID list of pairwise comparison ops */	List	   *opclasses;		/* OID list of containing operator classes */	List	   *largs;			/* the left-hand input arguments */	List	   *rargs;			/* the right-hand input arguments */} RowCompareExpr;/* * CoalesceExpr - a COALESCE expression */typedef struct CoalesceExpr{	Expr		xpr;	Oid			coalescetype;	/* type of expression result */	List	   *args;			/* the arguments */} CoalesceExpr;/* * MinMaxExpr - a GREATEST or LEAST function */typedef enum MinMaxOp{	IS_GREATEST,	IS_LEAST} MinMaxOp;typedef struct MinMaxExpr{	Expr		xpr;	Oid			minmaxtype;		/* common type of arguments and result */	MinMaxOp	op;				/* function to execute */	List	   *args;			/* the arguments */} MinMaxExpr;/* * NullIfExpr - a NULLIF expression * * Like DistinctExpr, this is represented the same as an OpExpr referencing * the "=" operator for x and y. */typedef OpExpr NullIfExpr;/* ---------------- * NullTest * * NullTest represents the operation of testing a value for NULLness. * The appropriate test is performed and returned as a boolean Datum. * * NOTE: the semantics of this for rowtype inputs are noticeably different * from the scalar case.  It would probably be a good idea to include an * "argisrow" flag in the struct to reflect that, but for the moment, * we do not do so to avoid forcing an initdb during 8.2beta. * ---------------- */typedef enum NullTestType{	IS_NULL, IS_NOT_NULL} NullTestType;typedef struct NullTest{	Expr		xpr;	Expr	   *arg;			/* input expression */	NullTestType nulltesttype;	/* IS NULL, IS NOT NULL */} NullTest;/* * BooleanTest * * BooleanTest represents the operation of determining whether a boolean * is TRUE, FALSE, or UNKNOWN (ie, NULL).  All six meaningful combinations * are supported.  Note that a NULL input does *not* cause a NULL result. * The appropriate test is performed and returned as a boolean Datum. */typedef enum BoolTestType{	IS_TRUE, IS_NOT_TRUE, IS_FALSE, IS_NOT_FALSE, IS_UNKNOWN, IS_NOT_UNKNOWN} BoolTestType;typedef struct BooleanTest{	Expr		xpr;	Expr	   *arg;			/* input expression */	BoolTestType booltesttype;	/* test type */} BooleanTest;/* * CoerceToDomain * * CoerceToDomain represents the operation of coercing a value to a domain * type.  At runtime (and not before) the precise set of constraints to be * checked will be determined.	If the value passes, it is returned as the * result; if not, an error is raised.	Note that this is equivalent to * RelabelType in the scenario where no constraints are applied. */typedef struct CoerceToDomain{	Expr		xpr;	Expr	   *arg;			/* input expression */	Oid			resulttype;		/* domain type ID (result type) */	int32		resulttypmod;	/* output typmod (currently always -1) */	CoercionForm coercionformat;	/* how to display this node */} CoerceToDomain;/* * Placeholder node for the value to be processed by a domain's check * constraint.	This is effectively like a Param, but can be implemented more * simply since we need only one replacement value at a time. * * Note: the typeId/typeMod will be set from the domain's base type, not * the domain itself.  This is because we shouldn't consider the value to * be a member of the domain if we haven't yet checked its constraints. */typedef struct CoerceToDomainValue{	Expr		xpr;	Oid			typeId;			/* type for substituted value */	int32		typeMod;		/* typemod for substituted value */} CoerceToDomainValue;/* * Placeholder node for a DEFAULT marker in an INSERT or UPDATE command. * * This is not an executable expression: it must be replaced by the actual * column default expression during rewriting.	But it is convenient to * treat it as an expression node during parsing and rewriting. */typedef struct SetToDefault{	Expr		xpr;	Oid			typeId;			/* type for substituted value */	int32		typeMod;		/* typemod for substituted value */} SetToDefault;/*-------------------- * TargetEntry - *	   a target entry (used in query target lists) * * Strictly speaking, a TargetEntry isn't an expression node (since it can't * be evaluated by ExecEvalExpr).  But we treat it as one anyway, since in * very many places it's convenient to process a whole query targetlist as a * single expression tree. * * In a SELECT's targetlist, resno should always be equal to the item's * ordinal position (counting from 1).	However, in an INSERT or UPDATE * targetlist, resno represents the attribute number of the destination * column for the item; so there may be missing or out-of-order resnos. * It is even legal to have duplicated resnos; consider *		UPDATE table SET arraycol[1] = ..., arraycol[2] = ..., ... * The two meanings come together in the executor, because the planner * transforms INSERT/UPDATE tlists into a normalized form with exactly * one entry for each column of the destination table.	Before that's * happened, however, it is risky to assume that resno == position. * Generally get_tle_by_resno() should be used rather than list_nth() * to fetch tlist entries by resno, and only in SELECT should you assume * that resno is a unique identifier. * * resname is required to represent the correct column name in non-resjunk * entries of top-level SELECT targetlists, since it will be used as the * column title sent to the frontend.  In most other contexts it is only * a debugging aid, and may be wrong or even NULL.	(In particular, it may * be wrong in a tlist from a stored rule, if the referenced column has been * renamed by ALTER TABLE since the rule was made.	Also, the planner tends * to store NULL rather than look up a valid name for tlist entries in * non-toplevel plan nodes.)  In resjunk entries, resname should be either * a specific system-generated name (such as "ctid") or NULL; anything else * risks confusing ExecGetJunkAttribute! * * ressortgroupref is used in the representation of ORDER BY and * GROUP BY items.	Targetlist entries with ressortgroupref=0 are not * sort/group items.  If ressortgroupref>0, then this item is an ORDER BY or * GROUP BY value.	No two entries in a targetlist may have the same nonzero * ressortgroupref --- but there is no particular meaning to the nonzero * values, except as tags.	(For example, one must not assume that lower * ressortgroupref means a more significant sort key.)	The order of the * associated SortClause or GroupClause lists determine the semantics. * * resorigtbl/resorigcol identify the source of the column, if it is a * simple reference to a column of a base table (or view).	If it is not * a simple reference, these fields are zeroes. * * If resjunk is true then the column is a working column (such as a sort key) * that should be removed from the final output of the query.  Resjunk columns * must have resnos that cannot duplicate any regular column's resno.  Also * note that there are places that assume resjunk columns come after non-junk * columns. *-------------------- */typedef struct TargetEntry{	Expr		xpr;	Expr	   *expr;			/* expression to evaluate */	AttrNumber	resno;			/* attribute number (see notes above) */	char	   *resname;		/* name of the column (could be NULL) */	Index		ressortgroupref;/* nonzero if referenced by a sort/group								 * clause */	Oid			resorigtbl;		/* OID of column's source table */	AttrNumber	resorigcol;		/* column's number in source table */	bool		resjunk;		/* set to true to eliminate the attribute from								 * final target list */} TargetEntry;/* ---------------------------------------------------------------- *					node types for join trees * * The leaves of a join tree structure are RangeTblRef nodes.  Above * these, JoinExpr nodes can appear to denote a specific kind of join * or qualified join.  Also, FromExpr nodes can appear to denote an * ordinary cross-product join ("FROM foo, bar, baz WHERE ..."). * FromExpr is like a JoinExpr of jointype JOIN_INNER, except that it * may have any number of child nodes, not just two. * * NOTE: the top level of a Query's jointree is always a FromExpr. * Even if the jointree contains no rels, there will be a FromExpr. * * NOTE: the qualification expressions present in JoinExpr nodes are * *in addition to* the query's main WHERE clause, which appears as the * qual of the top-level FromExpr.	The reason for associating quals with * specific nodes in the jointree is that the position of a qual is critical * when outer joins are present.  (If we enforce a qual too soon or too late, * that may cause the outer join to produce the wrong set of NULL-extended * rows.)  If all joins are inner joins then all the qual positions are * semantically interchangeable. * * NOTE: in the raw output of gram.y, a join tree contains RangeVar, * RangeSubselect, and RangeFunction nodes, which are all replaced by * RangeTblRef nodes during the parse analysis phase.  Also, the top-level * FromExpr is added during parse analysis; the grammar regards FROM and * WHERE as separate. * ---------------------------------------------------------------- *//* * RangeTblRef - reference to an entry in the query's rangetable * * We could use direct pointers to the RT entries and skip having these * nodes, but multiple pointers to the same node in a querytree cause * lots of headaches, so it seems better to store an index into the RT. */typedef struct RangeTblRef{	NodeTag		type;	int			rtindex;} RangeTblRef;/*---------- * JoinExpr - for SQL JOIN expressions * * isNatural, using, and quals are interdependent.	The user can write only * one of NATURAL, USING(), or ON() (this is enforced by the grammar). * If he writes NATURAL then parse analysis generates the equivalent USING() * list, and from that fills in "quals" with the right equality comparisons. * If he writes USING() then "quals" is filled with equality comparisons. * If he writes ON() then only "quals" is set.	Note that NATURAL/USING * are not equivalent to ON() since they also affect the output column list. * * alias is an Alias node representing the AS alias-clause attached to the * join expression, or NULL if no clause.  NB: presence or absence of the * alias has a critical impact on semantics, because a join with an alias * restricts visibility of the tables/columns inside it. * * During parse analysis, an RTE is created for the Join, and its index * is filled into rtindex.	This RTE is present mainly so that Vars can * be created that refer to the outputs of the join. *---------- */typedef struct JoinExpr{	NodeTag		type;	JoinType	jointype;		/* type of join */	bool		isNatural;		/* Natural join? Will need to shape table */	Node	   *larg;			/* left subtree */	Node	   *rarg;			/* right subtree */	List	   *using;			/* USING clause, if any (list of String) */	Node	   *quals;			/* qualifiers on join, if any */	Alias	   *alias;			/* user-written alias clause, if any */	int			rtindex;		/* RT index assigned for join */} JoinExpr;/*---------- * FromExpr - represents a FROM ... WHERE ... construct * * This is both more flexible than a JoinExpr (it can have any number of * children, including zero) and less so --- we don't need to deal with * aliases and so on.  The output column set is implicitly just the union * of the outputs of the children. *---------- */typedef struct FromExpr{	NodeTag		type;	List	   *fromlist;		/* List of join subtrees */	Node	   *quals;			/* qualifiers on join, if any */} FromExpr;#endif   /* PRIMNODES_H */

⌨️ 快捷键说明

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