parsenodes.h

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

H
1,961
字号
/*------------------------------------------------------------------------- * * parsenodes.h *	  definitions for parse tree 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/parsenodes.h,v 1.334 2006/11/05 22:42:10 tgl Exp $ * *------------------------------------------------------------------------- */#ifndef PARSENODES_H#define PARSENODES_H#include "nodes/primnodes.h"#include "nodes/value.h"/* Possible sources of a Query */typedef enum QuerySource{	QSRC_ORIGINAL,				/* original parsetree (explicit query) */	QSRC_PARSER,				/* added by parse analysis */	QSRC_INSTEAD_RULE,			/* added by unconditional INSTEAD rule */	QSRC_QUAL_INSTEAD_RULE,		/* added by conditional INSTEAD rule */	QSRC_NON_INSTEAD_RULE		/* added by non-INSTEAD rule */} QuerySource;/* What to do at commit time for temporary relations */typedef enum OnCommitAction{	ONCOMMIT_NOOP,				/* No ON COMMIT clause (do nothing) */	ONCOMMIT_PRESERVE_ROWS,		/* ON COMMIT PRESERVE ROWS (do nothing) */	ONCOMMIT_DELETE_ROWS,		/* ON COMMIT DELETE ROWS */	ONCOMMIT_DROP				/* ON COMMIT DROP */} OnCommitAction;/* * Grantable rights are encoded so that we can OR them together in a bitmask. * The present representation of AclItem limits us to 16 distinct rights, * even though AclMode is defined as uint32.  See utils/acl.h. * * Caution: changing these codes breaks stored ACLs, hence forces initdb. */typedef uint32 AclMode;			/* a bitmask of privilege bits */#define ACL_INSERT		(1<<0)	/* for relations */#define ACL_SELECT		(1<<1)#define ACL_UPDATE		(1<<2)#define ACL_DELETE		(1<<3)/* #define ACL_RULE		(1<<4)	unused, available */#define ACL_REFERENCES	(1<<5)#define ACL_TRIGGER		(1<<6)#define ACL_EXECUTE		(1<<7)	/* for functions */#define ACL_USAGE		(1<<8)	/* for languages and namespaces */#define ACL_CREATE		(1<<9)	/* for namespaces and databases */#define ACL_CREATE_TEMP (1<<10) /* for databases */#define ACL_CONNECT		(1<<11) /* for databases */#define N_ACL_RIGHTS	12		/* 1 plus the last 1<<x */#define ACL_NO_RIGHTS	0/* Currently, SELECT ... FOR UPDATE/FOR SHARE requires UPDATE privileges */#define ACL_SELECT_FOR_UPDATE	ACL_UPDATE/***************************************************************************** *	Query Tree *****************************************************************************//* * Query - *	  all statements are turned into a Query tree (via transformStmt) *	  for further processing by the optimizer * *	  utility statements (i.e. non-optimizable statements) have the *	  utilityStmt field set, and the Query itself is mostly dummy. */typedef struct Query{	NodeTag		type;	CmdType		commandType;	/* select|insert|update|delete|utility */	QuerySource querySource;	/* where did I come from? */	bool		canSetTag;		/* do I set the command result tag? */	Node	   *utilityStmt;	/* non-null if this is a non-optimizable								 * statement */	int			resultRelation; /* rtable index of target relation for								 * INSERT/UPDATE/DELETE; 0 for SELECT */	RangeVar   *into;			/* target relation for SELECT INTO */	List	   *intoOptions;	/* options from WITH clause */	OnCommitAction intoOnCommit;	/* what do we do at COMMIT? */	char	   *intoTableSpaceName;		/* table space to use, or NULL */	bool		hasAggs;		/* has aggregates in tlist or havingQual */	bool		hasSubLinks;	/* has subquery SubLink */	List	   *rtable;			/* list of range table entries */	FromExpr   *jointree;		/* table join tree (FROM and WHERE clauses) */	List	   *targetList;		/* target list (of TargetEntry) */	List	   *returningList;	/* return-values list (of TargetEntry) */	List	   *groupClause;	/* a list of GroupClause's */	Node	   *havingQual;		/* qualifications applied to groups */	List	   *distinctClause; /* a list of SortClause's */	List	   *sortClause;		/* a list of SortClause's */	Node	   *limitOffset;	/* # of result tuples to skip (int8 expr) */	Node	   *limitCount;		/* # of result tuples to return (int8 expr) */	List	   *rowMarks;		/* a list of RowMarkClause's */	Node	   *setOperations;	/* set-operation tree if this is top level of								 * a UNION/INTERSECT/EXCEPT query */	/*	 * If the resultRelation turns out to be the parent of an inheritance	 * tree, the planner will add all the child tables to the rtable and store	 * a list of the rtindexes of all the result relations here. This is done	 * at plan time, not parse time, since we don't want to commit to the	 * exact set of child tables at parse time.  XXX This field ought to go in	 * some sort of TopPlan plan node, not in the Query.	 */	List	   *resultRelations;	/* integer list of RT indexes, or NIL */	/*	 * If the query has a returningList then the planner will store a list of	 * processed targetlists (one per result relation) here.  We must have a	 * separate RETURNING targetlist for each result rel because column	 * numbers may vary within an inheritance tree.  In the targetlists, Vars	 * referencing the result relation will have their original varno and	 * varattno, while Vars referencing other rels will be converted to have	 * varno OUTER and varattno referencing a resjunk entry in the top plan	 * node's targetlist.  XXX This field ought to go in some sort of TopPlan	 * plan node, not in the Query.	 */	List	   *returningLists; /* list of lists of TargetEntry, or NIL */} Query;/**************************************************************************** *	Supporting data structures for Parse Trees * *	Most of these node types appear in raw parsetrees output by the grammar, *	and get transformed to something else by the analyzer.	A few of them *	are used as-is in transformed querytrees. * *	Many of the node types used in raw parsetrees include a "location" field. *	This is a byte (not character) offset in the original source text, to be *	used for positioning an error cursor when there is an analysis-time *	error related to the node. ****************************************************************************//* * TypeName - specifies a type in definitions * * For TypeName structures generated internally, it is often easier to * specify the type by OID than by name.  If "names" is NIL then the * actual type OID is given by typeid, otherwise typeid is unused. * * If pct_type is TRUE, then names is actually a field name and we look up * the type of that field.	Otherwise (the normal case), names is a type * name possibly qualified with schema and database name. */typedef struct TypeName{	NodeTag		type;	List	   *names;			/* qualified name (list of Value strings) */	Oid			typeid;			/* type identified by OID */	bool		timezone;		/* timezone specified? */	bool		setof;			/* is a set? */	bool		pct_type;		/* %TYPE specified? */	int32		typmod;			/* type modifier */	List	   *arrayBounds;	/* array bounds */	int			location;		/* token location, or -1 if unknown */} TypeName;/* * ColumnRef - specifies a reference to a column, or possibly a whole tuple * *		The "fields" list must be nonempty; its last component may be "*" *		instead of a regular field name. * * Note: any array subscripting or selection of fields from composite columns * is represented by an A_Indirection node above the ColumnRef.  However, * for simplicity in the normal case, initial field selection from a table * name is represented within ColumnRef and not by adding A_Indirection. */typedef struct ColumnRef{	NodeTag		type;	List	   *fields;			/* field names (list of Value strings) */	int			location;		/* token location, or -1 if unknown */} ColumnRef;/* * ParamRef - specifies a $n parameter reference */typedef struct ParamRef{	NodeTag		type;	int			number;			/* the number of the parameter */} ParamRef;/* * A_Expr - infix, prefix, and postfix expressions */typedef enum A_Expr_Kind{	AEXPR_OP,					/* normal operator */	AEXPR_AND,					/* booleans - name field is unused */	AEXPR_OR,	AEXPR_NOT,	AEXPR_OP_ANY,				/* scalar op ANY (array) */	AEXPR_OP_ALL,				/* scalar op ALL (array) */	AEXPR_DISTINCT,				/* IS DISTINCT FROM - name must be "=" */	AEXPR_NULLIF,				/* NULLIF - name must be "=" */	AEXPR_OF,					/* IS [NOT] OF - name must be "=" or "<>" */	AEXPR_IN					/* [NOT] IN - name must be "=" or "<>" */} A_Expr_Kind;typedef struct A_Expr{	NodeTag		type;	A_Expr_Kind kind;			/* see above */	List	   *name;			/* possibly-qualified name of operator */	Node	   *lexpr;			/* left argument, or NULL if none */	Node	   *rexpr;			/* right argument, or NULL if none */	int			location;		/* token location, or -1 if unknown */} A_Expr;/* * A_Const - a constant expression */typedef struct A_Const{	NodeTag		type;	Value		val;			/* the value (with the tag) */	TypeName   *typename;		/* typecast, or NULL if none */} A_Const;/* * TypeCast - a CAST expression * * NOTE: for mostly historical reasons, A_Const parsenodes contain * room for a TypeName; we only generate a separate TypeCast node if the * argument to be casted is not a constant.  In theory either representation * would work, but the combined representation saves a bit of code in many * productions in gram.y. */typedef struct TypeCast{	NodeTag		type;	Node	   *arg;			/* the expression being casted */	TypeName   *typename;		/* the target type */} TypeCast;/* * FuncCall - a function or aggregate invocation * * agg_star indicates we saw a 'foo(*)' construct, while agg_distinct * indicates we saw 'foo(DISTINCT ...)'.  In either case, the construct * *must* be an aggregate call.  Otherwise, it might be either an * aggregate or some other kind of function. */typedef struct FuncCall{	NodeTag		type;	List	   *funcname;		/* qualified name of function */	List	   *args;			/* the arguments (list of exprs) */	bool		agg_star;		/* argument was really '*' */	bool		agg_distinct;	/* arguments were labeled DISTINCT */	int			location;		/* token location, or -1 if unknown */} FuncCall;/* * A_Indices - array reference or bounds ([lidx:uidx] or [uidx]) */typedef struct A_Indices{	NodeTag		type;	Node	   *lidx;			/* could be NULL */	Node	   *uidx;} A_Indices;/* * A_Indirection - select a field and/or array element from an expression * * The indirection list can contain both A_Indices nodes (representing * subscripting) and string Value nodes (representing field selection * --- the string value is the name of the field to select).  For example, * a complex selection operation like *				(foo).field1[42][7].field2 * would be represented with a single A_Indirection node having a 4-element * indirection list. * * Note: as of Postgres 8.0, we don't support arrays of composite values, * so cases in which a field select follows a subscript aren't actually * semantically legal.	However the parser is prepared to handle such. */typedef struct A_Indirection{	NodeTag		type;	Node	   *arg;			/* the thing being selected from */	List	   *indirection;	/* subscripts and/or field names */} A_Indirection;/* * ResTarget - *	  result target (used in target list of pre-transformed parse trees) * * In a SELECT target list, 'name' is the column label from an * 'AS ColumnLabel' clause, or NULL if there was none, and 'val' is the * value expression itself.  The 'indirection' field is not used. * * INSERT uses ResTarget in its target-column-names list.  Here, 'name' is * the name of the destination column, 'indirection' stores any subscripts * attached to the destination, and 'val' is not used. * * In an UPDATE target list, 'name' is the name of the destination column, * 'indirection' stores any subscripts attached to the destination, and * 'val' is the expression to assign. * * See A_Indirection for more info about what can appear in 'indirection'. */typedef struct ResTarget{	NodeTag		type;	char	   *name;			/* column name or NULL */	List	   *indirection;	/* subscripts and field names, or NIL */	Node	   *val;			/* the value expression to compute or assign */	int			location;		/* token location, or -1 if unknown */} ResTarget;/* * SortBy - for ORDER BY clause */#define SORTBY_ASC		1#define SORTBY_DESC		2#define SORTBY_USING	3typedef struct SortBy{	NodeTag		type;	int			sortby_kind;	/* see codes above */	List	   *useOp;			/* name of op to use, if SORTBY_USING */	Node	   *node;			/* expression to sort on */} SortBy;/* * RangeSubselect - subquery appearing in a FROM clause */typedef struct RangeSubselect{	NodeTag		type;	Node	   *subquery;		/* the untransformed sub-select clause */	Alias	   *alias;			/* table alias & optional column aliases */} RangeSubselect;/* * RangeFunction - function call appearing in a FROM clause */typedef struct RangeFunction{	NodeTag		type;	Node	   *funccallnode;	/* untransformed function call tree */	Alias	   *alias;			/* table alias & optional column aliases */	List	   *coldeflist;		/* list of ColumnDef nodes to describe result								 * of function returning RECORD */} RangeFunction;/* * ColumnDef - column definition (used in various creates) * * If the column has a default value, we may have the value expression * in either "raw" form (an untransformed parse tree) or "cooked" form * (the nodeToString representation of an executable expression tree), * depending on how this ColumnDef node was created (by parsing, or by * inheritance from an existing relation).	We should never have both * in the same node! * * The constraints list may contain a CONSTR_DEFAULT item in a raw * parsetree produced by gram.y, but transformCreateStmt will remove

⌨️ 快捷键说明

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