1 /*-------------------------------------------------------------------------
4 * definitions for parse tree nodes
6 * Many of the node types used in parsetrees include a "location" field.
7 * This is a byte (not character) offset in the original source text, to be
8 * used for positioning an error cursor when there is an error related to
9 * the node. Access to the original source text is needed to make use of
13 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
14 * Portions Copyright (c) 1994, Regents of the University of California
18 *-------------------------------------------------------------------------
23 #include "nodes/bitmapset.h"
24 #include "nodes/primnodes.h"
25 #include "nodes/value.h"
27 /* Possible sources of a Query */
28 typedef enum QuerySource
30 QSRC_ORIGINAL
, /* original parsetree (explicit query) */
31 QSRC_PARSER
, /* added by parse analysis (now unused) */
32 QSRC_INSTEAD_RULE
, /* added by unconditional INSTEAD rule */
33 QSRC_QUAL_INSTEAD_RULE
, /* added by conditional INSTEAD rule */
34 QSRC_NON_INSTEAD_RULE
/* added by non-INSTEAD rule */
37 /* Sort ordering options for ORDER BY and CREATE INDEX */
38 typedef enum SortByDir
43 SORTBY_USING
/* not allowed in CREATE INDEX ... */
46 typedef enum SortByNulls
54 * Grantable rights are encoded so that we can OR them together in a bitmask.
55 * The present representation of AclItem limits us to 16 distinct rights,
56 * even though AclMode is defined as uint32. See utils/acl.h.
58 * Caution: changing these codes breaks stored ACLs, hence forces initdb.
60 typedef uint32 AclMode
; /* a bitmask of privilege bits */
62 #define ACL_INSERT (1<<0) /* for relations */
63 #define ACL_SELECT (1<<1)
64 #define ACL_UPDATE (1<<2)
65 #define ACL_DELETE (1<<3)
66 #define ACL_TRUNCATE (1<<4)
67 #define ACL_REFERENCES (1<<5)
68 #define ACL_TRIGGER (1<<6)
69 #define ACL_EXECUTE (1<<7) /* for functions */
70 #define ACL_USAGE (1<<8) /* for languages, namespaces, FDWs, and
72 #define ACL_CREATE (1<<9) /* for namespaces and databases */
73 #define ACL_CREATE_TEMP (1<<10) /* for databases */
74 #define ACL_CONNECT (1<<11) /* for databases */
75 #define N_ACL_RIGHTS 12 /* 1 plus the last 1<<x */
76 #define ACL_NO_RIGHTS 0
77 /* Currently, SELECT ... FOR UPDATE/FOR SHARE requires UPDATE privileges */
78 #define ACL_SELECT_FOR_UPDATE ACL_UPDATE
81 /*****************************************************************************
83 *****************************************************************************/
87 * Parse analysis turns all statements into a Query tree (via transformStmt)
88 * for further processing by the rewriter and planner.
90 * Utility statements (i.e. non-optimizable statements) have the
91 * utilityStmt field set, and the Query itself is mostly dummy.
92 * DECLARE CURSOR is a special case: it is represented like a SELECT,
93 * but the original DeclareCursorStmt is stored in utilityStmt.
95 * Planning converts a Query tree into a Plan tree headed by a PlannedStmt
96 * node --- the Query structure is not used by the executor.
102 CmdType commandType
; /* select|insert|update|delete|utility */
104 QuerySource querySource
; /* where did I come from? */
106 bool canSetTag
; /* do I set the command result tag? */
108 Node
*utilityStmt
; /* non-null if this is DECLARE CURSOR or a
109 * non-optimizable statement */
111 int resultRelation
; /* rtable index of target relation for
112 * INSERT/UPDATE/DELETE; 0 for SELECT */
114 IntoClause
*intoClause
; /* target for SELECT INTO / CREATE TABLE AS */
116 bool hasAggs
; /* has aggregates in tlist or havingQual */
117 bool hasWindowFuncs
; /* has window functions in tlist */
118 bool hasSubLinks
; /* has subquery SubLink */
119 bool hasDistinctOn
; /* distinctClause is from DISTINCT ON */
120 bool hasRecursive
; /* WITH RECURSIVE was specified */
122 List
*cteList
; /* WITH list (of CommonTableExpr's) */
124 List
*rtable
; /* list of range table entries */
125 FromExpr
*jointree
; /* table join tree (FROM and WHERE clauses) */
127 List
*targetList
; /* target list (of TargetEntry) */
129 List
*returningList
; /* return-values list (of TargetEntry) */
131 List
*groupClause
; /* a list of SortGroupClause's */
133 Node
*havingQual
; /* qualifications applied to groups */
135 List
*windowClause
; /* a list of WindowClause's */
137 List
*distinctClause
; /* a list of SortGroupClause's */
139 List
*sortClause
; /* a list of SortGroupClause's */
141 Node
*limitOffset
; /* # of result tuples to skip (int8 expr) */
142 Node
*limitCount
; /* # of result tuples to return (int8 expr) */
144 List
*rowMarks
; /* a list of RowMarkClause's */
146 Node
*setOperations
; /* set-operation tree if this is top level of
147 * a UNION/INTERSECT/EXCEPT query */
151 /****************************************************************************
152 * Supporting data structures for Parse Trees
154 * Most of these node types appear in raw parsetrees output by the grammar,
155 * and get transformed to something else by the analyzer. A few of them
156 * are used as-is in transformed querytrees.
157 ****************************************************************************/
160 * TypeName - specifies a type in definitions
162 * For TypeName structures generated internally, it is often easier to
163 * specify the type by OID than by name. If "names" is NIL then the
164 * actual type OID is given by typeid, otherwise typeid is unused.
165 * Similarly, if "typmods" is NIL then the actual typmod is expected to
166 * be prespecified in typemod, otherwise typemod is unused.
168 * If pct_type is TRUE, then names is actually a field name and we look up
169 * the type of that field. Otherwise (the normal case), names is a type
170 * name possibly qualified with schema and database name.
172 typedef struct TypeName
175 List
*names
; /* qualified name (list of Value strings) */
176 Oid
typeid; /* type identified by OID */
177 bool setof
; /* is a set? */
178 bool pct_type
; /* %TYPE specified? */
179 List
*typmods
; /* type modifier expression(s) */
180 int32 typemod
; /* prespecified type modifier */
181 List
*arrayBounds
; /* array bounds */
182 int location
; /* token location, or -1 if unknown */
186 * ColumnRef - specifies a reference to a column, or possibly a whole tuple
188 * The "fields" list must be nonempty. It can contain string Value nodes
189 * (representing names) and A_Star nodes (representing occurrence of a '*').
190 * Currently, A_Star must appear only as the last list element --- the grammar
191 * is responsible for enforcing this!
193 * Note: any array subscripting or selection of fields from composite columns
194 * is represented by an A_Indirection node above the ColumnRef. However,
195 * for simplicity in the normal case, initial field selection from a table
196 * name is represented within ColumnRef and not by adding A_Indirection.
198 typedef struct ColumnRef
201 List
*fields
; /* field names (Value strings) or A_Star */
202 int location
; /* token location, or -1 if unknown */
206 * ParamRef - specifies a $n parameter reference
208 typedef struct ParamRef
211 int number
; /* the number of the parameter */
212 int location
; /* token location, or -1 if unknown */
216 * A_Expr - infix, prefix, and postfix expressions
218 typedef enum A_Expr_Kind
220 AEXPR_OP
, /* normal operator */
221 AEXPR_AND
, /* booleans - name field is unused */
224 AEXPR_OP_ANY
, /* scalar op ANY (array) */
225 AEXPR_OP_ALL
, /* scalar op ALL (array) */
226 AEXPR_DISTINCT
, /* IS DISTINCT FROM - name must be "=" */
227 AEXPR_NULLIF
, /* NULLIF - name must be "=" */
228 AEXPR_OF
, /* IS [NOT] OF - name must be "=" or "<>" */
229 AEXPR_IN
/* [NOT] IN - name must be "=" or "<>" */
232 typedef struct A_Expr
235 A_Expr_Kind kind
; /* see above */
236 List
*name
; /* possibly-qualified name of operator */
237 Node
*lexpr
; /* left argument, or NULL if none */
238 Node
*rexpr
; /* right argument, or NULL if none */
239 int location
; /* token location, or -1 if unknown */
243 * A_Const - a literal constant
245 typedef struct A_Const
248 Value val
; /* value (includes type info, see value.h) */
249 int location
; /* token location, or -1 if unknown */
253 * TypeCast - a CAST expression
255 typedef struct TypeCast
258 Node
*arg
; /* the expression being casted */
259 TypeName
*typename
; /* the target type */
260 int location
; /* token location, or -1 if unknown */
264 * FuncCall - a function or aggregate invocation
266 * agg_star indicates we saw a 'foo(*)' construct, while agg_distinct
267 * indicates we saw 'foo(DISTINCT ...)'. In either case, the construct
268 * *must* be an aggregate call. Otherwise, it might be either an
269 * aggregate or some other kind of function. However, if OVER is present
270 * it had better be an aggregate or window function.
272 typedef struct FuncCall
275 List
*funcname
; /* qualified name of function */
276 List
*args
; /* the arguments (list of exprs) */
277 bool agg_star
; /* argument was really '*' */
278 bool agg_distinct
; /* arguments were labeled DISTINCT */
279 bool func_variadic
; /* last argument was labeled VARIADIC */
280 struct WindowDef
*over
; /* OVER clause, if any */
281 int location
; /* token location, or -1 if unknown */
285 * A_Star - '*' representing all columns of a table or compound field
287 * This can appear within ColumnRef.fields, A_Indirection.indirection, and
288 * ResTarget.indirection lists.
290 typedef struct A_Star
296 * A_Indices - array subscript or slice bounds ([lidx:uidx] or [uidx])
298 typedef struct A_Indices
301 Node
*lidx
; /* NULL if it's a single subscript */
306 * A_Indirection - select a field and/or array element from an expression
308 * The indirection list can contain A_Indices nodes (representing
309 * subscripting), string Value nodes (representing field selection --- the
310 * string value is the name of the field to select), and A_Star nodes
311 * (representing selection of all fields of a composite type).
312 * For example, a complex selection operation like
313 * (foo).field1[42][7].field2
314 * would be represented with a single A_Indirection node having a 4-element
317 * Currently, A_Star must appear only as the last list element --- the grammar
318 * is responsible for enforcing this!
320 typedef struct A_Indirection
323 Node
*arg
; /* the thing being selected from */
324 List
*indirection
; /* subscripts and/or field names and/or * */
328 * A_ArrayExpr - an ARRAY[] construct
330 typedef struct A_ArrayExpr
333 List
*elements
; /* array element expressions */
334 int location
; /* token location, or -1 if unknown */
339 * result target (used in target list of pre-transformed parse trees)
341 * In a SELECT target list, 'name' is the column label from an
342 * 'AS ColumnLabel' clause, or NULL if there was none, and 'val' is the
343 * value expression itself. The 'indirection' field is not used.
345 * INSERT uses ResTarget in its target-column-names list. Here, 'name' is
346 * the name of the destination column, 'indirection' stores any subscripts
347 * attached to the destination, and 'val' is not used.
349 * In an UPDATE target list, 'name' is the name of the destination column,
350 * 'indirection' stores any subscripts attached to the destination, and
351 * 'val' is the expression to assign.
353 * See A_Indirection for more info about what can appear in 'indirection'.
355 typedef struct ResTarget
358 char *name
; /* column name or NULL */
359 List
*indirection
; /* subscripts, field names, and '*', or NIL */
360 Node
*val
; /* the value expression to compute or assign */
361 int location
; /* token location, or -1 if unknown */
365 * SortBy - for ORDER BY clause
367 typedef struct SortBy
370 Node
*node
; /* expression to sort on */
371 SortByDir sortby_dir
; /* ASC/DESC/USING/default */
372 SortByNulls sortby_nulls
; /* NULLS FIRST/LAST */
373 List
*useOp
; /* name of op to use, if SORTBY_USING */
374 int location
; /* operator location, or -1 if none/unknown */
378 * WindowDef - raw representation of WINDOW and OVER clauses
380 * For entries in a WINDOW list, "name" is the window name being defined.
381 * For OVER clauses, we use "name" for the "OVER window" syntax, or "refname"
382 * for the "OVER (window)" syntax, which is subtly different --- the latter
383 * implies overriding the window frame clause.
385 typedef struct WindowDef
388 char *name
; /* window's own name */
389 char *refname
; /* referenced window name, if any */
390 List
*partitionClause
; /* PARTITION BY expression list */
391 List
*orderClause
; /* ORDER BY (list of SortBy) */
392 int frameOptions
; /* frame_clause options, see below */
393 int location
; /* parse location, or -1 if none/unknown */
397 * frameOptions is an OR of these bits. The NONDEFAULT and BETWEEN bits are
398 * used so that ruleutils.c can tell which properties were specified and
399 * which were defaulted; the correct behavioral bits must be set either way.
400 * The START_foo and END_foo options must come in pairs of adjacent bits for
401 * the convenience of gram.y, even though some of them are useless/invalid.
402 * We will need more bits (and fields) to cover the full SQL:2008 option set.
404 #define FRAMEOPTION_NONDEFAULT 0x00001 /* any specified? */
405 #define FRAMEOPTION_RANGE 0x00002 /* RANGE behavior */
406 #define FRAMEOPTION_ROWS 0x00004 /* ROWS behavior */
407 #define FRAMEOPTION_BETWEEN 0x00008 /* BETWEEN given? */
408 #define FRAMEOPTION_START_UNBOUNDED_PRECEDING 0x00010 /* start is U. P. */
409 #define FRAMEOPTION_END_UNBOUNDED_PRECEDING 0x00020 /* (disallowed) */
410 #define FRAMEOPTION_START_UNBOUNDED_FOLLOWING 0x00040 /* (disallowed) */
411 #define FRAMEOPTION_END_UNBOUNDED_FOLLOWING 0x00080 /* end is U. F. */
412 #define FRAMEOPTION_START_CURRENT_ROW 0x00100 /* start is C. R. */
413 #define FRAMEOPTION_END_CURRENT_ROW 0x00200 /* end is C. R. */
415 #define FRAMEOPTION_DEFAULTS \
416 (FRAMEOPTION_RANGE | FRAMEOPTION_START_UNBOUNDED_PRECEDING | \
417 FRAMEOPTION_END_CURRENT_ROW)
420 * RangeSubselect - subquery appearing in a FROM clause
422 typedef struct RangeSubselect
425 Node
*subquery
; /* the untransformed sub-select clause */
426 Alias
*alias
; /* table alias & optional column aliases */
430 * RangeFunction - function call appearing in a FROM clause
432 typedef struct RangeFunction
435 Node
*funccallnode
; /* untransformed function call tree */
436 Alias
*alias
; /* table alias & optional column aliases */
437 List
*coldeflist
; /* list of ColumnDef nodes to describe result
438 * of function returning RECORD */
442 * ColumnDef - column definition (used in various creates)
444 * If the column has a default value, we may have the value expression
445 * in either "raw" form (an untransformed parse tree) or "cooked" form
446 * (the nodeToString representation of an executable expression tree),
447 * depending on how this ColumnDef node was created (by parsing, or by
448 * inheritance from an existing relation). We should never have both
451 * The constraints list may contain a CONSTR_DEFAULT item in a raw
452 * parsetree produced by gram.y, but transformCreateStmt will remove
453 * the item and set raw_default instead. CONSTR_DEFAULT items
454 * should not appear in any subsequent processing.
456 typedef struct ColumnDef
459 char *colname
; /* name of column */
460 TypeName
*typename
; /* type of column */
461 int inhcount
; /* number of times column is inherited */
462 bool is_local
; /* column has local (non-inherited) def'n */
463 bool is_not_null
; /* NOT NULL constraint specified? */
464 Node
*raw_default
; /* default value (untransformed parse tree) */
465 char *cooked_default
; /* nodeToString representation */
466 List
*constraints
; /* other constraints on column */
470 * inhRelation - Relations a CREATE TABLE is to inherit attributes of
472 typedef struct InhRelation
476 List
*options
; /* integer List of CreateStmtLikeOption */
479 typedef enum CreateStmtLikeOption
481 CREATE_TABLE_LIKE_INCLUDING_DEFAULTS
,
482 CREATE_TABLE_LIKE_EXCLUDING_DEFAULTS
,
483 CREATE_TABLE_LIKE_INCLUDING_CONSTRAINTS
,
484 CREATE_TABLE_LIKE_EXCLUDING_CONSTRAINTS
,
485 CREATE_TABLE_LIKE_INCLUDING_INDEXES
,
486 CREATE_TABLE_LIKE_EXCLUDING_INDEXES
487 } CreateStmtLikeOption
;
490 * IndexElem - index parameters (used in CREATE INDEX)
492 * For a plain index attribute, 'name' is the name of the table column to
493 * index, and 'expr' is NULL. For an index expression, 'name' is NULL and
494 * 'expr' is the expression tree.
496 typedef struct IndexElem
499 char *name
; /* name of attribute to index, or NULL */
500 Node
*expr
; /* expression to index, or NULL */
501 List
*opclass
; /* name of desired opclass; NIL = default */
502 SortByDir ordering
; /* ASC/DESC/default */
503 SortByNulls nulls_ordering
; /* FIRST/LAST/default */
507 * DefElem - a generic "name = value" option definition
509 * In some contexts the name can be qualified. Also, certain SQL commands
510 * allow a SET/ADD/DROP action to be attached to option settings, so it's
511 * convenient to carry a field for that too. (Note: currently, it is our
512 * practice that the grammar allows namespace and action only in statements
513 * where they are relevant; C code can just ignore those fields in other
516 typedef enum DefElemAction
518 DEFELEM_UNSPEC
, /* no action given */
524 typedef struct DefElem
527 char *defnamespace
; /* NULL if unqualified name */
529 Node
*arg
; /* a (Value *) or a (TypeName *) */
530 DefElemAction defaction
; /* unspecified action, or SET/ADD/DROP */
534 * LockingClause - raw representation of FOR UPDATE/SHARE options
536 * Note: lockedRels == NIL means "all relations in query". Otherwise it
537 * is a list of RangeVar nodes. (We use RangeVar mainly because it carries
538 * a location field --- currently, parse analysis insists on unqualified
539 * names in LockingClause.)
541 typedef struct LockingClause
544 List
*lockedRels
; /* FOR UPDATE or FOR SHARE relations */
545 bool forUpdate
; /* true = FOR UPDATE, false = FOR SHARE */
546 bool noWait
; /* NOWAIT option */
550 * XMLSERIALIZE (in raw parse tree only)
552 typedef struct XmlSerialize
555 XmlOptionType xmloption
; /* DOCUMENT or CONTENT */
558 int location
; /* token location, or -1 if unknown */
562 /****************************************************************************
563 * Nodes for a Query tree
564 ****************************************************************************/
566 /*--------------------
568 * A range table is a List of RangeTblEntry nodes.
570 * A range table entry may represent a plain relation, a sub-select in
571 * FROM, or the result of a JOIN clause. (Only explicit JOIN syntax
572 * produces an RTE, not the implicit join resulting from multiple FROM
573 * items. This is because we only need the RTE to deal with SQL features
574 * like outer joins and join-output-column aliasing.) Other special
575 * RTE types also exist, as indicated by RTEKind.
577 * alias is an Alias node representing the AS alias-clause attached to the
578 * FROM expression, or NULL if no clause.
580 * eref is the table reference name and column reference names (either
581 * real or aliases). Note that system columns (OID etc) are not included
582 * in the column list.
583 * eref->aliasname is required to be present, and should generally be used
584 * to identify the RTE for error messages etc.
586 * In RELATION RTEs, the colnames in both alias and eref are indexed by
587 * physical attribute number; this means there must be colname entries for
588 * dropped columns. When building an RTE we insert empty strings ("") for
589 * dropped columns. Note however that a stored rule may have nonempty
590 * colnames for columns dropped since the rule was created (and for that
591 * matter the colnames might be out of date due to column renamings).
592 * The same comments apply to FUNCTION RTEs when the function's return type
593 * is a named composite type.
595 * In JOIN RTEs, the colnames in both alias and eref are one-to-one with
596 * joinaliasvars entries. A JOIN RTE will omit columns of its inputs when
597 * those columns are known to be dropped at parse time. Again, however,
598 * a stored rule might contain entries for columns dropped since the rule
599 * was created. (This is only possible for columns not actually referenced
600 * in the rule.) When loading a stored rule, we replace the joinaliasvars
601 * items for any such columns with NULL Consts. (We can't simply delete
602 * them from the joinaliasvars list, because that would affect the attnums
603 * of Vars referencing the rest of the list.)
605 * inh is TRUE for relation references that should be expanded to include
606 * inheritance children, if the rel has any. This *must* be FALSE for
607 * RTEs other than RTE_RELATION entries.
609 * inFromCl marks those range variables that are listed in the FROM clause.
610 * It's false for RTEs that are added to a query behind the scenes, such
611 * as the NEW and OLD variables for a rule, or the subqueries of a UNION.
612 * This flag is not used anymore during parsing, since the parser now uses
613 * a separate "namespace" data structure to control visibility, but it is
614 * needed by ruleutils.c to determine whether RTEs should be shown in
615 * decompiled queries.
617 * requiredPerms and checkAsUser specify run-time access permissions
618 * checks to be performed at query startup. The user must have *all*
619 * of the permissions that are OR'd together in requiredPerms (zero
620 * indicates no permissions checking). If checkAsUser is not zero,
621 * then do the permissions checks using the access rights of that user,
622 * not the current effective user ID. (This allows rules to act as
625 * For SELECT/INSERT/UPDATE permissions, if the user doesn't have
626 * table-wide permissions then it is sufficient to have the permissions
627 * on all columns identified in selectedCols (for SELECT) and/or
628 * modifiedCols (for INSERT/UPDATE; we can tell which from the query type).
629 * selectedCols and modifiedCols are bitmapsets, which cannot have negative
630 * integer members, so we subtract FirstLowInvalidHeapAttributeNumber from
631 * column numbers before storing them in these fields. A whole-row Var
632 * reference is represented by setting the bit for InvalidAttrNumber.
633 *--------------------
637 RTE_RELATION
, /* ordinary relation reference */
638 RTE_SUBQUERY
, /* subquery in FROM */
640 RTE_SPECIAL
, /* special rule relation (NEW or OLD) */
641 RTE_FUNCTION
, /* function in FROM */
642 RTE_VALUES
, /* VALUES (<exprlist>), (<exprlist>), ... */
643 RTE_CTE
/* common table expr (WITH list element) */
646 typedef struct RangeTblEntry
650 RTEKind rtekind
; /* see above */
653 * XXX the fields applicable to only some rte kinds should be merged into
654 * a union. I didn't do this yet because the diffs would impact a lot of
655 * code that is being actively worked on. FIXME someday.
659 * Fields valid for a plain relation RTE (else zero):
661 Oid relid
; /* OID of the relation */
664 * Fields valid for a subquery RTE (else NULL):
666 Query
*subquery
; /* the sub-query */
669 * Fields valid for a join RTE (else NULL/zero):
671 * joinaliasvars is a list of Vars or COALESCE expressions corresponding
672 * to the columns of the join result. An alias Var referencing column K
673 * of the join result can be replaced by the K'th element of joinaliasvars
674 * --- but to simplify the task of reverse-listing aliases correctly, we
675 * do not do that until planning time. In a Query loaded from a stored
676 * rule, it is also possible for joinaliasvars items to be NULL Consts,
677 * denoting columns dropped since the rule was made.
679 JoinType jointype
; /* type of join */
680 List
*joinaliasvars
; /* list of alias-var expansions */
683 * Fields valid for a function RTE (else NULL):
685 * If the function returns RECORD, funccoltypes lists the column types
686 * declared in the RTE's column type specification, and funccoltypmods
687 * lists their declared typmods. Otherwise, both fields are NIL.
689 Node
*funcexpr
; /* expression tree for func call */
690 List
*funccoltypes
; /* OID list of column type OIDs */
691 List
*funccoltypmods
; /* integer list of column typmods */
694 * Fields valid for a values RTE (else NIL):
696 List
*values_lists
; /* list of expression lists */
699 * Fields valid for a CTE RTE (else NULL/zero):
701 char *ctename
; /* name of the WITH list item */
702 Index ctelevelsup
; /* number of query levels up */
703 bool self_reference
; /* is this a recursive self-reference? */
704 List
*ctecoltypes
; /* OID list of column type OIDs */
705 List
*ctecoltypmods
; /* integer list of column typmods */
708 * Fields valid in all RTEs:
710 Alias
*alias
; /* user-written alias clause, if any */
711 Alias
*eref
; /* expanded reference names */
712 bool inh
; /* inheritance requested? */
713 bool inFromCl
; /* present in FROM clause? */
714 AclMode requiredPerms
; /* bitmask of required access permissions */
715 Oid checkAsUser
; /* if valid, check access as this role */
716 Bitmapset
*selectedCols
; /* columns needing SELECT permission */
717 Bitmapset
*modifiedCols
; /* columns needing INSERT/UPDATE permission */
722 * representation of ORDER BY, GROUP BY, PARTITION BY,
723 * DISTINCT, DISTINCT ON items
725 * You might think that ORDER BY is only interested in defining ordering,
726 * and GROUP/DISTINCT are only interested in defining equality. However,
727 * one way to implement grouping is to sort and then apply a "uniq"-like
728 * filter. So it's also interesting to keep track of possible sort operators
729 * for GROUP/DISTINCT, and in particular to try to sort for the grouping
730 * in a way that will also yield a requested ORDER BY ordering. So we need
731 * to be able to compare ORDER BY and GROUP/DISTINCT lists, which motivates
732 * the decision to give them the same representation.
734 * tleSortGroupRef must match ressortgroupref of exactly one entry of the
735 * query's targetlist; that is the expression to be sorted or grouped by.
736 * eqop is the OID of the equality operator.
737 * sortop is the OID of the ordering operator (a "<" or ">" operator),
738 * or InvalidOid if not available.
739 * nulls_first means about what you'd expect. If sortop is InvalidOid
740 * then nulls_first is meaningless and should be set to false.
742 * In an ORDER BY item, all fields must be valid. (The eqop isn't essential
743 * here, but it's cheap to get it along with the sortop, and requiring it
744 * to be valid eases comparisons to grouping items.)
746 * In a grouping item, eqop must be valid. If the eqop is a btree equality
747 * operator, then sortop should be set to a compatible ordering operator.
748 * We prefer to set eqop/sortop/nulls_first to match any ORDER BY item that
749 * the query presents for the same tlist item. If there is none, we just
750 * use the default ordering op for the datatype.
752 * If the tlist item's type has a hash opclass but no btree opclass, then
753 * we will set eqop to the hash equality operator, sortop to InvalidOid,
754 * and nulls_first to false. A grouping item of this kind can only be
755 * implemented by hashing, and of course it'll never match an ORDER BY item.
757 * A query might have both ORDER BY and DISTINCT (or DISTINCT ON) clauses.
758 * In SELECT DISTINCT, the distinctClause list is as long or longer than the
759 * sortClause list, while in SELECT DISTINCT ON it's typically shorter.
760 * The two lists must match up to the end of the shorter one --- the parser
761 * rearranges the distinctClause if necessary to make this true. (This
762 * restriction ensures that only one sort step is needed to both satisfy the
763 * ORDER BY and set up for the Unique step. This is semantically necessary
764 * for DISTINCT ON, and presents no real drawback for DISTINCT.)
766 typedef struct SortGroupClause
769 Index tleSortGroupRef
; /* reference into targetlist */
770 Oid eqop
; /* the equality operator ('=' op) */
771 Oid sortop
; /* the ordering operator ('<' op), or 0 */
772 bool nulls_first
; /* do NULLs come before normal values? */
777 * transformed representation of WINDOW and OVER clauses
779 * A parsed Query's windowClause list contains these structs. "name" is set
780 * if the clause originally came from WINDOW, and is NULL if it originally
781 * was an OVER clause (but note that we collapse out duplicate OVERs).
782 * partitionClause and orderClause are lists of SortGroupClause structs.
783 * winref is an ID number referenced by WindowFunc nodes; it must be unique
784 * among the members of a Query's windowClause list.
785 * When refname isn't null, the partitionClause is always copied from there;
786 * the orderClause might or might not be copied (see copiedOrder); the framing
787 * options are never copied, per spec.
789 typedef struct WindowClause
792 char *name
; /* window name (NULL in an OVER clause) */
793 char *refname
; /* referenced window name, if any */
794 List
*partitionClause
; /* PARTITION BY list */
795 List
*orderClause
; /* ORDER BY list */
796 int frameOptions
; /* frame_clause options, see WindowDef */
797 Index winref
; /* ID referenced by window functions */
798 bool copiedOrder
; /* did we copy orderClause from refname? */
803 * representation of FOR UPDATE/SHARE clauses
805 * We create a separate RowMarkClause node for each target relation. In the
806 * output of the parser and rewriter, all RowMarkClauses have rti == prti and
807 * isParent == false. When the planner discovers that a target relation
808 * is the root of an inheritance tree, it sets isParent true, and adds an
809 * additional RowMarkClause to the list for each child relation (including
810 * the target rel itself in its role as a child). The child entries have
811 * rti == child rel's RT index, prti == parent's RT index, and can therefore
812 * be recognized as children by the fact that prti != rti.
814 typedef struct RowMarkClause
817 Index rti
; /* range table index of target relation */
818 Index prti
; /* range table index of parent relation */
819 bool forUpdate
; /* true = FOR UPDATE, false = FOR SHARE */
820 bool noWait
; /* NOWAIT option */
821 bool isParent
; /* set by planner when expanding inheritance */
826 * representation of WITH clause
828 * Note: WithClause does not propagate into the Query representation;
829 * but CommonTableExpr does.
831 typedef struct WithClause
834 List
*ctes
; /* list of CommonTableExprs */
835 bool recursive
; /* true = WITH RECURSIVE */
836 int location
; /* token location, or -1 if unknown */
841 * representation of WITH list element
843 * We don't currently support the SEARCH or CYCLE clause.
845 typedef struct CommonTableExpr
848 char *ctename
; /* query name (never qualified) */
849 List
*aliascolnames
; /* optional list of column names */
850 Node
*ctequery
; /* subquery (SelectStmt or Query) */
851 int location
; /* token location, or -1 if unknown */
852 /* These fields are set during parse analysis: */
853 bool cterecursive
; /* is this CTE actually recursive? */
854 int cterefcount
; /* number of RTEs referencing this CTE
855 * (excluding internal self-references) */
856 List
*ctecolnames
; /* list of output column names */
857 List
*ctecoltypes
; /* OID list of output column type OIDs */
858 List
*ctecoltypmods
; /* integer list of output column typmods */
861 /*****************************************************************************
862 * Optimizable Statements
863 *****************************************************************************/
865 /* ----------------------
868 * The source expression is represented by SelectStmt for both the
869 * SELECT and VALUES cases. If selectStmt is NULL, then the query
870 * is INSERT ... DEFAULT VALUES.
871 * ----------------------
873 typedef struct InsertStmt
876 RangeVar
*relation
; /* relation to insert into */
877 List
*cols
; /* optional: names of the target columns */
878 Node
*selectStmt
; /* the source SELECT/VALUES, or NULL */
879 List
*returningList
; /* list of expressions to return */
882 /* ----------------------
884 * ----------------------
886 typedef struct DeleteStmt
889 RangeVar
*relation
; /* relation to delete from */
890 List
*usingClause
; /* optional using clause for more tables */
891 Node
*whereClause
; /* qualifications */
892 List
*returningList
; /* list of expressions to return */
895 /* ----------------------
897 * ----------------------
899 typedef struct UpdateStmt
902 RangeVar
*relation
; /* relation to update */
903 List
*targetList
; /* the target list (of ResTarget) */
904 Node
*whereClause
; /* qualifications */
905 List
*fromClause
; /* optional from clause for more tables */
906 List
*returningList
; /* list of expressions to return */
909 /* ----------------------
912 * A "simple" SELECT is represented in the output of gram.y by a single
913 * SelectStmt node; so is a VALUES construct. A query containing set
914 * operators (UNION, INTERSECT, EXCEPT) is represented by a tree of SelectStmt
915 * nodes, in which the leaf nodes are component SELECTs and the internal nodes
916 * represent UNION, INTERSECT, or EXCEPT operators. Using the same node
917 * type for both leaf and internal nodes allows gram.y to stick ORDER BY,
918 * LIMIT, etc, clause values into a SELECT statement without worrying
919 * whether it is a simple or compound SELECT.
920 * ----------------------
922 typedef enum SetOperation
930 typedef struct SelectStmt
935 * These fields are used only in "leaf" SelectStmts.
937 List
*distinctClause
; /* NULL, list of DISTINCT ON exprs, or
938 * lcons(NIL,NIL) for all (SELECT DISTINCT) */
939 IntoClause
*intoClause
; /* target for SELECT INTO / CREATE TABLE AS */
940 List
*targetList
; /* the target list (of ResTarget) */
941 List
*fromClause
; /* the FROM clause */
942 Node
*whereClause
; /* WHERE qualification */
943 List
*groupClause
; /* GROUP BY clauses */
944 Node
*havingClause
; /* HAVING conditional-expression */
945 List
*windowClause
; /* WINDOW window_name AS (...), ... */
946 WithClause
*withClause
; /* WITH clause */
949 * In a "leaf" node representing a VALUES list, the above fields are all
950 * null, and instead this field is set. Note that the elements of the
951 * sublists are just expressions, without ResTarget decoration. Also note
952 * that a list element can be DEFAULT (represented as a SetToDefault
953 * node), regardless of the context of the VALUES list. It's up to parse
954 * analysis to reject that where not valid.
956 List
*valuesLists
; /* untransformed list of expression lists */
959 * These fields are used in both "leaf" SelectStmts and upper-level
962 List
*sortClause
; /* sort clause (a list of SortBy's) */
963 Node
*limitOffset
; /* # of result tuples to skip */
964 Node
*limitCount
; /* # of result tuples to return */
965 List
*lockingClause
; /* FOR UPDATE (list of LockingClause's) */
968 * These fields are used only in upper-level SelectStmts.
970 SetOperation op
; /* type of set op */
971 bool all
; /* ALL specified? */
972 struct SelectStmt
*larg
; /* left child */
973 struct SelectStmt
*rarg
; /* right child */
974 /* Eventually add fields for CORRESPONDING spec here */
978 /* ----------------------
979 * Set Operation node for post-analysis query trees
981 * After parse analysis, a SELECT with set operations is represented by a
982 * top-level Query node containing the leaf SELECTs as subqueries in its
983 * range table. Its setOperations field shows the tree of set operations,
984 * with leaf SelectStmt nodes replaced by RangeTblRef nodes, and internal
985 * nodes replaced by SetOperationStmt nodes. Information about the output
986 * column types is added, too. (Note that the child nodes do not necessarily
987 * produce these types directly, but we've checked that their output types
988 * can be coerced to the output column type.) Also, if it's not UNION ALL,
989 * information about the types' sort/group semantics is provided in the form
990 * of a SortGroupClause list (same representation as, eg, DISTINCT).
991 * ----------------------
993 typedef struct SetOperationStmt
996 SetOperation op
; /* type of set op */
997 bool all
; /* ALL specified? */
998 Node
*larg
; /* left child */
999 Node
*rarg
; /* right child */
1000 /* Eventually add fields for CORRESPONDING spec here */
1002 /* Fields derived during parse analysis: */
1003 List
*colTypes
; /* OID list of output column type OIDs */
1004 List
*colTypmods
; /* integer list of output column typmods */
1005 List
*groupClauses
; /* a list of SortGroupClause's */
1006 /* groupClauses is NIL if UNION ALL, but must be set otherwise */
1010 /*****************************************************************************
1011 * Other Statements (no optimizations required)
1013 * These are not touched by parser/analyze.c except to put them into
1014 * the utilityStmt field of a Query. This is eventually passed to
1015 * ProcessUtility (by-passing rewriting and planning). Some of the
1016 * statements do need attention from parse analysis, and this is
1017 * done by routines in parser/parse_utilcmd.c after ProcessUtility
1018 * receives the command for execution.
1019 *****************************************************************************/
1022 * When a command can act on several kinds of objects with only one
1023 * parse structure required, use these constants to designate the
1027 typedef enum ObjectType
1037 OBJECT_FOREIGN_SERVER
,
1052 OBJECT_TSCONFIGURATION
,
1053 OBJECT_TSDICTIONARY
,
1060 /* ----------------------
1061 * Create Schema Statement
1063 * NOTE: the schemaElts list contains raw parsetrees for component statements
1064 * of the schema, such as CREATE TABLE, GRANT, etc. These are analyzed and
1065 * executed after the schema itself is created.
1066 * ----------------------
1068 typedef struct CreateSchemaStmt
1071 char *schemaname
; /* the name of the schema to create */
1072 char *authid
; /* the owner of the created schema */
1073 List
*schemaElts
; /* schema components (list of parsenodes) */
1076 typedef enum DropBehavior
1078 DROP_RESTRICT
, /* drop fails if any dependent objects */
1079 DROP_CASCADE
/* remove dependent objects too */
1082 /* ----------------------
1084 * ----------------------
1086 typedef struct AlterTableStmt
1089 RangeVar
*relation
; /* table to work on */
1090 List
*cmds
; /* list of subcommands */
1091 ObjectType relkind
; /* type of object */
1094 typedef enum AlterTableType
1096 AT_AddColumn
, /* add column */
1097 AT_AddColumnToView
, /* implicitly via CREATE OR REPLACE VIEW */
1098 AT_ColumnDefault
, /* alter column default */
1099 AT_DropNotNull
, /* alter column drop not null */
1100 AT_SetNotNull
, /* alter column set not null */
1101 AT_SetStatistics
, /* alter column statistics */
1102 AT_SetStorage
, /* alter column storage */
1103 AT_DropColumn
, /* drop column */
1104 AT_DropColumnRecurse
, /* internal to commands/tablecmds.c */
1105 AT_AddIndex
, /* add index */
1106 AT_ReAddIndex
, /* internal to commands/tablecmds.c */
1107 AT_AddConstraint
, /* add constraint */
1108 AT_AddConstraintRecurse
, /* internal to commands/tablecmds.c */
1109 AT_ProcessedConstraint
, /* pre-processed add constraint (local in
1110 * parser/parse_utilcmd.c) */
1111 AT_DropConstraint
, /* drop constraint */
1112 AT_DropConstraintRecurse
, /* internal to commands/tablecmds.c */
1113 AT_AlterColumnType
, /* alter column type */
1114 AT_ChangeOwner
, /* change owner */
1115 AT_ClusterOn
, /* CLUSTER ON */
1116 AT_DropCluster
, /* SET WITHOUT CLUSTER */
1117 AT_AddOids
, /* SET WITH OIDS */
1118 AT_DropOids
, /* SET WITHOUT OIDS */
1119 AT_SetTableSpace
, /* SET TABLESPACE */
1120 AT_SetRelOptions
, /* SET (...) -- AM specific parameters */
1121 AT_ResetRelOptions
, /* RESET (...) -- AM specific parameters */
1122 AT_EnableTrig
, /* ENABLE TRIGGER name */
1123 AT_EnableAlwaysTrig
, /* ENABLE ALWAYS TRIGGER name */
1124 AT_EnableReplicaTrig
, /* ENABLE REPLICA TRIGGER name */
1125 AT_DisableTrig
, /* DISABLE TRIGGER name */
1126 AT_EnableTrigAll
, /* ENABLE TRIGGER ALL */
1127 AT_DisableTrigAll
, /* DISABLE TRIGGER ALL */
1128 AT_EnableTrigUser
, /* ENABLE TRIGGER USER */
1129 AT_DisableTrigUser
, /* DISABLE TRIGGER USER */
1130 AT_EnableRule
, /* ENABLE RULE name */
1131 AT_EnableAlwaysRule
, /* ENABLE ALWAYS RULE name */
1132 AT_EnableReplicaRule
, /* ENABLE REPLICA RULE name */
1133 AT_DisableRule
, /* DISABLE RULE name */
1134 AT_AddInherit
, /* INHERIT parent */
1135 AT_DropInherit
/* NO INHERIT parent */
1138 typedef struct AlterTableCmd
/* one subcommand of an ALTER TABLE */
1141 AlterTableType subtype
; /* Type of table alteration to apply */
1142 char *name
; /* column, constraint, or trigger to act on,
1143 * or new owner or tablespace */
1144 Node
*def
; /* definition of new column, column type,
1145 * index, constraint, or parent table */
1146 Node
*transform
; /* transformation expr for ALTER TYPE */
1147 DropBehavior behavior
; /* RESTRICT or CASCADE for DROP cases */
1151 /* ----------------------
1154 * The fields are used in different ways by the different variants of
1156 * ----------------------
1158 typedef struct AlterDomainStmt
1161 char subtype
; /*------------
1162 * T = alter column default
1163 * N = alter column drop not null
1164 * O = alter column set not null
1165 * C = add constraint
1166 * X = drop constraint
1169 List
*typename
; /* domain to work on */
1170 char *name
; /* column or constraint name to act on */
1171 Node
*def
; /* definition of default or constraint */
1172 DropBehavior behavior
; /* RESTRICT or CASCADE for DROP cases */
1176 /* ----------------------
1177 * Grant|Revoke Statement
1178 * ----------------------
1180 typedef enum GrantObjectType
1182 ACL_OBJECT_COLUMN
, /* column */
1183 ACL_OBJECT_RELATION
, /* table, view */
1184 ACL_OBJECT_SEQUENCE
, /* sequence */
1185 ACL_OBJECT_DATABASE
, /* database */
1186 ACL_OBJECT_FDW
, /* foreign-data wrapper */
1187 ACL_OBJECT_FOREIGN_SERVER
, /* foreign server */
1188 ACL_OBJECT_FUNCTION
, /* function */
1189 ACL_OBJECT_LANGUAGE
, /* procedural language */
1190 ACL_OBJECT_NAMESPACE
, /* namespace */
1191 ACL_OBJECT_TABLESPACE
/* tablespace */
1194 typedef struct GrantStmt
1197 bool is_grant
; /* true = GRANT, false = REVOKE */
1198 GrantObjectType objtype
; /* kind of object being operated on */
1199 List
*objects
; /* list of RangeVar nodes, FuncWithArgs nodes,
1200 * or plain names (as Value strings) */
1201 List
*privileges
; /* list of AccessPriv nodes */
1202 /* privileges == NIL denotes ALL PRIVILEGES */
1203 List
*grantees
; /* list of PrivGrantee nodes */
1204 bool grant_option
; /* grant or revoke grant option */
1205 DropBehavior behavior
; /* drop behavior (for REVOKE) */
1208 typedef struct PrivGrantee
1211 char *rolname
; /* if NULL then PUBLIC */
1215 * Note: FuncWithArgs carries only the types of the input parameters of the
1216 * function. So it is sufficient to identify an existing function, but it
1217 * is not enough info to define a function nor to call it.
1219 typedef struct FuncWithArgs
1222 List
*funcname
; /* qualified name of function */
1223 List
*funcargs
; /* list of Typename nodes */
1227 * An access privilege, with optional list of column names
1228 * priv_name == NULL denotes ALL PRIVILEGES (only used with a column list)
1229 * cols == NIL denotes "all columns"
1230 * Note that simple "ALL PRIVILEGES" is represented as a NIL list, not
1231 * an AccessPriv with both fields null.
1233 typedef struct AccessPriv
1236 char *priv_name
; /* string name of privilege */
1237 List
*cols
; /* list of Value strings */
1240 /* ----------------------
1241 * Grant/Revoke Role Statement
1243 * Note: because of the parsing ambiguity with the GRANT <privileges>
1244 * statement, granted_roles is a list of AccessPriv; the execution code
1245 * should complain if any column lists appear. grantee_roles is a list
1246 * of role names, as Value strings.
1247 * ----------------------
1249 typedef struct GrantRoleStmt
1252 List
*granted_roles
; /* list of roles to be granted/revoked */
1253 List
*grantee_roles
; /* list of member roles to add/delete */
1254 bool is_grant
; /* true = GRANT, false = REVOKE */
1255 bool admin_opt
; /* with admin option */
1256 char *grantor
; /* set grantor to other than current role */
1257 DropBehavior behavior
; /* drop behavior (for REVOKE) */
1260 /* ----------------------
1263 * We support "COPY relation FROM file", "COPY relation TO file", and
1264 * "COPY (query) TO file". In any given CopyStmt, exactly one of "relation"
1265 * and "query" must be non-NULL.
1266 * ----------------------
1268 typedef struct CopyStmt
1271 RangeVar
*relation
; /* the relation to copy */
1272 Node
*query
; /* the SELECT query to copy */
1273 List
*attlist
; /* List of column names (as Strings), or NIL
1274 * for all columns */
1275 bool is_from
; /* TO or FROM */
1276 char *filename
; /* filename, or NULL for STDIN/STDOUT */
1277 List
*options
; /* List of DefElem nodes */
1280 /* ----------------------
1281 * SET Statement (includes RESET)
1283 * "SET var TO DEFAULT" and "RESET var" are semantically equivalent, but we
1284 * preserve the distinction in VariableSetKind for CreateCommandTag().
1285 * ----------------------
1289 VAR_SET_VALUE
, /* SET var = value */
1290 VAR_SET_DEFAULT
, /* SET var TO DEFAULT */
1291 VAR_SET_CURRENT
, /* SET var FROM CURRENT */
1292 VAR_SET_MULTI
, /* special case for SET TRANSACTION ... */
1293 VAR_RESET
, /* RESET var */
1294 VAR_RESET_ALL
/* RESET ALL */
1297 typedef struct VariableSetStmt
1300 VariableSetKind kind
;
1301 char *name
; /* variable to be set */
1302 List
*args
; /* List of A_Const nodes */
1303 bool is_local
; /* SET LOCAL? */
1306 /* ----------------------
1308 * ----------------------
1310 typedef struct VariableShowStmt
1316 /* ----------------------
1317 * Create Table Statement
1319 * NOTE: in the raw gram.y output, ColumnDef, Constraint, and FkConstraint
1320 * nodes are intermixed in tableElts, and constraints is NIL. After parse
1321 * analysis, tableElts contains just ColumnDefs, and constraints contains
1322 * just Constraint nodes (in fact, only CONSTR_CHECK nodes, in the present
1324 * ----------------------
1327 typedef struct CreateStmt
1330 RangeVar
*relation
; /* relation to create */
1331 List
*tableElts
; /* column definitions (list of ColumnDef) */
1332 List
*inhRelations
; /* relations to inherit from (list of
1334 List
*constraints
; /* constraints (list of Constraint nodes) */
1335 List
*options
; /* options from WITH clause */
1336 OnCommitAction oncommit
; /* what do we do at COMMIT? */
1337 char *tablespacename
; /* table space to use, or NULL */
1341 * Definitions for plain (non-FOREIGN KEY) constraints in CreateStmt
1343 * XXX probably these ought to be unified with FkConstraints at some point?
1344 * To this end we include CONSTR_FOREIGN in the ConstrType enum, even though
1345 * the parser does not generate it.
1347 * For constraints that use expressions (CONSTR_DEFAULT, CONSTR_CHECK)
1348 * we may have the expression in either "raw" form (an untransformed
1349 * parse tree) or "cooked" form (the nodeToString representation of
1350 * an executable expression tree), depending on how this Constraint
1351 * node was created (by parsing, or by inheritance from an existing
1352 * relation). We should never have both in the same node!
1354 * Constraint attributes (DEFERRABLE etc) are initially represented as
1355 * separate Constraint nodes for simplicity of parsing. parse_utilcmd.c makes
1356 * a pass through the constraints list to attach the info to the appropriate
1357 * FkConstraint node (and, perhaps, someday to other kinds of constraints).
1361 typedef enum ConstrType
/* types of constraints */
1363 CONSTR_NULL
, /* not SQL92, but a lot of people expect it */
1370 CONSTR_ATTR_DEFERRABLE
, /* attributes for previous constraint node */
1371 CONSTR_ATTR_NOT_DEFERRABLE
,
1372 CONSTR_ATTR_DEFERRED
,
1373 CONSTR_ATTR_IMMEDIATE
1376 typedef struct Constraint
1380 char *name
; /* name, or NULL if unnamed */
1381 Node
*raw_expr
; /* expr, as untransformed parse tree */
1382 char *cooked_expr
; /* expr, as nodeToString representation */
1383 List
*keys
; /* String nodes naming referenced column(s) */
1384 List
*options
; /* options from WITH clause */
1385 char *indexspace
; /* index tablespace for PKEY/UNIQUE
1386 * constraints; NULL for default */
1390 * Definitions for FOREIGN KEY constraints in CreateStmt
1392 * Note: FKCONSTR_ACTION_xxx values are stored into pg_constraint.confupdtype
1393 * and pg_constraint.confdeltype columns; FKCONSTR_MATCH_xxx values are
1394 * stored into pg_constraint.confmatchtype. Changing the code values may
1395 * require an initdb!
1397 * If skip_validation is true then we skip checking that the existing rows
1398 * in the table satisfy the constraint, and just install the catalog entries
1399 * for the constraint. This is currently used only during CREATE TABLE
1400 * (when we know the table must be empty).
1403 #define FKCONSTR_ACTION_NOACTION 'a'
1404 #define FKCONSTR_ACTION_RESTRICT 'r'
1405 #define FKCONSTR_ACTION_CASCADE 'c'
1406 #define FKCONSTR_ACTION_SETNULL 'n'
1407 #define FKCONSTR_ACTION_SETDEFAULT 'd'
1409 #define FKCONSTR_MATCH_FULL 'f'
1410 #define FKCONSTR_MATCH_PARTIAL 'p'
1411 #define FKCONSTR_MATCH_UNSPECIFIED 'u'
1413 typedef struct FkConstraint
1416 char *constr_name
; /* Constraint name, or NULL if unnamed */
1417 RangeVar
*pktable
; /* Primary key table */
1418 List
*fk_attrs
; /* Attributes of foreign key */
1419 List
*pk_attrs
; /* Corresponding attrs in PK table */
1420 char fk_matchtype
; /* FULL, PARTIAL, UNSPECIFIED */
1421 char fk_upd_action
; /* ON UPDATE action */
1422 char fk_del_action
; /* ON DELETE action */
1423 bool deferrable
; /* DEFERRABLE */
1424 bool initdeferred
; /* INITIALLY DEFERRED */
1425 bool skip_validation
; /* skip validation of existing rows? */
1429 /* ----------------------
1430 * Create/Drop Table Space Statements
1431 * ----------------------
1434 typedef struct CreateTableSpaceStmt
1437 char *tablespacename
;
1440 } CreateTableSpaceStmt
;
1442 typedef struct DropTableSpaceStmt
1445 char *tablespacename
;
1446 bool missing_ok
; /* skip error if missing? */
1447 } DropTableSpaceStmt
;
1449 /* ----------------------
1450 * Create/Drop FOREIGN DATA WRAPPER Statements
1451 * ----------------------
1454 typedef struct CreateFdwStmt
1457 char *fdwname
; /* foreign-data wrapper name */
1458 List
*validator
; /* optional validator function (qual. name) */
1459 List
*options
; /* generic options to FDW */
1462 typedef struct AlterFdwStmt
1465 char *fdwname
; /* foreign-data wrapper name */
1466 List
*validator
; /* optional validator function (qual. name) */
1467 bool change_validator
;
1468 List
*options
; /* generic options to FDW */
1471 typedef struct DropFdwStmt
1474 char *fdwname
; /* foreign-data wrapper name */
1475 bool missing_ok
; /* don't complain if missing */
1476 DropBehavior behavior
; /* drop behavior - cascade/restrict */
1479 /* ----------------------
1480 * Create/Drop FOREIGN SERVER Statements
1481 * ----------------------
1484 typedef struct CreateForeignServerStmt
1487 char *servername
; /* server name */
1488 char *servertype
; /* optional server type */
1489 char *version
; /* optional server version */
1490 char *fdwname
; /* FDW name */
1491 List
*options
; /* generic options to server */
1492 } CreateForeignServerStmt
;
1494 typedef struct AlterForeignServerStmt
1497 char *servername
; /* server name */
1498 char *version
; /* optional server version */
1499 List
*options
; /* generic options to server */
1500 bool has_version
; /* version specified */
1501 } AlterForeignServerStmt
;
1503 typedef struct DropForeignServerStmt
1506 char *servername
; /* server name */
1507 bool missing_ok
; /* ignore missing servers */
1508 DropBehavior behavior
; /* drop behavior - cascade/restrict */
1509 } DropForeignServerStmt
;
1511 /* ----------------------
1512 * Create/Drop USER MAPPING Statements
1513 * ----------------------
1516 typedef struct CreateUserMappingStmt
1519 char *username
; /* username or PUBLIC/CURRENT_USER */
1520 char *servername
; /* server name */
1521 List
*options
; /* generic options to server */
1522 } CreateUserMappingStmt
;
1524 typedef struct AlterUserMappingStmt
1527 char *username
; /* username or PUBLIC/CURRENT_USER */
1528 char *servername
; /* server name */
1529 List
*options
; /* generic options to server */
1530 } AlterUserMappingStmt
;
1532 typedef struct DropUserMappingStmt
1535 char *username
; /* username or PUBLIC/CURRENT_USER */
1536 char *servername
; /* server name */
1537 bool missing_ok
; /* ignore missing mappings */
1538 } DropUserMappingStmt
;
1540 /* ----------------------
1541 * Create/Drop TRIGGER Statements
1542 * ----------------------
1545 typedef struct CreateTrigStmt
1548 char *trigname
; /* TRIGGER's name */
1549 RangeVar
*relation
; /* relation trigger is on */
1550 List
*funcname
; /* qual. name of function to call */
1551 List
*args
; /* list of (T_String) Values or NIL */
1552 bool before
; /* BEFORE/AFTER */
1553 bool row
; /* ROW/STATEMENT */
1554 /* events uses the TRIGGER_TYPE bits defined in catalog/pg_trigger.h */
1555 int16 events
; /* INSERT/UPDATE/DELETE/TRUNCATE */
1557 /* The following are used for referential */
1558 /* integrity constraint triggers */
1559 bool isconstraint
; /* This is an RI trigger */
1560 bool deferrable
; /* [NOT] DEFERRABLE */
1561 bool initdeferred
; /* INITIALLY {DEFERRED|IMMEDIATE} */
1562 RangeVar
*constrrel
; /* opposite relation */
1565 /* ----------------------
1566 * Create/Drop PROCEDURAL LANGUAGE Statement
1567 * ----------------------
1569 typedef struct CreatePLangStmt
1572 char *plname
; /* PL name */
1573 List
*plhandler
; /* PL call handler function (qual. name) */
1574 List
*plvalidator
; /* optional validator function (qual. name) */
1575 bool pltrusted
; /* PL is trusted */
1578 typedef struct DropPLangStmt
1581 char *plname
; /* PL name */
1582 DropBehavior behavior
; /* RESTRICT or CASCADE behavior */
1583 bool missing_ok
; /* skip error if missing? */
1586 /* ----------------------
1587 * Create/Alter/Drop Role Statements
1589 * Note: these node types are also used for the backwards-compatible
1590 * Create/Alter/Drop User/Group statements. In the ALTER and DROP cases
1591 * there's really no need to distinguish what the original spelling was,
1592 * but for CREATE we mark the type because the defaults vary.
1593 * ----------------------
1595 typedef enum RoleStmtType
1602 typedef struct CreateRoleStmt
1605 RoleStmtType stmt_type
; /* ROLE/USER/GROUP */
1606 char *role
; /* role name */
1607 List
*options
; /* List of DefElem nodes */
1610 typedef struct AlterRoleStmt
1613 char *role
; /* role name */
1614 List
*options
; /* List of DefElem nodes */
1615 int action
; /* +1 = add members, -1 = drop members */
1618 typedef struct AlterRoleSetStmt
1621 char *role
; /* role name */
1622 VariableSetStmt
*setstmt
; /* SET or RESET subcommand */
1625 typedef struct DropRoleStmt
1628 List
*roles
; /* List of roles to remove */
1629 bool missing_ok
; /* skip error if a role is missing? */
1632 /* ----------------------
1633 * {Create|Alter} SEQUENCE Statement
1634 * ----------------------
1637 typedef struct CreateSeqStmt
1640 RangeVar
*sequence
; /* the sequence to create */
1644 typedef struct AlterSeqStmt
1647 RangeVar
*sequence
; /* the sequence to alter */
1651 /* ----------------------
1652 * Create {Aggregate|Operator|Type} Statement
1653 * ----------------------
1655 typedef struct DefineStmt
1658 ObjectType kind
; /* aggregate, operator, type */
1659 bool oldstyle
; /* hack to signal old CREATE AGG syntax */
1660 List
*defnames
; /* qualified name (list of Value strings) */
1661 List
*args
; /* a list of TypeName (if needed) */
1662 List
*definition
; /* a list of DefElem */
1665 /* ----------------------
1666 * Create Domain Statement
1667 * ----------------------
1669 typedef struct CreateDomainStmt
1672 List
*domainname
; /* qualified name (list of Value strings) */
1673 TypeName
*typename
; /* the base type */
1674 List
*constraints
; /* constraints (list of Constraint nodes) */
1677 /* ----------------------
1678 * Create Operator Class Statement
1679 * ----------------------
1681 typedef struct CreateOpClassStmt
1684 List
*opclassname
; /* qualified name (list of Value strings) */
1685 List
*opfamilyname
; /* qualified name (ditto); NIL if omitted */
1686 char *amname
; /* name of index AM opclass is for */
1687 TypeName
*datatype
; /* datatype of indexed column */
1688 List
*items
; /* List of CreateOpClassItem nodes */
1689 bool isDefault
; /* Should be marked as default for type? */
1690 } CreateOpClassStmt
;
1692 #define OPCLASS_ITEM_OPERATOR 1
1693 #define OPCLASS_ITEM_FUNCTION 2
1694 #define OPCLASS_ITEM_STORAGETYPE 3
1696 typedef struct CreateOpClassItem
1699 int itemtype
; /* see codes above */
1700 /* fields used for an operator or function item: */
1701 List
*name
; /* operator or function name */
1702 List
*args
; /* argument types */
1703 int number
; /* strategy num or support proc num */
1704 List
*class_args
; /* only used for functions */
1705 /* fields used for a storagetype item: */
1706 TypeName
*storedtype
; /* datatype stored in index */
1707 } CreateOpClassItem
;
1709 /* ----------------------
1710 * Create Operator Family Statement
1711 * ----------------------
1713 typedef struct CreateOpFamilyStmt
1716 List
*opfamilyname
; /* qualified name (list of Value strings) */
1717 char *amname
; /* name of index AM opfamily is for */
1718 } CreateOpFamilyStmt
;
1720 /* ----------------------
1721 * Alter Operator Family Statement
1722 * ----------------------
1724 typedef struct AlterOpFamilyStmt
1727 List
*opfamilyname
; /* qualified name (list of Value strings) */
1728 char *amname
; /* name of index AM opfamily is for */
1729 bool isDrop
; /* ADD or DROP the items? */
1730 List
*items
; /* List of CreateOpClassItem nodes */
1731 } AlterOpFamilyStmt
;
1733 /* ----------------------
1734 * Drop Table|Sequence|View|Index|Type|Domain|Conversion|Schema Statement
1735 * ----------------------
1738 typedef struct DropStmt
1741 List
*objects
; /* list of sublists of names (as Values) */
1742 ObjectType removeType
; /* object type */
1743 DropBehavior behavior
; /* RESTRICT or CASCADE behavior */
1744 bool missing_ok
; /* skip error if object is missing? */
1747 /* ----------------------
1748 * Drop Rule|Trigger Statement
1750 * In general this may be used for dropping any property of a relation;
1751 * for example, someday soon we may have DROP ATTRIBUTE.
1752 * ----------------------
1755 typedef struct DropPropertyStmt
1758 RangeVar
*relation
; /* owning relation */
1759 char *property
; /* name of rule, trigger, etc */
1760 ObjectType removeType
; /* OBJECT_RULE or OBJECT_TRIGGER */
1761 DropBehavior behavior
; /* RESTRICT or CASCADE behavior */
1762 bool missing_ok
; /* skip error if missing? */
1765 /* ----------------------
1766 * Truncate Table Statement
1767 * ----------------------
1769 typedef struct TruncateStmt
1772 List
*relations
; /* relations (RangeVars) to be truncated */
1773 bool restart_seqs
; /* restart owned sequences? */
1774 DropBehavior behavior
; /* RESTRICT or CASCADE behavior */
1777 /* ----------------------
1778 * Comment On Statement
1779 * ----------------------
1781 typedef struct CommentStmt
1784 ObjectType objtype
; /* Object's type */
1785 List
*objname
; /* Qualified name of the object */
1786 List
*objargs
; /* Arguments if needed (eg, for functions) */
1787 char *comment
; /* Comment to insert, or NULL to remove */
1790 /* ----------------------
1791 * Declare Cursor Statement
1793 * Note: the "query" field of DeclareCursorStmt is only used in the raw grammar
1794 * output. After parse analysis it's set to null, and the Query points to the
1795 * DeclareCursorStmt, not vice versa.
1796 * ----------------------
1798 #define CURSOR_OPT_BINARY 0x0001 /* BINARY */
1799 #define CURSOR_OPT_SCROLL 0x0002 /* SCROLL explicitly given */
1800 #define CURSOR_OPT_NO_SCROLL 0x0004 /* NO SCROLL explicitly given */
1801 #define CURSOR_OPT_INSENSITIVE 0x0008 /* INSENSITIVE */
1802 #define CURSOR_OPT_HOLD 0x0010 /* WITH HOLD */
1803 #define CURSOR_OPT_FAST_PLAN 0x0020 /* prefer fast-start plan */
1805 typedef struct DeclareCursorStmt
1808 char *portalname
; /* name of the portal (cursor) */
1809 int options
; /* bitmask of options (see above) */
1810 Node
*query
; /* the raw SELECT query */
1811 } DeclareCursorStmt
;
1813 /* ----------------------
1814 * Close Portal Statement
1815 * ----------------------
1817 typedef struct ClosePortalStmt
1820 char *portalname
; /* name of the portal (cursor) */
1821 /* NULL means CLOSE ALL */
1824 /* ----------------------
1825 * Fetch Statement (also Move)
1826 * ----------------------
1828 typedef enum FetchDirection
1830 /* for these, howMany is how many rows to fetch; FETCH_ALL means ALL */
1833 /* for these, howMany indicates a position; only one row is fetched */
1838 #define FETCH_ALL LONG_MAX
1840 typedef struct FetchStmt
1843 FetchDirection direction
; /* see above */
1844 long howMany
; /* number of rows, or position argument */
1845 char *portalname
; /* name of portal (cursor) */
1846 bool ismove
; /* TRUE if MOVE */
1849 /* ----------------------
1850 * Create Index Statement
1851 * ----------------------
1853 typedef struct IndexStmt
1856 char *idxname
; /* name of new index, or NULL for default */
1857 RangeVar
*relation
; /* relation to build index on */
1858 char *accessMethod
; /* name of access method (eg. btree) */
1859 char *tableSpace
; /* tablespace, or NULL for default */
1860 List
*indexParams
; /* a list of IndexElem */
1861 List
*options
; /* options from WITH clause */
1862 Node
*whereClause
; /* qualification (partial-index predicate) */
1863 bool unique
; /* is index unique? */
1864 bool primary
; /* is index on primary key? */
1865 bool isconstraint
; /* is it from a CONSTRAINT clause? */
1866 bool concurrent
; /* should this be a concurrent index build? */
1869 /* ----------------------
1870 * Create Function Statement
1871 * ----------------------
1873 typedef struct CreateFunctionStmt
1876 bool replace
; /* T => replace if already exists */
1877 List
*funcname
; /* qualified name of function to create */
1878 List
*parameters
; /* a list of FunctionParameter */
1879 TypeName
*returnType
; /* the return type */
1880 List
*options
; /* a list of DefElem */
1881 List
*withClause
; /* a list of DefElem */
1882 } CreateFunctionStmt
;
1884 typedef enum FunctionParameterMode
1886 /* the assigned enum values appear in pg_proc, don't change 'em! */
1887 FUNC_PARAM_IN
= 'i', /* input only */
1888 FUNC_PARAM_OUT
= 'o', /* output only */
1889 FUNC_PARAM_INOUT
= 'b', /* both */
1890 FUNC_PARAM_VARIADIC
= 'v', /* variadic (always input) */
1891 FUNC_PARAM_TABLE
= 't' /* table function output column */
1892 } FunctionParameterMode
;
1894 typedef struct FunctionParameter
1897 char *name
; /* parameter name, or NULL if not given */
1898 TypeName
*argType
; /* TypeName for parameter type */
1899 FunctionParameterMode mode
; /* IN/OUT/etc */
1900 Node
*defexpr
; /* raw default expr, or NULL if not given */
1901 } FunctionParameter
;
1903 typedef struct AlterFunctionStmt
1906 FuncWithArgs
*func
; /* name and args of function */
1907 List
*actions
; /* list of DefElem */
1908 } AlterFunctionStmt
;
1910 /* ----------------------
1911 * Drop {Function|Aggregate|Operator} Statement
1912 * ----------------------
1914 typedef struct RemoveFuncStmt
1917 ObjectType kind
; /* function, aggregate, operator */
1918 List
*name
; /* qualified name of object to drop */
1919 List
*args
; /* types of the arguments */
1920 DropBehavior behavior
; /* RESTRICT or CASCADE behavior */
1921 bool missing_ok
; /* skip error if missing? */
1924 /* ----------------------
1925 * Drop Operator Class Statement
1926 * ----------------------
1928 typedef struct RemoveOpClassStmt
1931 List
*opclassname
; /* qualified name (list of Value strings) */
1932 char *amname
; /* name of index AM opclass is for */
1933 DropBehavior behavior
; /* RESTRICT or CASCADE behavior */
1934 bool missing_ok
; /* skip error if missing? */
1935 } RemoveOpClassStmt
;
1937 /* ----------------------
1938 * Drop Operator Family Statement
1939 * ----------------------
1941 typedef struct RemoveOpFamilyStmt
1944 List
*opfamilyname
; /* qualified name (list of Value strings) */
1945 char *amname
; /* name of index AM opfamily is for */
1946 DropBehavior behavior
; /* RESTRICT or CASCADE behavior */
1947 bool missing_ok
; /* skip error if missing? */
1948 } RemoveOpFamilyStmt
;
1950 /* ----------------------
1951 * Alter Object Rename Statement
1952 * ----------------------
1954 typedef struct RenameStmt
1957 ObjectType renameType
; /* OBJECT_TABLE, OBJECT_COLUMN, etc */
1958 RangeVar
*relation
; /* in case it's a table */
1959 List
*object
; /* in case it's some other object */
1960 List
*objarg
; /* argument types, if applicable */
1961 char *subname
; /* name of contained object (column, rule,
1963 char *newname
; /* the new name */
1966 /* ----------------------
1967 * ALTER object SET SCHEMA Statement
1968 * ----------------------
1970 typedef struct AlterObjectSchemaStmt
1973 ObjectType objectType
; /* OBJECT_TABLE, OBJECT_TYPE, etc */
1974 RangeVar
*relation
; /* in case it's a table */
1975 List
*object
; /* in case it's some other object */
1976 List
*objarg
; /* argument types, if applicable */
1977 char *addname
; /* additional name if needed */
1978 char *newschema
; /* the new schema */
1979 } AlterObjectSchemaStmt
;
1981 /* ----------------------
1982 * Alter Object Owner Statement
1983 * ----------------------
1985 typedef struct AlterOwnerStmt
1988 ObjectType objectType
; /* OBJECT_TABLE, OBJECT_TYPE, etc */
1989 RangeVar
*relation
; /* in case it's a table */
1990 List
*object
; /* in case it's some other object */
1991 List
*objarg
; /* argument types, if applicable */
1992 char *addname
; /* additional name if needed */
1993 char *newowner
; /* the new owner */
1997 /* ----------------------
1998 * Create Rule Statement
1999 * ----------------------
2001 typedef struct RuleStmt
2004 RangeVar
*relation
; /* relation the rule is for */
2005 char *rulename
; /* name of the rule */
2006 Node
*whereClause
; /* qualifications */
2007 CmdType event
; /* SELECT, INSERT, etc */
2008 bool instead
; /* is a 'do instead'? */
2009 List
*actions
; /* the action statements */
2010 bool replace
; /* OR REPLACE */
2013 /* ----------------------
2015 * ----------------------
2017 typedef struct NotifyStmt
2020 char *conditionname
; /* condition name to notify */
2023 /* ----------------------
2025 * ----------------------
2027 typedef struct ListenStmt
2030 char *conditionname
; /* condition name to listen on */
2033 /* ----------------------
2034 * Unlisten Statement
2035 * ----------------------
2037 typedef struct UnlistenStmt
2040 char *conditionname
; /* name to unlisten on, or NULL for all */
2043 /* ----------------------
2044 * {Begin|Commit|Rollback} Transaction Statement
2045 * ----------------------
2047 typedef enum TransactionStmtKind
2050 TRANS_STMT_START
, /* semantically identical to BEGIN */
2052 TRANS_STMT_ROLLBACK
,
2053 TRANS_STMT_SAVEPOINT
,
2055 TRANS_STMT_ROLLBACK_TO
,
2057 TRANS_STMT_COMMIT_PREPARED
,
2058 TRANS_STMT_ROLLBACK_PREPARED
2059 } TransactionStmtKind
;
2061 typedef struct TransactionStmt
2064 TransactionStmtKind kind
; /* see above */
2065 List
*options
; /* for BEGIN/START and savepoint commands */
2066 char *gid
; /* for two-phase-commit related commands */
2069 /* ----------------------
2070 * Create Type Statement, composite types
2071 * ----------------------
2073 typedef struct CompositeTypeStmt
2076 RangeVar
*typevar
; /* the composite type to be created */
2077 List
*coldeflist
; /* list of ColumnDef nodes */
2078 } CompositeTypeStmt
;
2080 /* ----------------------
2081 * Create Type Statement, enum types
2082 * ----------------------
2084 typedef struct CreateEnumStmt
2087 List
*typename
; /* qualified name (list of Value strings) */
2088 List
*vals
; /* enum values (list of Value strings) */
2092 /* ----------------------
2093 * Create View Statement
2094 * ----------------------
2096 typedef struct ViewStmt
2099 RangeVar
*view
; /* the view to be created */
2100 List
*aliases
; /* target column names */
2101 Node
*query
; /* the SELECT query */
2102 bool replace
; /* replace an existing view? */
2105 /* ----------------------
2107 * ----------------------
2109 typedef struct LoadStmt
2112 char *filename
; /* file to load */
2115 /* ----------------------
2116 * Createdb Statement
2117 * ----------------------
2119 typedef struct CreatedbStmt
2122 char *dbname
; /* name of database to create */
2123 List
*options
; /* List of DefElem nodes */
2126 /* ----------------------
2128 * ----------------------
2130 typedef struct AlterDatabaseStmt
2133 char *dbname
; /* name of database to alter */
2134 List
*options
; /* List of DefElem nodes */
2135 } AlterDatabaseStmt
;
2137 typedef struct AlterDatabaseSetStmt
2140 char *dbname
; /* database name */
2141 VariableSetStmt
*setstmt
; /* SET or RESET subcommand */
2142 } AlterDatabaseSetStmt
;
2144 /* ----------------------
2146 * ----------------------
2148 typedef struct DropdbStmt
2151 char *dbname
; /* database to drop */
2152 bool missing_ok
; /* skip error if db is missing? */
2155 /* ----------------------
2156 * Cluster Statement (support pbrown's cluster index implementation)
2157 * ----------------------
2159 typedef struct ClusterStmt
2162 RangeVar
*relation
; /* relation being indexed, or NULL if all */
2163 char *indexname
; /* original index defined */
2164 bool verbose
; /* print progress info */
2167 /* ----------------------
2168 * Vacuum and Analyze Statements
2170 * Even though these are nominally two statements, it's convenient to use
2171 * just one node type for both.
2172 * ----------------------
2174 typedef struct VacuumStmt
2177 bool vacuum
; /* do VACUUM step */
2178 bool full
; /* do FULL (non-concurrent) vacuum */
2179 bool analyze
; /* do ANALYZE step */
2180 bool verbose
; /* print progress info */
2181 int freeze_min_age
; /* min freeze age, or -1 to use default */
2182 int freeze_table_age
; /* age at which to scan whole table */
2183 RangeVar
*relation
; /* single table to process, or NULL */
2184 List
*va_cols
; /* list of column names, or NIL for all */
2187 /* ----------------------
2189 * ----------------------
2191 typedef struct ExplainStmt
2194 Node
*query
; /* the query (as a raw parse tree) */
2195 bool verbose
; /* print plan info */
2196 bool analyze
; /* get statistics by executing plan */
2199 /* ----------------------
2200 * Checkpoint Statement
2201 * ----------------------
2203 typedef struct CheckPointStmt
2208 /* ----------------------
2210 * ----------------------
2213 typedef enum DiscardMode
2220 typedef struct DiscardStmt
2226 /* ----------------------
2228 * ----------------------
2230 typedef struct LockStmt
2233 List
*relations
; /* relations to lock */
2234 int mode
; /* lock mode */
2235 bool nowait
; /* no wait mode */
2238 /* ----------------------
2239 * SET CONSTRAINTS Statement
2240 * ----------------------
2242 typedef struct ConstraintsSetStmt
2245 List
*constraints
; /* List of names as RangeVars */
2247 } ConstraintsSetStmt
;
2249 /* ----------------------
2251 * ----------------------
2253 typedef struct ReindexStmt
2256 ObjectType kind
; /* OBJECT_INDEX, OBJECT_TABLE, OBJECT_DATABASE */
2257 RangeVar
*relation
; /* Table or index to reindex */
2258 const char *name
; /* name of database to reindex */
2259 bool do_system
; /* include system tables in database case */
2260 bool do_user
; /* include user tables in database case */
2263 /* ----------------------
2264 * CREATE CONVERSION Statement
2265 * ----------------------
2267 typedef struct CreateConversionStmt
2270 List
*conversion_name
; /* Name of the conversion */
2271 char *for_encoding_name
; /* source encoding name */
2272 char *to_encoding_name
; /* destination encoding name */
2273 List
*func_name
; /* qualified conversion function name */
2274 bool def
; /* is this a default conversion? */
2275 } CreateConversionStmt
;
2277 /* ----------------------
2278 * CREATE CAST Statement
2279 * ----------------------
2281 typedef struct CreateCastStmt
2284 TypeName
*sourcetype
;
2285 TypeName
*targettype
;
2287 CoercionContext context
;
2291 /* ----------------------
2292 * DROP CAST Statement
2293 * ----------------------
2295 typedef struct DropCastStmt
2298 TypeName
*sourcetype
;
2299 TypeName
*targettype
;
2300 DropBehavior behavior
;
2301 bool missing_ok
; /* skip error if missing? */
2305 /* ----------------------
2307 * ----------------------
2309 typedef struct PrepareStmt
2312 char *name
; /* Name of plan, arbitrary */
2313 List
*argtypes
; /* Types of parameters (List of TypeName) */
2314 Node
*query
; /* The query itself (as a raw parsetree) */
2318 /* ----------------------
2320 * ----------------------
2323 typedef struct ExecuteStmt
2326 char *name
; /* The name of the plan to execute */
2327 IntoClause
*into
; /* Optional table to store results in */
2328 List
*params
; /* Values to assign to parameters */
2332 /* ----------------------
2333 * DEALLOCATE Statement
2334 * ----------------------
2336 typedef struct DeallocateStmt
2339 char *name
; /* The name of the plan to remove */
2340 /* NULL means DEALLOCATE ALL */
2344 * DROP OWNED statement
2346 typedef struct DropOwnedStmt
2350 DropBehavior behavior
;
2354 * REASSIGN OWNED statement
2356 typedef struct ReassignOwnedStmt
2361 } ReassignOwnedStmt
;
2364 * TS Dictionary stmts: DefineStmt, RenameStmt and DropStmt are default
2366 typedef struct AlterTSDictionaryStmt
2369 List
*dictname
; /* qualified name (list of Value strings) */
2370 List
*options
; /* List of DefElem nodes */
2371 } AlterTSDictionaryStmt
;
2374 * TS Configuration stmts: DefineStmt, RenameStmt and DropStmt are default
2376 typedef struct AlterTSConfigurationStmt
2379 List
*cfgname
; /* qualified name (list of Value strings) */
2382 * dicts will be non-NIL if ADD/ALTER MAPPING was specified. If dicts is
2383 * NIL, but tokentype isn't, DROP MAPPING was specified.
2385 List
*tokentype
; /* list of Value strings */
2386 List
*dicts
; /* list of list of Value strings */
2387 bool override
; /* if true - remove old variant */
2388 bool replace
; /* if true - replace dictionary by another */
2389 bool missing_ok
; /* for DROP - skip error if missing? */
2390 } AlterTSConfigurationStmt
;
2392 #endif /* PARSENODES_H */