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.305 2006/03/16 00:31:55 tgl Exp $
12 *-------------------------------------------------------------------------
17 #include "nodes/primnodes.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 N_ACL_RIGHTS 11 /* 1 plus the last 1<<x */
61 #define ACL_NO_RIGHTS 0
62 /* Currently, SELECT ... FOR UPDATE/FOR SHARE requires UPDATE privileges */
63 #define ACL_SELECT_FOR_UPDATE ACL_UPDATE
66 /*****************************************************************************
68 *****************************************************************************/
72 * all statements are turned into a Query tree (via transformStmt)
73 * for further processing by the optimizer
75 * utility statements (i.e. non-optimizable statements) have the
76 * utilityStmt field set, and the Query itself is mostly dummy.
82 CmdType commandType; /* select|insert|update|delete|utility */
84 QuerySource querySource; /* where did I come from? */
86 bool canSetTag; /* do I set the command result tag? */
88 Node *utilityStmt; /* non-null if this is a non-optimizable
91 int resultRelation; /* target relation (index into rtable) */
93 RangeVar *into; /* target relation for SELECT INTO */
94 bool intoHasOids; /* should target relation contain OIDs? */
95 OnCommitAction intoOnCommit; /* what do we do at COMMIT? */
96 char *intoTableSpaceName; /* table space to use, or NULL */
98 bool hasAggs; /* has aggregates in tlist or havingQual */
99 bool hasSubLinks; /* has subquery SubLink */
101 List *rtable; /* list of range table entries */
102 FromExpr *jointree; /* table join tree (FROM and WHERE clauses) */
104 List *rowMarks; /* integer list of RT indexes of relations
105 * that are selected FOR UPDATE/SHARE */
107 bool forUpdate; /* true if rowMarks are FOR UPDATE, false if
108 * they are FOR SHARE */
109 bool rowNoWait; /* FOR UPDATE/SHARE NOWAIT option */
111 List *targetList; /* target list (of TargetEntry) */
113 List *groupClause; /* a list of GroupClause's */
115 Node *havingQual; /* qualifications applied to groups */
117 List *distinctClause; /* a list of SortClause's */
119 List *sortClause; /* a list of SortClause's */
121 Node *limitOffset; /* # of result tuples to skip */
122 Node *limitCount; /* # of result tuples to return */
124 Node *setOperations; /* set-operation tree if this is top level of
125 * a UNION/INTERSECT/EXCEPT query */
128 * If the resultRelation turns out to be the parent of an inheritance
129 * tree, the planner will add all the child tables to the rtable and store
130 * a list of the rtindexes of all the result relations here. This is done
131 * at plan time, not parse time, since we don't want to commit to the
132 * exact set of child tables at parse time. This field ought to go in
133 * some sort of TopPlan plan node, not in the Query.
135 List *resultRelations; /* integer list of RT indexes, or NIL */
139 /****************************************************************************
140 * Supporting data structures for Parse Trees
142 * Most of these node types appear in raw parsetrees output by the grammar,
143 * and get transformed to something else by the analyzer. A few of them
144 * are used as-is in transformed querytrees.
146 * Many of the node types used in raw parsetrees include a "location" field.
147 * This is a byte (not character) offset in the original source text, to be
148 * used for positioning an error cursor when there is an analysis-time
149 * error related to the node.
150 ****************************************************************************/
153 * TypeName - specifies a type in definitions
155 * For TypeName structures generated internally, it is often easier to
156 * specify the type by OID than by name. If "names" is NIL then the
157 * actual type OID is given by typeid, otherwise typeid is unused.
159 * If pct_type is TRUE, then names is actually a field name and we look up
160 * the type of that field. Otherwise (the normal case), names is a type
161 * name possibly qualified with schema and database name.
163 typedef struct TypeName
166 List *names; /* qualified name (list of Value strings) */
167 Oid typeid; /* type identified by OID */
168 bool timezone; /* timezone specified? */
169 bool setof; /* is a set? */
170 bool pct_type; /* %TYPE specified? */
171 int32 typmod; /* type modifier */
172 List *arrayBounds; /* array bounds */
173 int location; /* token location, or -1 if unknown */
177 * ColumnRef - specifies a reference to a column, or possibly a whole tuple
179 * The "fields" list must be nonempty; its last component may be "*"
180 * instead of a regular field name.
182 * Note: any array subscripting or selection of fields from composite columns
183 * is represented by an A_Indirection node above the ColumnRef. However,
184 * for simplicity in the normal case, initial field selection from a table
185 * name is represented within ColumnRef and not by adding A_Indirection.
187 typedef struct ColumnRef
190 List *fields; /* field names (list of Value strings) */
191 int location; /* token location, or -1 if unknown */
195 * ParamRef - specifies a $n parameter reference
197 typedef struct ParamRef
200 int number; /* the number of the parameter */
204 * A_Expr - infix, prefix, and postfix expressions
206 typedef enum A_Expr_Kind
208 AEXPR_OP, /* normal operator */
209 AEXPR_AND, /* booleans - name field is unused */
212 AEXPR_OP_ANY, /* scalar op ANY (array) */
213 AEXPR_OP_ALL, /* scalar op ALL (array) */
214 AEXPR_DISTINCT, /* IS DISTINCT FROM - name must be "=" */
215 AEXPR_NULLIF, /* NULLIF - name must be "=" */
216 AEXPR_OF, /* IS [NOT] OF - name must be "=" or "<>" */
217 AEXPR_IN /* [NOT] IN - name must be "=" or "<>" */
220 typedef struct A_Expr
223 A_Expr_Kind kind; /* see above */
224 List *name; /* possibly-qualified name of operator */
225 Node *lexpr; /* left argument, or NULL if none */
226 Node *rexpr; /* right argument, or NULL if none */
227 int location; /* token location, or -1 if unknown */
231 * A_Const - a constant expression
233 typedef struct A_Const
236 Value val; /* the value (with the tag) */
237 TypeName *typename; /* typecast, or NULL if none */
241 * TypeCast - a CAST expression
243 * NOTE: for mostly historical reasons, A_Const parsenodes contain
244 * room for a TypeName; we only generate a separate TypeCast node if the
245 * argument to be casted is not a constant. In theory either representation
246 * would work, but the combined representation saves a bit of code in many
247 * productions in gram.y.
249 typedef struct TypeCast
252 Node *arg; /* the expression being casted */
253 TypeName *typename; /* the target type */
257 * FuncCall - a function or aggregate invocation
259 * agg_star indicates we saw a 'foo(*)' construct, while agg_distinct
260 * indicates we saw 'foo(DISTINCT ...)'. In either case, the construct
261 * *must* be an aggregate call. Otherwise, it might be either an
262 * aggregate or some other kind of function.
264 typedef struct FuncCall
267 List *funcname; /* qualified name of function */
268 List *args; /* the arguments (list of exprs) */
269 bool agg_star; /* argument was really '*' */
270 bool agg_distinct; /* arguments were labeled DISTINCT */
271 int location; /* token location, or -1 if unknown */
275 * A_Indices - array reference or bounds ([lidx:uidx] or [uidx])
277 typedef struct A_Indices
280 Node *lidx; /* could be NULL */
285 * A_Indirection - select a field and/or array element from an expression
287 * The indirection list can contain both A_Indices nodes (representing
288 * subscripting) and string Value nodes (representing field selection
289 * --- the string value is the name of the field to select). For example,
290 * a complex selection operation like
291 * (foo).field1[42][7].field2
292 * would be represented with a single A_Indirection node having a 4-element
295 * Note: as of Postgres 8.0, we don't support arrays of composite values,
296 * so cases in which a field select follows a subscript aren't actually
297 * semantically legal. However the parser is prepared to handle such.
299 typedef struct A_Indirection
302 Node *arg; /* the thing being selected from */
303 List *indirection; /* subscripts and/or field names */
308 * result target (used in target list of pre-transformed parse trees)
310 * In a SELECT or INSERT target list, 'name' is the column label from an
311 * 'AS ColumnLabel' clause, or NULL if there was none, and 'val' is the
312 * value expression itself. The 'indirection' field is not used.
314 * INSERT has a second ResTarget list which is the target-column-names list.
315 * Here, 'val' is not used, 'name' is the name of the destination column,
316 * and 'indirection' stores any subscripts attached to the destination.
318 * In an UPDATE target list, 'name' is the name of the destination column,
319 * 'indirection' stores any subscripts attached to the destination, and
320 * 'val' is the expression to assign.
322 * See A_Indirection for more info about what can appear in 'indirection'.
324 typedef struct ResTarget
327 char *name; /* column name or NULL */
328 List *indirection; /* subscripts and field names, or NIL */
329 Node *val; /* the value expression to compute or assign */
333 * SortBy - for ORDER BY clause
336 #define SORTBY_DESC 2
337 #define SORTBY_USING 3
339 typedef struct SortBy
342 int sortby_kind; /* see codes above */
343 List *useOp; /* name of op to use, if SORTBY_USING */
344 Node *node; /* expression to sort on */
348 * RangeSubselect - subquery appearing in a FROM clause
350 typedef struct RangeSubselect
353 Node *subquery; /* the untransformed sub-select clause */
354 Alias *alias; /* table alias & optional column aliases */
358 * RangeFunction - function call appearing in a FROM clause
360 typedef struct RangeFunction
363 Node *funccallnode; /* untransformed function call tree */
364 Alias *alias; /* table alias & optional column aliases */
365 List *coldeflist; /* list of ColumnDef nodes to describe
366 * result of function returning RECORD */
370 * ColumnDef - column definition (used in various creates)
372 * If the column has a default value, we may have the value expression
373 * in either "raw" form (an untransformed parse tree) or "cooked" form
374 * (the nodeToString representation of an executable expression tree),
375 * depending on how this ColumnDef node was created (by parsing, or by
376 * inheritance from an existing relation). We should never have both
379 * The constraints list may contain a CONSTR_DEFAULT item in a raw
380 * parsetree produced by gram.y, but transformCreateStmt will remove
381 * the item and set raw_default instead. CONSTR_DEFAULT items
382 * should not appear in any subsequent processing.
384 * The "support" field, if not null, denotes a supporting relation that
385 * should be linked by an internal dependency to the column. Currently
386 * this is only used to link a SERIAL column's sequence to the column.
388 typedef struct ColumnDef
391 char *colname; /* name of column */
392 TypeName *typename; /* type of column */
393 int inhcount; /* number of times column is inherited */
394 bool is_local; /* column has local (non-inherited) def'n */
395 bool is_not_null; /* NOT NULL constraint specified? */
396 Node *raw_default; /* default value (untransformed parse tree) */
397 char *cooked_default; /* nodeToString representation */
398 List *constraints; /* other constraints on column */
399 RangeVar *support; /* supporting relation, if any */
403 * inhRelation - Relations a CREATE TABLE is to inherit attributes of
405 typedef struct InhRelation
409 bool including_defaults;
413 * IndexElem - index parameters (used in CREATE INDEX)
415 * For a plain index attribute, 'name' is the name of the table column to
416 * index, and 'expr' is NULL. For an index expression, 'name' is NULL and
417 * 'expr' is the expression tree.
419 typedef struct IndexElem
422 char *name; /* name of attribute to index, or NULL */
423 Node *expr; /* expression to index, or NULL */
424 List *opclass; /* name of desired opclass; NIL = default */
429 * a definition (used in definition lists in the form of defname = arg)
431 typedef struct DefElem
435 Node *arg; /* a (Value *) or a (TypeName *) */
439 * LockingClause - raw representation of FOR UPDATE/SHARE options
441 * Note: lockedRels == NIL means "all relations in query". Otherwise it
442 * is a list of String nodes giving relation eref names.
444 typedef struct LockingClause
447 List *lockedRels; /* FOR UPDATE or FOR SHARE relations */
448 bool forUpdate; /* true = FOR UPDATE, false = FOR SHARE */
449 bool nowait; /* NOWAIT option */
453 /****************************************************************************
454 * Nodes for a Query tree
455 ****************************************************************************/
457 /*--------------------
459 * A range table is a List of RangeTblEntry nodes.
461 * A range table entry may represent a plain relation, a sub-select in
462 * FROM, or the result of a JOIN clause. (Only explicit JOIN syntax
463 * produces an RTE, not the implicit join resulting from multiple FROM
464 * items. This is because we only need the RTE to deal with SQL features
465 * like outer joins and join-output-column aliasing.) Other special
466 * RTE types also exist, as indicated by RTEKind.
468 * alias is an Alias node representing the AS alias-clause attached to the
469 * FROM expression, or NULL if no clause.
471 * eref is the table reference name and column reference names (either
472 * real or aliases). Note that system columns (OID etc) are not included
473 * in the column list.
474 * eref->aliasname is required to be present, and should generally be used
475 * to identify the RTE for error messages etc.
477 * In RELATION RTEs, the colnames in both alias and eref are indexed by
478 * physical attribute number; this means there must be colname entries for
479 * dropped columns. When building an RTE we insert empty strings ("") for
480 * dropped columns. Note however that a stored rule may have nonempty
481 * colnames for columns dropped since the rule was created (and for that
482 * matter the colnames might be out of date due to column renamings).
483 * The same comments apply to FUNCTION RTEs when the function's return type
484 * is a named composite type.
486 * In JOIN RTEs, the colnames in both alias and eref are one-to-one with
487 * joinaliasvars entries. A JOIN RTE will omit columns of its inputs when
488 * those columns are known to be dropped at parse time. Again, however,
489 * a stored rule might contain entries for columns dropped since the rule
490 * was created. (This is only possible for columns not actually referenced
491 * in the rule.) When loading a stored rule, we replace the joinaliasvars
492 * items for any such columns with NULL Consts. (We can't simply delete
493 * them from the joinaliasvars list, because that would affect the attnums
494 * of Vars referencing the rest of the list.)
496 * inh is TRUE for relation references that should be expanded to include
497 * inheritance children, if the rel has any. This *must* be FALSE for
498 * RTEs other than RTE_RELATION entries.
500 * inFromCl marks those range variables that are listed in the FROM clause.
501 * It's false for RTEs that are added to a query behind the scenes, such
502 * as the NEW and OLD variables for a rule, or the subqueries of a UNION.
503 * This flag is not used anymore during parsing, since the parser now uses
504 * a separate "namespace" data structure to control visibility, but it is
505 * needed by ruleutils.c to determine whether RTEs should be shown in
506 * decompiled queries.
508 * requiredPerms and checkAsUser specify run-time access permissions
509 * checks to be performed at query startup. The user must have *all*
510 * of the permissions that are OR'd together in requiredPerms (zero
511 * indicates no permissions checking). If checkAsUser is not zero,
512 * then do the permissions checks using the access rights of that user,
513 * not the current effective user ID. (This allows rules to act as
515 *--------------------
519 RTE_RELATION, /* ordinary relation reference */
520 RTE_SUBQUERY, /* subquery in FROM */
522 RTE_SPECIAL, /* special rule relation (NEW or OLD) */
523 RTE_FUNCTION /* function in FROM */
526 typedef struct RangeTblEntry
530 RTEKind rtekind; /* see above */
533 * XXX the fields applicable to only some rte kinds should be merged into
534 * a union. I didn't do this yet because the diffs would impact a lot of
535 * code that is being actively worked on. FIXME later.
539 * Fields valid for a plain relation RTE (else zero):
541 Oid relid; /* OID of the relation */
544 * Fields valid for a subquery RTE (else NULL):
546 Query *subquery; /* the sub-query */
549 * Fields valid for a function RTE (else NULL):
551 * If the function returns RECORD, funccoltypes lists the column types
552 * declared in the RTE's column type specification, and funccoltypmods
553 * lists their declared typmods. Otherwise, both fields are NIL.
555 Node *funcexpr; /* expression tree for func call */
556 List *funccoltypes; /* OID list of column type OIDs */
557 List *funccoltypmods; /* integer list of column typmods */
560 * Fields valid for a join RTE (else NULL/zero):
562 * joinaliasvars is a list of Vars or COALESCE expressions corresponding
563 * to the columns of the join result. An alias Var referencing column K
564 * of the join result can be replaced by the K'th element of joinaliasvars
565 * --- but to simplify the task of reverse-listing aliases correctly, we
566 * do not do that until planning time. In a Query loaded from a stored
567 * rule, it is also possible for joinaliasvars items to be NULL Consts,
568 * denoting columns dropped since the rule was made.
570 JoinType jointype; /* type of join */
571 List *joinaliasvars; /* list of alias-var expansions */
574 * Fields valid in all RTEs:
576 Alias *alias; /* user-written alias clause, if any */
577 Alias *eref; /* expanded reference names */
578 bool inh; /* inheritance requested? */
579 bool inFromCl; /* present in FROM clause? */
580 AclMode requiredPerms; /* bitmask of required access permissions */
581 Oid checkAsUser; /* if valid, check access as this role */
586 * representation of ORDER BY clauses
588 * tleSortGroupRef must match ressortgroupref of exactly one entry of the
589 * associated targetlist; that is the expression to be sorted (or grouped) by.
590 * sortop is the OID of the ordering operator.
592 * SortClauses are also used to identify targets that we will do a "Unique"
593 * filter step on (for SELECT DISTINCT and SELECT DISTINCT ON). The
594 * distinctClause list is simply a copy of the relevant members of the
595 * sortClause list. Note that distinctClause can be a subset of sortClause,
596 * but cannot have members not present in sortClause; and the members that
597 * do appear must be in the same order as in sortClause.
599 typedef struct SortClause
602 Index tleSortGroupRef; /* reference into targetlist */
603 Oid sortop; /* the sort operator to use */
608 * representation of GROUP BY clauses
610 * GroupClause is exactly like SortClause except for the nodetag value
611 * (it's probably not even really necessary to have two different
612 * nodetags...). We have routines that operate interchangeably on both.
614 typedef SortClause GroupClause;
617 /*****************************************************************************
618 * Optimizable Statements
619 *****************************************************************************/
621 /* ----------------------
623 * ----------------------
625 typedef struct InsertStmt
628 RangeVar *relation; /* relation to insert into */
629 List *cols; /* optional: names of the target columns */
632 * An INSERT statement has *either* VALUES or SELECT, never both. If
633 * VALUES, a targetList is supplied (empty for DEFAULT VALUES). If SELECT,
634 * a complete SelectStmt (or set-operation tree) is supplied.
636 List *targetList; /* the target list (of ResTarget) */
637 Node *selectStmt; /* the source SELECT */
640 /* ----------------------
642 * ----------------------
644 typedef struct DeleteStmt
647 RangeVar *relation; /* relation to delete from */
648 Node *whereClause; /* qualifications */
649 List *usingClause; /* optional using clause for more tables */
652 /* ----------------------
654 * ----------------------
656 typedef struct UpdateStmt
659 RangeVar *relation; /* relation to update */
660 List *targetList; /* the target list (of ResTarget) */
661 Node *whereClause; /* qualifications */
662 List *fromClause; /* optional from clause for more tables */
665 /* ----------------------
668 * A "simple" SELECT is represented in the output of gram.y by a single
669 * SelectStmt node. A SELECT construct containing set operators (UNION,
670 * INTERSECT, EXCEPT) is represented by a tree of SelectStmt nodes, in
671 * which the leaf nodes are component SELECTs and the internal nodes
672 * represent UNION, INTERSECT, or EXCEPT operators. Using the same node
673 * type for both leaf and internal nodes allows gram.y to stick ORDER BY,
674 * LIMIT, etc, clause values into a SELECT statement without worrying
675 * whether it is a simple or compound SELECT.
676 * ----------------------
678 typedef enum SetOperation
686 typedef enum ContainsOids
688 MUST_HAVE_OIDS, /* WITH OIDS explicitly specified */
689 MUST_NOT_HAVE_OIDS, /* WITHOUT OIDS explicitly specified */
690 DEFAULT_OIDS /* neither specified; use the default, which
691 * is the value of the default_with_oids GUC
695 typedef struct SelectStmt
700 * These fields are used only in "leaf" SelectStmts.
702 * into, intoColNames, intoHasOids, intoOnCommit, and
703 * intoTableSpaceName are a kluge; they belong somewhere else...
705 List *distinctClause; /* NULL, list of DISTINCT ON exprs, or
706 * lcons(NIL,NIL) for all (SELECT DISTINCT) */
707 RangeVar *into; /* target table (for select into table) */
708 List *intoColNames; /* column names for into table */
709 ContainsOids intoHasOids; /* should target table have OIDs? */
710 OnCommitAction intoOnCommit; /* what do we do at COMMIT? */
711 char *intoTableSpaceName; /* table space to use, or NULL */
712 List *targetList; /* the target list (of ResTarget) */
713 List *fromClause; /* the FROM clause */
714 Node *whereClause; /* WHERE qualification */
715 List *groupClause; /* GROUP BY clauses */
716 Node *havingClause; /* HAVING conditional-expression */
719 * These fields are used in both "leaf" SelectStmts and upper-level
722 List *sortClause; /* sort clause (a list of SortBy's) */
723 Node *limitOffset; /* # of result tuples to skip */
724 Node *limitCount; /* # of result tuples to return */
725 LockingClause *lockingClause; /* FOR UPDATE/FOR SHARE */
728 * These fields are used only in upper-level SelectStmts.
730 SetOperation op; /* type of set op */
731 bool all; /* ALL specified? */
732 struct SelectStmt *larg; /* left child */
733 struct SelectStmt *rarg; /* right child */
734 /* Eventually add fields for CORRESPONDING spec here */
738 /* ----------------------
739 * Set Operation node for post-analysis query trees
741 * After parse analysis, a SELECT with set operations is represented by a
742 * top-level Query node containing the leaf SELECTs as subqueries in its
743 * range table. Its setOperations field shows the tree of set operations,
744 * with leaf SelectStmt nodes replaced by RangeTblRef nodes, and internal
745 * nodes replaced by SetOperationStmt nodes.
746 * ----------------------
748 typedef struct SetOperationStmt
751 SetOperation op; /* type of set op */
752 bool all; /* ALL specified? */
753 Node *larg; /* left child */
754 Node *rarg; /* right child */
755 /* Eventually add fields for CORRESPONDING spec here */
757 /* Fields derived during parse analysis: */
758 List *colTypes; /* list of OIDs of output column types */
762 /*****************************************************************************
763 * Other Statements (no optimizations required)
765 * Some of them require a little bit of transformation (which is also
766 * done by transformStmt). The whole structure is then passed on to
767 * ProcessUtility (by-passing the optimization step) as the utilityStmt
769 *****************************************************************************/
772 * When a command can act on several kinds of objects with only one
773 * parse structure required, use these constants to designate the
777 typedef enum ObjectType
803 /* ----------------------
804 * Create Schema Statement
806 * NOTE: the schemaElts list contains raw parsetrees for component statements
807 * of the schema, such as CREATE TABLE, GRANT, etc. These are analyzed and
808 * executed after the schema itself is created.
809 * ----------------------
811 typedef struct CreateSchemaStmt
814 char *schemaname; /* the name of the schema to create */
815 char *authid; /* the owner of the created schema */
816 List *schemaElts; /* schema components (list of parsenodes) */
819 typedef enum DropBehavior
821 DROP_RESTRICT, /* drop fails if any dependent objects */
822 DROP_CASCADE /* remove dependent objects too */
825 /* ----------------------
827 * ----------------------
829 typedef struct AlterTableStmt
832 RangeVar *relation; /* table to work on */
833 List *cmds; /* list of subcommands */
834 ObjectType relkind; /* type of object */
837 typedef enum AlterTableType
839 AT_AddColumn, /* add column */
840 AT_ColumnDefault, /* alter column default */
841 AT_DropNotNull, /* alter column drop not null */
842 AT_SetNotNull, /* alter column set not null */
843 AT_SetStatistics, /* alter column statistics */
844 AT_SetStorage, /* alter column storage */
845 AT_DropColumn, /* drop column */
846 AT_DropColumnRecurse, /* internal to commands/tablecmds.c */
847 AT_AddIndex, /* add index */
848 AT_ReAddIndex, /* internal to commands/tablecmds.c */
849 AT_AddConstraint, /* add constraint */
850 AT_ProcessedConstraint, /* pre-processed add constraint (local in
851 * parser/analyze.c) */
852 AT_DropConstraint, /* drop constraint */
853 AT_DropConstraintQuietly, /* drop constraint, no error/warning (local in
854 * commands/tablecmds.c) */
855 AT_AlterColumnType, /* alter column type */
856 AT_ToastTable, /* create toast table */
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_EnableTrig, /* ENABLE TRIGGER name */
863 AT_DisableTrig, /* DISABLE TRIGGER name */
864 AT_EnableTrigAll, /* ENABLE TRIGGER ALL */
865 AT_DisableTrigAll, /* DISABLE TRIGGER ALL */
866 AT_EnableTrigUser, /* ENABLE TRIGGER USER */
867 AT_DisableTrigUser /* DISABLE TRIGGER USER */
870 typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */
873 AlterTableType subtype; /* Type of table alteration to apply */
874 char *name; /* column, constraint, or trigger to act on,
875 * or new owner or tablespace */
876 Node *def; /* definition of new column, column type,
877 * index, or constraint */
878 Node *transform; /* transformation expr for ALTER TYPE */
879 DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
883 /* ----------------------
886 * The fields are used in different ways by the different variants of
888 * ----------------------
890 typedef struct AlterDomainStmt
893 char subtype; /*------------
894 * T = alter column default
895 * N = alter column drop not null
896 * O = alter column set not null
898 * X = drop constraint
901 List *typename; /* domain to work on */
902 char *name; /* column or constraint name to act on */
903 Node *def; /* definition of default or constraint */
904 DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
908 /* ----------------------
909 * Grant|Revoke Statement
910 * ----------------------
912 typedef enum GrantObjectType
914 ACL_OBJECT_RELATION, /* table, view */
915 ACL_OBJECT_SEQUENCE, /* sequence */
916 ACL_OBJECT_DATABASE, /* database */
917 ACL_OBJECT_FUNCTION, /* function */
918 ACL_OBJECT_LANGUAGE, /* procedural language */
919 ACL_OBJECT_NAMESPACE, /* namespace */
920 ACL_OBJECT_TABLESPACE /* tablespace */
923 typedef struct GrantStmt
926 bool is_grant; /* true = GRANT, false = REVOKE */
927 GrantObjectType objtype; /* kind of object being operated on */
928 List *objects; /* list of RangeVar nodes, FuncWithArgs nodes,
929 * or plain names (as Value strings) */
930 List *privileges; /* list of privilege names (as Strings) */
931 /* privileges == NIL denotes "all privileges" */
932 List *grantees; /* list of PrivGrantee nodes */
933 bool grant_option; /* grant or revoke grant option */
934 DropBehavior behavior; /* drop behavior (for REVOKE) */
937 typedef struct PrivGrantee
940 char *rolname; /* if NULL then PUBLIC */
944 * Note: FuncWithArgs carries only the types of the input parameters of the
945 * function. So it is sufficient to identify an existing function, but it
946 * is not enough info to define a function nor to call it.
948 typedef struct FuncWithArgs
951 List *funcname; /* qualified name of function */
952 List *funcargs; /* list of Typename nodes */
955 /* This is only used internally in gram.y. */
956 typedef struct PrivTarget
959 GrantObjectType objtype;
963 /* ----------------------
964 * Grant/Revoke Role Statement
966 * Note: the lists of roles are lists of names, as Value strings
967 * ----------------------
969 typedef struct GrantRoleStmt
972 List *granted_roles; /* list of roles to be granted/revoked */
973 List *grantee_roles; /* list of member roles to add/delete */
974 bool is_grant; /* true = GRANT, false = REVOKE */
975 bool admin_opt; /* with admin option */
976 char *grantor; /* set grantor to other than current role */
977 DropBehavior behavior; /* drop behavior (for REVOKE) */
980 /* ----------------------
982 * ----------------------
984 typedef struct CopyStmt
987 RangeVar *relation; /* the relation to copy */
988 List *attlist; /* List of column names (as Strings), or NIL
990 bool is_from; /* TO or FROM */
991 char *filename; /* if NULL, use stdin/stdout */
992 List *options; /* List of DefElem nodes */
995 /* ----------------------
996 * Create Table Statement
998 * NOTE: in the raw gram.y output, ColumnDef, Constraint, and FkConstraint
999 * nodes are intermixed in tableElts, and constraints is NIL. After parse
1000 * analysis, tableElts contains just ColumnDefs, and constraints contains
1001 * just Constraint nodes (in fact, only CONSTR_CHECK nodes, in the present
1003 * ----------------------
1006 typedef struct CreateStmt
1009 RangeVar *relation; /* relation to create */
1010 List *tableElts; /* column definitions (list of ColumnDef) */
1011 List *inhRelations; /* relations to inherit from (list of
1013 List *constraints; /* constraints (list of Constraint nodes) */
1014 ContainsOids hasoids; /* should it have OIDs? */
1015 OnCommitAction oncommit; /* what do we do at COMMIT? */
1016 char *tablespacename; /* table space to use, or NULL */
1020 * Definitions for plain (non-FOREIGN KEY) constraints in CreateStmt
1022 * XXX probably these ought to be unified with FkConstraints at some point?
1023 * To this end we include CONSTR_FOREIGN in the ConstrType enum, even though
1024 * the parser does not generate it.
1026 * For constraints that use expressions (CONSTR_DEFAULT, CONSTR_CHECK)
1027 * we may have the expression in either "raw" form (an untransformed
1028 * parse tree) or "cooked" form (the nodeToString representation of
1029 * an executable expression tree), depending on how this Constraint
1030 * node was created (by parsing, or by inheritance from an existing
1031 * relation). We should never have both in the same node!
1033 * Constraint attributes (DEFERRABLE etc) are initially represented as
1034 * separate Constraint nodes for simplicity of parsing. analyze.c makes
1035 * a pass through the constraints list to attach the info to the appropriate
1036 * FkConstraint node (and, perhaps, someday to other kinds of constraints).
1040 typedef enum ConstrType /* types of constraints */
1042 CONSTR_NULL, /* not SQL92, but a lot of people expect it */
1049 CONSTR_ATTR_DEFERRABLE, /* attributes for previous constraint node */
1050 CONSTR_ATTR_NOT_DEFERRABLE,
1051 CONSTR_ATTR_DEFERRED,
1052 CONSTR_ATTR_IMMEDIATE
1055 typedef struct Constraint
1059 char *name; /* name, or NULL if unnamed */
1060 Node *raw_expr; /* expr, as untransformed parse tree */
1061 char *cooked_expr; /* expr, as nodeToString representation */
1062 List *keys; /* String nodes naming referenced column(s) */
1063 char *indexspace; /* index tablespace for PKEY/UNIQUE
1064 * constraints; NULL for default */
1068 * Definitions for FOREIGN KEY constraints in CreateStmt
1070 * Note: FKCONSTR_ACTION_xxx values are stored into pg_constraint.confupdtype
1071 * and pg_constraint.confdeltype columns; FKCONSTR_MATCH_xxx values are
1072 * stored into pg_constraint.confmatchtype. Changing the code values may
1073 * require an initdb!
1075 * If skip_validation is true then we skip checking that the existing rows
1076 * in the table satisfy the constraint, and just install the catalog entries
1077 * for the constraint. This is currently used only during CREATE TABLE
1078 * (when we know the table must be empty).
1081 #define FKCONSTR_ACTION_NOACTION 'a'
1082 #define FKCONSTR_ACTION_RESTRICT 'r'
1083 #define FKCONSTR_ACTION_CASCADE 'c'
1084 #define FKCONSTR_ACTION_SETNULL 'n'
1085 #define FKCONSTR_ACTION_SETDEFAULT 'd'
1087 #define FKCONSTR_MATCH_FULL 'f'
1088 #define FKCONSTR_MATCH_PARTIAL 'p'
1089 #define FKCONSTR_MATCH_UNSPECIFIED 'u'
1091 typedef struct FkConstraint
1094 char *constr_name; /* Constraint name, or NULL if unnamed */
1095 RangeVar *pktable; /* Primary key table */
1096 List *fk_attrs; /* Attributes of foreign key */
1097 List *pk_attrs; /* Corresponding attrs in PK table */
1098 char fk_matchtype; /* FULL, PARTIAL, UNSPECIFIED */
1099 char fk_upd_action; /* ON UPDATE action */
1100 char fk_del_action; /* ON DELETE action */
1101 bool deferrable; /* DEFERRABLE */
1102 bool initdeferred; /* INITIALLY DEFERRED */
1103 bool skip_validation; /* skip validation of existing rows? */
1107 /* ----------------------
1108 * Create/Drop Table Space Statements
1109 * ----------------------
1112 typedef struct CreateTableSpaceStmt
1115 char *tablespacename;
1118 } CreateTableSpaceStmt;
1120 typedef struct DropTableSpaceStmt
1123 char *tablespacename;
1124 } DropTableSpaceStmt;
1126 /* ----------------------
1127 * Create/Drop TRIGGER Statements
1128 * ----------------------
1131 typedef struct CreateTrigStmt
1134 char *trigname; /* TRIGGER's name */
1135 RangeVar *relation; /* relation trigger is on */
1136 List *funcname; /* qual. name of function to call */
1137 List *args; /* list of (T_String) Values or NIL */
1138 bool before; /* BEFORE/AFTER */
1139 bool row; /* ROW/STATEMENT */
1140 char actions[4]; /* 1 to 3 of 'i', 'u', 'd', + trailing \0 */
1142 /* The following are used for referential */
1143 /* integrity constraint triggers */
1144 bool isconstraint; /* This is an RI trigger */
1145 bool deferrable; /* [NOT] DEFERRABLE */
1146 bool initdeferred; /* INITIALLY {DEFERRED|IMMEDIATE} */
1147 RangeVar *constrrel; /* opposite relation */
1150 /* ----------------------
1151 * Create/Drop PROCEDURAL LANGUAGE Statement
1152 * ----------------------
1154 typedef struct CreatePLangStmt
1157 char *plname; /* PL name */
1158 List *plhandler; /* PL call handler function (qual. name) */
1159 List *plvalidator; /* optional validator function (qual. name) */
1160 bool pltrusted; /* PL is trusted */
1163 typedef struct DropPLangStmt
1166 char *plname; /* PL name */
1167 DropBehavior behavior; /* RESTRICT or CASCADE behavior */
1170 /* ----------------------
1171 * Create/Alter/Drop Role Statements
1173 * Note: these node types are also used for the backwards-compatible
1174 * Create/Alter/Drop User/Group statements. In the ALTER and DROP cases
1175 * there's really no need to distinguish what the original spelling was,
1176 * but for CREATE we mark the type because the defaults vary.
1177 * ----------------------
1179 typedef enum RoleStmtType
1186 typedef struct CreateRoleStmt
1189 RoleStmtType stmt_type; /* ROLE/USER/GROUP */
1190 char *role; /* role name */
1191 List *options; /* List of DefElem nodes */
1194 typedef struct AlterRoleStmt
1197 char *role; /* role name */
1198 List *options; /* List of DefElem nodes */
1199 int action; /* +1 = add members, -1 = drop members */
1202 typedef struct AlterRoleSetStmt
1205 char *role; /* role name */
1206 char *variable; /* GUC variable name */
1207 List *value; /* value for variable, or NIL for Reset */
1210 typedef struct DropRoleStmt
1213 List *roles; /* List of roles to remove */
1214 bool missing_ok; /* skip error if a role is missing? */
1217 /* ----------------------
1218 * {Create|Alter} SEQUENCE Statement
1219 * ----------------------
1222 typedef struct CreateSeqStmt
1225 RangeVar *sequence; /* the sequence to create */
1229 typedef struct AlterSeqStmt
1232 RangeVar *sequence; /* the sequence to alter */
1236 /* ----------------------
1237 * Create {Aggregate|Operator|Type} Statement
1238 * ----------------------
1240 typedef struct DefineStmt
1243 ObjectType kind; /* aggregate, operator, type */
1244 List *defnames; /* qualified name (list of Value strings) */
1245 List *definition; /* a list of DefElem */
1248 /* ----------------------
1249 * Create Domain Statement
1250 * ----------------------
1252 typedef struct CreateDomainStmt
1255 List *domainname; /* qualified name (list of Value strings) */
1256 TypeName *typename; /* the base type */
1257 List *constraints; /* constraints (list of Constraint nodes) */
1260 /* ----------------------
1261 * Create Operator Class Statement
1262 * ----------------------
1264 typedef struct CreateOpClassStmt
1267 List *opclassname; /* qualified name (list of Value strings) */
1268 char *amname; /* name of index AM opclass is for */
1269 TypeName *datatype; /* datatype of indexed column */
1270 List *items; /* List of CreateOpClassItem nodes */
1271 bool isDefault; /* Should be marked as default for type? */
1272 } CreateOpClassStmt;
1274 #define OPCLASS_ITEM_OPERATOR 1
1275 #define OPCLASS_ITEM_FUNCTION 2
1276 #define OPCLASS_ITEM_STORAGETYPE 3
1278 typedef struct CreateOpClassItem
1281 int itemtype; /* see codes above */
1282 /* fields used for an operator or function item: */
1283 List *name; /* operator or function name */
1284 List *args; /* argument types */
1285 int number; /* strategy num or support proc num */
1286 bool recheck; /* only used for operators */
1287 /* fields used for a storagetype item: */
1288 TypeName *storedtype; /* datatype stored in index */
1289 } CreateOpClassItem;
1291 /* ----------------------
1292 * Drop Table|Sequence|View|Index|Type|Domain|Conversion|Schema Statement
1293 * ----------------------
1296 typedef struct DropStmt
1299 List *objects; /* list of sublists of names (as Values) */
1300 ObjectType removeType; /* object type */
1301 DropBehavior behavior; /* RESTRICT or CASCADE behavior */
1302 bool missing_ok; /* skip error if object is missing? */
1305 /* ----------------------
1306 * Drop Rule|Trigger Statement
1308 * In general this may be used for dropping any property of a relation;
1309 * for example, someday soon we may have DROP ATTRIBUTE.
1310 * ----------------------
1313 typedef struct DropPropertyStmt
1316 RangeVar *relation; /* owning relation */
1317 char *property; /* name of rule, trigger, etc */
1318 ObjectType removeType; /* OBJECT_RULE or OBJECT_TRIGGER */
1319 DropBehavior behavior; /* RESTRICT or CASCADE behavior */
1322 /* ----------------------
1323 * Truncate Table Statement
1324 * ----------------------
1326 typedef struct TruncateStmt
1329 List *relations; /* relations (RangeVars) to be truncated */
1330 DropBehavior behavior; /* RESTRICT or CASCADE behavior */
1333 /* ----------------------
1334 * Comment On Statement
1335 * ----------------------
1337 typedef struct CommentStmt
1340 ObjectType objtype; /* Object's type */
1341 List *objname; /* Qualified name of the object */
1342 List *objargs; /* Arguments if needed (eg, for functions) */
1343 char *comment; /* Comment to insert, or NULL to remove */
1346 /* ----------------------
1347 * Declare Cursor Statement
1348 * ----------------------
1350 #define CURSOR_OPT_BINARY 0x0001
1351 #define CURSOR_OPT_SCROLL 0x0002
1352 #define CURSOR_OPT_NO_SCROLL 0x0004
1353 #define CURSOR_OPT_INSENSITIVE 0x0008
1354 #define CURSOR_OPT_HOLD 0x0010
1356 typedef struct DeclareCursorStmt
1359 char *portalname; /* name of the portal (cursor) */
1360 int options; /* bitmask of options (see above) */
1361 Node *query; /* the SELECT query */
1362 } DeclareCursorStmt;
1364 /* ----------------------
1365 * Close Portal Statement
1366 * ----------------------
1368 typedef struct ClosePortalStmt
1371 char *portalname; /* name of the portal (cursor) */
1374 /* ----------------------
1375 * Fetch Statement (also Move)
1376 * ----------------------
1378 typedef enum FetchDirection
1380 /* for these, howMany is how many rows to fetch; FETCH_ALL means ALL */
1383 /* for these, howMany indicates a position; only one row is fetched */
1388 #define FETCH_ALL LONG_MAX
1390 typedef struct FetchStmt
1393 FetchDirection direction; /* see above */
1394 long howMany; /* number of rows, or position argument */
1395 char *portalname; /* name of portal (cursor) */
1396 bool ismove; /* TRUE if MOVE */
1399 /* ----------------------
1400 * Create Index Statement
1401 * ----------------------
1403 typedef struct IndexStmt
1406 char *idxname; /* name of new index, or NULL for default */
1407 RangeVar *relation; /* relation to build index on */
1408 char *accessMethod; /* name of access method (eg. btree) */
1409 char *tableSpace; /* tablespace, or NULL to use parent's */
1410 List *indexParams; /* a list of IndexElem */
1411 Node *whereClause; /* qualification (partial-index predicate) */
1412 List *rangetable; /* range table for qual and/or expressions,
1413 * filled in by transformStmt() */
1414 bool unique; /* is index unique? */
1415 bool primary; /* is index on primary key? */
1416 bool isconstraint; /* is it from a CONSTRAINT clause? */
1419 /* ----------------------
1420 * Create Function Statement
1421 * ----------------------
1423 typedef struct CreateFunctionStmt
1426 bool replace; /* T => replace if already exists */
1427 List *funcname; /* qualified name of function to create */
1428 List *parameters; /* a list of FunctionParameter */
1429 TypeName *returnType; /* the return type */
1430 List *options; /* a list of DefElem */
1431 List *withClause; /* a list of DefElem */
1432 } CreateFunctionStmt;
1434 typedef enum FunctionParameterMode
1436 /* the assigned enum values appear in pg_proc, don't change 'em! */
1437 FUNC_PARAM_IN = 'i', /* input only */
1438 FUNC_PARAM_OUT = 'o', /* output only */
1439 FUNC_PARAM_INOUT = 'b' /* both */
1440 } FunctionParameterMode;
1442 typedef struct FunctionParameter
1445 char *name; /* parameter name, or NULL if not given */
1446 TypeName *argType; /* TypeName for parameter type */
1447 FunctionParameterMode mode; /* IN/OUT/INOUT */
1448 } FunctionParameter;
1450 typedef struct AlterFunctionStmt
1453 FuncWithArgs *func; /* name and args of function */
1454 List *actions; /* list of DefElem */
1455 } AlterFunctionStmt;
1457 /* ----------------------
1458 * Drop Aggregate Statement
1459 * ----------------------
1461 typedef struct RemoveAggrStmt
1464 List *aggname; /* aggregate to drop */
1465 TypeName *aggtype; /* TypeName for input datatype, or NULL */
1466 DropBehavior behavior; /* RESTRICT or CASCADE behavior */
1469 /* ----------------------
1470 * Drop Function Statement
1471 * ----------------------
1473 typedef struct RemoveFuncStmt
1476 List *funcname; /* function to drop */
1477 List *args; /* types of the arguments */
1478 DropBehavior behavior; /* RESTRICT or CASCADE behavior */
1481 /* ----------------------
1482 * Drop Operator Statement
1483 * ----------------------
1485 typedef struct RemoveOperStmt
1488 List *opname; /* operator to drop */
1489 List *args; /* types of the arguments */
1490 DropBehavior behavior; /* RESTRICT or CASCADE behavior */
1493 /* ----------------------
1494 * Drop Operator Class Statement
1495 * ----------------------
1497 typedef struct RemoveOpClassStmt
1500 List *opclassname; /* qualified name (list of Value strings) */
1501 char *amname; /* name of index AM opclass is for */
1502 DropBehavior behavior; /* RESTRICT or CASCADE behavior */
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 Value strings */
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;
1863 /* ----------------------
1865 * ----------------------
1867 typedef struct PrepareStmt
1870 char *name; /* Name of plan, arbitrary */
1871 List *argtypes; /* Types of parameters (TypeNames) */
1872 List *argtype_oids; /* Types of parameters (OIDs) */
1873 Query *query; /* The query itself */
1877 /* ----------------------
1879 * ----------------------
1882 typedef struct ExecuteStmt
1885 char *name; /* The name of the plan to execute */
1886 RangeVar *into; /* Optional table to store results in */
1887 ContainsOids into_contains_oids; /* Should it have OIDs? */
1888 bool into_has_oids; /* Merge GUC info with user input */
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 */