📄 parsenodes.h
字号:
* 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 */} 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. 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;/***************************************************************************** * 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 */ List *usingClause; /* optional using clause for more tables */} 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 enum ContainsOids{ MUST_HAVE_OIDS, /* WITH OIDS explicitely specified */ MUST_NOT_HAVE_OIDS, /* WITHOUT OIDS explicitely specified */ DEFAULT_OIDS /* neither specified; use the default, which * is the value of the default_with_oids GUC * var */} ContainsOids;typedef struct SelectStmt{ NodeTag type; /* * These fields are used only in "leaf" SelectStmts. * * into, intoColNames and intoHasOids 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 */ ContainsOids intoHasOids; /* should target table have OIDs? */ 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 */ LockingClause *lockingClause; /* FOR UPDATE/FOR SHARE */ /* * 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_INDEX, OBJECT_LANGUAGE, OBJECT_LARGEOBJECT, OBJECT_OPCLASS, OBJECT_OPERATOR, OBJECT_ROLE, OBJECT_RULE, OBJECT_SCHEMA, OBJECT_SEQUENCE, OBJECT_TABLE, OBJECT_TABLESPACE, OBJECT_TRIGGER, OBJECT_TYPE, 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 * ---------------------- */typedef struct AlterTableStmt{ NodeTag type; RangeVar *relation; /* table to work on */ List *cmds; /* list of subcommands */ ObjectType relkind; /* type of object */} AlterTableStmt;typedef enum AlterTableType{ AT_AddColumn, /* add column */ AT_ColumnDefault, /* alter column default */ AT_DropNotNull, /* alter column drop not null */ AT_SetNotNull, /* alter column set not null */ AT_SetStatistics, /* alter column statistics */ AT_SetStorage, /* alter column storage */ AT_DropColumn, /* drop column */ AT_DropColumnRecurse, /* internal to commands/tablecmds.c */ AT_AddIndex, /* add index */ AT_ReAddIndex, /* internal to commands/tablecmds.c */ AT_AddConstraint, /* add constraint */ AT_ProcessedConstraint, /* pre-processed add constraint (local in * parser/analyze.c) */ AT_DropConstraint, /* drop constraint */ AT_DropConstraintQuietly, /* drop constraint, no error/warning (local in * commands/tablecmds.c) */ AT_AlterColumnType, /* alter column type */ AT_ToastTable, /* create toast table */ AT_ChangeOwner, /* change owner */ AT_ClusterOn, /* CLUSTER ON */ AT_DropCluster, /* SET WITHOUT CLUSTER */ AT_DropOids, /* SET WITHOUT OIDS */ AT_SetTableSpace, /* SET TABLESPACE */ AT_EnableTrig, /* ENABLE TRIGGER name */ AT_DisableTrig, /* DISABLE TRIGGER name */ AT_EnableTrigAll, /* ENABLE TRIGGER ALL */ AT_DisableTrigAll, /* DISABLE TRIGGER ALL */ AT_EnableTrigUser, /* ENABLE TRIGGER USER */ AT_DisableTrigUser /* DISABLE TRIGGER USER */} AlterTableType;typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */{ NodeTag type; AlterTableType subtype; /* Type of table alteration to apply */ char *name; /* column, constraint, or trigger to act on, * or new owner or tablespace */ Node *def; /* definition of new column, column type, * index, or constraint */ Node *transform; /* transformation expr for ALTER TYPE */ DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */} AlterTableCmd;/* ---------------------- * Alter Domain * * The fields are used in different ways by the different variants of * this command. * ---------------------- */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 *------------ */ List *typename; /* domain to work on */ char *name; /* column or constraint name to act on */ 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 */ ACL_OBJECT_TABLESPACE /* tablespace */} GrantObjectType;typedef 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; /* list of privilege names (as Strings) */ /* privileges == NIL denotes "all privileges" */ 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 *rolname; /* if NULL then PUBLIC */} PrivGrantee;/* * Note: FuncWithArgs carries only the types of the input parameters of the * function. So it is sufficient to identify an existing function, but it * is not enough info to define a function nor to call it. */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;/* ---------------------- * Grant/Revoke Role Statement * * Note: the lists of roles are lists of names, as Value strings * ---------------------- */typedef struct GrantRoleStmt
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -