X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Finclude%2Fnodes%2Fparsenodes.h;h=bc62c90f4dcef3f5e99dbcdfffa339eac0896cd0;hb=a78fcfb5124379532ce35f3076679f04bd987d60;hp=85016f351123ee92c3fe79ea3f0e2515a713b126;hpb=ad161bcc8a3792d18ef2f3ebe66bb1e22d42b6f2;p=pg-rex%2Fsyncrep.git diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 85016f3511..bc62c90f4d 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -4,10 +4,10 @@ * definitions for parse tree nodes * * - * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * 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.276 2005/04/06 16:34:07 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.335 2006/12/23 00:43:12 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -15,7 +15,7 @@ #define PARSENODES_H #include "nodes/primnodes.h" - +#include "nodes/value.h" /* Possible sources of a Query */ typedef enum QuerySource @@ -27,9 +27,19 @@ typedef enum QuerySource 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 15 distinct rights, + * 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. @@ -40,17 +50,17 @@ typedef uint32 AclMode; /* a bitmask of privilege bits */ #define ACL_SELECT (1<<1) #define ACL_UPDATE (1<<2) #define ACL_DELETE (1<<3) -#define ACL_RULE (1<<4) +/* #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 N_ACL_RIGHTS 11 /* 1 plus the last 1<" */ + AEXPR_IN /* [NOT] IN - name must be "=" or "<>" */ } A_Expr_Kind; typedef struct A_Expr @@ -212,6 +236,7 @@ typedef struct A_Expr 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; /* @@ -221,7 +246,7 @@ typedef struct A_Const { NodeTag type; Value val; /* the value (with the tag) */ - TypeName *typename; /* typecast */ + TypeName *typename; /* typecast, or NULL if none */ } A_Const; /* @@ -230,8 +255,8 @@ typedef struct A_Const * 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 it is convenient to have the target type immediately - * available while resolving a constant's datatype. + * would work, but the combined representation saves a bit of code in many + * productions in gram.y. */ typedef struct TypeCast { @@ -255,6 +280,7 @@ typedef struct FuncCall 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; /* @@ -293,13 +319,13 @@ typedef struct A_Indirection * ResTarget - * result target (used in target list of pre-transformed parse trees) * - * In a SELECT or INSERT target list, 'name' is the column label from an + * 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 has a second ResTarget list which is the target-column-names list. - * Here, 'val' is not used, 'name' is the name of the destination column, - * and 'indirection' stores any subscripts attached to the destination. + * 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 @@ -312,8 +338,8 @@ 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 */ + Node *val; /* the value expression to compute or assign */ + int location; /* token location, or -1 if unknown */ } ResTarget; /* @@ -349,8 +375,8 @@ typedef struct RangeFunction NodeTag type; Node *funccallnode; /* untransformed function call tree */ Alias *alias; /* table alias & optional column aliases */ - List *coldeflist; /* list of ColumnDef nodes for runtime - * assignment of RECORD TupleDesc */ + List *coldeflist; /* list of ColumnDef nodes to describe result + * of function returning RECORD */ } RangeFunction; /* @@ -367,10 +393,6 @@ typedef struct RangeFunction * parsetree produced by gram.y, but transformCreateStmt will remove * the item and set raw_default instead. CONSTR_DEFAULT items * should not appear in any subsequent processing. - * - * The "support" field, if not null, denotes a supporting relation that - * should be linked by an internal dependency to the column. Currently - * this is only used to link a SERIAL column's sequence to the column. */ typedef struct ColumnDef { @@ -380,11 +402,9 @@ typedef struct ColumnDef 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) */ + Node *raw_default; /* default value (untransformed parse tree) */ char *cooked_default; /* nodeToString representation */ List *constraints; /* other constraints on column */ - RangeVar *support; /* supporting relation, if any */ } ColumnDef; /* @@ -394,9 +414,19 @@ typedef struct InhRelation { NodeTag type; RangeVar *relation; - bool including_defaults; + 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) * @@ -423,6 +453,20 @@ typedef struct DefElem 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 @@ -462,21 +506,22 @@ typedef struct DefElem * 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.) + * 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. - * In SQL, the query can only refer to range variables listed in the - * FROM clause, but POSTQUEL allows you to refer to tables not listed, - * in which case a range table entry will be generated. We still support - * this POSTQUEL feature, although there is some doubt whether it's - * convenient or merely confusing. The flag is needed since an - * implicitly-added RTE shouldn't change the namespace for unqualified - * column names processed later, and it also shouldn't affect the - * expansion of '*'. + * 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* @@ -493,7 +538,8 @@ typedef enum RTEKind RTE_SUBQUERY, /* subquery in FROM */ RTE_JOIN, /* join */ RTE_SPECIAL, /* special rule relation (NEW or OLD) */ - RTE_FUNCTION /* function in FROM */ + RTE_FUNCTION, /* function in FROM */ + RTE_VALUES /* VALUES (), (), ... */ } RTEKind; typedef struct RangeTblEntry @@ -503,9 +549,9 @@ typedef struct RangeTblEntry 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. + * 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. */ /* @@ -520,19 +566,30 @@ typedef struct RangeTblEntry /* * 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 *coldeflist; /* list of ColumnDef nodes for runtime - * assignment of RECORD TupleDesc */ + 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. + * 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 */ @@ -543,9 +600,9 @@ typedef struct RangeTblEntry Alias *alias; /* user-written alias clause, if any */ Alias *eref; /* expanded reference names */ bool inh; /* inheritance requested? */ - bool inFromCl; /* present in FROM clause */ + bool inFromCl; /* present in FROM clause? */ AclMode requiredPerms; /* bitmask of required access permissions */ - AclId checkAsUser; /* if not zero, check access as this user */ + Oid checkAsUser; /* if valid, check access as this role */ } RangeTblEntry; /* @@ -580,6 +637,19 @@ typedef struct SortClause */ 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 @@ -587,6 +657,10 @@ typedef SortClause GroupClause; /* ---------------------- * 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 @@ -594,14 +668,8 @@ 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 */ + Node *selectStmt; /* the source SELECT/VALUES, or NULL */ + List *returningList; /* list of expressions to return */ } InsertStmt; /* ---------------------- @@ -612,7 +680,9 @@ 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; /* ---------------------- @@ -626,15 +696,16 @@ typedef struct UpdateStmt 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. 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 + * 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 @@ -649,15 +720,6 @@ typedef enum SetOperation 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; @@ -665,15 +727,16 @@ typedef struct SelectStmt /* * These fields are used only in "leaf" SelectStmts. * - * into, intoColNames and intoHasOids are a kluge; they belong somewhere - * else... + * 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) */ + * 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 *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 */ @@ -681,13 +744,23 @@ typedef struct SelectStmt 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 *forUpdate; /* FOR UPDATE clause */ + List *lockingClause; /* FOR UPDATE (list of LockingClause's) */ /* * These fields are used only in upper-level SelectStmts. @@ -699,6 +772,7 @@ typedef struct SelectStmt /* Eventually add fields for CORRESPONDING spec here */ } SelectStmt; + /* ---------------------- * Set Operation node for post-analysis query trees * @@ -719,7 +793,8 @@ typedef struct SetOperationStmt /* Eventually add fields for CORRESPONDING spec here */ /* Fields derived during parse analysis: */ - List *colTypes; /* list of OIDs of output column types */ + List *colTypes; /* OID list of output column type OIDs */ + List *colTypmods; /* integer list of output column typmods */ } SetOperationStmt; @@ -748,12 +823,12 @@ typedef enum ObjectType OBJECT_DATABASE, OBJECT_DOMAIN, OBJECT_FUNCTION, - OBJECT_GROUP, OBJECT_INDEX, OBJECT_LANGUAGE, OBJECT_LARGEOBJECT, OBJECT_OPCLASS, OBJECT_OPERATOR, + OBJECT_ROLE, OBJECT_RULE, OBJECT_SCHEMA, OBJECT_SEQUENCE, @@ -761,7 +836,6 @@ typedef enum ObjectType OBJECT_TABLESPACE, OBJECT_TRIGGER, OBJECT_TYPE, - OBJECT_USER, OBJECT_VIEW } ObjectType; @@ -815,25 +889,34 @@ typedef enum AlterTableType 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_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_SetTableSpace, /* SET TABLESPACE */ + AT_SetRelOptions, /* SET (...) -- AM specific parameters */ + AT_ResetRelOptions, /* RESET (...) -- AM specific parameters */ + 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 */ + AT_AddInherit, /* INHERIT parent */ + AT_DropInherit /* NO INHERIT parent */ } AlterTableType; typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */ { NodeTag type; AlterTableType subtype; /* Type of table alteration to apply */ - char *name; /* column or constraint name to act on, or - * new owner or tablespace */ + 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 */ + * index, constraint, or parent table */ Node *transform; /* transformation expr for ALTER TYPE */ DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */ } AlterTableCmd; @@ -870,7 +953,8 @@ typedef struct AlterDomainStmt */ typedef enum GrantObjectType { - ACL_OBJECT_RELATION, /* table, view, sequence */ + ACL_OBJECT_RELATION, /* table, view */ + ACL_OBJECT_SEQUENCE, /* sequence */ ACL_OBJECT_DATABASE, /* database */ ACL_OBJECT_FUNCTION, /* function */ ACL_OBJECT_LANGUAGE, /* procedural language */ @@ -883,10 +967,10 @@ 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; /* integer list of privilege codes */ + 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) */ @@ -895,8 +979,7 @@ typedef struct GrantStmt typedef struct PrivGrantee { NodeTag type; - char *username; /* if both are NULL then PUBLIC */ - char *groupname; + char *rolname; /* if NULL then PUBLIC */ } PrivGrantee; /* @@ -920,17 +1003,40 @@ typedef struct PrivTarget } PrivTarget; /* ---------------------- + * Grant/Revoke Role Statement + * + * Note: the lists of roles are lists of names, as Value strings + * ---------------------- + */ +typedef struct GrantRoleStmt +{ + NodeTag type; + List *granted_roles; /* list of roles to be granted/revoked */ + List *grantee_roles; /* list of member roles to add/delete */ + bool is_grant; /* true = GRANT, false = REVOKE */ + bool admin_opt; /* with admin option */ + char *grantor; /* set grantor to other than current role */ + DropBehavior behavior; /* drop behavior (for REVOKE) */ +} GrantRoleStmt; + +/* ---------------------- * Copy Statement + * + * We support "COPY relation FROM file", "COPY relation TO file", and + * "COPY (query) TO file". In any given CopyStmt, exactly one of "relation" + * and "query" must be non-NULL. Note: "query" is a SelectStmt before + * parse analysis, and a Query afterwards. * ---------------------- */ typedef struct CopyStmt { NodeTag type; RangeVar *relation; /* the relation to copy */ - List *attlist; /* List of column names (as Strings), or - * NIL for all columns */ + Query *query; /* the query to copy */ + List *attlist; /* List of column names (as Strings), or NIL + * for all columns */ bool is_from; /* TO or FROM */ - char *filename; /* if NULL, use stdin/stdout */ + char *filename; /* filename, or NULL for STDIN/STDOUT */ List *options; /* List of DefElem nodes */ } CopyStmt; @@ -945,15 +1051,6 @@ typedef struct CopyStmt * ---------------------- */ -/* 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; - typedef struct CreateStmt { NodeTag type; @@ -962,7 +1059,7 @@ typedef struct CreateStmt List *inhRelations; /* relations to inherit from (list of * inhRelation) */ List *constraints; /* constraints (list of Constraint nodes) */ - ContainsOids hasoids; /* should it have OIDs? */ + List *options; /* options from WITH clause */ OnCommitAction oncommit; /* what do we do at COMMIT? */ char *tablespacename; /* table space to use, or NULL */ } CreateStmt; @@ -990,8 +1087,7 @@ typedef struct CreateStmt typedef enum ConstrType /* types of constraints */ { - CONSTR_NULL, /* not SQL92, but a lot of people expect - * it */ + CONSTR_NULL, /* not SQL92, but a lot of people expect it */ CONSTR_NOTNULL, CONSTR_DEFAULT, CONSTR_CHECK, @@ -1011,8 +1107,8 @@ typedef struct Constraint char *name; /* name, or NULL if unnamed */ Node *raw_expr; /* expr, as untransformed parse tree */ char *cooked_expr; /* expr, as nodeToString representation */ - List *keys; /* String nodes naming referenced - * column(s) */ + List *keys; /* String nodes naming referenced column(s) */ + List *options; /* options from WITH clause */ char *indexspace; /* index tablespace for PKEY/UNIQUE * constraints; NULL for default */ } Constraint; @@ -1074,6 +1170,7 @@ typedef struct DropTableSpaceStmt { NodeTag type; char *tablespacename; + bool missing_ok; /* skip error if a missing? */ } DropTableSpaceStmt; /* ---------------------- @@ -1109,8 +1206,7 @@ typedef struct CreatePLangStmt NodeTag type; char *plname; /* PL name */ List *plhandler; /* PL call handler function (qual. name) */ - List *plvalidator; /* optional validator function (qual. - * name) */ + List *plvalidator; /* optional validator function (qual. name) */ bool pltrusted; /* PL is trusted */ } CreatePLangStmt; @@ -1119,64 +1215,55 @@ typedef struct DropPLangStmt NodeTag type; char *plname; /* PL name */ DropBehavior behavior; /* RESTRICT or CASCADE behavior */ + bool missing_ok; /* skip error if missing? */ } DropPLangStmt; /* ---------------------- - * Create/Alter/Drop User Statements + * Create/Alter/Drop Role Statements + * + * Note: these node types are also used for the backwards-compatible + * Create/Alter/Drop User/Group statements. In the ALTER and DROP cases + * there's really no need to distinguish what the original spelling was, + * but for CREATE we mark the type because the defaults vary. * ---------------------- */ -typedef struct CreateUserStmt +typedef enum RoleStmtType { - NodeTag type; - char *user; /* PostgreSQL user login name */ - List *options; /* List of DefElem nodes */ -} CreateUserStmt; + ROLESTMT_ROLE, + ROLESTMT_USER, + ROLESTMT_GROUP +} RoleStmtType; -typedef struct AlterUserStmt +typedef struct CreateRoleStmt { NodeTag type; - char *user; /* PostgreSQL user login name */ + RoleStmtType stmt_type; /* ROLE/USER/GROUP */ + char *role; /* role name */ List *options; /* List of DefElem nodes */ -} AlterUserStmt; - -typedef struct AlterUserSetStmt -{ - NodeTag type; - char *user; - char *variable; - List *value; -} AlterUserSetStmt; - -typedef struct DropUserStmt -{ - NodeTag type; - List *users; /* List of users to remove */ -} DropUserStmt; +} CreateRoleStmt; -/* ---------------------- - * Create/Alter/Drop Group Statements - * ---------------------- - */ -typedef struct CreateGroupStmt +typedef struct AlterRoleStmt { NodeTag type; - char *name; /* name of the new group */ + char *role; /* role name */ List *options; /* List of DefElem nodes */ -} CreateGroupStmt; + int action; /* +1 = add members, -1 = drop members */ +} AlterRoleStmt; -typedef struct AlterGroupStmt +typedef struct AlterRoleSetStmt { NodeTag type; - char *name; /* name of group to alter */ - int action; /* +1 = add, -1 = drop user */ - List *listUsers; /* list of users to add/drop */ -} AlterGroupStmt; + char *role; /* role name */ + char *variable; /* GUC variable name */ + List *value; /* value for variable, or NIL for Reset */ +} AlterRoleSetStmt; -typedef struct DropGroupStmt +typedef struct DropRoleStmt { NodeTag type; - char *name; -} DropGroupStmt; + List *roles; /* List of roles to remove */ + bool missing_ok; /* skip error if a role is missing? */ +} DropRoleStmt; /* ---------------------- * {Create|Alter} SEQUENCE Statement @@ -1205,7 +1292,9 @@ typedef struct DefineStmt { NodeTag type; ObjectType kind; /* aggregate, operator, type */ + bool oldstyle; /* hack to signal old CREATE AGG syntax */ List *defnames; /* qualified name (list of Value strings) */ + List *args; /* a list of TypeName (if needed) */ List *definition; /* a list of DefElem */ } DefineStmt; @@ -1229,6 +1318,7 @@ typedef struct CreateOpClassStmt { NodeTag type; List *opclassname; /* qualified name (list of Value strings) */ + List *opfamilyname; /* qualified name (ditto); NIL if omitted */ char *amname; /* name of index AM opclass is for */ TypeName *datatype; /* datatype of indexed column */ List *items; /* List of CreateOpClassItem nodes */ @@ -1263,6 +1353,7 @@ typedef struct DropStmt List *objects; /* list of sublists of names (as Values) */ ObjectType removeType; /* object type */ DropBehavior behavior; /* RESTRICT or CASCADE behavior */ + bool missing_ok; /* skip error if object is missing? */ } DropStmt; /* ---------------------- @@ -1280,6 +1371,7 @@ typedef struct DropPropertyStmt char *property; /* name of rule, trigger, etc */ ObjectType removeType; /* OBJECT_RULE or OBJECT_TRIGGER */ DropBehavior behavior; /* RESTRICT or CASCADE behavior */ + bool missing_ok; /* skip error if a missing? */ } DropPropertyStmt; /* ---------------------- @@ -1290,6 +1382,7 @@ typedef struct TruncateStmt { NodeTag type; List *relations; /* relations (RangeVars) to be truncated */ + DropBehavior behavior; /* RESTRICT or CASCADE behavior */ } TruncateStmt; /* ---------------------- @@ -1370,13 +1463,14 @@ typedef struct IndexStmt char *accessMethod; /* name of access method (eg. btree) */ char *tableSpace; /* tablespace, or NULL to use parent's */ List *indexParams; /* a list of IndexElem */ + List *options; /* options from WITH clause */ Node *whereClause; /* qualification (partial-index predicate) */ - List *rangetable; /* range table for qual and/or - * expressions, filled in by - * transformStmt() */ + List *rangetable; /* range table for qual and/or expressions, + * filled in by transformStmt() */ bool unique; /* is index unique? */ bool primary; /* is index on primary key? */ bool isconstraint; /* is it from a CONSTRAINT clause? */ + bool concurrent; /* should this be a concurrent index build? */ } IndexStmt; /* ---------------------- @@ -1407,7 +1501,7 @@ typedef struct FunctionParameter NodeTag type; char *name; /* parameter name, or NULL if not given */ TypeName *argType; /* TypeName for parameter type */ - FunctionParameterMode mode; /* IN/OUT/INOUT */ + FunctionParameterMode mode; /* IN/OUT/INOUT */ } FunctionParameter; typedef struct AlterFunctionStmt @@ -1418,42 +1512,20 @@ typedef struct AlterFunctionStmt } AlterFunctionStmt; /* ---------------------- - * Drop Aggregate Statement - * ---------------------- - */ -typedef struct RemoveAggrStmt -{ - NodeTag type; - List *aggname; /* aggregate to drop */ - TypeName *aggtype; /* TypeName for input datatype, or NULL */ - DropBehavior behavior; /* RESTRICT or CASCADE behavior */ -} RemoveAggrStmt; - -/* ---------------------- - * Drop Function Statement + * Drop {Function|Aggregate|Operator} Statement * ---------------------- */ typedef struct RemoveFuncStmt { NodeTag type; - List *funcname; /* function to drop */ + ObjectType kind; /* function, aggregate, operator */ + List *name; /* qualified name of object to drop */ List *args; /* types of the arguments */ DropBehavior behavior; /* RESTRICT or CASCADE behavior */ + bool missing_ok; /* skip error if a missing? */ } RemoveFuncStmt; /* ---------------------- - * Drop Operator Statement - * ---------------------- - */ -typedef struct RemoveOperStmt -{ - NodeTag type; - List *opname; /* operator to drop */ - List *args; /* types of the arguments */ - DropBehavior behavior; /* RESTRICT or CASCADE behavior */ -} RemoveOperStmt; - -/* ---------------------- * Drop Operator Class Statement * ---------------------- */ @@ -1463,6 +1535,7 @@ typedef struct RemoveOpClassStmt List *opclassname; /* qualified name (list of Value strings) */ char *amname; /* name of index AM opclass is for */ DropBehavior behavior; /* RESTRICT or CASCADE behavior */ + bool missing_ok; /* skip error if a missing? */ } RemoveOpClassStmt; /* ---------------------- @@ -1472,28 +1545,43 @@ typedef struct RemoveOpClassStmt typedef struct RenameStmt { NodeTag type; + ObjectType renameType; /* OBJECT_TABLE, OBJECT_COLUMN, etc */ RangeVar *relation; /* in case it's a table */ List *object; /* in case it's some other object */ List *objarg; /* argument types, if applicable */ char *subname; /* name of contained object (column, rule, * trigger, etc) */ char *newname; /* the new name */ - ObjectType renameType; /* OBJECT_TABLE, OBJECT_COLUMN, etc */ } RenameStmt; /* ---------------------- + * ALTER object SET SCHEMA Statement + * ---------------------- + */ +typedef struct AlterObjectSchemaStmt +{ + NodeTag type; + ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */ + RangeVar *relation; /* in case it's a table */ + List *object; /* in case it's some other object */ + List *objarg; /* argument types, if applicable */ + char *addname; /* additional name if needed */ + char *newschema; /* the new schema */ +} AlterObjectSchemaStmt; + +/* ---------------------- * Alter Object Owner Statement * ---------------------- */ typedef struct AlterOwnerStmt { NodeTag type; + ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */ RangeVar *relation; /* in case it's a table */ List *object; /* in case it's some other object */ List *objarg; /* argument types, if applicable */ char *addname; /* additional name if needed */ char *newowner; /* the new owner */ - ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */ } AlterOwnerStmt; @@ -1555,7 +1643,10 @@ typedef enum TransactionStmtKind TRANS_STMT_ROLLBACK, TRANS_STMT_SAVEPOINT, TRANS_STMT_RELEASE, - TRANS_STMT_ROLLBACK_TO + TRANS_STMT_ROLLBACK_TO, + TRANS_STMT_PREPARE, + TRANS_STMT_COMMIT_PREPARED, + TRANS_STMT_ROLLBACK_PREPARED } TransactionStmtKind; typedef struct TransactionStmt @@ -1563,6 +1654,7 @@ typedef struct TransactionStmt NodeTag type; TransactionStmtKind kind; /* see above */ List *options; /* for BEGIN/START and savepoint commands */ + char *gid; /* for two-phase-commit related commands */ } TransactionStmt; /* ---------------------- @@ -1615,6 +1707,13 @@ typedef struct CreatedbStmt * Alter Database * ---------------------- */ +typedef struct AlterDatabaseStmt +{ + NodeTag type; + char *dbname; /* name of database to alter */ + List *options; /* List of DefElem nodes */ +} AlterDatabaseStmt; + typedef struct AlterDatabaseSetStmt { NodeTag type; @@ -1631,6 +1730,7 @@ typedef struct DropdbStmt { NodeTag type; char *dbname; /* database to drop */ + bool missing_ok; /* skip error if db is missing? */ } DropdbStmt; /* ---------------------- @@ -1657,8 +1757,8 @@ typedef struct VacuumStmt bool vacuum; /* do VACUUM step */ bool full; /* do FULL (non-concurrent) vacuum */ bool analyze; /* do ANALYZE step */ - bool freeze; /* early-freeze option */ bool verbose; /* print progress info */ + int freeze_min_age; /* min freeze age, or -1 to use default */ RangeVar *relation; /* single table to process, or NULL */ List *va_cols; /* list of column names, or NIL for all */ } VacuumStmt; @@ -1738,7 +1838,7 @@ typedef struct LockStmt typedef struct ConstraintsSetStmt { NodeTag type; - List *constraints; /* List of names as Value strings */ + List *constraints; /* List of names as RangeVars */ bool deferred; } ConstraintsSetStmt; @@ -1749,12 +1849,11 @@ typedef struct ConstraintsSetStmt typedef struct ReindexStmt { NodeTag type; - ObjectType kind; /* OBJECT_INDEX, OBJECT_TABLE, - * OBJECT_DATABASE */ + ObjectType kind; /* OBJECT_INDEX, OBJECT_TABLE, OBJECT_DATABASE */ RangeVar *relation; /* Table or index to reindex */ const char *name; /* name of database to reindex */ - bool force; - bool all; + bool do_system; /* include system tables in database case */ + bool do_user; /* include user tables in database case */ } ReindexStmt; /* ---------------------- @@ -1794,6 +1893,7 @@ typedef struct DropCastStmt TypeName *sourcetype; TypeName *targettype; DropBehavior behavior; + bool missing_ok; /* skip error if a missing? */ } DropCastStmt; @@ -1821,6 +1921,9 @@ typedef struct ExecuteStmt NodeTag type; char *name; /* The name of the plan to execute */ RangeVar *into; /* Optional table to store results in */ + List *intoOptions; /* Options from WITH clause */ + OnCommitAction into_on_commit; /* What do we do at COMMIT? */ + char *into_tbl_space; /* Tablespace to use, or NULL */ List *params; /* Values to assign to parameters */ } ExecuteStmt; @@ -1835,4 +1938,24 @@ typedef struct DeallocateStmt char *name; /* The name of the plan to remove */ } DeallocateStmt; +/* + * DROP OWNED statement + */ +typedef struct DropOwnedStmt +{ + NodeTag type; + List *roles; + DropBehavior behavior; +} DropOwnedStmt; + +/* + * REASSIGN OWNED statement + */ +typedef struct ReassignOwnedStmt +{ + NodeTag type; + List *roles; + char *newrole; +} ReassignOwnedStmt; + #endif /* PARSENODES_H */