1 /*-------------------------------------------------------------------------
4 * definitions for parse tree nodes
7 * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.319 2006/07/31 01:16:38 tgl Exp $
12 *-------------------------------------------------------------------------
17 #include "nodes/primnodes.h"
18 #include "nodes/value.h"
20 /* Possible sources of a Query */
21 typedef enum QuerySource
23 QSRC_ORIGINAL, /* original parsetree (explicit query) */
24 QSRC_PARSER, /* added by parse analysis */
25 QSRC_INSTEAD_RULE, /* added by unconditional INSTEAD rule */
26 QSRC_QUAL_INSTEAD_RULE, /* added by conditional INSTEAD rule */
27 QSRC_NON_INSTEAD_RULE /* added by non-INSTEAD rule */
30 /* What to do at commit time for temporary relations */
31 typedef enum OnCommitAction
33 ONCOMMIT_NOOP, /* No ON COMMIT clause (do nothing) */
34 ONCOMMIT_PRESERVE_ROWS, /* ON COMMIT PRESERVE ROWS (do nothing) */
35 ONCOMMIT_DELETE_ROWS, /* ON COMMIT DELETE ROWS */
36 ONCOMMIT_DROP /* ON COMMIT DROP */
41 * Grantable rights are encoded so that we can OR them together in a bitmask.
42 * The present representation of AclItem limits us to 16 distinct rights,
43 * even though AclMode is defined as uint32. See utils/acl.h.
45 * Caution: changing these codes breaks stored ACLs, hence forces initdb.
47 typedef uint32 AclMode; /* a bitmask of privilege bits */
49 #define ACL_INSERT (1<<0) /* for relations */
50 #define ACL_SELECT (1<<1)
51 #define ACL_UPDATE (1<<2)
52 #define ACL_DELETE (1<<3)
53 #define ACL_RULE (1<<4)
54 #define ACL_REFERENCES (1<<5)
55 #define ACL_TRIGGER (1<<6)
56 #define ACL_EXECUTE (1<<7) /* for functions */
57 #define ACL_USAGE (1<<8) /* for languages and namespaces */
58 #define ACL_CREATE (1<<9) /* for namespaces and databases */
59 #define ACL_CREATE_TEMP (1<<10) /* for databases */
60 #define ACL_CONNECT (1<<11) /* for databases */
61 #define N_ACL_RIGHTS 12 /* 1 plus the last 1<<x */
62 #define ACL_NO_RIGHTS 0
63 /* Currently, SELECT ... FOR UPDATE/FOR SHARE requires UPDATE privileges */
64 #define ACL_SELECT_FOR_UPDATE ACL_UPDATE
67 /*****************************************************************************
69 *****************************************************************************/
73 * all statements are turned into a Query tree (via transformStmt)
74 * for further processing by the optimizer
76 * utility statements (i.e. non-optimizable statements) have the
77 * utilityStmt field set, and the Query itself is mostly dummy.
83 CmdType commandType; /* select|insert|update|delete|utility */
85 QuerySource querySource; /* where did I come from? */
87 bool canSetTag; /* do I set the command result tag? */
89 Node *utilityStmt; /* non-null if this is a non-optimizable
92 int resultRelation; /* target relation (index into rtable) */
94 RangeVar *into; /* target relation for SELECT INTO */
95 List *intoOptions; /* options from WITH clause */
96 OnCommitAction intoOnCommit; /* what do we do at COMMIT? */
97 char *intoTableSpaceName; /* table space to use, or NULL */
99 bool hasAggs; /* has aggregates in tlist or havingQual */
100 bool hasSubLinks; /* has subquery SubLink */
102 List *rtable; /* list of range table entries */
103 FromExpr *jointree; /* table join tree (FROM and WHERE clauses) */
105 List *targetList; /* target list (of TargetEntry) */
107 List *groupClause; /* a list of GroupClause's */
109 Node *havingQual; /* qualifications applied to groups */
111 List *distinctClause; /* a list of SortClause's */
113 List *sortClause; /* a list of SortClause's */
115 Node *limitOffset; /* # of result tuples to skip (int8 expr) */
116 Node *limitCount; /* # of result tuples to return (int8 expr) */
118 List *rowMarks; /* a list of RowMarkClause's */
120 Node *setOperations; /* set-operation tree if this is top level of
121 * a UNION/INTERSECT/EXCEPT query */
124 * If the resultRelation turns out to be the parent of an inheritance
125 * tree, the planner will add all the child tables to the rtable and store
126 * a list of the rtindexes of all the result relations here. This is done
127 * at plan time, not parse time, since we don't want to commit to the
128 * exact set of child tables at parse time. This field ought to go in
129 * some sort of TopPlan plan node, not in the Query.
131 List *resultRelations; /* integer list of RT indexes, or NIL */
135 /****************************************************************************
136 * Supporting data structures for Parse Trees
138 * Most of these node types appear in raw parsetrees output by the grammar,
139 * and get transformed to something else by the analyzer. A few of them
140 * are used as-is in transformed querytrees.
142 * Many of the node types used in raw parsetrees include a "location" field.
143 * This is a byte (not character) offset in the original source text, to be
144 * used for positioning an error cursor when there is an analysis-time
145 * error related to the node.
146 ****************************************************************************/
149 * TypeName - specifies a type in definitions
151 * For TypeName structures generated internally, it is often easier to
152 * specify the type by OID than by name. If "names" is NIL then the
153 * actual type OID is given by typeid, otherwise typeid is unused.
155 * If pct_type is TRUE, then names is actually a field name and we look up
156 * the type of that field. Otherwise (the normal case), names is a type
157 * name possibly qualified with schema and database name.
159 typedef struct TypeName
162 List *names; /* qualified name (list of Value strings) */
163 Oid typeid; /* type identified by OID */
164 bool timezone; /* timezone specified? */
165 bool setof; /* is a set? */
166 bool pct_type; /* %TYPE specified? */
167 int32 typmod; /* type modifier */
168 List *arrayBounds; /* array bounds */
169 int location; /* token location, or -1 if unknown */
173 * ColumnRef - specifies a reference to a column, or possibly a whole tuple
175 * The "fields" list must be nonempty; its last component may be "*"
176 * instead of a regular field name.
178 * Note: any array subscripting or selection of fields from composite columns
179 * is represented by an A_Indirection node above the ColumnRef. However,
180 * for simplicity in the normal case, initial field selection from a table
181 * name is represented within ColumnRef and not by adding A_Indirection.
183 typedef struct ColumnRef
186 List *fields; /* field names (list of Value strings) */
187 int location; /* token location, or -1 if unknown */
191 * ParamRef - specifies a $n parameter reference
193 typedef struct ParamRef
196 int number; /* the number of the parameter */
200 * A_Expr - infix, prefix, and postfix expressions
202 typedef enum A_Expr_Kind
204 AEXPR_OP, /* normal operator */
205 AEXPR_AND, /* booleans - name field is unused */
208 AEXPR_OP_ANY, /* scalar op ANY (array) */
209 AEXPR_OP_ALL, /* scalar op ALL (array) */
210 AEXPR_DISTINCT, /* IS DISTINCT FROM - name must be "=" */
211 AEXPR_NULLIF, /* NULLIF - name must be "=" */
212 AEXPR_OF, /* IS [NOT] OF - name must be "=" or "<>" */
213 AEXPR_IN /* [NOT] IN - name must be "=" or "<>" */
216 typedef struct A_Expr
219 A_Expr_Kind kind; /* see above */
220 List *name; /* possibly-qualified name of operator */
221 Node *lexpr; /* left argument, or NULL if none */
222 Node *rexpr; /* right argument, or NULL if none */
223 int location; /* token location, or -1 if unknown */
227 * A_Const - a constant expression
229 typedef struct A_Const
232 Value val; /* the value (with the tag) */
233 TypeName *typename; /* typecast, or NULL if none */
237 * TypeCast - a CAST expression
239 * NOTE: for mostly historical reasons, A_Const parsenodes contain
240 * room for a TypeName; we only generate a separate TypeCast node if the
241 * argument to be casted is not a constant. In theory either representation
242 * would work, but the combined representation saves a bit of code in many
243 * productions in gram.y.
245 typedef struct TypeCast
248 Node *arg; /* the expression being casted */
249 TypeName *typename; /* the target type */
253 * FuncCall - a function or aggregate invocation
255 * agg_star indicates we saw a 'foo(*)' construct, while agg_distinct
256 * indicates we saw 'foo(DISTINCT ...)'. In either case, the construct
257 * *must* be an aggregate call. Otherwise, it might be either an
258 * aggregate or some other kind of function.
260 typedef struct FuncCall
263 List *funcname; /* qualified name of function */
264 List *args; /* the arguments (list of exprs) */
265 bool agg_star; /* argument was really '*' */
266 bool agg_distinct; /* arguments were labeled DISTINCT */
267 int location; /* token location, or -1 if unknown */
271 * A_Indices - array reference or bounds ([lidx:uidx] or [uidx])
273 typedef struct A_Indices
276 Node *lidx; /* could be NULL */
281 * A_Indirection - select a field and/or array element from an expression
283 * The indirection list can contain both A_Indices nodes (representing
284 * subscripting) and string Value nodes (representing field selection
285 * --- the string value is the name of the field to select). For example,
286 * a complex selection operation like
287 * (foo).field1[42][7].field2
288 * would be represented with a single A_Indirection node having a 4-element
291 * Note: as of Postgres 8.0, we don't support arrays of composite values,
292 * so cases in which a field select follows a subscript aren't actually
293 * semantically legal. However the parser is prepared to handle such.
295 typedef struct A_Indirection
298 Node *arg; /* the thing being selected from */
299 List *indirection; /* subscripts and/or field names */
304 * result target (used in target list of pre-transformed parse trees)
306 * In a SELECT or INSERT target list, 'name' is the column label from an
307 * 'AS ColumnLabel' clause, or NULL if there was none, and 'val' is the
308 * value expression itself. The 'indirection' field is not used.
310 * INSERT has a second ResTarget list which is the target-column-names list.
311 * Here, 'val' is not used, 'name' is the name of the destination column,
312 * and 'indirection' stores any subscripts attached to the destination.
314 * In an UPDATE target list, 'name' is the name of the destination column,
315 * 'indirection' stores any subscripts attached to the destination, and
316 * 'val' is the expression to assign.
318 * See A_Indirection for more info about what can appear in 'indirection'.
320 typedef struct ResTarget
323 char *name; /* column name or NULL */
324 List *indirection; /* subscripts and field names, or NIL */
325 Node *val; /* the value expression to compute or assign */
326 int location; /* token location, or -1 if unknown */
330 * SortBy - for ORDER BY clause
333 #define SORTBY_DESC 2
334 #define SORTBY_USING 3
336 typedef struct SortBy
339 int sortby_kind; /* see codes above */
340 List *useOp; /* name of op to use, if SORTBY_USING */
341 Node *node; /* expression to sort on */
345 * RangeSubselect - subquery appearing in a FROM clause
347 typedef struct RangeSubselect
350 Node *subquery; /* the untransformed sub-select clause */
351 Alias *alias; /* table alias & optional column aliases */
355 * RangeFunction - function call appearing in a FROM clause
357 typedef struct RangeFunction
360 Node *funccallnode; /* untransformed function call tree */
361 Alias *alias; /* table alias & optional column aliases */
362 List *coldeflist; /* list of ColumnDef nodes to describe
363 * result of function returning RECORD */
367 * ColumnDef - column definition (used in various creates)
369 * If the column has a default value, we may have the value expression
370 * in either "raw" form (an untransformed parse tree) or "cooked" form
371 * (the nodeToString representation of an executable expression tree),
372 * depending on how this ColumnDef node was created (by parsing, or by
373 * inheritance from an existing relation). We should never have both
376 * The constraints list may contain a CONSTR_DEFAULT item in a raw
377 * parsetree produced by gram.y, but transformCreateStmt will remove
378 * the item and set raw_default instead. CONSTR_DEFAULT items
379 * should not appear in any subsequent processing.
381 * The "support" field, if not null, denotes a supporting relation that
382 * should be linked by an internal dependency to the column. Currently
383 * this is only used to link a SERIAL column's sequence to the column.
385 typedef struct ColumnDef
388 char *colname; /* name of column */
389 TypeName *typename; /* type of column */
390 int inhcount; /* number of times column is inherited */
391 bool is_local; /* column has local (non-inherited) def'n */
392 bool is_not_null; /* NOT NULL constraint specified? */
393 Node *raw_default; /* default value (untransformed parse tree) */
394 char *cooked_default; /* nodeToString representation */
395 List *constraints; /* other constraints on column */
396 RangeVar *support; /* supporting relation, if any */
400 * inhRelation - Relations a CREATE TABLE is to inherit attributes of
402 typedef struct InhRelation
410 * IndexElem - index parameters (used in CREATE INDEX)
412 * For a plain index attribute, 'name' is the name of the table column to
413 * index, and 'expr' is NULL. For an index expression, 'name' is NULL and
414 * 'expr' is the expression tree.
416 typedef struct IndexElem
419 char *name; /* name of attribute to index, or NULL */
420 Node *expr; /* expression to index, or NULL */
421 List *opclass; /* name of desired opclass; NIL = default */
426 * a definition (used in definition lists in the form of defname = arg)
428 typedef struct DefElem
432 Node *arg; /* a (Value *) or a (TypeName *) */
436 * LockingClause - raw representation of FOR UPDATE/SHARE options
438 * Note: lockedRels == NIL means "all relations in query". Otherwise it
439 * is a list of String nodes giving relation eref names.
441 typedef struct LockingClause
444 List *lockedRels; /* FOR UPDATE or FOR SHARE relations */
445 bool forUpdate; /* true = FOR UPDATE, false = FOR SHARE */
446 bool noWait; /* NOWAIT option */
450 /****************************************************************************
451 * Nodes for a Query tree
452 ****************************************************************************/
454 /*--------------------
456 * A range table is a List of RangeTblEntry nodes.
458 * A range table entry may represent a plain relation, a sub-select in
459 * FROM, or the result of a JOIN clause. (Only explicit JOIN syntax
460 * produces an RTE, not the implicit join resulting from multiple FROM
461 * items. This is because we only need the RTE to deal with SQL features
462 * like outer joins and join-output-column aliasing.) Other special
463 * RTE types also exist, as indicated by RTEKind.
465 * alias is an Alias node representing the AS alias-clause attached to the
466 * FROM expression, or NULL if no clause.
468 * eref is the table reference name and column reference names (either
469 * real or aliases). Note that system columns (OID etc) are not included
470 * in the column list.
471 * eref->aliasname is required to be present, and should generally be used
472 * to identify the RTE for error messages etc.
474 * In RELATION RTEs, the colnames in both alias and eref are indexed by
475 * physical attribute number; this means there must be colname entries for
476 * dropped columns. When building an RTE we insert empty strings ("") for
477 * dropped columns. Note however that a stored rule may have nonempty
478 * colnames for columns dropped since the rule was created (and for that
479 * matter the colnames might be out of date due to column renamings).
480 * The same comments apply to FUNCTION RTEs when the function's return type
481 * is a named composite type.
483 * In JOIN RTEs, the colnames in both alias and eref are one-to-one with
484 * joinaliasvars entries. A JOIN RTE will omit columns of its inputs when
485 * those columns are known to be dropped at parse time. Again, however,
486 * a stored rule might contain entries for columns dropped since the rule
487 * was created. (This is only possible for columns not actually referenced
488 * in the rule.) When loading a stored rule, we replace the joinaliasvars
489 * items for any such columns with NULL Consts. (We can't simply delete
490 * them from the joinaliasvars list, because that would affect the attnums
491 * of Vars referencing the rest of the list.)
493 * inh is TRUE for relation references that should be expanded to include
494 * inheritance children, if the rel has any. This *must* be FALSE for
495 * RTEs other than RTE_RELATION entries.
497 * inFromCl marks those range variables that are listed in the FROM clause.
498 * It's false for RTEs that are added to a query behind the scenes, such
499 * as the NEW and OLD variables for a rule, or the subqueries of a UNION.
500 * This flag is not used anymore during parsing, since the parser now uses
501 * a separate "namespace" data structure to control visibility, but it is
502 * needed by ruleutils.c to determine whether RTEs should be shown in
503 * decompiled queries.
505 * requiredPerms and checkAsUser specify run-time access permissions
506 * checks to be performed at query startup. The user must have *all*
507 * of the permissions that are OR'd together in requiredPerms (zero
508 * indicates no permissions checking). If checkAsUser is not zero,
509 * then do the permissions checks using the access rights of that user,
510 * not the current effective user ID. (This allows rules to act as
512 *--------------------
516 RTE_RELATION, /* ordinary relation reference */
517 RTE_SUBQUERY, /* subquery in FROM */
519 RTE_SPECIAL, /* special rule relation (NEW or OLD) */
520 RTE_FUNCTION /* function in FROM */
523 typedef struct RangeTblEntry
527 RTEKind rtekind; /* see above */
530 * XXX the fields applicable to only some rte kinds should be merged into
531 * a union. I didn't do this yet because the diffs would impact a lot of
532 * code that is being actively worked on. FIXME later.
536 * Fields valid for a plain relation RTE (else zero):
538 Oid relid; /* OID of the relation */
541 * Fields valid for a subquery RTE (else NULL):
543 Query *subquery; /* the sub-query */
546 * Fields valid for a function RTE (else NULL):
548 * If the function returns RECORD, funccoltypes lists the column types
549 * declared in the RTE's column type specification, and funccoltypmods
550 * lists their declared typmods. Otherwise, both fields are NIL.
552 Node *funcexpr; /* expression tree for func call */
553 List *funccoltypes; /* OID list of column type OIDs */
554 List *funccoltypmods; /* integer list of column typmods */
557 * Fields valid for a join RTE (else NULL/zero):
559 * joinaliasvars is a list of Vars or COALESCE expressions corresponding
560 * to the columns of the join result. An alias Var referencing column K
561 * of the join result can be replaced by the K'th element of joinaliasvars
562 * --- but to simplify the task of reverse-listing aliases correctly, we
563 * do not do that until planning time. In a Query loaded from a stored
564 * rule, it is also possible for joinaliasvars items to be NULL Consts,
565 * denoting columns dropped since the rule was made.
567 JoinType jointype; /* type of join */
568 List *joinaliasvars; /* list of alias-var expansions */
571 * Fields valid in all RTEs:
573 Alias *alias; /* user-written alias clause, if any */
574 Alias *eref; /* expanded reference names */
575 bool inh; /* inheritance requested? */
576 bool inFromCl; /* present in FROM clause? */
577 AclMode requiredPerms; /* bitmask of required access permissions */
578 Oid checkAsUser; /* if valid, check access as this role */
583 * representation of ORDER BY clauses
585 * tleSortGroupRef must match ressortgroupref of exactly one entry of the
586 * associated targetlist; that is the expression to be sorted (or grouped) by.
587 * sortop is the OID of the ordering operator.
589 * SortClauses are also used to identify targets that we will do a "Unique"
590 * filter step on (for SELECT DISTINCT and SELECT DISTINCT ON). The
591 * distinctClause list is simply a copy of the relevant members of the
592 * sortClause list. Note that distinctClause can be a subset of sortClause,
593 * but cannot have members not present in sortClause; and the members that
594 * do appear must be in the same order as in sortClause.
596 typedef struct SortClause
599 Index tleSortGroupRef; /* reference into targetlist */
600 Oid sortop; /* the sort operator to use */
605 * representation of GROUP BY clauses
607 * GroupClause is exactly like SortClause except for the nodetag value
608 * (it's probably not even really necessary to have two different
609 * nodetags...). We have routines that operate interchangeably on both.
611 typedef SortClause GroupClause;
615 * representation of FOR UPDATE/SHARE clauses
617 * We create a separate RowMarkClause node for each target relation
619 typedef struct RowMarkClause
622 Index rti; /* range table index of target relation */
623 bool forUpdate; /* true = FOR UPDATE, false = FOR SHARE */
624 bool noWait; /* NOWAIT option */
627 /*****************************************************************************
628 * Optimizable Statements
629 *****************************************************************************/
631 /* ----------------------
633 * ----------------------
635 typedef struct InsertStmt
638 RangeVar *relation; /* relation to insert into */
639 List *cols; /* optional: names of the target columns */
642 * An INSERT statement has *either* VALUES or SELECT, never both. If
643 * VALUES, a targetList is supplied (empty for DEFAULT VALUES). If SELECT,
644 * a complete SelectStmt (or set-operation tree) is supplied.
646 List *targetList; /* the target list (of ResTarget) */
647 Node *selectStmt; /* the source SELECT */
650 /* ----------------------
652 * ----------------------
654 typedef struct DeleteStmt
657 RangeVar *relation; /* relation to delete from */
658 Node *whereClause; /* qualifications */
659 List *usingClause; /* optional using clause for more tables */
662 /* ----------------------
664 * ----------------------
666 typedef struct UpdateStmt
669 RangeVar *relation; /* relation to update */
670 List *targetList; /* the target list (of ResTarget) */
671 Node *whereClause; /* qualifications */
672 List *fromClause; /* optional from clause for more tables */
675 /* ----------------------
678 * A "simple" SELECT is represented in the output of gram.y by a single
679 * SelectStmt node. A SELECT construct containing set operators (UNION,
680 * INTERSECT, EXCEPT) is represented by a tree of SelectStmt nodes, in
681 * which the leaf nodes are component SELECTs and the internal nodes
682 * represent UNION, INTERSECT, or EXCEPT operators. Using the same node
683 * type for both leaf and internal nodes allows gram.y to stick ORDER BY,
684 * LIMIT, etc, clause values into a SELECT statement without worrying
685 * whether it is a simple or compound SELECT.
686 * ----------------------
688 typedef enum SetOperation
696 typedef struct SelectStmt
701 * These fields are used only in "leaf" SelectStmts.
703 * into, intoColNames, intoOptions, intoOnCommit, and
704 * intoTableSpaceName are a kluge; they belong somewhere else...
706 List *distinctClause; /* NULL, list of DISTINCT ON exprs, or
707 * lcons(NIL,NIL) for all (SELECT DISTINCT) */
708 RangeVar *into; /* target table (for select into table) */
709 List *intoColNames; /* column names for into table */
710 List *intoOptions; /* options from WITH clause */
711 OnCommitAction intoOnCommit; /* what do we do at COMMIT? */
712 char *intoTableSpaceName; /* table space to use, or NULL */
713 List *targetList; /* the target list (of ResTarget) */
714 List *fromClause; /* the FROM clause */
715 Node *whereClause; /* WHERE qualification */
716 List *groupClause; /* GROUP BY clauses */
717 Node *havingClause; /* HAVING conditional-expression */
720 * These fields are used in both "leaf" SelectStmts and upper-level
723 List *sortClause; /* sort clause (a list of SortBy's) */
724 Node *limitOffset; /* # of result tuples to skip */
725 Node *limitCount; /* # of result tuples to return */
726 List *lockingClause; /* FOR UPDATE (list of LockingClause's) */
729 * These fields are used only in upper-level SelectStmts.
731 SetOperation op; /* type of set op */
732 bool all; /* ALL specified? */
733 struct SelectStmt *larg; /* left child */
734 struct SelectStmt *rarg; /* right child */
735 /* Eventually add fields for CORRESPONDING spec here */
739 /* ----------------------
740 * Set Operation node for post-analysis query trees
742 * After parse analysis, a SELECT with set operations is represented by a
743 * top-level Query node containing the leaf SELECTs as subqueries in its
744 * range table. Its setOperations field shows the tree of set operations,
745 * with leaf SelectStmt nodes replaced by RangeTblRef nodes, and internal
746 * nodes replaced by SetOperationStmt nodes.
747 * ----------------------
749 typedef struct SetOperationStmt
752 SetOperation op; /* type of set op */
753 bool all; /* ALL specified? */
754 Node *larg; /* left child */
755 Node *rarg; /* right child */
756 /* Eventually add fields for CORRESPONDING spec here */
758 /* Fields derived during parse analysis: */
759 List *colTypes; /* list of OIDs of output column types */
763 /*****************************************************************************
764 * Other Statements (no optimizations required)
766 * Some of them require a little bit of transformation (which is also
767 * done by transformStmt). The whole structure is then passed on to
768 * ProcessUtility (by-passing the optimization step) as the utilityStmt
770 *****************************************************************************/
773 * When a command can act on several kinds of objects with only one
774 * parse structure required, use these constants to designate the
778 typedef enum ObjectType
804 /* ----------------------
805 * Create Schema Statement
807 * NOTE: the schemaElts list contains raw parsetrees for component statements
808 * of the schema, such as CREATE TABLE, GRANT, etc. These are analyzed and
809 * executed after the schema itself is created.
810 * ----------------------
812 typedef struct CreateSchemaStmt
815 char *schemaname; /* the name of the schema to create */
816 char *authid; /* the owner of the created schema */
817 List *schemaElts; /* schema components (list of parsenodes) */
820 typedef enum DropBehavior
822 DROP_RESTRICT, /* drop fails if any dependent objects */
823 DROP_CASCADE /* remove dependent objects too */
826 /* ----------------------
828 * ----------------------
830 typedef struct AlterTableStmt
833 RangeVar *relation; /* table to work on */
834 List *cmds; /* list of subcommands */
835 ObjectType relkind; /* type of object */
838 typedef enum AlterTableType
840 AT_AddColumn, /* add column */
841 AT_ColumnDefault, /* alter column default */
842 AT_DropNotNull, /* alter column drop not null */
843 AT_SetNotNull, /* alter column set not null */
844 AT_SetStatistics, /* alter column statistics */
845 AT_SetStorage, /* alter column storage */
846 AT_DropColumn, /* drop column */
847 AT_DropColumnRecurse, /* internal to commands/tablecmds.c */
848 AT_AddIndex, /* add index */
849 AT_ReAddIndex, /* internal to commands/tablecmds.c */
850 AT_AddConstraint, /* add constraint */
851 AT_ProcessedConstraint, /* pre-processed add constraint (local in
852 * parser/analyze.c) */
853 AT_DropConstraint, /* drop constraint */
854 AT_DropConstraintQuietly, /* drop constraint, no error/warning (local in
855 * commands/tablecmds.c) */
856 AT_AlterColumnType, /* alter column type */
857 AT_ChangeOwner, /* change owner */
858 AT_ClusterOn, /* CLUSTER ON */
859 AT_DropCluster, /* SET WITHOUT CLUSTER */
860 AT_DropOids, /* SET WITHOUT OIDS */
861 AT_SetTableSpace, /* SET TABLESPACE */
862 AT_SetRelOptions, /* SET (...) -- AM specific parameters */
863 AT_ResetRelOptions, /* RESET (...) -- AM specific parameters */
864 AT_EnableTrig, /* ENABLE TRIGGER name */
865 AT_DisableTrig, /* DISABLE TRIGGER name */
866 AT_EnableTrigAll, /* ENABLE TRIGGER ALL */
867 AT_DisableTrigAll, /* DISABLE TRIGGER ALL */
868 AT_EnableTrigUser, /* ENABLE TRIGGER USER */
869 AT_DisableTrigUser, /* DISABLE TRIGGER USER */
870 AT_AddInherits, /* ADD INHERITS parent */
871 AT_DropInherits /* DROP INHERITS parent */
874 typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */
877 AlterTableType subtype; /* Type of table alteration to apply */
878 char *name; /* column, constraint, or trigger to act on,
879 * or new owner or tablespace */
880 RangeVar *parent; /* Parent table for add/drop inherits */
881 Node *def; /* definition of new column, column type,
882 * index, or constraint */
883 Node *transform; /* transformation expr for ALTER TYPE */
884 DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
888 /* ----------------------
891 * The fields are used in different ways by the different variants of
893 * ----------------------
895 typedef struct AlterDomainStmt
898 char subtype; /*------------
899 * T = alter column default
900 * N = alter column drop not null
901 * O = alter column set not null
903 * X = drop constraint
906 List *typename; /* domain to work on */
907 char *name; /* column or constraint name to act on */
908 Node *def; /* definition of default or constraint */
909 DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
913 /* ----------------------
914 * Grant|Revoke Statement
915 * ----------------------
917 typedef enum GrantObjectType
919 ACL_OBJECT_RELATION, /* table, view */
920 ACL_OBJECT_SEQUENCE, /* sequence */
921 ACL_OBJECT_DATABASE, /* database */
922 ACL_OBJECT_FUNCTION, /* function */
923 ACL_OBJECT_LANGUAGE, /* procedural language */
924 ACL_OBJECT_NAMESPACE, /* namespace */
925 ACL_OBJECT_TABLESPACE /* tablespace */
928 typedef struct GrantStmt
931 bool is_grant; /* true = GRANT, false = REVOKE */
932 GrantObjectType objtype; /* kind of object being operated on */
933 List *objects; /* list of RangeVar nodes, FuncWithArgs nodes,
934 * or plain names (as Value strings) */
935 List *privileges; /* list of privilege names (as Strings) */
936 /* privileges == NIL denotes "all privileges" */
937 List *grantees; /* list of PrivGrantee nodes */
938 bool grant_option; /* grant or revoke grant option */
939 DropBehavior behavior; /* drop behavior (for REVOKE) */
942 typedef struct PrivGrantee
945 char *rolname; /* if NULL then PUBLIC */
949 * Note: FuncWithArgs carries only the types of the input parameters of the
950 * function. So it is sufficient to identify an existing function, but it
951 * is not enough info to define a function nor to call it.
953 typedef struct FuncWithArgs
956 List *funcname; /* qualified name of function */
957 List *funcargs; /* list of Typename nodes */
960 /* This is only used internally in gram.y. */
961 typedef struct PrivTarget
964 GrantObjectType objtype;
968 /* ----------------------
969 * Grant/Revoke Role Statement
971 * Note: the lists of roles are lists of names, as Value strings
972 * ----------------------
974 typedef struct GrantRoleStmt
977 List *granted_roles; /* list of roles to be granted/revoked */
978 List *grantee_roles; /* list of member roles to add/delete */
979 bool is_grant; /* true = GRANT, false = REVOKE */
980 bool admin_opt; /* with admin option */
981 char *grantor; /* set grantor to other than current role */
982 DropBehavior behavior; /* drop behavior (for REVOKE) */
985 /* ----------------------
987 * ----------------------
989 typedef struct CopyStmt
992 RangeVar *relation; /* the relation to copy */
993 List *attlist; /* List of column names (as Strings), or NIL
995 bool is_from; /* TO or FROM */
996 char *filename; /* if NULL, use stdin/stdout */
997 List *options; /* List of DefElem nodes */
1000 /* ----------------------
1001 * Create Table Statement
1003 * NOTE: in the raw gram.y output, ColumnDef, Constraint, and FkConstraint
1004 * nodes are intermixed in tableElts, and constraints is NIL. After parse
1005 * analysis, tableElts contains just ColumnDefs, and constraints contains
1006 * just Constraint nodes (in fact, only CONSTR_CHECK nodes, in the present
1008 * ----------------------
1011 typedef struct CreateStmt
1014 RangeVar *relation; /* relation to create */
1015 List *tableElts; /* column definitions (list of ColumnDef) */
1016 List *inhRelations; /* relations to inherit from (list of
1018 List *constraints; /* constraints (list of Constraint nodes) */
1019 List *options; /* options from WITH clause */
1020 OnCommitAction oncommit; /* what do we do at COMMIT? */
1021 char *tablespacename; /* table space to use, or NULL */
1024 typedef enum CreateStmtLikeOption {
1025 CREATE_TABLE_LIKE_INCLUDING_DEFAULTS,
1026 CREATE_TABLE_LIKE_EXCLUDING_DEFAULTS,
1027 CREATE_TABLE_LIKE_INCLUDING_CONSTRAINTS,
1028 CREATE_TABLE_LIKE_EXCLUDING_CONSTRAINTS,
1029 CREATE_TABLE_LIKE_INCLUDING_INDEXES,
1030 CREATE_TABLE_LIKE_EXCLUDING_INDEXES
1031 } CreateStmtLikeOption;
1034 * Definitions for plain (non-FOREIGN KEY) constraints in CreateStmt
1036 * XXX probably these ought to be unified with FkConstraints at some point?
1037 * To this end we include CONSTR_FOREIGN in the ConstrType enum, even though
1038 * the parser does not generate it.
1040 * For constraints that use expressions (CONSTR_DEFAULT, CONSTR_CHECK)
1041 * we may have the expression in either "raw" form (an untransformed
1042 * parse tree) or "cooked" form (the nodeToString representation of
1043 * an executable expression tree), depending on how this Constraint
1044 * node was created (by parsing, or by inheritance from an existing
1045 * relation). We should never have both in the same node!
1047 * Constraint attributes (DEFERRABLE etc) are initially represented as
1048 * separate Constraint nodes for simplicity of parsing. analyze.c makes
1049 * a pass through the constraints list to attach the info to the appropriate
1050 * FkConstraint node (and, perhaps, someday to other kinds of constraints).
1054 typedef enum ConstrType /* types of constraints */
1056 CONSTR_NULL, /* not SQL92, but a lot of people expect it */
1063 CONSTR_ATTR_DEFERRABLE, /* attributes for previous constraint node */
1064 CONSTR_ATTR_NOT_DEFERRABLE,
1065 CONSTR_ATTR_DEFERRED,
1066 CONSTR_ATTR_IMMEDIATE
1069 typedef struct Constraint
1073 char *name; /* name, or NULL if unnamed */
1074 Node *raw_expr; /* expr, as untransformed parse tree */
1075 char *cooked_expr; /* expr, as nodeToString representation */
1076 List *keys; /* String nodes naming referenced column(s) */
1077 List *options; /* options from WITH clause */
1078 char *indexspace; /* index tablespace for PKEY/UNIQUE
1079 * constraints; NULL for default */
1083 * Definitions for FOREIGN KEY constraints in CreateStmt
1085 * Note: FKCONSTR_ACTION_xxx values are stored into pg_constraint.confupdtype
1086 * and pg_constraint.confdeltype columns; FKCONSTR_MATCH_xxx values are
1087 * stored into pg_constraint.confmatchtype. Changing the code values may
1088 * require an initdb!
1090 * If skip_validation is true then we skip checking that the existing rows
1091 * in the table satisfy the constraint, and just install the catalog entries
1092 * for the constraint. This is currently used only during CREATE TABLE
1093 * (when we know the table must be empty).
1096 #define FKCONSTR_ACTION_NOACTION 'a'
1097 #define FKCONSTR_ACTION_RESTRICT 'r'
1098 #define FKCONSTR_ACTION_CASCADE 'c'
1099 #define FKCONSTR_ACTION_SETNULL 'n'
1100 #define FKCONSTR_ACTION_SETDEFAULT 'd'
1102 #define FKCONSTR_MATCH_FULL 'f'
1103 #define FKCONSTR_MATCH_PARTIAL 'p'
1104 #define FKCONSTR_MATCH_UNSPECIFIED 'u'
1106 typedef struct FkConstraint
1109 char *constr_name; /* Constraint name, or NULL if unnamed */
1110 RangeVar *pktable; /* Primary key table */
1111 List *fk_attrs; /* Attributes of foreign key */
1112 List *pk_attrs; /* Corresponding attrs in PK table */
1113 char fk_matchtype; /* FULL, PARTIAL, UNSPECIFIED */
1114 char fk_upd_action; /* ON UPDATE action */
1115 char fk_del_action; /* ON DELETE action */
1116 bool deferrable; /* DEFERRABLE */
1117 bool initdeferred; /* INITIALLY DEFERRED */
1118 bool skip_validation; /* skip validation of existing rows? */
1122 /* ----------------------
1123 * Create/Drop Table Space Statements
1124 * ----------------------
1127 typedef struct CreateTableSpaceStmt
1130 char *tablespacename;
1133 } CreateTableSpaceStmt;
1135 typedef struct DropTableSpaceStmt
1138 char *tablespacename;
1139 bool missing_ok; /* skip error if a missing? */
1140 } DropTableSpaceStmt;
1142 /* ----------------------
1143 * Create/Drop TRIGGER Statements
1144 * ----------------------
1147 typedef struct CreateTrigStmt
1150 char *trigname; /* TRIGGER's name */
1151 RangeVar *relation; /* relation trigger is on */
1152 List *funcname; /* qual. name of function to call */
1153 List *args; /* list of (T_String) Values or NIL */
1154 bool before; /* BEFORE/AFTER */
1155 bool row; /* ROW/STATEMENT */
1156 char actions[4]; /* 1 to 3 of 'i', 'u', 'd', + trailing \0 */
1158 /* The following are used for referential */
1159 /* integrity constraint triggers */
1160 bool isconstraint; /* This is an RI trigger */
1161 bool deferrable; /* [NOT] DEFERRABLE */
1162 bool initdeferred; /* INITIALLY {DEFERRED|IMMEDIATE} */
1163 RangeVar *constrrel; /* opposite relation */
1166 /* ----------------------
1167 * Create/Drop PROCEDURAL LANGUAGE Statement
1168 * ----------------------
1170 typedef struct CreatePLangStmt
1173 char *plname; /* PL name */
1174 List *plhandler; /* PL call handler function (qual. name) */
1175 List *plvalidator; /* optional validator function (qual. name) */
1176 bool pltrusted; /* PL is trusted */
1179 typedef struct DropPLangStmt
1182 char *plname; /* PL name */
1183 DropBehavior behavior; /* RESTRICT or CASCADE behavior */
1184 bool missing_ok; /* skip error if missing? */
1187 /* ----------------------
1188 * Create/Alter/Drop Role Statements
1190 * Note: these node types are also used for the backwards-compatible
1191 * Create/Alter/Drop User/Group statements. In the ALTER and DROP cases
1192 * there's really no need to distinguish what the original spelling was,
1193 * but for CREATE we mark the type because the defaults vary.
1194 * ----------------------
1196 typedef enum RoleStmtType
1203 typedef struct CreateRoleStmt
1206 RoleStmtType stmt_type; /* ROLE/USER/GROUP */
1207 char *role; /* role name */
1208 List *options; /* List of DefElem nodes */
1211 typedef struct AlterRoleStmt
1214 char *role; /* role name */
1215 List *options; /* List of DefElem nodes */
1216 int action; /* +1 = add members, -1 = drop members */
1219 typedef struct AlterRoleSetStmt
1222 char *role; /* role name */
1223 char *variable; /* GUC variable name */
1224 List *value; /* value for variable, or NIL for Reset */
1227 typedef struct DropRoleStmt
1230 List *roles; /* List of roles to remove */
1231 bool missing_ok; /* skip error if a role is missing? */
1234 /* ----------------------
1235 * {Create|Alter} SEQUENCE Statement
1236 * ----------------------
1239 typedef struct CreateSeqStmt
1242 RangeVar *sequence; /* the sequence to create */
1246 typedef struct AlterSeqStmt
1249 RangeVar *sequence; /* the sequence to alter */
1253 /* ----------------------
1254 * Create {Aggregate|Operator|Type} Statement
1255 * ----------------------
1257 typedef struct DefineStmt
1260 ObjectType kind; /* aggregate, operator, type */
1261 bool oldstyle; /* hack to signal old CREATE AGG syntax */
1262 List *defnames; /* qualified name (list of Value strings) */
1263 List *args; /* a list of TypeName (if needed) */
1264 List *definition; /* a list of DefElem */
1267 /* ----------------------
1268 * Create Domain Statement
1269 * ----------------------
1271 typedef struct CreateDomainStmt
1274 List *domainname; /* qualified name (list of Value strings) */
1275 TypeName *typename; /* the base type */
1276 List *constraints; /* constraints (list of Constraint nodes) */
1279 /* ----------------------
1280 * Create Operator Class Statement
1281 * ----------------------
1283 typedef struct CreateOpClassStmt
1286 List *opclassname; /* qualified name (list of Value strings) */
1287 char *amname; /* name of index AM opclass is for */
1288 TypeName *datatype; /* datatype of indexed column */
1289 List *items; /* List of CreateOpClassItem nodes */
1290 bool isDefault; /* Should be marked as default for type? */
1291 } CreateOpClassStmt;
1293 #define OPCLASS_ITEM_OPERATOR 1
1294 #define OPCLASS_ITEM_FUNCTION 2
1295 #define OPCLASS_ITEM_STORAGETYPE 3
1297 typedef struct CreateOpClassItem
1300 int itemtype; /* see codes above */
1301 /* fields used for an operator or function item: */
1302 List *name; /* operator or function name */
1303 List *args; /* argument types */
1304 int number; /* strategy num or support proc num */
1305 bool recheck; /* only used for operators */
1306 /* fields used for a storagetype item: */
1307 TypeName *storedtype; /* datatype stored in index */
1308 } CreateOpClassItem;
1310 /* ----------------------
1311 * Drop Table|Sequence|View|Index|Type|Domain|Conversion|Schema Statement
1312 * ----------------------
1315 typedef struct DropStmt
1318 List *objects; /* list of sublists of names (as Values) */
1319 ObjectType removeType; /* object type */
1320 DropBehavior behavior; /* RESTRICT or CASCADE behavior */
1321 bool missing_ok; /* skip error if object is missing? */
1324 /* ----------------------
1325 * Drop Rule|Trigger Statement
1327 * In general this may be used for dropping any property of a relation;
1328 * for example, someday soon we may have DROP ATTRIBUTE.
1329 * ----------------------
1332 typedef struct DropPropertyStmt
1335 RangeVar *relation; /* owning relation */
1336 char *property; /* name of rule, trigger, etc */
1337 ObjectType removeType; /* OBJECT_RULE or OBJECT_TRIGGER */
1338 DropBehavior behavior; /* RESTRICT or CASCADE behavior */
1339 bool missing_ok; /* skip error if a missing? */
1342 /* ----------------------
1343 * Truncate Table Statement
1344 * ----------------------
1346 typedef struct TruncateStmt
1349 List *relations; /* relations (RangeVars) to be truncated */
1350 DropBehavior behavior; /* RESTRICT or CASCADE behavior */
1353 /* ----------------------
1354 * Comment On Statement
1355 * ----------------------
1357 typedef struct CommentStmt
1360 ObjectType objtype; /* Object's type */
1361 List *objname; /* Qualified name of the object */
1362 List *objargs; /* Arguments if needed (eg, for functions) */
1363 char *comment; /* Comment to insert, or NULL to remove */
1366 /* ----------------------
1367 * Declare Cursor Statement
1368 * ----------------------
1370 #define CURSOR_OPT_BINARY 0x0001
1371 #define CURSOR_OPT_SCROLL 0x0002
1372 #define CURSOR_OPT_NO_SCROLL 0x0004
1373 #define CURSOR_OPT_INSENSITIVE 0x0008
1374 #define CURSOR_OPT_HOLD 0x0010
1376 typedef struct DeclareCursorStmt
1379 char *portalname; /* name of the portal (cursor) */
1380 int options; /* bitmask of options (see above) */
1381 Node *query; /* the SELECT query */
1382 } DeclareCursorStmt;
1384 /* ----------------------
1385 * Close Portal Statement
1386 * ----------------------
1388 typedef struct ClosePortalStmt
1391 char *portalname; /* name of the portal (cursor) */
1394 /* ----------------------
1395 * Fetch Statement (also Move)
1396 * ----------------------
1398 typedef enum FetchDirection
1400 /* for these, howMany is how many rows to fetch; FETCH_ALL means ALL */
1403 /* for these, howMany indicates a position; only one row is fetched */
1408 #define FETCH_ALL LONG_MAX
1410 typedef struct FetchStmt
1413 FetchDirection direction; /* see above */
1414 long howMany; /* number of rows, or position argument */
1415 char *portalname; /* name of portal (cursor) */
1416 bool ismove; /* TRUE if MOVE */
1419 /* ----------------------
1420 * Create Index Statement
1421 * ----------------------
1423 typedef struct IndexStmt
1426 char *idxname; /* name of new index, or NULL for default */
1427 RangeVar *relation; /* relation to build index on */
1428 char *accessMethod; /* name of access method (eg. btree) */
1429 char *tableSpace; /* tablespace, or NULL to use parent's */
1430 List *indexParams; /* a list of IndexElem */
1431 List *options; /* options from WITH clause */
1432 Node *whereClause; /* qualification (partial-index predicate) */
1433 List *rangetable; /* range table for qual and/or expressions,
1434 * filled in by transformStmt() */
1435 bool unique; /* is index unique? */
1436 bool primary; /* is index on primary key? */
1437 bool isconstraint; /* is it from a CONSTRAINT clause? */
1440 /* ----------------------
1441 * Create Function Statement
1442 * ----------------------
1444 typedef struct CreateFunctionStmt
1447 bool replace; /* T => replace if already exists */
1448 List *funcname; /* qualified name of function to create */
1449 List *parameters; /* a list of FunctionParameter */
1450 TypeName *returnType; /* the return type */
1451 List *options; /* a list of DefElem */
1452 List *withClause; /* a list of DefElem */
1453 } CreateFunctionStmt;
1455 typedef enum FunctionParameterMode
1457 /* the assigned enum values appear in pg_proc, don't change 'em! */
1458 FUNC_PARAM_IN = 'i', /* input only */
1459 FUNC_PARAM_OUT = 'o', /* output only */
1460 FUNC_PARAM_INOUT = 'b' /* both */
1461 } FunctionParameterMode;
1463 typedef struct FunctionParameter
1466 char *name; /* parameter name, or NULL if not given */
1467 TypeName *argType; /* TypeName for parameter type */
1468 FunctionParameterMode mode; /* IN/OUT/INOUT */
1469 } FunctionParameter;
1471 typedef struct AlterFunctionStmt
1474 FuncWithArgs *func; /* name and args of function */
1475 List *actions; /* list of DefElem */
1476 } AlterFunctionStmt;
1478 /* ----------------------
1479 * Drop {Function|Aggregate|Operator} Statement
1480 * ----------------------
1482 typedef struct RemoveFuncStmt
1485 ObjectType kind; /* function, aggregate, operator */
1486 List *name; /* qualified name of object to drop */
1487 List *args; /* types of the arguments */
1488 DropBehavior behavior; /* RESTRICT or CASCADE behavior */
1489 bool missing_ok; /* skip error if a missing? */
1492 /* ----------------------
1493 * Drop Operator Class Statement
1494 * ----------------------
1496 typedef struct RemoveOpClassStmt
1499 List *opclassname; /* qualified name (list of Value strings) */
1500 char *amname; /* name of index AM opclass is for */
1501 DropBehavior behavior; /* RESTRICT or CASCADE behavior */
1502 bool missing_ok; /* skip error if a missing? */
1503 } RemoveOpClassStmt;
1505 /* ----------------------
1506 * Alter Object Rename Statement
1507 * ----------------------
1509 typedef struct RenameStmt
1512 ObjectType renameType; /* OBJECT_TABLE, OBJECT_COLUMN, etc */
1513 RangeVar *relation; /* in case it's a table */
1514 List *object; /* in case it's some other object */
1515 List *objarg; /* argument types, if applicable */
1516 char *subname; /* name of contained object (column, rule,
1518 char *newname; /* the new name */
1521 /* ----------------------
1522 * ALTER object SET SCHEMA Statement
1523 * ----------------------
1525 typedef struct AlterObjectSchemaStmt
1528 ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
1529 RangeVar *relation; /* in case it's a table */
1530 List *object; /* in case it's some other object */
1531 List *objarg; /* argument types, if applicable */
1532 char *addname; /* additional name if needed */
1533 char *newschema; /* the new schema */
1534 } AlterObjectSchemaStmt;
1536 /* ----------------------
1537 * Alter Object Owner Statement
1538 * ----------------------
1540 typedef struct AlterOwnerStmt
1543 ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
1544 RangeVar *relation; /* in case it's a table */
1545 List *object; /* in case it's some other object */
1546 List *objarg; /* argument types, if applicable */
1547 char *addname; /* additional name if needed */
1548 char *newowner; /* the new owner */
1552 /* ----------------------
1553 * Create Rule Statement
1554 * ----------------------
1556 typedef struct RuleStmt
1559 RangeVar *relation; /* relation the rule is for */
1560 char *rulename; /* name of the rule */
1561 Node *whereClause; /* qualifications */
1562 CmdType event; /* SELECT, INSERT, etc */
1563 bool instead; /* is a 'do instead'? */
1564 List *actions; /* the action statements */
1565 bool replace; /* OR REPLACE */
1568 /* ----------------------
1570 * ----------------------
1572 typedef struct NotifyStmt
1575 RangeVar *relation; /* qualified name to notify */
1578 /* ----------------------
1580 * ----------------------
1582 typedef struct ListenStmt
1585 RangeVar *relation; /* qualified name to listen on */
1588 /* ----------------------
1589 * Unlisten Statement
1590 * ----------------------
1592 typedef struct UnlistenStmt
1595 RangeVar *relation; /* qualified name to unlisten on, or '*' */
1598 /* ----------------------
1599 * {Begin|Commit|Rollback} Transaction Statement
1600 * ----------------------
1602 typedef enum TransactionStmtKind
1605 TRANS_STMT_START, /* semantically identical to BEGIN */
1607 TRANS_STMT_ROLLBACK,
1608 TRANS_STMT_SAVEPOINT,
1610 TRANS_STMT_ROLLBACK_TO,
1612 TRANS_STMT_COMMIT_PREPARED,
1613 TRANS_STMT_ROLLBACK_PREPARED
1614 } TransactionStmtKind;
1616 typedef struct TransactionStmt
1619 TransactionStmtKind kind; /* see above */
1620 List *options; /* for BEGIN/START and savepoint commands */
1621 char *gid; /* for two-phase-commit related commands */
1624 /* ----------------------
1625 * Create Type Statement, composite types
1626 * ----------------------
1628 typedef struct CompositeTypeStmt
1631 RangeVar *typevar; /* the composite type to be created */
1632 List *coldeflist; /* list of ColumnDef nodes */
1633 } CompositeTypeStmt;
1636 /* ----------------------
1637 * Create View Statement
1638 * ----------------------
1640 typedef struct ViewStmt
1643 RangeVar *view; /* the view to be created */
1644 List *aliases; /* target column names */
1645 Query *query; /* the SQL statement */
1646 bool replace; /* replace an existing view? */
1649 /* ----------------------
1651 * ----------------------
1653 typedef struct LoadStmt
1656 char *filename; /* file to load */
1659 /* ----------------------
1660 * Createdb Statement
1661 * ----------------------
1663 typedef struct CreatedbStmt
1666 char *dbname; /* name of database to create */
1667 List *options; /* List of DefElem nodes */
1670 /* ----------------------
1672 * ----------------------
1674 typedef struct AlterDatabaseStmt
1677 char *dbname; /* name of database to alter */
1678 List *options; /* List of DefElem nodes */
1679 } AlterDatabaseStmt;
1681 typedef struct AlterDatabaseSetStmt
1687 } AlterDatabaseSetStmt;
1689 /* ----------------------
1691 * ----------------------
1693 typedef struct DropdbStmt
1696 char *dbname; /* database to drop */
1697 bool missing_ok; /* skip error if db is missing? */
1700 /* ----------------------
1701 * Cluster Statement (support pbrown's cluster index implementation)
1702 * ----------------------
1704 typedef struct ClusterStmt
1707 RangeVar *relation; /* relation being indexed, or NULL if all */
1708 char *indexname; /* original index defined */
1711 /* ----------------------
1712 * Vacuum and Analyze Statements
1714 * Even though these are nominally two statements, it's convenient to use
1715 * just one node type for both.
1716 * ----------------------
1718 typedef struct VacuumStmt
1721 bool vacuum; /* do VACUUM step */
1722 bool full; /* do FULL (non-concurrent) vacuum */
1723 bool analyze; /* do ANALYZE step */
1724 bool freeze; /* early-freeze option */
1725 bool verbose; /* print progress info */
1726 RangeVar *relation; /* single table to process, or NULL */
1727 List *va_cols; /* list of column names, or NIL for all */
1730 /* ----------------------
1732 * ----------------------
1734 typedef struct ExplainStmt
1737 Query *query; /* the query */
1738 bool verbose; /* print plan info */
1739 bool analyze; /* get statistics by executing plan */
1742 /* ----------------------
1743 * Checkpoint Statement
1744 * ----------------------
1746 typedef struct CheckPointStmt
1751 /* ----------------------
1753 * ----------------------
1756 typedef struct VariableSetStmt
1761 bool is_local; /* SET LOCAL */
1764 /* ----------------------
1766 * ----------------------
1769 typedef struct VariableShowStmt
1775 /* ----------------------
1777 * ----------------------
1780 typedef struct VariableResetStmt
1784 } VariableResetStmt;
1786 /* ----------------------
1788 * ----------------------
1790 typedef struct LockStmt
1793 List *relations; /* relations to lock */
1794 int mode; /* lock mode */
1795 bool nowait; /* no wait mode */
1798 /* ----------------------
1799 * SET CONSTRAINTS Statement
1800 * ----------------------
1802 typedef struct ConstraintsSetStmt
1805 List *constraints; /* List of names as RangeVars */
1807 } ConstraintsSetStmt;
1809 /* ----------------------
1811 * ----------------------
1813 typedef struct ReindexStmt
1816 ObjectType kind; /* OBJECT_INDEX, OBJECT_TABLE, OBJECT_DATABASE */
1817 RangeVar *relation; /* Table or index to reindex */
1818 const char *name; /* name of database to reindex */
1819 bool do_system; /* include system tables in database case */
1820 bool do_user; /* include user tables in database case */
1823 /* ----------------------
1824 * CREATE CONVERSION Statement
1825 * ----------------------
1827 typedef struct CreateConversionStmt
1830 List *conversion_name; /* Name of the conversion */
1831 char *for_encoding_name; /* source encoding name */
1832 char *to_encoding_name; /* destination encoding name */
1833 List *func_name; /* qualified conversion function name */
1834 bool def; /* is this a default conversion? */
1835 } CreateConversionStmt;
1837 /* ----------------------
1838 * CREATE CAST Statement
1839 * ----------------------
1841 typedef struct CreateCastStmt
1844 TypeName *sourcetype;
1845 TypeName *targettype;
1847 CoercionContext context;
1850 /* ----------------------
1851 * DROP CAST Statement
1852 * ----------------------
1854 typedef struct DropCastStmt
1857 TypeName *sourcetype;
1858 TypeName *targettype;
1859 DropBehavior behavior;
1860 bool missing_ok; /* skip error if a missing? */
1864 /* ----------------------
1866 * ----------------------
1868 typedef struct PrepareStmt
1871 char *name; /* Name of plan, arbitrary */
1872 List *argtypes; /* Types of parameters (TypeNames) */
1873 List *argtype_oids; /* Types of parameters (OIDs) */
1874 Query *query; /* The query itself */
1878 /* ----------------------
1880 * ----------------------
1883 typedef struct ExecuteStmt
1886 char *name; /* The name of the plan to execute */
1887 RangeVar *into; /* Optional table to store results in */
1888 List *intoOptions; /* Options from WITH clause */
1889 OnCommitAction into_on_commit; /* What do we do at COMMIT? */
1890 char *into_tbl_space; /* Tablespace to use, or NULL */
1891 List *params; /* Values to assign to parameters */
1895 /* ----------------------
1896 * DEALLOCATE Statement
1897 * ----------------------
1899 typedef struct DeallocateStmt
1902 char *name; /* The name of the plan to remove */
1906 * DROP OWNED statement
1908 typedef struct DropOwnedStmt
1912 DropBehavior behavior;
1916 * REASSIGN OWNED statement
1918 typedef struct ReassignOwnedStmt
1923 } ReassignOwnedStmt;
1925 #endif /* PARSENODES_H */