parsenodes.h
来自「PostgreSQL7.4.6 for Linux」· C头文件 代码 · 共 1,701 行 · 第 1/4 页
H
1,701 行
* checkForRead, checkForWrite, and checkAsUser control run-time access * permissions checks. A rel will be checked for read or write access * (or both, or neither) per checkForRead and checkForWrite. If * checkAsUser is not InvalidOid, 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 */} 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): */ Node *funcexpr; /* expression tree for func call */ List *coldeflist; /* list of ColumnDef nodes for runtime * assignment of RECORD TupleDesc */ /* * 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. */ 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 */ bool checkForRead; /* check rel for read access */ bool checkForWrite; /* check rel for write access */ Oid checkAsUser; /* if not zero, check access as this user */} RangeTblEntry;/* * SortClause - * representation of ORDER BY clauses * * tleSortGroupRef must match ressortgroupref of exactly one Resdom 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 Resdoms 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;/***************************************************************************** * Optimizable Statements *****************************************************************************//* ---------------------- * Insert Statement * ---------------------- */typedef struct InsertStmt{ NodeTag type; RangeVar *relation; /* relation to insert into */ List *cols; /* optional: names of the target columns */ /* * An INSERT statement has *either* VALUES or SELECT, never both. If * VALUES, a targetList is supplied (empty for DEFAULT VALUES). If * SELECT, a complete SelectStmt (or set-operation tree) is supplied. */ List *targetList; /* the target list (of ResTarget) */ Node *selectStmt; /* the source SELECT */} InsertStmt;/* ---------------------- * Delete Statement * ---------------------- */typedef struct DeleteStmt{ NodeTag type; RangeVar *relation; /* relation to delete from */ Node *whereClause; /* qualifications */} 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 */} UpdateStmt;/* ---------------------- * Select Statement * * A "simple" SELECT is represented in the output of gram.y by a single * SelectStmt node. A SELECT construct 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 and intoColNames 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 *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 */ /* * 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 *forUpdate; /* FOR UPDATE clause */ /* * 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{ NodeTag type; SetOperation op; /* type of set op */ bool all; /* ALL specified? */ Node *larg; /* left child */ Node *rarg; /* right child */ /* Eventually add fields for CORRESPONDING spec here */ /* Fields derived during parse analysis: */ List *colTypes; /* list of OIDs of output column types */} SetOperationStmt;/***************************************************************************** * Other Statements (no optimizations required) * * Some of them require a little bit of transformation (which is also * done by transformStmt). The whole structure is then passed on to * ProcessUtility (by-passing the optimization step) as the utilityStmt * field in Query. *****************************************************************************//* * When a command can act on several kinds of objects with only one * parse structure required, use these constants to designate the * object type. */typedef enum ObjectType{ OBJECT_AGGREGATE, OBJECT_CAST, OBJECT_COLUMN, OBJECT_CONSTRAINT, OBJECT_CONVERSION, OBJECT_DATABASE, OBJECT_DOMAIN, OBJECT_FUNCTION, OBJECT_GROUP, OBJECT_INDEX, OBJECT_LANGUAGE, OBJECT_OPCLASS, OBJECT_OPERATOR, OBJECT_RULE, OBJECT_SCHEMA, OBJECT_SEQUENCE, OBJECT_TABLE, OBJECT_TRIGGER, OBJECT_TYPE, OBJECT_USER, OBJECT_VIEW} ObjectType;/* ---------------------- * Create Schema Statement * * NOTE: the schemaElts list contains raw parsetrees for component statements * of the schema, such as CREATE TABLE, GRANT, etc. These are analyzed and * executed after the schema itself is created. * ---------------------- */typedef struct CreateSchemaStmt{ NodeTag type; char *schemaname; /* the name of the schema to create */ char *authid; /* the owner of the created schema */ List *schemaElts; /* schema components (list of parsenodes) */} CreateSchemaStmt;typedef enum DropBehavior{ DROP_RESTRICT, /* drop fails if any dependent objects */ DROP_CASCADE /* remove dependent objects too */} DropBehavior;/* ---------------------- * Alter Table * * The fields are used in different ways by the different variants of * this command. * ---------------------- */typedef struct AlterTableStmt{ NodeTag type; char subtype; /*------------ * A = add column * T = alter column default * N = alter column drop not null * n = alter column set not null * S = alter column statistics * M = alter column storage * D = drop column * C = add constraint * c = pre-processed add constraint * (local in parser/analyze.c) * X = drop constraint * E = create toast table * U = change owner * L = CLUSTER ON * o = DROP OIDS *------------ */ RangeVar *relation; /* table to work on */ char *name; /* column or constraint name to act on, or * new owner */ Node *def; /* definition of new column or constraint */ DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */} AlterTableStmt;/* ---------------------- * Alter Domain * * The fields are used in different ways by the different variants of * this command. Subtypes should match AlterTable subtypes where possible. * ---------------------- */typedef struct AlterDomainStmt{ NodeTag type; char subtype; /*------------ * T = alter column default * N = alter column drop not null * O = alter column set not null * C = add constraint * X = drop constraint * U = change owner *------------ */ List *typename; /* table to work on */ char *name; /* column or constraint name to act on, or * new owner */ Node *def; /* definition of default or constraint */ DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */} AlterDomainStmt;/* ---------------------- * Grant|Revoke Statement * ---------------------- */typedef enum GrantObjectType{ ACL_OBJECT_RELATION, /* table, view, sequence */ ACL_OBJECT_DATABASE, /* database */ ACL_OBJECT_FUNCTION, /* function */ ACL_OBJECT_LANGUAGE, /* procedural language */ ACL_OBJECT_NAMESPACE /* namespace */} GrantObjectType;/* * Grantable rights are encoded so that we can OR them together in a bitmask. * The present representation of AclItem limits us to 15 distinct rights. * Caution: changing these codes breaks stored ACLs, hence forces initdb. */#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)#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 N_ACL_RIGHTS 11 /* 1 plus the last 1<<x */#define ACL_ALL_RIGHTS (-1) /* all-privileges marker in GRANT list */#define ACL_NO_RIGHTS 0typedef struct GrantStmt{ NodeTag type; bool is_grant; /* true = GRANT, false = REVOKE */ GrantObjectType objtype; /* kind of object being operated on */ List *objects; /* list of RangeVar nodes, FuncWithArgs * nodes, or plain names (as Value * strings) */ List *privileges; /* integer list of privilege codes */ List *grantees; /* list of PrivGrantee nodes */ bool grant_option; /* grant or revoke grant option */ DropBehavior behavior; /* drop behavior (for REVOKE) */} GrantStmt;typedef struct PrivGrantee{ NodeTag type; char *username; /* if both are NULL then PUBLIC */ char *groupname;} PrivGrantee;typedef struct FuncWithArgs{ NodeTag type; List *funcname; /* qualified name of function */ List *funcargs; /* list of Typename nodes */} FuncWithArgs;/* This is only used internally in gram.y. */typedef struct PrivTarget{ NodeTag type; GrantObjectType objtype; List *objs;} PrivTarget;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?