parsenodes.h

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

H
1,961
字号
 * the item and set raw_default instead.  CONSTR_DEFAULT items * should not appear in any subsequent processing. */typedef struct ColumnDef{	NodeTag		type;	char	   *colname;		/* name of column */	TypeName   *typename;		/* type of column */	int			inhcount;		/* number of times column is inherited */	bool		is_local;		/* column has local (non-inherited) def'n */	bool		is_not_null;	/* NOT NULL constraint specified? */	Node	   *raw_default;	/* default value (untransformed parse tree) */	char	   *cooked_default; /* nodeToString representation */	List	   *constraints;	/* other constraints on column */} ColumnDef;/* * inhRelation - Relations a CREATE TABLE is to inherit attributes of */typedef struct InhRelation{	NodeTag		type;	RangeVar   *relation;	List	   *options;		/* integer List of CreateStmtLikeOption */} InhRelation;typedef enum CreateStmtLikeOption{	CREATE_TABLE_LIKE_INCLUDING_DEFAULTS,	CREATE_TABLE_LIKE_EXCLUDING_DEFAULTS,	CREATE_TABLE_LIKE_INCLUDING_CONSTRAINTS,	CREATE_TABLE_LIKE_EXCLUDING_CONSTRAINTS,	CREATE_TABLE_LIKE_INCLUDING_INDEXES,	CREATE_TABLE_LIKE_EXCLUDING_INDEXES} CreateStmtLikeOption;/* * IndexElem - index parameters (used in CREATE INDEX) * * For a plain index attribute, 'name' is the name of the table column to * index, and 'expr' is NULL.  For an index expression, 'name' is NULL and * 'expr' is the expression tree. */typedef struct IndexElem{	NodeTag		type;	char	   *name;			/* name of attribute to index, or NULL */	Node	   *expr;			/* expression to index, or NULL */	List	   *opclass;		/* name of desired opclass; NIL = default */} IndexElem;/* * DefElem - *	  a definition (used in definition lists in the form of defname = arg) */typedef struct DefElem{	NodeTag		type;	char	   *defname;	Node	   *arg;			/* a (Value *) or a (TypeName *) */} DefElem;/* * LockingClause - raw representation of FOR UPDATE/SHARE options * * Note: lockedRels == NIL means "all relations in query".	Otherwise it * is a list of String nodes giving relation eref names. */typedef struct LockingClause{	NodeTag		type;	List	   *lockedRels;		/* FOR UPDATE or FOR SHARE relations */	bool		forUpdate;		/* true = FOR UPDATE, false = FOR SHARE */	bool		noWait;			/* NOWAIT option */} LockingClause;/**************************************************************************** *	Nodes for a Query tree ****************************************************************************//*-------------------- * RangeTblEntry - *	  A range table is a List of RangeTblEntry nodes. * *	  A range table entry may represent a plain relation, a sub-select in *	  FROM, or the result of a JOIN clause.  (Only explicit JOIN syntax *	  produces an RTE, not the implicit join resulting from multiple FROM *	  items.  This is because we only need the RTE to deal with SQL features *	  like outer joins and join-output-column aliasing.)  Other special *	  RTE types also exist, as indicated by RTEKind. * *	  alias is an Alias node representing the AS alias-clause attached to the *	  FROM expression, or NULL if no clause. * *	  eref is the table reference name and column reference names (either *	  real or aliases).  Note that system columns (OID etc) are not included *	  in the column list. *	  eref->aliasname is required to be present, and should generally be used *	  to identify the RTE for error messages etc. * *	  In RELATION RTEs, the colnames in both alias and eref are indexed by *	  physical attribute number; this means there must be colname entries for *	  dropped columns.	When building an RTE we insert empty strings ("") for *	  dropped columns.	Note however that a stored rule may have nonempty *	  colnames for columns dropped since the rule was created (and for that *	  matter the colnames might be out of date due to column renamings). *	  The same comments apply to FUNCTION RTEs when the function's return type *	  is a named composite type. * *	  In JOIN RTEs, the colnames in both alias and eref are one-to-one with *	  joinaliasvars entries.  A JOIN RTE will omit columns of its inputs when *	  those columns are known to be dropped at parse time.	Again, however, *	  a stored rule might contain entries for columns dropped since the rule *	  was created.	(This is only possible for columns not actually referenced *	  in the rule.)  When loading a stored rule, we replace the joinaliasvars *	  items for any such columns with NULL Consts.	(We can't simply delete *	  them from the joinaliasvars list, because that would affect the attnums *	  of Vars referencing the rest of the list.) * *	  inh is TRUE for relation references that should be expanded to include *	  inheritance children, if the rel has any.  This *must* be FALSE for *	  RTEs other than RTE_RELATION entries. * *	  inFromCl marks those range variables that are listed in the FROM clause. *	  It's false for RTEs that are added to a query behind the scenes, such *	  as the NEW and OLD variables for a rule, or the subqueries of a UNION. *	  This flag is not used anymore during parsing, since the parser now uses *	  a separate "namespace" data structure to control visibility, but it is *	  needed by ruleutils.c to determine whether RTEs should be shown in *	  decompiled queries. * *	  requiredPerms and checkAsUser specify run-time access permissions *	  checks to be performed at query startup.	The user must have *all* *	  of the permissions that are OR'd together in requiredPerms (zero *	  indicates no permissions checking).  If checkAsUser is not zero, *	  then do the permissions checks using the access rights of that user, *	  not the current effective user ID.  (This allows rules to act as *	  setuid gateways.) *-------------------- */typedef enum RTEKind{	RTE_RELATION,				/* ordinary relation reference */	RTE_SUBQUERY,				/* subquery in FROM */	RTE_JOIN,					/* join */	RTE_SPECIAL,				/* special rule relation (NEW or OLD) */	RTE_FUNCTION,				/* function in FROM */	RTE_VALUES					/* VALUES (<exprlist>), (<exprlist>), ... */} RTEKind;typedef struct RangeTblEntry{	NodeTag		type;	RTEKind		rtekind;		/* see above */	/*	 * XXX the fields applicable to only some rte kinds should be merged into	 * a union.  I didn't do this yet because the diffs would impact a lot of	 * code that is being actively worked on.  FIXME later.	 */	/*	 * Fields valid for a plain relation RTE (else zero):	 */	Oid			relid;			/* OID of the relation */	/*	 * Fields valid for a subquery RTE (else NULL):	 */	Query	   *subquery;		/* the sub-query */	/*	 * Fields valid for a function RTE (else NULL):	 *	 * If the function returns RECORD, funccoltypes lists the column types	 * declared in the RTE's column type specification, and funccoltypmods	 * lists their declared typmods.  Otherwise, both fields are NIL.	 */	Node	   *funcexpr;		/* expression tree for func call */	List	   *funccoltypes;	/* OID list of column type OIDs */	List	   *funccoltypmods; /* integer list of column typmods */	/*	 * Fields valid for a values RTE (else NIL):	 */	List	   *values_lists;	/* list of expression lists */	/*	 * Fields valid for a join RTE (else NULL/zero):	 *	 * joinaliasvars is a list of Vars or COALESCE expressions corresponding	 * to the columns of the join result.  An alias Var referencing column K	 * of the join result can be replaced by the K'th element of joinaliasvars	 * --- but to simplify the task of reverse-listing aliases correctly, we	 * do not do that until planning time.	In a Query loaded from a stored	 * rule, it is also possible for joinaliasvars items to be NULL Consts,	 * denoting columns dropped since the rule was made.	 */	JoinType	jointype;		/* type of join */	List	   *joinaliasvars;	/* list of alias-var expansions */	/*	 * Fields valid in all RTEs:	 */	Alias	   *alias;			/* user-written alias clause, if any */	Alias	   *eref;			/* expanded reference names */	bool		inh;			/* inheritance requested? */	bool		inFromCl;		/* present in FROM clause? */	AclMode		requiredPerms;	/* bitmask of required access permissions */	Oid			checkAsUser;	/* if valid, check access as this role */} RangeTblEntry;/* * SortClause - *	   representation of ORDER BY clauses * * tleSortGroupRef must match ressortgroupref of exactly one entry of the * associated targetlist; that is the expression to be sorted (or grouped) by. * sortop is the OID of the ordering operator. * * SortClauses are also used to identify targets that we will do a "Unique" * filter step on (for SELECT DISTINCT and SELECT DISTINCT ON).  The * distinctClause list is simply a copy of the relevant members of the * sortClause list.  Note that distinctClause can be a subset of sortClause, * but cannot have members not present in sortClause; and the members that * do appear must be in the same order as in sortClause. */typedef struct SortClause{	NodeTag		type;	Index		tleSortGroupRef;	/* reference into targetlist */	Oid			sortop;			/* the sort operator to use */} SortClause;/* * GroupClause - *	   representation of GROUP BY clauses * * GroupClause is exactly like SortClause except for the nodetag value * (it's probably not even really necessary to have two different * nodetags...).  We have routines that operate interchangeably on both. */typedef SortClause GroupClause;/* * RowMarkClause - *	   representation of FOR UPDATE/SHARE clauses * * We create a separate RowMarkClause node for each target relation */typedef struct RowMarkClause{	NodeTag		type;	Index		rti;			/* range table index of target relation */	bool		forUpdate;		/* true = FOR UPDATE, false = FOR SHARE */	bool		noWait;			/* NOWAIT option */} RowMarkClause;/***************************************************************************** *		Optimizable Statements *****************************************************************************//* ---------------------- *		Insert Statement * * The source expression is represented by SelectStmt for both the * SELECT and VALUES cases.  If selectStmt is NULL, then the query * is INSERT ... DEFAULT VALUES. * ---------------------- */typedef struct InsertStmt{	NodeTag		type;	RangeVar   *relation;		/* relation to insert into */	List	   *cols;			/* optional: names of the target columns */	Node	   *selectStmt;		/* the source SELECT/VALUES, or NULL */	List	   *returningList;	/* list of expressions to return */} InsertStmt;/* ---------------------- *		Delete Statement * ---------------------- */typedef struct DeleteStmt{	NodeTag		type;	RangeVar   *relation;		/* relation to delete from */	List	   *usingClause;	/* optional using clause for more tables */	Node	   *whereClause;	/* qualifications */	List	   *returningList;	/* list of expressions to return */} DeleteStmt;/* ---------------------- *		Update Statement * ---------------------- */typedef struct UpdateStmt{	NodeTag		type;	RangeVar   *relation;		/* relation to update */	List	   *targetList;		/* the target list (of ResTarget) */	Node	   *whereClause;	/* qualifications */	List	   *fromClause;		/* optional from clause for more tables */	List	   *returningList;	/* list of expressions to return */} UpdateStmt;/* ---------------------- *		Select Statement * * A "simple" SELECT is represented in the output of gram.y by a single * SelectStmt node; so is a VALUES construct.  A query containing set * operators (UNION, INTERSECT, EXCEPT) is represented by a tree of SelectStmt * nodes, in which the leaf nodes are component SELECTs and the internal nodes * represent UNION, INTERSECT, or EXCEPT operators.  Using the same node * type for both leaf and internal nodes allows gram.y to stick ORDER BY, * LIMIT, etc, clause values into a SELECT statement without worrying * whether it is a simple or compound SELECT. * ---------------------- */typedef enum SetOperation{	SETOP_NONE = 0,	SETOP_UNION,	SETOP_INTERSECT,	SETOP_EXCEPT} SetOperation;typedef struct SelectStmt{	NodeTag		type;	/*	 * These fields are used only in "leaf" SelectStmts.	 *	 * into, intoColNames, intoOptions, intoOnCommit, and intoTableSpaceName	 * are a kluge; they belong somewhere else...	 */	List	   *distinctClause; /* NULL, list of DISTINCT ON exprs, or								 * lcons(NIL,NIL) for all (SELECT DISTINCT) */	RangeVar   *into;			/* target table (for select into table) */	List	   *intoColNames;	/* column names for into table */	List	   *intoOptions;	/* options from WITH clause */	OnCommitAction intoOnCommit;	/* what do we do at COMMIT? */	char	   *intoTableSpaceName;		/* table space to use, or NULL */	List	   *targetList;		/* the target list (of ResTarget) */	List	   *fromClause;		/* the FROM clause */	Node	   *whereClause;	/* WHERE qualification */	List	   *groupClause;	/* GROUP BY clauses */	Node	   *havingClause;	/* HAVING conditional-expression */	/*	 * In a "leaf" node representing a VALUES list, the above fields are all	 * null, and instead this field is set.  Note that the elements of the	 * sublists are just expressions, without ResTarget decoration. Also note	 * that a list element can be DEFAULT (represented as a SetToDefault	 * node), regardless of the context of the VALUES list. It's up to parse	 * analysis to reject that where not valid.	 */	List	   *valuesLists;	/* untransformed list of expression lists */	/*	 * These fields are used in both "leaf" SelectStmts and upper-level	 * SelectStmts.	 */	List	   *sortClause;		/* sort clause (a list of SortBy's) */	Node	   *limitOffset;	/* # of result tuples to skip */	Node	   *limitCount;		/* # of result tuples to return */	List	   *lockingClause;	/* FOR UPDATE (list of LockingClause's) */	/*	 * These fields are used only in upper-level SelectStmts.	 */	SetOperation op;			/* type of set op */	bool		all;			/* ALL specified? */	struct SelectStmt *larg;	/* left child */	struct SelectStmt *rarg;	/* right child */	/* Eventually add fields for CORRESPONDING spec here */} SelectStmt;/* ---------------------- *		Set Operation node for post-analysis query trees * * After parse analysis, a SELECT with set operations is represented by a * top-level Query node containing the leaf SELECTs as subqueries in its * range table.  Its setOperations field shows the tree of set operations, * with leaf SelectStmt nodes replaced by RangeTblRef nodes, and internal * nodes replaced by SetOperationStmt nodes. * ---------------------- */typedef struct SetOperationStmt

⌨️ 快捷键说明

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