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
10 * the location. At the topmost (statement) level, we also provide a
11 * statement length, likewise measured in bytes, for convenience in
12 * identifying statement boundaries in multi-statement source strings.
15 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
16 * Portions Copyright (c) 1994, Regents of the University of California
18 * src/include/nodes/parsenodes.h
20 *-------------------------------------------------------------------------
25 #include "common/relpath.h"
26 #include "nodes/bitmapset.h"
27 #include "nodes/lockoptions.h"
28 #include "nodes/primnodes.h"
29 #include "nodes/value.h"
30 #include "partitioning/partdefs.h"
33 /* Possible sources of a Query */
34 typedef enum QuerySource
36 QSRC_ORIGINAL
, /* original parsetree (explicit query) */
37 QSRC_PARSER
, /* added by parse analysis (now unused) */
38 QSRC_INSTEAD_RULE
, /* added by unconditional INSTEAD rule */
39 QSRC_QUAL_INSTEAD_RULE
, /* added by conditional INSTEAD rule */
40 QSRC_NON_INSTEAD_RULE
, /* added by non-INSTEAD rule */
43 /* Sort ordering options for ORDER BY and CREATE INDEX */
44 typedef enum SortByDir
49 SORTBY_USING
, /* not allowed in CREATE INDEX ... */
52 typedef enum SortByNulls
59 /* Options for [ ALL | DISTINCT ] */
60 typedef enum SetQuantifier
62 SET_QUANTIFIER_DEFAULT
,
64 SET_QUANTIFIER_DISTINCT
,
68 * Grantable rights are encoded so that we can OR them together in a bitmask.
69 * The present representation of AclItem limits us to 32 distinct rights,
70 * even though AclMode is defined as uint64. See utils/acl.h.
72 * Caution: changing these codes breaks stored ACLs, hence forces initdb.
74 typedef uint64 AclMode
; /* a bitmask of privilege bits */
76 #define ACL_INSERT (1<<0) /* for relations */
77 #define ACL_SELECT (1<<1)
78 #define ACL_UPDATE (1<<2)
79 #define ACL_DELETE (1<<3)
80 #define ACL_TRUNCATE (1<<4)
81 #define ACL_REFERENCES (1<<5)
82 #define ACL_TRIGGER (1<<6)
83 #define ACL_EXECUTE (1<<7) /* for functions */
84 #define ACL_USAGE (1<<8) /* for various object types */
85 #define ACL_CREATE (1<<9) /* for namespaces and databases */
86 #define ACL_CREATE_TEMP (1<<10) /* for databases */
87 #define ACL_CONNECT (1<<11) /* for databases */
88 #define ACL_SET (1<<12) /* for configuration parameters */
89 #define ACL_ALTER_SYSTEM (1<<13) /* for configuration parameters */
90 #define ACL_MAINTAIN (1<<14) /* for relations */
91 #define N_ACL_RIGHTS 15 /* 1 plus the last 1<<x */
92 #define ACL_NO_RIGHTS 0
93 /* Currently, SELECT ... FOR [KEY] UPDATE/SHARE requires UPDATE privileges */
94 #define ACL_SELECT_FOR_UPDATE ACL_UPDATE
97 /*****************************************************************************
99 *****************************************************************************/
103 * Parse analysis turns all statements into a Query tree
104 * for further processing by the rewriter and planner.
106 * Utility statements (i.e. non-optimizable statements) have the
107 * utilityStmt field set, and the rest of the Query is mostly dummy.
109 * Planning converts a Query tree into a Plan tree headed by a PlannedStmt
110 * node --- the Query structure is not used by the executor.
112 * All the fields ignored for the query jumbling are not semantically
113 * significant (such as alias names), as is ignored anything that can
114 * be deduced from child nodes (else we'd just be double-hashing that
115 * piece of information).
121 CmdType commandType
; /* select|insert|update|delete|merge|utility */
123 /* where did I come from? */
124 QuerySource querySource
pg_node_attr(query_jumble_ignore
);
127 * query identifier (can be set by plugins); ignored for equal, as it
128 * might not be set; also not stored. This is the result of the query
129 * jumble, hence ignored.
131 uint64 queryId
pg_node_attr(equal_ignore
, query_jumble_ignore
, read_write_ignore
, read_as(0));
133 /* do I set the command result tag? */
134 bool canSetTag
pg_node_attr(query_jumble_ignore
);
136 Node
*utilityStmt
; /* non-null if commandType == CMD_UTILITY */
139 * rtable index of target relation for INSERT/UPDATE/DELETE/MERGE; 0 for
140 * SELECT. This is ignored in the query jumble as unrelated to the
141 * compilation of the query ID.
143 int resultRelation
pg_node_attr(query_jumble_ignore
);
145 /* has aggregates in tlist or havingQual */
146 bool hasAggs
pg_node_attr(query_jumble_ignore
);
147 /* has window functions in tlist */
148 bool hasWindowFuncs
pg_node_attr(query_jumble_ignore
);
149 /* has set-returning functions in tlist */
150 bool hasTargetSRFs
pg_node_attr(query_jumble_ignore
);
151 /* has subquery SubLink */
152 bool hasSubLinks
pg_node_attr(query_jumble_ignore
);
153 /* distinctClause is from DISTINCT ON */
154 bool hasDistinctOn
pg_node_attr(query_jumble_ignore
);
155 /* WITH RECURSIVE was specified */
156 bool hasRecursive
pg_node_attr(query_jumble_ignore
);
157 /* has INSERT/UPDATE/DELETE/MERGE in WITH */
158 bool hasModifyingCTE
pg_node_attr(query_jumble_ignore
);
159 /* FOR [KEY] UPDATE/SHARE was specified */
160 bool hasForUpdate
pg_node_attr(query_jumble_ignore
);
161 /* rewriter has applied some RLS policy */
162 bool hasRowSecurity
pg_node_attr(query_jumble_ignore
);
163 /* parser has added an RTE_GROUP RTE */
164 bool hasGroupRTE
pg_node_attr(query_jumble_ignore
);
165 /* is a RETURN statement */
166 bool isReturn
pg_node_attr(query_jumble_ignore
);
168 List
*cteList
; /* WITH list (of CommonTableExpr's) */
170 List
*rtable
; /* list of range table entries */
173 * list of RTEPermissionInfo nodes for the rtable entries having
176 List
*rteperminfos
pg_node_attr(query_jumble_ignore
);
177 FromExpr
*jointree
; /* table join tree (FROM and WHERE clauses);
178 * also USING clause for MERGE */
180 List
*mergeActionList
; /* list of actions for MERGE (only) */
183 * rtable index of target relation for MERGE to pull data. Initially, this
184 * is the same as resultRelation, but after query rewriting, if the target
185 * relation is a trigger-updatable view, this is the index of the expanded
186 * view subquery, whereas resultRelation is the index of the target view.
188 int mergeTargetRelation
pg_node_attr(query_jumble_ignore
);
190 /* join condition between source and target for MERGE */
191 Node
*mergeJoinCondition
;
193 List
*targetList
; /* target list (of TargetEntry) */
195 /* OVERRIDING clause */
196 OverridingKind override
pg_node_attr(query_jumble_ignore
);
198 OnConflictExpr
*onConflict
; /* ON CONFLICT DO [NOTHING | UPDATE] */
201 * The following three fields describe the contents of the RETURNING list
202 * for INSERT/UPDATE/DELETE/MERGE. returningOldAlias and returningNewAlias
203 * are the alias names for OLD and NEW, which may be user-supplied values,
204 * the defaults "old" and "new", or NULL (if the default "old"/"new" is
205 * already in use as the alias for some other relation).
207 char *returningOldAlias
pg_node_attr(query_jumble_ignore
);
208 char *returningNewAlias
pg_node_attr(query_jumble_ignore
);
209 List
*returningList
; /* return-values list (of TargetEntry) */
211 List
*groupClause
; /* a list of SortGroupClause's */
212 bool groupDistinct
; /* is the group by clause distinct? */
214 List
*groupingSets
; /* a list of GroupingSet's if present */
216 Node
*havingQual
; /* qualifications applied to groups */
218 List
*windowClause
; /* a list of WindowClause's */
220 List
*distinctClause
; /* a list of SortGroupClause's */
222 List
*sortClause
; /* a list of SortGroupClause's */
224 Node
*limitOffset
; /* # of result tuples to skip (int8 expr) */
225 Node
*limitCount
; /* # of result tuples to return (int8 expr) */
226 LimitOption limitOption
; /* limit type */
228 List
*rowMarks
; /* a list of RowMarkClause's */
230 Node
*setOperations
; /* set-operation tree if this is top level of
231 * a UNION/INTERSECT/EXCEPT query */
234 * A list of pg_constraint OIDs that the query depends on to be
237 List
*constraintDeps
pg_node_attr(query_jumble_ignore
);
239 /* a list of WithCheckOption's (added during rewrite) */
240 List
*withCheckOptions
pg_node_attr(query_jumble_ignore
);
243 * The following two fields identify the portion of the source text string
244 * containing this query. They are typically only populated in top-level
245 * Queries, not in sub-queries. When not set, they might both be zero, or
246 * both be -1 meaning "unknown".
248 /* start location, or -1 if unknown */
249 ParseLoc stmt_location
;
250 /* length in bytes; 0 means "rest of string" */
251 ParseLoc stmt_len
pg_node_attr(query_jumble_ignore
);
255 /****************************************************************************
256 * Supporting data structures for Parse Trees
258 * Most of these node types appear in raw parsetrees output by the grammar,
259 * and get transformed to something else by the analyzer. A few of them
260 * are used as-is in transformed querytrees.
261 ****************************************************************************/
264 * TypeName - specifies a type in definitions
266 * For TypeName structures generated internally, it is often easier to
267 * specify the type by OID than by name. If "names" is NIL then the
268 * actual type OID is given by typeOid, otherwise typeOid is unused.
269 * Similarly, if "typmods" is NIL then the actual typmod is expected to
270 * be prespecified in typemod, otherwise typemod is unused.
272 * If pct_type is true, then names is actually a field name and we look up
273 * the type of that field. Otherwise (the normal case), names is a type
274 * name possibly qualified with schema and database name.
276 typedef struct TypeName
279 List
*names
; /* qualified name (list of String nodes) */
280 Oid typeOid
; /* type identified by OID */
281 bool setof
; /* is a set? */
282 bool pct_type
; /* %TYPE specified? */
283 List
*typmods
; /* type modifier expression(s) */
284 int32 typemod
; /* prespecified type modifier */
285 List
*arrayBounds
; /* array bounds */
286 ParseLoc location
; /* token location, or -1 if unknown */
290 * ColumnRef - specifies a reference to a column, or possibly a whole tuple
292 * The "fields" list must be nonempty. It can contain String nodes
293 * (representing names) and A_Star nodes (representing occurrence of a '*').
294 * Currently, A_Star must appear only as the last list element --- the grammar
295 * is responsible for enforcing this!
297 * Note: any container subscripting or selection of fields from composite columns
298 * is represented by an A_Indirection node above the ColumnRef. However,
299 * for simplicity in the normal case, initial field selection from a table
300 * name is represented within ColumnRef and not by adding A_Indirection.
302 typedef struct ColumnRef
305 List
*fields
; /* field names (String nodes) or A_Star */
306 ParseLoc location
; /* token location, or -1 if unknown */
310 * ParamRef - specifies a $n parameter reference
312 typedef struct ParamRef
315 int number
; /* the number of the parameter */
316 ParseLoc location
; /* token location, or -1 if unknown */
320 * A_Expr - infix, prefix, and postfix expressions
322 typedef enum A_Expr_Kind
324 AEXPR_OP
, /* normal operator */
325 AEXPR_OP_ANY
, /* scalar op ANY (array) */
326 AEXPR_OP_ALL
, /* scalar op ALL (array) */
327 AEXPR_DISTINCT
, /* IS DISTINCT FROM - name must be "=" */
328 AEXPR_NOT_DISTINCT
, /* IS NOT DISTINCT FROM - name must be "=" */
329 AEXPR_NULLIF
, /* NULLIF - name must be "=" */
330 AEXPR_IN
, /* [NOT] IN - name must be "=" or "<>" */
331 AEXPR_LIKE
, /* [NOT] LIKE - name must be "~~" or "!~~" */
332 AEXPR_ILIKE
, /* [NOT] ILIKE - name must be "~~*" or "!~~*" */
333 AEXPR_SIMILAR
, /* [NOT] SIMILAR - name must be "~" or "!~" */
334 AEXPR_BETWEEN
, /* name must be "BETWEEN" */
335 AEXPR_NOT_BETWEEN
, /* name must be "NOT BETWEEN" */
336 AEXPR_BETWEEN_SYM
, /* name must be "BETWEEN SYMMETRIC" */
337 AEXPR_NOT_BETWEEN_SYM
, /* name must be "NOT BETWEEN SYMMETRIC" */
340 typedef struct A_Expr
342 pg_node_attr(custom_read_write
)
345 A_Expr_Kind kind
; /* see above */
346 List
*name
; /* possibly-qualified name of operator */
347 Node
*lexpr
; /* left argument, or NULL if none */
348 Node
*rexpr
; /* right argument, or NULL if none */
349 ParseLoc location
; /* token location, or -1 if unknown */
353 * A_Const - a literal constant
355 * Value nodes are inline for performance. You can treat 'val' as a node,
356 * as in IsA(&val, Integer). 'val' is not valid if isnull is true.
368 typedef struct A_Const
370 pg_node_attr(custom_copy_equal
, custom_read_write
, custom_query_jumble
)
374 bool isnull
; /* SQL NULL constant */
375 ParseLoc location
; /* token location, or -1 if unknown */
379 * TypeCast - a CAST expression
381 typedef struct TypeCast
384 Node
*arg
; /* the expression being casted */
385 TypeName
*typeName
; /* the target type */
386 ParseLoc location
; /* token location, or -1 if unknown */
390 * CollateClause - a COLLATE expression
392 typedef struct CollateClause
395 Node
*arg
; /* input expression */
396 List
*collname
; /* possibly-qualified collation name */
397 ParseLoc location
; /* token location, or -1 if unknown */
401 * RoleSpec - a role name or one of a few special values.
403 typedef enum RoleSpecType
405 ROLESPEC_CSTRING
, /* role name is stored as a C string */
406 ROLESPEC_CURRENT_ROLE
, /* role spec is CURRENT_ROLE */
407 ROLESPEC_CURRENT_USER
, /* role spec is CURRENT_USER */
408 ROLESPEC_SESSION_USER
, /* role spec is SESSION_USER */
409 ROLESPEC_PUBLIC
, /* role name is "public" */
412 typedef struct RoleSpec
415 RoleSpecType roletype
; /* Type of this rolespec */
416 char *rolename
; /* filled only for ROLESPEC_CSTRING */
417 ParseLoc location
; /* token location, or -1 if unknown */
421 * FuncCall - a function or aggregate invocation
423 * agg_order (if not NIL) indicates we saw 'foo(... ORDER BY ...)', or if
424 * agg_within_group is true, it was 'foo(...) WITHIN GROUP (ORDER BY ...)'.
425 * agg_star indicates we saw a 'foo(*)' construct, while agg_distinct
426 * indicates we saw 'foo(DISTINCT ...)'. In any of these cases, the
427 * construct *must* be an aggregate call. Otherwise, it might be either an
428 * aggregate or some other kind of function. However, if FILTER or OVER is
429 * present it had better be an aggregate or window function.
431 * Normally, you'd initialize this via makeFuncCall() and then only change the
432 * parts of the struct its defaults don't match afterwards, as needed.
434 typedef struct FuncCall
437 List
*funcname
; /* qualified name of function */
438 List
*args
; /* the arguments (list of exprs) */
439 List
*agg_order
; /* ORDER BY (list of SortBy) */
440 Node
*agg_filter
; /* FILTER clause, if any */
441 struct WindowDef
*over
; /* OVER clause, if any */
442 bool agg_within_group
; /* ORDER BY appeared in WITHIN GROUP */
443 bool agg_star
; /* argument was really '*' */
444 bool agg_distinct
; /* arguments were labeled DISTINCT */
445 bool func_variadic
; /* last argument was labeled VARIADIC */
446 CoercionForm funcformat
; /* how to display this node */
447 ParseLoc location
; /* token location, or -1 if unknown */
451 * A_Star - '*' representing all columns of a table or compound field
453 * This can appear within ColumnRef.fields, A_Indirection.indirection, and
454 * ResTarget.indirection lists.
456 typedef struct A_Star
462 * A_Indices - array subscript or slice bounds ([idx] or [lidx:uidx])
464 * In slice case, either or both of lidx and uidx can be NULL (omitted).
465 * In non-slice case, uidx holds the single subscript and lidx is always NULL.
467 typedef struct A_Indices
470 bool is_slice
; /* true if slice (i.e., colon present) */
471 Node
*lidx
; /* slice lower bound, if any */
472 Node
*uidx
; /* subscript, or slice upper bound if any */
476 * A_Indirection - select a field and/or array element from an expression
478 * The indirection list can contain A_Indices nodes (representing
479 * subscripting), String nodes (representing field selection --- the
480 * string value is the name of the field to select), and A_Star nodes
481 * (representing selection of all fields of a composite type).
482 * For example, a complex selection operation like
483 * (foo).field1[42][7].field2
484 * would be represented with a single A_Indirection node having a 4-element
487 * Currently, A_Star must appear only as the last list element --- the grammar
488 * is responsible for enforcing this!
490 typedef struct A_Indirection
493 Node
*arg
; /* the thing being selected from */
494 List
*indirection
; /* subscripts and/or field names and/or * */
498 * A_ArrayExpr - an ARRAY[] construct
500 typedef struct A_ArrayExpr
503 List
*elements
; /* array element expressions */
504 ParseLoc location
; /* token location, or -1 if unknown */
509 * result target (used in target list of pre-transformed parse trees)
511 * In a SELECT target list, 'name' is the column label from an
512 * 'AS ColumnLabel' clause, or NULL if there was none, and 'val' is the
513 * value expression itself. The 'indirection' field is not used.
515 * INSERT uses ResTarget in its target-column-names list. Here, 'name' is
516 * the name of the destination column, 'indirection' stores any subscripts
517 * attached to the destination, and 'val' is not used.
519 * In an UPDATE target list, 'name' is the name of the destination column,
520 * 'indirection' stores any subscripts attached to the destination, and
521 * 'val' is the expression to assign.
523 * See A_Indirection for more info about what can appear in 'indirection'.
525 typedef struct ResTarget
528 char *name
; /* column name or NULL */
529 List
*indirection
; /* subscripts, field names, and '*', or NIL */
530 Node
*val
; /* the value expression to compute or assign */
531 ParseLoc location
; /* token location, or -1 if unknown */
535 * MultiAssignRef - element of a row source expression for UPDATE
537 * In an UPDATE target list, when we have SET (a,b,c) = row-valued-expression,
538 * we generate separate ResTarget items for each of a,b,c. Their "val" trees
539 * are MultiAssignRef nodes numbered 1..n, linking to a common copy of the
540 * row-valued-expression (which parse analysis will process only once, when
541 * handling the MultiAssignRef with colno=1).
543 typedef struct MultiAssignRef
546 Node
*source
; /* the row-valued expression */
547 int colno
; /* column number for this target (1..n) */
548 int ncolumns
; /* number of targets in the construct */
552 * SortBy - for ORDER BY clause
554 typedef struct SortBy
557 Node
*node
; /* expression to sort on */
558 SortByDir sortby_dir
; /* ASC/DESC/USING/default */
559 SortByNulls sortby_nulls
; /* NULLS FIRST/LAST */
560 List
*useOp
; /* name of op to use, if SORTBY_USING */
561 ParseLoc location
; /* operator location, or -1 if none/unknown */
565 * WindowDef - raw representation of WINDOW and OVER clauses
567 * For entries in a WINDOW list, "name" is the window name being defined.
568 * For OVER clauses, we use "name" for the "OVER window" syntax, or "refname"
569 * for the "OVER (window)" syntax, which is subtly different --- the latter
570 * implies overriding the window frame clause.
572 typedef struct WindowDef
575 char *name
; /* window's own name */
576 char *refname
; /* referenced window name, if any */
577 List
*partitionClause
; /* PARTITION BY expression list */
578 List
*orderClause
; /* ORDER BY (list of SortBy) */
579 int frameOptions
; /* frame_clause options, see below */
580 Node
*startOffset
; /* expression for starting bound, if any */
581 Node
*endOffset
; /* expression for ending bound, if any */
582 ParseLoc location
; /* parse location, or -1 if none/unknown */
586 * frameOptions is an OR of these bits. The NONDEFAULT and BETWEEN bits are
587 * used so that ruleutils.c can tell which properties were specified and
588 * which were defaulted; the correct behavioral bits must be set either way.
589 * The START_foo and END_foo options must come in pairs of adjacent bits for
590 * the convenience of gram.y, even though some of them are useless/invalid.
592 #define FRAMEOPTION_NONDEFAULT 0x00001 /* any specified? */
593 #define FRAMEOPTION_RANGE 0x00002 /* RANGE behavior */
594 #define FRAMEOPTION_ROWS 0x00004 /* ROWS behavior */
595 #define FRAMEOPTION_GROUPS 0x00008 /* GROUPS behavior */
596 #define FRAMEOPTION_BETWEEN 0x00010 /* BETWEEN given? */
597 #define FRAMEOPTION_START_UNBOUNDED_PRECEDING 0x00020 /* start is U. P. */
598 #define FRAMEOPTION_END_UNBOUNDED_PRECEDING 0x00040 /* (disallowed) */
599 #define FRAMEOPTION_START_UNBOUNDED_FOLLOWING 0x00080 /* (disallowed) */
600 #define FRAMEOPTION_END_UNBOUNDED_FOLLOWING 0x00100 /* end is U. F. */
601 #define FRAMEOPTION_START_CURRENT_ROW 0x00200 /* start is C. R. */
602 #define FRAMEOPTION_END_CURRENT_ROW 0x00400 /* end is C. R. */
603 #define FRAMEOPTION_START_OFFSET_PRECEDING 0x00800 /* start is O. P. */
604 #define FRAMEOPTION_END_OFFSET_PRECEDING 0x01000 /* end is O. P. */
605 #define FRAMEOPTION_START_OFFSET_FOLLOWING 0x02000 /* start is O. F. */
606 #define FRAMEOPTION_END_OFFSET_FOLLOWING 0x04000 /* end is O. F. */
607 #define FRAMEOPTION_EXCLUDE_CURRENT_ROW 0x08000 /* omit C.R. */
608 #define FRAMEOPTION_EXCLUDE_GROUP 0x10000 /* omit C.R. & peers */
609 #define FRAMEOPTION_EXCLUDE_TIES 0x20000 /* omit C.R.'s peers */
611 #define FRAMEOPTION_START_OFFSET \
612 (FRAMEOPTION_START_OFFSET_PRECEDING | FRAMEOPTION_START_OFFSET_FOLLOWING)
613 #define FRAMEOPTION_END_OFFSET \
614 (FRAMEOPTION_END_OFFSET_PRECEDING | FRAMEOPTION_END_OFFSET_FOLLOWING)
615 #define FRAMEOPTION_EXCLUSION \
616 (FRAMEOPTION_EXCLUDE_CURRENT_ROW | FRAMEOPTION_EXCLUDE_GROUP | \
617 FRAMEOPTION_EXCLUDE_TIES)
619 #define FRAMEOPTION_DEFAULTS \
620 (FRAMEOPTION_RANGE | FRAMEOPTION_START_UNBOUNDED_PRECEDING | \
621 FRAMEOPTION_END_CURRENT_ROW)
624 * RangeSubselect - subquery appearing in a FROM clause
626 typedef struct RangeSubselect
629 bool lateral
; /* does it have LATERAL prefix? */
630 Node
*subquery
; /* the untransformed sub-select clause */
631 Alias
*alias
; /* table alias & optional column aliases */
635 * RangeFunction - function call appearing in a FROM clause
637 * functions is a List because we use this to represent the construct
638 * ROWS FROM(func1(...), func2(...), ...). Each element of this list is a
639 * two-element sublist, the first element being the untransformed function
640 * call tree, and the second element being a possibly-empty list of ColumnDef
641 * nodes representing any columndef list attached to that function within the
642 * ROWS FROM() syntax.
644 * alias and coldeflist represent any alias and/or columndef list attached
645 * at the top level. (We disallow coldeflist appearing both here and
646 * per-function, but that's checked in parse analysis, not by the grammar.)
648 typedef struct RangeFunction
651 bool lateral
; /* does it have LATERAL prefix? */
652 bool ordinality
; /* does it have WITH ORDINALITY suffix? */
653 bool is_rowsfrom
; /* is result of ROWS FROM() syntax? */
654 List
*functions
; /* per-function information, see above */
655 Alias
*alias
; /* table alias & optional column aliases */
656 List
*coldeflist
; /* list of ColumnDef nodes to describe result
657 * of function returning RECORD */
661 * RangeTableFunc - raw form of "table functions" such as XMLTABLE
663 * Note: JSON_TABLE is also a "table function", but it uses JsonTable node,
664 * not RangeTableFunc.
666 typedef struct RangeTableFunc
669 bool lateral
; /* does it have LATERAL prefix? */
670 Node
*docexpr
; /* document expression */
671 Node
*rowexpr
; /* row generator expression */
672 List
*namespaces
; /* list of namespaces as ResTarget */
673 List
*columns
; /* list of RangeTableFuncCol */
674 Alias
*alias
; /* table alias & optional column aliases */
675 ParseLoc location
; /* token location, or -1 if unknown */
679 * RangeTableFuncCol - one column in a RangeTableFunc->columns
681 * If for_ordinality is true (FOR ORDINALITY), then the column is an int4
682 * column and the rest of the fields are ignored.
684 typedef struct RangeTableFuncCol
687 char *colname
; /* name of generated column */
688 TypeName
*typeName
; /* type of generated column */
689 bool for_ordinality
; /* does it have FOR ORDINALITY? */
690 bool is_not_null
; /* does it have NOT NULL? */
691 Node
*colexpr
; /* column filter expression */
692 Node
*coldefexpr
; /* column default value expression */
693 ParseLoc location
; /* token location, or -1 if unknown */
697 * RangeTableSample - TABLESAMPLE appearing in a raw FROM clause
699 * This node, appearing only in raw parse trees, represents
700 * <relation> TABLESAMPLE <method> (<params>) REPEATABLE (<num>)
701 * Currently, the <relation> can only be a RangeVar, but we might in future
702 * allow RangeSubselect and other options. Note that the RangeTableSample
703 * is wrapped around the node representing the <relation>, rather than being
706 typedef struct RangeTableSample
709 Node
*relation
; /* relation to be sampled */
710 List
*method
; /* sampling method name (possibly qualified) */
711 List
*args
; /* argument(s) for sampling method */
712 Node
*repeatable
; /* REPEATABLE expression, or NULL if none */
713 ParseLoc location
; /* method name location, or -1 if unknown */
717 * ColumnDef - column definition (used in various creates)
719 * If the column has a default value, we may have the value expression
720 * in either "raw" form (an untransformed parse tree) or "cooked" form
721 * (a post-parse-analysis, executable expression tree), depending on
722 * how this ColumnDef node was created (by parsing, or by inheritance
723 * from an existing relation). We should never have both in the same node!
725 * Similarly, we may have a COLLATE specification in either raw form
726 * (represented as a CollateClause with arg==NULL) or cooked form
727 * (the collation's OID).
729 * The constraints list may contain a CONSTR_DEFAULT item in a raw
730 * parsetree produced by gram.y, but transformCreateStmt will remove
731 * the item and set raw_default instead. CONSTR_DEFAULT items
732 * should not appear in any subsequent processing.
734 typedef struct ColumnDef
737 char *colname
; /* name of column */
738 TypeName
*typeName
; /* type of column */
739 char *compression
; /* compression method for column */
740 int16 inhcount
; /* number of times column is inherited */
741 bool is_local
; /* column has local (non-inherited) def'n */
742 bool is_not_null
; /* NOT NULL constraint specified? */
743 bool is_from_type
; /* column definition came from table type */
744 char storage
; /* attstorage setting, or 0 for default */
745 char *storage_name
; /* attstorage setting name or NULL for default */
746 Node
*raw_default
; /* default value (untransformed parse tree) */
747 Node
*cooked_default
; /* default value (transformed expr tree) */
748 char identity
; /* attidentity setting */
749 RangeVar
*identitySequence
; /* to store identity sequence name for
750 * ALTER TABLE ... ADD COLUMN */
751 char generated
; /* attgenerated setting */
752 CollateClause
*collClause
; /* untransformed COLLATE spec, if any */
753 Oid collOid
; /* collation OID (InvalidOid if not set) */
754 List
*constraints
; /* other constraints on column */
755 List
*fdwoptions
; /* per-column FDW options */
756 ParseLoc location
; /* parse location, or -1 if none/unknown */
760 * TableLikeClause - CREATE TABLE ( ... LIKE ... ) clause
762 typedef struct TableLikeClause
766 bits32 options
; /* OR of TableLikeOption flags */
767 Oid relationOid
; /* If table has been looked up, its OID */
770 typedef enum TableLikeOption
772 CREATE_TABLE_LIKE_COMMENTS
= 1 << 0,
773 CREATE_TABLE_LIKE_COMPRESSION
= 1 << 1,
774 CREATE_TABLE_LIKE_CONSTRAINTS
= 1 << 2,
775 CREATE_TABLE_LIKE_DEFAULTS
= 1 << 3,
776 CREATE_TABLE_LIKE_GENERATED
= 1 << 4,
777 CREATE_TABLE_LIKE_IDENTITY
= 1 << 5,
778 CREATE_TABLE_LIKE_INDEXES
= 1 << 6,
779 CREATE_TABLE_LIKE_STATISTICS
= 1 << 7,
780 CREATE_TABLE_LIKE_STORAGE
= 1 << 8,
781 CREATE_TABLE_LIKE_ALL
= PG_INT32_MAX
785 * IndexElem - index parameters (used in CREATE INDEX, and in ON CONFLICT)
787 * For a plain index attribute, 'name' is the name of the table column to
788 * index, and 'expr' is NULL. For an index expression, 'name' is NULL and
789 * 'expr' is the expression tree.
791 typedef struct IndexElem
794 char *name
; /* name of attribute to index, or NULL */
795 Node
*expr
; /* expression to index, or NULL */
796 char *indexcolname
; /* name for index column; NULL = default */
797 List
*collation
; /* name of collation; NIL = default */
798 List
*opclass
; /* name of desired opclass; NIL = default */
799 List
*opclassopts
; /* opclass-specific options, or NIL */
800 SortByDir ordering
; /* ASC/DESC/default */
801 SortByNulls nulls_ordering
; /* FIRST/LAST/default */
805 * DefElem - a generic "name = value" option definition
807 * In some contexts the name can be qualified. Also, certain SQL commands
808 * allow a SET/ADD/DROP action to be attached to option settings, so it's
809 * convenient to carry a field for that too. (Note: currently, it is our
810 * practice that the grammar allows namespace and action only in statements
811 * where they are relevant; C code can just ignore those fields in other
814 typedef enum DefElemAction
816 DEFELEM_UNSPEC
, /* no action given */
822 typedef struct DefElem
825 char *defnamespace
; /* NULL if unqualified name */
827 Node
*arg
; /* typically Integer, Float, String, or
829 DefElemAction defaction
; /* unspecified action, or SET/ADD/DROP */
830 ParseLoc location
; /* token location, or -1 if unknown */
834 * LockingClause - raw representation of FOR [NO KEY] UPDATE/[KEY] SHARE
837 * Note: lockedRels == NIL means "all relations in query". Otherwise it
838 * is a list of RangeVar nodes. (We use RangeVar mainly because it carries
839 * a location field --- currently, parse analysis insists on unqualified
840 * names in LockingClause.)
842 typedef struct LockingClause
845 List
*lockedRels
; /* FOR [KEY] UPDATE/SHARE relations */
846 LockClauseStrength strength
;
847 LockWaitPolicy waitPolicy
; /* NOWAIT and SKIP LOCKED */
851 * XMLSERIALIZE (in raw parse tree only)
853 typedef struct XmlSerialize
856 XmlOptionType xmloption
; /* DOCUMENT or CONTENT */
859 bool indent
; /* [NO] INDENT */
860 ParseLoc location
; /* token location, or -1 if unknown */
863 /* Partitioning related definitions */
866 * PartitionElem - parse-time representation of a single partition key
868 * expr can be either a raw expression tree or a parse-analyzed expression.
869 * We don't store these on-disk, though.
871 typedef struct PartitionElem
874 char *name
; /* name of column to partition on, or NULL */
875 Node
*expr
; /* expression to partition on, or NULL */
876 List
*collation
; /* name of collation; NIL = default */
877 List
*opclass
; /* name of desired opclass; NIL = default */
878 ParseLoc location
; /* token location, or -1 if unknown */
881 typedef enum PartitionStrategy
883 PARTITION_STRATEGY_LIST
= 'l',
884 PARTITION_STRATEGY_RANGE
= 'r',
885 PARTITION_STRATEGY_HASH
= 'h',
889 * PartitionSpec - parse-time representation of a partition key specification
891 * This represents the key space we will be partitioning on.
893 typedef struct PartitionSpec
896 PartitionStrategy strategy
;
897 List
*partParams
; /* List of PartitionElems */
898 ParseLoc location
; /* token location, or -1 if unknown */
902 * PartitionBoundSpec - a partition bound specification
904 * This represents the portion of the partition key space assigned to a
905 * particular partition. These are stored on disk in pg_class.relpartbound.
907 struct PartitionBoundSpec
911 char strategy
; /* see PARTITION_STRATEGY codes above */
912 bool is_default
; /* is it a default partition bound? */
914 /* Partitioning info for HASH strategy: */
918 /* Partitioning info for LIST strategy: */
919 List
*listdatums
; /* List of Consts (or A_Consts in raw tree) */
921 /* Partitioning info for RANGE strategy: */
922 List
*lowerdatums
; /* List of PartitionRangeDatums */
923 List
*upperdatums
; /* List of PartitionRangeDatums */
925 ParseLoc location
; /* token location, or -1 if unknown */
929 * PartitionRangeDatum - one of the values in a range partition bound
931 * This can be MINVALUE, MAXVALUE or a specific bounded value.
933 typedef enum PartitionRangeDatumKind
935 PARTITION_RANGE_DATUM_MINVALUE
= -1, /* less than any other value */
936 PARTITION_RANGE_DATUM_VALUE
= 0, /* a specific (bounded) value */
937 PARTITION_RANGE_DATUM_MAXVALUE
= 1, /* greater than any other value */
938 } PartitionRangeDatumKind
;
940 typedef struct PartitionRangeDatum
944 PartitionRangeDatumKind kind
;
945 Node
*value
; /* Const (or A_Const in raw tree), if kind is
946 * PARTITION_RANGE_DATUM_VALUE, else NULL */
948 ParseLoc location
; /* token location, or -1 if unknown */
949 } PartitionRangeDatum
;
952 * PartitionCmd - info for ALTER TABLE/INDEX ATTACH/DETACH PARTITION commands
954 typedef struct PartitionCmd
957 RangeVar
*name
; /* name of partition to attach/detach */
958 PartitionBoundSpec
*bound
; /* FOR VALUES, if attaching */
962 /****************************************************************************
963 * Nodes for a Query tree
964 ****************************************************************************/
966 /*--------------------
968 * A range table is a List of RangeTblEntry nodes.
970 * A range table entry may represent a plain relation, a sub-select in
971 * FROM, or the result of a JOIN clause. (Only explicit JOIN syntax
972 * produces an RTE, not the implicit join resulting from multiple FROM
973 * items. This is because we only need the RTE to deal with SQL features
974 * like outer joins and join-output-column aliasing.) Other special
975 * RTE types also exist, as indicated by RTEKind.
977 * Note that we consider RTE_RELATION to cover anything that has a pg_class
978 * entry. relkind distinguishes the sub-cases.
980 * alias is an Alias node representing the AS alias-clause attached to the
981 * FROM expression, or NULL if no clause.
983 * eref is the table reference name and column reference names (either
984 * real or aliases). Note that system columns (OID etc) are not included
985 * in the column list.
986 * eref->aliasname is required to be present, and should generally be used
987 * to identify the RTE for error messages etc.
989 * In RELATION RTEs, the colnames in both alias and eref are indexed by
990 * physical attribute number; this means there must be colname entries for
991 * dropped columns. When building an RTE we insert empty strings ("") for
992 * dropped columns. Note however that a stored rule may have nonempty
993 * colnames for columns dropped since the rule was created (and for that
994 * matter the colnames might be out of date due to column renamings).
995 * The same comments apply to FUNCTION RTEs when a function's return type
996 * is a named composite type.
998 * In JOIN RTEs, the colnames in both alias and eref are one-to-one with
999 * joinaliasvars entries. A JOIN RTE will omit columns of its inputs when
1000 * those columns are known to be dropped at parse time. Again, however,
1001 * a stored rule might contain entries for columns dropped since the rule
1002 * was created. (This is only possible for columns not actually referenced
1003 * in the rule.) When loading a stored rule, we replace the joinaliasvars
1004 * items for any such columns with null pointers. (We can't simply delete
1005 * them from the joinaliasvars list, because that would affect the attnums
1006 * of Vars referencing the rest of the list.)
1008 * inFromCl marks those range variables that are listed in the FROM clause.
1009 * It's false for RTEs that are added to a query behind the scenes, such
1010 * as the NEW and OLD variables for a rule, or the subqueries of a UNION.
1011 * This flag is not used during parsing (except in transformLockingClause,
1012 * q.v.); the parser now uses a separate "namespace" data structure to
1013 * control visibility. But it is needed by ruleutils.c to determine
1014 * whether RTEs should be shown in decompiled queries.
1016 * securityQuals is a list of security barrier quals (boolean expressions),
1017 * to be tested in the listed order before returning a row from the
1018 * relation. It is always NIL in parser output. Entries are added by the
1019 * rewriter to implement security-barrier views and/or row-level security.
1020 * Note that the planner turns each boolean expression into an implicitly
1021 * AND'ed sublist, as is its usual habit with qualification expressions.
1022 *--------------------
1024 typedef enum RTEKind
1026 RTE_RELATION
, /* ordinary relation reference */
1027 RTE_SUBQUERY
, /* subquery in FROM */
1028 RTE_JOIN
, /* join */
1029 RTE_FUNCTION
, /* function in FROM */
1030 RTE_TABLEFUNC
, /* TableFunc(.., column list) */
1031 RTE_VALUES
, /* VALUES (<exprlist>), (<exprlist>), ... */
1032 RTE_CTE
, /* common table expr (WITH list element) */
1033 RTE_NAMEDTUPLESTORE
, /* tuplestore, e.g. for AFTER triggers */
1034 RTE_RESULT
, /* RTE represents an empty FROM clause; such
1035 * RTEs are added by the planner, they're not
1036 * present during parsing or rewriting */
1037 RTE_GROUP
, /* the grouping step */
1040 typedef struct RangeTblEntry
1042 pg_node_attr(custom_read_write
)
1047 * Fields valid in all RTEs:
1049 * put alias + eref first to make dump more legible
1051 /* user-written alias clause, if any */
1052 Alias
*alias
pg_node_attr(query_jumble_ignore
);
1053 /* expanded reference names */
1054 Alias
*eref
pg_node_attr(query_jumble_ignore
);
1056 RTEKind rtekind
; /* see above */
1059 * Fields valid for a plain relation RTE (else zero):
1061 * inh is true for relation references that should be expanded to include
1062 * inheritance children, if the rel has any. In the parser, this will
1063 * only be true for RTE_RELATION entries. The planner also uses this
1064 * field to mark RTE_SUBQUERY entries that contain UNION ALL queries that
1065 * it has flattened into pulled-up subqueries (creating a structure much
1066 * like the effects of inheritance).
1068 * rellockmode is really LOCKMODE, but it's declared int to avoid having
1069 * to include lock-related headers here. It must be RowExclusiveLock if
1070 * the RTE is an INSERT/UPDATE/DELETE/MERGE target, else RowShareLock if
1071 * the RTE is a SELECT FOR UPDATE/FOR SHARE target, else AccessShareLock.
1073 * Note: in some cases, rule expansion may result in RTEs that are marked
1074 * with RowExclusiveLock even though they are not the target of the
1075 * current query; this happens if a DO ALSO rule simply scans the original
1076 * target table. We leave such RTEs with their original lockmode so as to
1077 * avoid getting an additional, lesser lock.
1079 * perminfoindex is 1-based index of the RTEPermissionInfo belonging to
1080 * this RTE in the containing struct's list of same; 0 if permissions need
1081 * not be checked for this RTE.
1083 * As a special case, relid, relkind, rellockmode, and perminfoindex can
1084 * also be set (nonzero) in an RTE_SUBQUERY RTE. This occurs when we
1085 * convert an RTE_RELATION RTE naming a view into an RTE_SUBQUERY
1086 * containing the view's query. We still need to perform run-time locking
1087 * and permission checks on the view, even though it's not directly used
1088 * in the query anymore, and the most expedient way to do that is to
1089 * retain these fields from the old state of the RTE.
1091 * As a special case, RTE_NAMEDTUPLESTORE can also set relid to indicate
1092 * that the tuple format of the tuplestore is the same as the referenced
1093 * relation. This allows plans referencing AFTER trigger transition
1094 * tables to be invalidated if the underlying table is altered.
1096 /* OID of the relation */
1098 /* inheritance requested? */
1100 /* relation kind (see pg_class.relkind) */
1101 char relkind
pg_node_attr(query_jumble_ignore
);
1102 /* lock level that query requires on the rel */
1103 int rellockmode
pg_node_attr(query_jumble_ignore
);
1104 /* index of RTEPermissionInfo entry, or 0 */
1105 Index perminfoindex
pg_node_attr(query_jumble_ignore
);
1106 /* sampling info, or NULL */
1107 struct TableSampleClause
*tablesample
;
1110 * Fields valid for a subquery RTE (else NULL):
1114 /* is from security_barrier view? */
1115 bool security_barrier
pg_node_attr(query_jumble_ignore
);
1118 * Fields valid for a join RTE (else NULL/zero):
1120 * joinaliasvars is a list of (usually) Vars corresponding to the columns
1121 * of the join result. An alias Var referencing column K of the join
1122 * result can be replaced by the K'th element of joinaliasvars --- but to
1123 * simplify the task of reverse-listing aliases correctly, we do not do
1124 * that until planning time. In detail: an element of joinaliasvars can
1125 * be a Var of one of the join's input relations, or such a Var with an
1126 * implicit coercion to the join's output column type, or a COALESCE
1127 * expression containing the two input column Vars (possibly coerced).
1128 * Elements beyond the first joinmergedcols entries are always just Vars,
1129 * and are never referenced from elsewhere in the query (that is, join
1130 * alias Vars are generated only for merged columns). We keep these
1131 * entries only because they're needed in expandRTE() and similar code.
1133 * Vars appearing within joinaliasvars are marked with varnullingrels sets
1134 * that describe the nulling effects of this join and lower ones. This is
1135 * essential for FULL JOIN cases, because the COALESCE expression only
1136 * describes the semantics correctly if its inputs have been nulled by the
1137 * join. For other cases, it allows expandRTE() to generate a valid
1138 * representation of the join's output without consulting additional
1141 * Within a Query loaded from a stored rule, it is possible for non-merged
1142 * joinaliasvars items to be null pointers, which are placeholders for
1143 * (necessarily unreferenced) columns dropped since the rule was made.
1144 * Also, once planning begins, joinaliasvars items can be almost anything,
1145 * as a result of subquery-flattening substitutions.
1147 * joinleftcols is an integer list of physical column numbers of the left
1148 * join input rel that are included in the join; likewise joinrighttcols
1149 * for the right join input rel. (Which rels those are can be determined
1150 * from the associated JoinExpr.) If the join is USING/NATURAL, then the
1151 * first joinmergedcols entries in each list identify the merged columns.
1152 * The merged columns come first in the join output, then remaining
1153 * columns of the left input, then remaining columns of the right.
1155 * Note that input columns could have been dropped after creation of a
1156 * stored rule, if they are not referenced in the query (in particular,
1157 * merged columns could not be dropped); this is not accounted for in
1158 * joinleftcols/joinrighttcols.
1161 /* number of merged (JOIN USING) columns */
1162 int joinmergedcols
pg_node_attr(query_jumble_ignore
);
1163 /* list of alias-var expansions */
1164 List
*joinaliasvars
pg_node_attr(query_jumble_ignore
);
1165 /* left-side input column numbers */
1166 List
*joinleftcols
pg_node_attr(query_jumble_ignore
);
1167 /* right-side input column numbers */
1168 List
*joinrightcols
pg_node_attr(query_jumble_ignore
);
1171 * join_using_alias is an alias clause attached directly to JOIN/USING. It
1172 * is different from the alias field (below) in that it does not hide the
1173 * range variables of the tables being joined.
1175 Alias
*join_using_alias
pg_node_attr(query_jumble_ignore
);
1178 * Fields valid for a function RTE (else NIL/zero):
1180 * When funcordinality is true, the eref->colnames list includes an alias
1181 * for the ordinality column. The ordinality column is otherwise
1182 * implicit, and must be accounted for "by hand" in places such as
1185 /* list of RangeTblFunction nodes */
1187 /* is this called WITH ORDINALITY? */
1188 bool funcordinality
;
1191 * Fields valid for a TableFunc RTE (else NULL):
1193 TableFunc
*tablefunc
;
1196 * Fields valid for a values RTE (else NIL):
1198 /* list of expression lists */
1202 * Fields valid for a CTE RTE (else NULL/zero):
1204 /* name of the WITH list item */
1206 /* number of query levels up */
1208 /* is this a recursive self-reference? */
1209 bool self_reference
pg_node_attr(query_jumble_ignore
);
1212 * Fields valid for CTE, VALUES, ENR, and TableFunc RTEs (else NIL):
1214 * We need these for CTE RTEs so that the types of self-referential
1215 * columns are well-defined. For VALUES RTEs, storing these explicitly
1216 * saves having to re-determine the info by scanning the values_lists. For
1217 * ENRs, we store the types explicitly here (we could get the information
1218 * from the catalogs if 'relid' was supplied, but we'd still need these
1219 * for TupleDesc-based ENRs, so we might as well always store the type
1220 * info here). For TableFuncs, these fields are redundant with data in
1221 * the TableFunc node, but keeping them here allows some code sharing with
1224 * For ENRs only, we have to consider the possibility of dropped columns.
1225 * A dropped column is included in these lists, but it will have zeroes in
1226 * all three lists (as well as an empty-string entry in eref). Testing
1227 * for zero coltype is the standard way to detect a dropped column.
1229 /* OID list of column type OIDs */
1230 List
*coltypes
pg_node_attr(query_jumble_ignore
);
1231 /* integer list of column typmods */
1232 List
*coltypmods
pg_node_attr(query_jumble_ignore
);
1233 /* OID list of column collation OIDs */
1234 List
*colcollations
pg_node_attr(query_jumble_ignore
);
1237 * Fields valid for ENR RTEs (else NULL/zero):
1239 /* name of ephemeral named relation */
1241 /* estimated or actual from caller */
1242 Cardinality enrtuples
pg_node_attr(query_jumble_ignore
);
1245 * Fields valid for a GROUP RTE (else NIL):
1247 /* list of grouping expressions */
1248 List
*groupexprs
pg_node_attr(query_jumble_ignore
);
1251 * Fields valid in all RTEs:
1253 /* was LATERAL specified? */
1254 bool lateral
pg_node_attr(query_jumble_ignore
);
1255 /* present in FROM clause? */
1256 bool inFromCl
pg_node_attr(query_jumble_ignore
);
1257 /* security barrier quals to apply, if any */
1258 List
*securityQuals
pg_node_attr(query_jumble_ignore
);
1263 * Per-relation information for permission checking. Added to the Query
1264 * node by the parser when adding the corresponding RTE to the query
1265 * range table and subsequently editorialized on by the rewriter if
1266 * needed after rule expansion.
1268 * Only the relations directly mentioned in the query are checked for
1269 * access permissions by the core executor, so only their RTEPermissionInfos
1270 * are present in the Query. However, extensions may want to check inheritance
1271 * children too, depending on the value of rte->inh, so it's copied in 'inh'
1272 * for their perusal.
1274 * requiredPerms and checkAsUser specify run-time access permissions checks
1275 * to be performed at query startup. The user must have *all* of the
1276 * permissions that are OR'd together in requiredPerms (never 0!). If
1277 * checkAsUser is not zero, then do the permissions checks using the access
1278 * rights of that user, not the current effective user ID. (This allows rules
1279 * to act as setuid gateways.)
1281 * For SELECT/INSERT/UPDATE permissions, if the user doesn't have table-wide
1282 * permissions then it is sufficient to have the permissions on all columns
1283 * identified in selectedCols (for SELECT) and/or insertedCols and/or
1284 * updatedCols (INSERT with ON CONFLICT DO UPDATE may have all 3).
1285 * selectedCols, insertedCols and updatedCols are bitmapsets, which cannot have
1286 * negative integer members, so we subtract FirstLowInvalidHeapAttributeNumber
1287 * from column numbers before storing them in these fields. A whole-row Var
1288 * reference is represented by setting the bit for InvalidAttrNumber.
1290 * updatedCols is also used in some other places, for example, to determine
1291 * which triggers to fire and in FDWs to know which changed columns they need
1294 typedef struct RTEPermissionInfo
1298 Oid relid
; /* relation OID */
1299 bool inh
; /* separately check inheritance children? */
1300 AclMode requiredPerms
; /* bitmask of required access permissions */
1301 Oid checkAsUser
; /* if valid, check access as this role */
1302 Bitmapset
*selectedCols
; /* columns needing SELECT permission */
1303 Bitmapset
*insertedCols
; /* columns needing INSERT permission */
1304 Bitmapset
*updatedCols
; /* columns needing UPDATE permission */
1305 } RTEPermissionInfo
;
1308 * RangeTblFunction -
1309 * RangeTblEntry subsidiary data for one function in a FUNCTION RTE.
1311 * If the function had a column definition list (required for an
1312 * otherwise-unspecified RECORD result), funccolnames lists the names given
1313 * in the definition list, funccoltypes lists their declared column types,
1314 * funccoltypmods lists their typmods, funccolcollations their collations.
1315 * Otherwise, those fields are NIL.
1317 * Notice we don't attempt to store info about the results of functions
1318 * returning named composite types, because those can change from time to
1319 * time. We do however remember how many columns we thought the type had
1320 * (including dropped columns!), so that we can successfully ignore any
1321 * columns added after the query was parsed.
1323 * The query jumbling only needs to track the function expression.
1325 typedef struct RangeTblFunction
1329 Node
*funcexpr
; /* expression tree for func call */
1330 /* number of columns it contributes to RTE */
1331 int funccolcount
pg_node_attr(query_jumble_ignore
);
1332 /* These fields record the contents of a column definition list, if any: */
1333 /* column names (list of String) */
1334 List
*funccolnames
pg_node_attr(query_jumble_ignore
);
1335 /* OID list of column type OIDs */
1336 List
*funccoltypes
pg_node_attr(query_jumble_ignore
);
1337 /* integer list of column typmods */
1338 List
*funccoltypmods
pg_node_attr(query_jumble_ignore
);
1339 /* OID list of column collation OIDs */
1340 List
*funccolcollations
pg_node_attr(query_jumble_ignore
);
1342 /* This is set during planning for use by the executor: */
1343 /* PARAM_EXEC Param IDs affecting this func */
1344 Bitmapset
*funcparams
pg_node_attr(query_jumble_ignore
);
1348 * TableSampleClause - TABLESAMPLE appearing in a transformed FROM clause
1350 * Unlike RangeTableSample, this is a subnode of the relevant RangeTblEntry.
1352 typedef struct TableSampleClause
1355 Oid tsmhandler
; /* OID of the tablesample handler function */
1356 List
*args
; /* tablesample argument expression(s) */
1357 Expr
*repeatable
; /* REPEATABLE expression, or NULL if none */
1358 } TableSampleClause
;
1362 * representation of WITH CHECK OPTION checks to be applied to new tuples
1363 * when inserting/updating an auto-updatable view, or RLS WITH CHECK
1364 * policies to be applied when inserting/updating a relation with RLS.
1366 typedef enum WCOKind
1368 WCO_VIEW_CHECK
, /* WCO on an auto-updatable view */
1369 WCO_RLS_INSERT_CHECK
, /* RLS INSERT WITH CHECK policy */
1370 WCO_RLS_UPDATE_CHECK
, /* RLS UPDATE WITH CHECK policy */
1371 WCO_RLS_CONFLICT_CHECK
, /* RLS ON CONFLICT DO UPDATE USING policy */
1372 WCO_RLS_MERGE_UPDATE_CHECK
, /* RLS MERGE UPDATE USING policy */
1373 WCO_RLS_MERGE_DELETE_CHECK
, /* RLS MERGE DELETE USING policy */
1376 typedef struct WithCheckOption
1379 WCOKind kind
; /* kind of WCO */
1380 char *relname
; /* name of relation that specified the WCO */
1381 char *polname
; /* name of RLS policy being checked */
1382 Node
*qual
; /* constraint qual to check */
1383 bool cascaded
; /* true for a cascaded WCO on a view */
1388 * representation of ORDER BY, GROUP BY, PARTITION BY,
1389 * DISTINCT, DISTINCT ON items
1391 * You might think that ORDER BY is only interested in defining ordering,
1392 * and GROUP/DISTINCT are only interested in defining equality. However,
1393 * one way to implement grouping is to sort and then apply a "uniq"-like
1394 * filter. So it's also interesting to keep track of possible sort operators
1395 * for GROUP/DISTINCT, and in particular to try to sort for the grouping
1396 * in a way that will also yield a requested ORDER BY ordering. So we need
1397 * to be able to compare ORDER BY and GROUP/DISTINCT lists, which motivates
1398 * the decision to give them the same representation.
1400 * tleSortGroupRef must match ressortgroupref of exactly one entry of the
1401 * query's targetlist; that is the expression to be sorted or grouped by.
1402 * eqop is the OID of the equality operator.
1403 * sortop is the OID of the ordering operator (a "<" or ">" operator),
1404 * or InvalidOid if not available.
1405 * nulls_first means about what you'd expect. If sortop is InvalidOid
1406 * then nulls_first is meaningless and should be set to false.
1407 * hashable is true if eqop is hashable (note this condition also depends
1408 * on the datatype of the input expression).
1410 * In an ORDER BY item, all fields must be valid. (The eqop isn't essential
1411 * here, but it's cheap to get it along with the sortop, and requiring it
1412 * to be valid eases comparisons to grouping items.) Note that this isn't
1413 * actually enough information to determine an ordering: if the sortop is
1414 * collation-sensitive, a collation OID is needed too. We don't store the
1415 * collation in SortGroupClause because it's not available at the time the
1416 * parser builds the SortGroupClause; instead, consult the exposed collation
1417 * of the referenced targetlist expression to find out what it is.
1419 * In a grouping item, eqop must be valid. If the eqop is a btree equality
1420 * operator, then sortop should be set to a compatible ordering operator.
1421 * We prefer to set eqop/sortop/nulls_first to match any ORDER BY item that
1422 * the query presents for the same tlist item. If there is none, we just
1423 * use the default ordering op for the datatype.
1425 * If the tlist item's type has a hash opclass but no btree opclass, then
1426 * we will set eqop to the hash equality operator, sortop to InvalidOid,
1427 * and nulls_first to false. A grouping item of this kind can only be
1428 * implemented by hashing, and of course it'll never match an ORDER BY item.
1430 * The hashable flag is provided since we generally have the requisite
1431 * information readily available when the SortGroupClause is constructed,
1432 * and it's relatively expensive to get it again later. Note there is no
1433 * need for a "sortable" flag since OidIsValid(sortop) serves the purpose.
1435 * A query might have both ORDER BY and DISTINCT (or DISTINCT ON) clauses.
1436 * In SELECT DISTINCT, the distinctClause list is as long or longer than the
1437 * sortClause list, while in SELECT DISTINCT ON it's typically shorter.
1438 * The two lists must match up to the end of the shorter one --- the parser
1439 * rearranges the distinctClause if necessary to make this true. (This
1440 * restriction ensures that only one sort step is needed to both satisfy the
1441 * ORDER BY and set up for the Unique step. This is semantically necessary
1442 * for DISTINCT ON, and presents no real drawback for DISTINCT.)
1444 typedef struct SortGroupClause
1447 Index tleSortGroupRef
; /* reference into targetlist */
1448 Oid eqop
; /* the equality operator ('=' op) */
1449 Oid sortop
; /* the ordering operator ('<' op), or 0 */
1450 bool reverse_sort
; /* is sortop a "greater than" operator? */
1451 bool nulls_first
; /* do NULLs come before normal values? */
1452 /* can eqop be implemented by hashing? */
1453 bool hashable
pg_node_attr(query_jumble_ignore
);
1458 * representation of CUBE, ROLLUP and GROUPING SETS clauses
1460 * In a Query with grouping sets, the groupClause contains a flat list of
1461 * SortGroupClause nodes for each distinct expression used. The actual
1462 * structure of the GROUP BY clause is given by the groupingSets tree.
1464 * In the raw parser output, GroupingSet nodes (of all types except SIMPLE
1465 * which is not used) are potentially mixed in with the expressions in the
1466 * groupClause of the SelectStmt. (An expression can't contain a GroupingSet,
1467 * but a list may mix GroupingSet and expression nodes.) At this stage, the
1468 * content of each node is a list of expressions, some of which may be RowExprs
1469 * which represent sublists rather than actual row constructors, and nested
1470 * GroupingSet nodes where legal in the grammar. The structure directly
1471 * reflects the query syntax.
1473 * In parse analysis, the transformed expressions are used to build the tlist
1474 * and groupClause list (of SortGroupClause nodes), and the groupingSets tree
1475 * is eventually reduced to a fixed format:
1477 * EMPTY nodes represent (), and obviously have no content
1479 * SIMPLE nodes represent a list of one or more expressions to be treated as an
1480 * atom by the enclosing structure; the content is an integer list of
1481 * ressortgroupref values (see SortGroupClause)
1483 * CUBE and ROLLUP nodes contain a list of one or more SIMPLE nodes.
1485 * SETS nodes contain a list of EMPTY, SIMPLE, CUBE or ROLLUP nodes, but after
1486 * parse analysis they cannot contain more SETS nodes; enough of the syntactic
1487 * transforms of the spec have been applied that we no longer have arbitrarily
1488 * deep nesting (though we still preserve the use of cube/rollup).
1490 * Note that if the groupingSets tree contains no SIMPLE nodes (only EMPTY
1491 * nodes at the leaves), then the groupClause will be empty, but this is still
1492 * an aggregation query (similar to using aggs or HAVING without GROUP BY).
1494 * As an example, the following clause:
1496 * GROUP BY GROUPING SETS ((a,b), CUBE(c,(d,e)))
1498 * looks like this after raw parsing:
1500 * SETS( RowExpr(a,b) , CUBE( c, RowExpr(d,e) ) )
1502 * and parse analysis converts it to:
1504 * SETS( SIMPLE(1,2), CUBE( SIMPLE(3), SIMPLE(4,5) ) )
1506 typedef enum GroupingSetKind
1509 GROUPING_SET_SIMPLE
,
1510 GROUPING_SET_ROLLUP
,
1515 typedef struct GroupingSet
1518 GroupingSetKind kind
pg_node_attr(query_jumble_ignore
);
1525 * transformed representation of WINDOW and OVER clauses
1527 * A parsed Query's windowClause list contains these structs. "name" is set
1528 * if the clause originally came from WINDOW, and is NULL if it originally
1529 * was an OVER clause (but note that we collapse out duplicate OVERs).
1530 * partitionClause and orderClause are lists of SortGroupClause structs.
1531 * partitionClause is sanitized by the query planner to remove any columns or
1532 * expressions belonging to redundant PathKeys.
1533 * If we have RANGE with offset PRECEDING/FOLLOWING, the semantics of that are
1534 * specified by startInRangeFunc/inRangeColl/inRangeAsc/inRangeNullsFirst
1535 * for the start offset, or endInRangeFunc/inRange* for the end offset.
1536 * winref is an ID number referenced by WindowFunc nodes; it must be unique
1537 * among the members of a Query's windowClause list.
1538 * When refname isn't null, the partitionClause is always copied from there;
1539 * the orderClause might or might not be copied (see copiedOrder); the framing
1540 * options are never copied, per spec.
1542 * The information relevant for the query jumbling is the partition clause
1543 * type and its bounds.
1545 typedef struct WindowClause
1548 /* window name (NULL in an OVER clause) */
1549 char *name
pg_node_attr(query_jumble_ignore
);
1550 /* referenced window name, if any */
1551 char *refname
pg_node_attr(query_jumble_ignore
);
1552 List
*partitionClause
; /* PARTITION BY list */
1555 int frameOptions
; /* frame_clause options, see WindowDef */
1556 Node
*startOffset
; /* expression for starting bound, if any */
1557 Node
*endOffset
; /* expression for ending bound, if any */
1558 /* in_range function for startOffset */
1559 Oid startInRangeFunc
pg_node_attr(query_jumble_ignore
);
1560 /* in_range function for endOffset */
1561 Oid endInRangeFunc
pg_node_attr(query_jumble_ignore
);
1562 /* collation for in_range tests */
1563 Oid inRangeColl
pg_node_attr(query_jumble_ignore
);
1564 /* use ASC sort order for in_range tests? */
1565 bool inRangeAsc
pg_node_attr(query_jumble_ignore
);
1566 /* nulls sort first for in_range tests? */
1567 bool inRangeNullsFirst
pg_node_attr(query_jumble_ignore
);
1568 Index winref
; /* ID referenced by window functions */
1569 /* did we copy orderClause from refname? */
1570 bool copiedOrder
pg_node_attr(query_jumble_ignore
);
1575 * parser output representation of FOR [KEY] UPDATE/SHARE clauses
1577 * Query.rowMarks contains a separate RowMarkClause node for each relation
1578 * identified as a FOR [KEY] UPDATE/SHARE target. If one of these clauses
1579 * is applied to a subquery, we generate RowMarkClauses for all normal and
1580 * subquery rels in the subquery, but they are marked pushedDown = true to
1581 * distinguish them from clauses that were explicitly written at this query
1582 * level. Also, Query.hasForUpdate tells whether there were explicit FOR
1583 * UPDATE/SHARE/KEY SHARE clauses in the current query level.
1585 typedef struct RowMarkClause
1588 Index rti
; /* range table index of target relation */
1589 LockClauseStrength strength
;
1590 LockWaitPolicy waitPolicy
; /* NOWAIT and SKIP LOCKED */
1591 bool pushedDown
; /* pushed down from higher query level? */
1596 * representation of WITH clause
1598 * Note: WithClause does not propagate into the Query representation;
1599 * but CommonTableExpr does.
1601 typedef struct WithClause
1604 List
*ctes
; /* list of CommonTableExprs */
1605 bool recursive
; /* true = WITH RECURSIVE */
1606 ParseLoc location
; /* token location, or -1 if unknown */
1611 * ON CONFLICT unique index inference clause
1613 * Note: InferClause does not propagate into the Query representation.
1615 typedef struct InferClause
1618 List
*indexElems
; /* IndexElems to infer unique index */
1619 Node
*whereClause
; /* qualification (partial-index predicate) */
1620 char *conname
; /* Constraint name, or NULL if unnamed */
1621 ParseLoc location
; /* token location, or -1 if unknown */
1625 * OnConflictClause -
1626 * representation of ON CONFLICT clause
1628 * Note: OnConflictClause does not propagate into the Query representation.
1630 typedef struct OnConflictClause
1633 OnConflictAction action
; /* DO NOTHING or UPDATE? */
1634 InferClause
*infer
; /* Optional index inference clause */
1635 List
*targetList
; /* the target list (of ResTarget) */
1636 Node
*whereClause
; /* qualifications */
1637 ParseLoc location
; /* token location, or -1 if unknown */
1642 * representation of WITH list element
1645 typedef enum CTEMaterialize
1647 CTEMaterializeDefault
, /* no option specified */
1648 CTEMaterializeAlways
, /* MATERIALIZED */
1649 CTEMaterializeNever
, /* NOT MATERIALIZED */
1652 typedef struct CTESearchClause
1655 List
*search_col_list
;
1656 bool search_breadth_first
;
1657 char *search_seq_column
;
1661 typedef struct CTECycleClause
1664 List
*cycle_col_list
;
1665 char *cycle_mark_column
;
1666 Node
*cycle_mark_value
;
1667 Node
*cycle_mark_default
;
1668 char *cycle_path_column
;
1670 /* These fields are set during parse analysis: */
1671 Oid cycle_mark_type
; /* common type of _value and _default */
1672 int cycle_mark_typmod
;
1673 Oid cycle_mark_collation
;
1674 Oid cycle_mark_neop
; /* <> operator for type */
1677 typedef struct CommonTableExpr
1682 * Query name (never qualified). The string name is included in the query
1683 * jumbling because RTE_CTE RTEs need it.
1686 /* optional list of column names */
1687 List
*aliascolnames
pg_node_attr(query_jumble_ignore
);
1688 CTEMaterialize ctematerialized
; /* is this an optimization fence? */
1689 /* SelectStmt/InsertStmt/etc before parse analysis, Query afterwards: */
1690 Node
*ctequery
; /* the CTE's subquery */
1691 CTESearchClause
*search_clause
pg_node_attr(query_jumble_ignore
);
1692 CTECycleClause
*cycle_clause
pg_node_attr(query_jumble_ignore
);
1693 ParseLoc location
; /* token location, or -1 if unknown */
1694 /* These fields are set during parse analysis: */
1695 /* is this CTE actually recursive? */
1696 bool cterecursive
pg_node_attr(query_jumble_ignore
);
1699 * Number of RTEs referencing this CTE (excluding internal
1700 * self-references), irrelevant for query jumbling.
1702 int cterefcount
pg_node_attr(query_jumble_ignore
);
1703 /* list of output column names */
1704 List
*ctecolnames
pg_node_attr(query_jumble_ignore
);
1705 /* OID list of output column type OIDs */
1706 List
*ctecoltypes
pg_node_attr(query_jumble_ignore
);
1707 /* integer list of output column typmods */
1708 List
*ctecoltypmods
pg_node_attr(query_jumble_ignore
);
1709 /* OID list of column collation OIDs */
1710 List
*ctecolcollations
pg_node_attr(query_jumble_ignore
);
1713 /* Convenience macro to get the output tlist of a CTE's query */
1714 #define GetCTETargetList(cte) \
1715 (AssertMacro(IsA((cte)->ctequery, Query)), \
1716 ((Query *) (cte)->ctequery)->commandType == CMD_SELECT ? \
1717 ((Query *) (cte)->ctequery)->targetList : \
1718 ((Query *) (cte)->ctequery)->returningList)
1722 * raw parser representation of a WHEN clause in a MERGE statement
1724 * This is transformed into MergeAction by parse analysis
1726 typedef struct MergeWhenClause
1729 MergeMatchKind matchKind
; /* MATCHED/NOT MATCHED BY SOURCE/TARGET */
1730 CmdType commandType
; /* INSERT/UPDATE/DELETE/DO NOTHING */
1731 OverridingKind override
; /* OVERRIDING clause */
1732 Node
*condition
; /* WHEN conditions (raw parser) */
1733 List
*targetList
; /* INSERT/UPDATE targetlist */
1734 /* the following members are only used in INSERT actions */
1735 List
*values
; /* VALUES to INSERT, or NULL */
1739 * ReturningOptionKind -
1740 * Possible kinds of option in RETURNING WITH(...) list
1742 * Currently, this is used only for specifying OLD/NEW aliases.
1744 typedef enum ReturningOptionKind
1746 RETURNING_OPTION_OLD
, /* specify alias for OLD in RETURNING */
1747 RETURNING_OPTION_NEW
, /* specify alias for NEW in RETURNING */
1748 } ReturningOptionKind
;
1752 * An individual option in the RETURNING WITH(...) list
1754 typedef struct ReturningOption
1757 ReturningOptionKind option
; /* specified option */
1758 char *value
; /* option's value */
1759 ParseLoc location
; /* token location, or -1 if unknown */
1764 * List of RETURNING expressions, together with any WITH(...) options
1766 typedef struct ReturningClause
1769 List
*options
; /* list of ReturningOption elements */
1770 List
*exprs
; /* list of expressions to return */
1774 * TriggerTransition -
1775 * representation of transition row or table naming clause
1777 * Only transition tables are initially supported in the syntax, and only for
1778 * AFTER triggers, but other permutations are accepted by the parser so we can
1779 * give a meaningful message from C code.
1781 typedef struct TriggerTransition
1787 } TriggerTransition
;
1789 /* Nodes for SQL/JSON support */
1793 * representation of JSON output clause (RETURNING type [FORMAT format])
1795 typedef struct JsonOutput
1798 TypeName
*typeName
; /* RETURNING type name, if specified */
1799 JsonReturning
*returning
; /* RETURNING FORMAT clause and type Oids */
1804 * representation of argument from JSON PASSING clause
1806 typedef struct JsonArgument
1809 JsonValueExpr
*val
; /* argument value expression */
1810 char *name
; /* argument name */
1815 * representation of [KEEP|OMIT] QUOTES clause for JSON_QUERY()
1817 typedef enum JsonQuotes
1819 JS_QUOTES_UNSPEC
, /* unspecified */
1820 JS_QUOTES_KEEP
, /* KEEP QUOTES */
1821 JS_QUOTES_OMIT
, /* OMIT QUOTES */
1826 * untransformed representation of function expressions for
1827 * SQL/JSON query functions
1829 typedef struct JsonFuncExpr
1832 JsonExprOp op
; /* expression type */
1833 char *column_name
; /* JSON_TABLE() column name or NULL if this is
1834 * not for a JSON_TABLE() */
1835 JsonValueExpr
*context_item
; /* context item expression */
1836 Node
*pathspec
; /* JSON path specification expression */
1837 List
*passing
; /* list of PASSING clause arguments, if any */
1838 JsonOutput
*output
; /* output clause, if specified */
1839 JsonBehavior
*on_empty
; /* ON EMPTY behavior */
1840 JsonBehavior
*on_error
; /* ON ERROR behavior */
1841 JsonWrapper wrapper
; /* array wrapper behavior (JSON_QUERY only) */
1842 JsonQuotes quotes
; /* omit or keep quotes? (JSON_QUERY only) */
1843 ParseLoc location
; /* token location, or -1 if unknown */
1848 * untransformed specification of JSON path expression with an optional
1851 typedef struct JsonTablePathSpec
1857 ParseLoc name_location
;
1858 ParseLoc location
; /* location of 'string' */
1859 } JsonTablePathSpec
;
1863 * untransformed representation of JSON_TABLE
1865 typedef struct JsonTable
1868 JsonValueExpr
*context_item
; /* context item expression */
1869 JsonTablePathSpec
*pathspec
; /* JSON path specification */
1870 List
*passing
; /* list of PASSING clause arguments, if any */
1871 List
*columns
; /* list of JsonTableColumn */
1872 JsonBehavior
*on_error
; /* ON ERROR behavior */
1873 Alias
*alias
; /* table alias in FROM clause */
1874 bool lateral
; /* does it have LATERAL prefix? */
1875 ParseLoc location
; /* token location, or -1 if unknown */
1879 * JsonTableColumnType -
1880 * enumeration of JSON_TABLE column types
1882 typedef enum JsonTableColumnType
1889 } JsonTableColumnType
;
1893 * untransformed representation of JSON_TABLE column
1895 typedef struct JsonTableColumn
1898 JsonTableColumnType coltype
; /* column type */
1899 char *name
; /* column name */
1900 TypeName
*typeName
; /* column type name */
1901 JsonTablePathSpec
*pathspec
; /* JSON path specification */
1902 JsonFormat
*format
; /* JSON format clause, if specified */
1903 JsonWrapper wrapper
; /* WRAPPER behavior for formatted columns */
1904 JsonQuotes quotes
; /* omit or keep quotes on scalar strings? */
1905 List
*columns
; /* nested columns */
1906 JsonBehavior
*on_empty
; /* ON EMPTY behavior */
1907 JsonBehavior
*on_error
; /* ON ERROR behavior */
1908 ParseLoc location
; /* token location, or -1 if unknown */
1913 * untransformed representation of JSON object key-value pair for
1914 * JSON_OBJECT() and JSON_OBJECTAGG()
1916 typedef struct JsonKeyValue
1919 Expr
*key
; /* key expression */
1920 JsonValueExpr
*value
; /* JSON value expression */
1925 * untransformed representation of JSON()
1927 typedef struct JsonParseExpr
1930 JsonValueExpr
*expr
; /* string expression */
1931 JsonOutput
*output
; /* RETURNING clause, if specified */
1932 bool unique_keys
; /* WITH UNIQUE KEYS? */
1933 ParseLoc location
; /* token location, or -1 if unknown */
1938 * untransformed representation of JSON_SCALAR()
1940 typedef struct JsonScalarExpr
1943 Expr
*expr
; /* scalar expression */
1944 JsonOutput
*output
; /* RETURNING clause, if specified */
1945 ParseLoc location
; /* token location, or -1 if unknown */
1949 * JsonSerializeExpr -
1950 * untransformed representation of JSON_SERIALIZE() function
1952 typedef struct JsonSerializeExpr
1955 JsonValueExpr
*expr
; /* json value expression */
1956 JsonOutput
*output
; /* RETURNING clause, if specified */
1957 ParseLoc location
; /* token location, or -1 if unknown */
1958 } JsonSerializeExpr
;
1961 * JsonObjectConstructor -
1962 * untransformed representation of JSON_OBJECT() constructor
1964 typedef struct JsonObjectConstructor
1967 List
*exprs
; /* list of JsonKeyValue pairs */
1968 JsonOutput
*output
; /* RETURNING clause, if specified */
1969 bool absent_on_null
; /* skip NULL values? */
1970 bool unique
; /* check key uniqueness? */
1971 ParseLoc location
; /* token location, or -1 if unknown */
1972 } JsonObjectConstructor
;
1975 * JsonArrayConstructor -
1976 * untransformed representation of JSON_ARRAY(element,...) constructor
1978 typedef struct JsonArrayConstructor
1981 List
*exprs
; /* list of JsonValueExpr elements */
1982 JsonOutput
*output
; /* RETURNING clause, if specified */
1983 bool absent_on_null
; /* skip NULL elements? */
1984 ParseLoc location
; /* token location, or -1 if unknown */
1985 } JsonArrayConstructor
;
1988 * JsonArrayQueryConstructor -
1989 * untransformed representation of JSON_ARRAY(subquery) constructor
1991 typedef struct JsonArrayQueryConstructor
1994 Node
*query
; /* subquery */
1995 JsonOutput
*output
; /* RETURNING clause, if specified */
1996 JsonFormat
*format
; /* FORMAT clause for subquery, if specified */
1997 bool absent_on_null
; /* skip NULL elements? */
1998 ParseLoc location
; /* token location, or -1 if unknown */
1999 } JsonArrayQueryConstructor
;
2002 * JsonAggConstructor -
2003 * common fields of untransformed representation of
2004 * JSON_ARRAYAGG() and JSON_OBJECTAGG()
2006 typedef struct JsonAggConstructor
2009 JsonOutput
*output
; /* RETURNING clause, if any */
2010 Node
*agg_filter
; /* FILTER clause, if any */
2011 List
*agg_order
; /* ORDER BY clause, if any */
2012 struct WindowDef
*over
; /* OVER clause, if any */
2013 ParseLoc location
; /* token location, or -1 if unknown */
2014 } JsonAggConstructor
;
2018 * untransformed representation of JSON_OBJECTAGG()
2020 typedef struct JsonObjectAgg
2023 JsonAggConstructor
*constructor
; /* common fields */
2024 JsonKeyValue
*arg
; /* object key-value pair */
2025 bool absent_on_null
; /* skip NULL values? */
2026 bool unique
; /* check key uniqueness? */
2031 * untransformed representation of JSON_ARRAYAGG()
2033 typedef struct JsonArrayAgg
2036 JsonAggConstructor
*constructor
; /* common fields */
2037 JsonValueExpr
*arg
; /* array element expression */
2038 bool absent_on_null
; /* skip NULL elements? */
2042 /*****************************************************************************
2043 * Raw Grammar Output Statements
2044 *****************************************************************************/
2047 * RawStmt --- container for any one statement's raw parse tree
2049 * Parse analysis converts a raw parse tree headed by a RawStmt node into
2050 * an analyzed statement headed by a Query node. For optimizable statements,
2051 * the conversion is complex. For utility statements, the parser usually just
2052 * transfers the raw parse tree (sans RawStmt) into the utilityStmt field of
2053 * the Query node, and all the useful work happens at execution time.
2055 * stmt_location/stmt_len identify the portion of the source text string
2056 * containing this raw statement (useful for multi-statement strings).
2058 * This is irrelevant for query jumbling, as this is not used in parsed
2061 typedef struct RawStmt
2063 pg_node_attr(no_query_jumble
)
2066 Node
*stmt
; /* raw parse tree */
2067 ParseLoc stmt_location
; /* start location, or -1 if unknown */
2068 ParseLoc stmt_len
; /* length in bytes; 0 means "rest of string" */
2071 /*****************************************************************************
2072 * Optimizable Statements
2073 *****************************************************************************/
2075 /* ----------------------
2078 * The source expression is represented by SelectStmt for both the
2079 * SELECT and VALUES cases. If selectStmt is NULL, then the query
2080 * is INSERT ... DEFAULT VALUES.
2081 * ----------------------
2083 typedef struct InsertStmt
2086 RangeVar
*relation
; /* relation to insert into */
2087 List
*cols
; /* optional: names of the target columns */
2088 Node
*selectStmt
; /* the source SELECT/VALUES, or NULL */
2089 OnConflictClause
*onConflictClause
; /* ON CONFLICT clause */
2090 ReturningClause
*returningClause
; /* RETURNING clause */
2091 WithClause
*withClause
; /* WITH clause */
2092 OverridingKind override
; /* OVERRIDING clause */
2093 ParseLoc stmt_location
; /* start location, or -1 if unknown */
2094 ParseLoc stmt_len
; /* length in bytes; 0 means "rest of string" */
2097 /* ----------------------
2099 * ----------------------
2101 typedef struct DeleteStmt
2104 RangeVar
*relation
; /* relation to delete from */
2105 List
*usingClause
; /* optional using clause for more tables */
2106 Node
*whereClause
; /* qualifications */
2107 ReturningClause
*returningClause
; /* RETURNING clause */
2108 WithClause
*withClause
; /* WITH clause */
2109 ParseLoc stmt_location
; /* start location, or -1 if unknown */
2110 ParseLoc stmt_len
; /* length in bytes; 0 means "rest of string" */
2113 /* ----------------------
2115 * ----------------------
2117 typedef struct UpdateStmt
2120 RangeVar
*relation
; /* relation to update */
2121 List
*targetList
; /* the target list (of ResTarget) */
2122 Node
*whereClause
; /* qualifications */
2123 List
*fromClause
; /* optional from clause for more tables */
2124 ReturningClause
*returningClause
; /* RETURNING clause */
2125 WithClause
*withClause
; /* WITH clause */
2126 ParseLoc stmt_location
; /* start location, or -1 if unknown */
2127 ParseLoc stmt_len
; /* length in bytes; 0 means "rest of string" */
2130 /* ----------------------
2132 * ----------------------
2134 typedef struct MergeStmt
2137 RangeVar
*relation
; /* target relation to merge into */
2138 Node
*sourceRelation
; /* source relation */
2139 Node
*joinCondition
; /* join condition between source and target */
2140 List
*mergeWhenClauses
; /* list of MergeWhenClause(es) */
2141 ReturningClause
*returningClause
; /* RETURNING clause */
2142 WithClause
*withClause
; /* WITH clause */
2143 ParseLoc stmt_location
; /* start location, or -1 if unknown */
2144 ParseLoc stmt_len
; /* length in bytes; 0 means "rest of string" */
2147 /* ----------------------
2150 * A "simple" SELECT is represented in the output of gram.y by a single
2151 * SelectStmt node; so is a VALUES construct. A query containing set
2152 * operators (UNION, INTERSECT, EXCEPT) is represented by a tree of SelectStmt
2153 * nodes, in which the leaf nodes are component SELECTs and the internal nodes
2154 * represent UNION, INTERSECT, or EXCEPT operators. Using the same node
2155 * type for both leaf and internal nodes allows gram.y to stick ORDER BY,
2156 * LIMIT, etc, clause values into a SELECT statement without worrying
2157 * whether it is a simple or compound SELECT.
2158 * ----------------------
2160 typedef enum SetOperation
2168 typedef struct SelectStmt
2173 * These fields are used only in "leaf" SelectStmts.
2175 List
*distinctClause
; /* NULL, list of DISTINCT ON exprs, or
2176 * lcons(NIL,NIL) for all (SELECT DISTINCT) */
2177 IntoClause
*intoClause
; /* target for SELECT INTO */
2178 List
*targetList
; /* the target list (of ResTarget) */
2179 List
*fromClause
; /* the FROM clause */
2180 Node
*whereClause
; /* WHERE qualification */
2181 List
*groupClause
; /* GROUP BY clauses */
2182 bool groupDistinct
; /* Is this GROUP BY DISTINCT? */
2183 Node
*havingClause
; /* HAVING conditional-expression */
2184 List
*windowClause
; /* WINDOW window_name AS (...), ... */
2187 * In a "leaf" node representing a VALUES list, the above fields are all
2188 * null, and instead this field is set. Note that the elements of the
2189 * sublists are just expressions, without ResTarget decoration. Also note
2190 * that a list element can be DEFAULT (represented as a SetToDefault
2191 * node), regardless of the context of the VALUES list. It's up to parse
2192 * analysis to reject that where not valid.
2194 List
*valuesLists
; /* untransformed list of expression lists */
2197 * These fields are used in both "leaf" SelectStmts and upper-level
2200 List
*sortClause
; /* sort clause (a list of SortBy's) */
2201 Node
*limitOffset
; /* # of result tuples to skip */
2202 Node
*limitCount
; /* # of result tuples to return */
2203 LimitOption limitOption
; /* limit type */
2204 List
*lockingClause
; /* FOR UPDATE (list of LockingClause's) */
2205 WithClause
*withClause
; /* WITH clause */
2208 * These fields are used only in upper-level SelectStmts.
2210 SetOperation op
; /* type of set op */
2211 bool all
; /* ALL specified? */
2212 struct SelectStmt
*larg
; /* left child */
2213 struct SelectStmt
*rarg
; /* right child */
2214 ParseLoc stmt_location
; /* start location, or -1 if unknown */
2215 ParseLoc stmt_len
; /* length in bytes; 0 means "rest of string" */
2216 /* Eventually add fields for CORRESPONDING spec here */
2220 /* ----------------------
2221 * Set Operation node for post-analysis query trees
2223 * After parse analysis, a SELECT with set operations is represented by a
2224 * top-level Query node containing the leaf SELECTs as subqueries in its
2225 * range table. Its setOperations field shows the tree of set operations,
2226 * with leaf SelectStmt nodes replaced by RangeTblRef nodes, and internal
2227 * nodes replaced by SetOperationStmt nodes. Information about the output
2228 * column types is added, too. (Note that the child nodes do not necessarily
2229 * produce these types directly, but we've checked that their output types
2230 * can be coerced to the output column type.) Also, if it's not UNION ALL,
2231 * information about the types' sort/group semantics is provided in the form
2232 * of a SortGroupClause list (same representation as, eg, DISTINCT).
2233 * The resolved common column collations are provided too; but note that if
2234 * it's not UNION ALL, it's okay for a column to not have a common collation,
2235 * so a member of the colCollations list could be InvalidOid even though the
2236 * column has a collatable type.
2237 * ----------------------
2239 typedef struct SetOperationStmt
2242 SetOperation op
; /* type of set op */
2243 bool all
; /* ALL specified? */
2244 Node
*larg
; /* left child */
2245 Node
*rarg
; /* right child */
2246 /* Eventually add fields for CORRESPONDING spec here */
2248 /* Fields derived during parse analysis (irrelevant for query jumbling): */
2249 /* OID list of output column type OIDs */
2250 List
*colTypes
pg_node_attr(query_jumble_ignore
);
2251 /* integer list of output column typmods */
2252 List
*colTypmods
pg_node_attr(query_jumble_ignore
);
2253 /* OID list of output column collation OIDs */
2254 List
*colCollations
pg_node_attr(query_jumble_ignore
);
2255 /* a list of SortGroupClause's */
2256 List
*groupClauses
pg_node_attr(query_jumble_ignore
);
2257 /* groupClauses is NIL if UNION ALL, but must be set otherwise */
2262 * RETURN statement (inside SQL function body)
2264 typedef struct ReturnStmt
2271 /* ----------------------
2272 * PL/pgSQL Assignment Statement
2274 * Like SelectStmt, this is transformed into a SELECT Query.
2275 * However, the targetlist of the result looks more like an UPDATE.
2276 * ----------------------
2278 typedef struct PLAssignStmt
2282 char *name
; /* initial column name */
2283 List
*indirection
; /* subscripts and field names, if any */
2284 int nnames
; /* number of names to use in ColumnRef */
2285 SelectStmt
*val
; /* the PL/pgSQL expression to assign */
2286 ParseLoc location
; /* name's token location, or -1 if unknown */
2290 /*****************************************************************************
2291 * Other Statements (no optimizations required)
2293 * These are not touched by parser/analyze.c except to put them into
2294 * the utilityStmt field of a Query. This is eventually passed to
2295 * ProcessUtility (by-passing rewriting and planning). Some of the
2296 * statements do need attention from parse analysis, and this is
2297 * done by routines in parser/parse_utilcmd.c after ProcessUtility
2298 * receives the command for execution.
2299 * DECLARE CURSOR, EXPLAIN, and CREATE TABLE AS are special cases:
2300 * they contain optimizable statements, which get processed normally
2301 * by parser/analyze.c.
2302 *****************************************************************************/
2305 * When a command can act on several kinds of objects with only one
2306 * parse structure required, use these constants to designate the
2307 * object type. Note that commands typically don't support all the types.
2310 typedef enum ObjectType
2312 OBJECT_ACCESS_METHOD
,
2316 OBJECT_ATTRIBUTE
, /* type's attribute, when distinct from column */
2325 OBJECT_DOMCONSTRAINT
,
2326 OBJECT_EVENT_TRIGGER
,
2329 OBJECT_FOREIGN_SERVER
,
2330 OBJECT_FOREIGN_TABLE
,
2339 OBJECT_PARAMETER_ACL
,
2343 OBJECT_PUBLICATION_NAMESPACE
,
2344 OBJECT_PUBLICATION_REL
,
2350 OBJECT_SUBSCRIPTION
,
2351 OBJECT_STATISTIC_EXT
,
2352 OBJECT_TABCONSTRAINT
,
2357 OBJECT_TSCONFIGURATION
,
2358 OBJECT_TSDICTIONARY
,
2362 OBJECT_USER_MAPPING
,
2366 /* ----------------------
2367 * Create Schema Statement
2369 * NOTE: the schemaElts list contains raw parsetrees for component statements
2370 * of the schema, such as CREATE TABLE, GRANT, etc. These are analyzed and
2371 * executed after the schema itself is created.
2372 * ----------------------
2374 typedef struct CreateSchemaStmt
2377 char *schemaname
; /* the name of the schema to create */
2378 RoleSpec
*authrole
; /* the owner of the created schema */
2379 List
*schemaElts
; /* schema components (list of parsenodes) */
2380 bool if_not_exists
; /* just do nothing if schema already exists? */
2383 typedef enum DropBehavior
2385 DROP_RESTRICT
, /* drop fails if any dependent objects */
2386 DROP_CASCADE
, /* remove dependent objects too */
2389 /* ----------------------
2391 * ----------------------
2393 typedef struct AlterTableStmt
2396 RangeVar
*relation
; /* table to work on */
2397 List
*cmds
; /* list of subcommands */
2398 ObjectType objtype
; /* type of object */
2399 bool missing_ok
; /* skip error if table missing */
2402 typedef enum AlterTableType
2404 AT_AddColumn
, /* add column */
2405 AT_AddColumnToView
, /* implicitly via CREATE OR REPLACE VIEW */
2406 AT_ColumnDefault
, /* alter column default */
2407 AT_CookedColumnDefault
, /* add a pre-cooked column default */
2408 AT_DropNotNull
, /* alter column drop not null */
2409 AT_SetNotNull
, /* alter column set not null */
2410 AT_SetExpression
, /* alter column set expression */
2411 AT_DropExpression
, /* alter column drop expression */
2412 AT_SetStatistics
, /* alter column set statistics */
2413 AT_SetOptions
, /* alter column set ( options ) */
2414 AT_ResetOptions
, /* alter column reset ( options ) */
2415 AT_SetStorage
, /* alter column set storage */
2416 AT_SetCompression
, /* alter column set compression */
2417 AT_DropColumn
, /* drop column */
2418 AT_AddIndex
, /* add index */
2419 AT_ReAddIndex
, /* internal to commands/tablecmds.c */
2420 AT_AddConstraint
, /* add constraint */
2421 AT_ReAddConstraint
, /* internal to commands/tablecmds.c */
2422 AT_ReAddDomainConstraint
, /* internal to commands/tablecmds.c */
2423 AT_AlterConstraint
, /* alter constraint */
2424 AT_ValidateConstraint
, /* validate constraint */
2425 AT_AddIndexConstraint
, /* add constraint using existing index */
2426 AT_DropConstraint
, /* drop constraint */
2427 AT_ReAddComment
, /* internal to commands/tablecmds.c */
2428 AT_AlterColumnType
, /* alter column type */
2429 AT_AlterColumnGenericOptions
, /* alter column OPTIONS (...) */
2430 AT_ChangeOwner
, /* change owner */
2431 AT_ClusterOn
, /* CLUSTER ON */
2432 AT_DropCluster
, /* SET WITHOUT CLUSTER */
2433 AT_SetLogged
, /* SET LOGGED */
2434 AT_SetUnLogged
, /* SET UNLOGGED */
2435 AT_DropOids
, /* SET WITHOUT OIDS */
2436 AT_SetAccessMethod
, /* SET ACCESS METHOD */
2437 AT_SetTableSpace
, /* SET TABLESPACE */
2438 AT_SetRelOptions
, /* SET (...) -- AM specific parameters */
2439 AT_ResetRelOptions
, /* RESET (...) -- AM specific parameters */
2440 AT_ReplaceRelOptions
, /* replace reloption list in its entirety */
2441 AT_EnableTrig
, /* ENABLE TRIGGER name */
2442 AT_EnableAlwaysTrig
, /* ENABLE ALWAYS TRIGGER name */
2443 AT_EnableReplicaTrig
, /* ENABLE REPLICA TRIGGER name */
2444 AT_DisableTrig
, /* DISABLE TRIGGER name */
2445 AT_EnableTrigAll
, /* ENABLE TRIGGER ALL */
2446 AT_DisableTrigAll
, /* DISABLE TRIGGER ALL */
2447 AT_EnableTrigUser
, /* ENABLE TRIGGER USER */
2448 AT_DisableTrigUser
, /* DISABLE TRIGGER USER */
2449 AT_EnableRule
, /* ENABLE RULE name */
2450 AT_EnableAlwaysRule
, /* ENABLE ALWAYS RULE name */
2451 AT_EnableReplicaRule
, /* ENABLE REPLICA RULE name */
2452 AT_DisableRule
, /* DISABLE RULE name */
2453 AT_AddInherit
, /* INHERIT parent */
2454 AT_DropInherit
, /* NO INHERIT parent */
2455 AT_AddOf
, /* OF <type_name> */
2456 AT_DropOf
, /* NOT OF */
2457 AT_ReplicaIdentity
, /* REPLICA IDENTITY */
2458 AT_EnableRowSecurity
, /* ENABLE ROW SECURITY */
2459 AT_DisableRowSecurity
, /* DISABLE ROW SECURITY */
2460 AT_ForceRowSecurity
, /* FORCE ROW SECURITY */
2461 AT_NoForceRowSecurity
, /* NO FORCE ROW SECURITY */
2462 AT_GenericOptions
, /* OPTIONS (...) */
2463 AT_AttachPartition
, /* ATTACH PARTITION */
2464 AT_DetachPartition
, /* DETACH PARTITION */
2465 AT_DetachPartitionFinalize
, /* DETACH PARTITION FINALIZE */
2466 AT_AddIdentity
, /* ADD IDENTITY */
2467 AT_SetIdentity
, /* SET identity column options */
2468 AT_DropIdentity
, /* DROP IDENTITY */
2469 AT_ReAddStatistics
, /* internal to commands/tablecmds.c */
2472 typedef struct ReplicaIdentityStmt
2477 } ReplicaIdentityStmt
;
2479 typedef struct AlterTableCmd
/* one subcommand of an ALTER TABLE */
2482 AlterTableType subtype
; /* Type of table alteration to apply */
2483 char *name
; /* column, constraint, or trigger to act on,
2484 * or tablespace, access method */
2485 int16 num
; /* attribute number for columns referenced by
2488 Node
*def
; /* definition of new column, index,
2489 * constraint, or parent table */
2490 DropBehavior behavior
; /* RESTRICT or CASCADE for DROP cases */
2491 bool missing_ok
; /* skip error if missing? */
2492 bool recurse
; /* exec-time recursion */
2496 /* ----------------------
2498 * ----------------------
2500 typedef struct AlterCollationStmt
2504 } AlterCollationStmt
;
2507 /* ----------------------
2510 * The fields are used in different ways by the different variants of
2512 * ----------------------
2514 typedef struct AlterDomainStmt
2517 char subtype
; /*------------
2518 * T = alter column default
2519 * N = alter column drop not null
2520 * O = alter column set not null
2521 * C = add constraint
2522 * X = drop constraint
2525 List
*typeName
; /* domain to work on */
2526 char *name
; /* column or constraint name to act on */
2527 Node
*def
; /* definition of default or constraint */
2528 DropBehavior behavior
; /* RESTRICT or CASCADE for DROP cases */
2529 bool missing_ok
; /* skip error if missing? */
2533 /* ----------------------
2534 * Grant|Revoke Statement
2535 * ----------------------
2537 typedef enum GrantTargetType
2539 ACL_TARGET_OBJECT
, /* grant on specific named object(s) */
2540 ACL_TARGET_ALL_IN_SCHEMA
, /* grant on all objects in given schema(s) */
2541 ACL_TARGET_DEFAULTS
, /* ALTER DEFAULT PRIVILEGES */
2544 typedef struct GrantStmt
2547 bool is_grant
; /* true = GRANT, false = REVOKE */
2548 GrantTargetType targtype
; /* type of the grant target */
2549 ObjectType objtype
; /* kind of object being operated on */
2550 List
*objects
; /* list of RangeVar nodes, ObjectWithArgs
2551 * nodes, or plain names (as String values) */
2552 List
*privileges
; /* list of AccessPriv nodes */
2553 /* privileges == NIL denotes ALL PRIVILEGES */
2554 List
*grantees
; /* list of RoleSpec nodes */
2555 bool grant_option
; /* grant or revoke grant option */
2557 DropBehavior behavior
; /* drop behavior (for REVOKE) */
2561 * ObjectWithArgs represents a function/procedure/operator name plus parameter
2564 * objargs includes only the types of the input parameters of the object.
2565 * In some contexts, that will be all we have, and it's enough to look up
2566 * objects according to the traditional Postgres rules (i.e., when only input
2567 * arguments matter).
2569 * objfuncargs, if not NIL, carries the full specification of the parameter
2570 * list, including parameter mode annotations.
2572 * Some grammar productions can set args_unspecified = true instead of
2573 * providing parameter info. In this case, lookup will succeed only if
2574 * the object name is unique. Note that otherwise, NIL parameter lists
2575 * mean zero arguments.
2577 typedef struct ObjectWithArgs
2580 List
*objname
; /* qualified name of function/operator */
2581 List
*objargs
; /* list of Typename nodes (input args only) */
2582 List
*objfuncargs
; /* list of FunctionParameter nodes */
2583 bool args_unspecified
; /* argument list was omitted? */
2587 * An access privilege, with optional list of column names
2588 * priv_name == NULL denotes ALL PRIVILEGES (only used with a column list)
2589 * cols == NIL denotes "all columns"
2590 * Note that simple "ALL PRIVILEGES" is represented as a NIL list, not
2591 * an AccessPriv with both fields null.
2593 typedef struct AccessPriv
2596 char *priv_name
; /* string name of privilege */
2597 List
*cols
; /* list of String */
2600 /* ----------------------
2601 * Grant/Revoke Role Statement
2603 * Note: because of the parsing ambiguity with the GRANT <privileges>
2604 * statement, granted_roles is a list of AccessPriv; the execution code
2605 * should complain if any column lists appear. grantee_roles is a list
2606 * of role names, as String values.
2607 * ----------------------
2609 typedef struct GrantRoleStmt
2612 List
*granted_roles
; /* list of roles to be granted/revoked */
2613 List
*grantee_roles
; /* list of member roles to add/delete */
2614 bool is_grant
; /* true = GRANT, false = REVOKE */
2615 List
*opt
; /* options e.g. WITH GRANT OPTION */
2616 RoleSpec
*grantor
; /* set grantor to other than current role */
2617 DropBehavior behavior
; /* drop behavior (for REVOKE) */
2620 /* ----------------------
2621 * Alter Default Privileges Statement
2622 * ----------------------
2624 typedef struct AlterDefaultPrivilegesStmt
2627 List
*options
; /* list of DefElem */
2628 GrantStmt
*action
; /* GRANT/REVOKE action (with objects=NIL) */
2629 } AlterDefaultPrivilegesStmt
;
2631 /* ----------------------
2634 * We support "COPY relation FROM file", "COPY relation TO file", and
2635 * "COPY (query) TO file". In any given CopyStmt, exactly one of "relation"
2636 * and "query" must be non-NULL.
2637 * ----------------------
2639 typedef struct CopyStmt
2642 RangeVar
*relation
; /* the relation to copy */
2643 Node
*query
; /* the query (SELECT or DML statement with
2644 * RETURNING) to copy, as a raw parse tree */
2645 List
*attlist
; /* List of column names (as Strings), or NIL
2646 * for all columns */
2647 bool is_from
; /* TO or FROM */
2648 bool is_program
; /* is 'filename' a program to popen? */
2649 char *filename
; /* filename, or NULL for STDIN/STDOUT */
2650 List
*options
; /* List of DefElem nodes */
2651 Node
*whereClause
; /* WHERE condition (or NULL) */
2654 /* ----------------------
2655 * SET Statement (includes RESET)
2657 * "SET var TO DEFAULT" and "RESET var" are semantically equivalent, but we
2658 * preserve the distinction in VariableSetKind for CreateCommandTag().
2659 * ----------------------
2661 typedef enum VariableSetKind
2663 VAR_SET_VALUE
, /* SET var = value */
2664 VAR_SET_DEFAULT
, /* SET var TO DEFAULT */
2665 VAR_SET_CURRENT
, /* SET var FROM CURRENT */
2666 VAR_SET_MULTI
, /* special case for SET TRANSACTION ... */
2667 VAR_RESET
, /* RESET var */
2668 VAR_RESET_ALL
, /* RESET ALL */
2671 typedef struct VariableSetStmt
2673 pg_node_attr(custom_query_jumble
)
2676 VariableSetKind kind
;
2677 /* variable to be set */
2679 /* List of A_Const nodes */
2683 * True if arguments should be accounted for in query jumbling. We use a
2684 * separate flag rather than query_jumble_ignore on "args" as several
2685 * grammar flavors of SET rely on a list of values that are parsed
2686 * directly from the grammar's keywords.
2691 /* token location, or -1 if unknown */
2692 ParseLoc location
pg_node_attr(query_jumble_location
);
2695 /* ----------------------
2697 * ----------------------
2699 typedef struct VariableShowStmt
2705 /* ----------------------
2706 * Create Table Statement
2708 * NOTE: in the raw gram.y output, ColumnDef and Constraint nodes are
2709 * intermixed in tableElts, and constraints and nnconstraints are NIL. After
2710 * parse analysis, tableElts contains just ColumnDefs, nnconstraints contains
2711 * Constraint nodes of CONSTR_NOTNULL type from various sources, and
2712 * constraints contains just CONSTR_CHECK Constraint nodes.
2713 * ----------------------
2716 typedef struct CreateStmt
2719 RangeVar
*relation
; /* relation to create */
2720 List
*tableElts
; /* column definitions (list of ColumnDef) */
2721 List
*inhRelations
; /* relations to inherit from (list of
2723 PartitionBoundSpec
*partbound
; /* FOR VALUES clause */
2724 PartitionSpec
*partspec
; /* PARTITION BY clause */
2725 TypeName
*ofTypename
; /* OF typename */
2726 List
*constraints
; /* constraints (list of Constraint nodes) */
2727 List
*nnconstraints
; /* NOT NULL constraints (ditto) */
2728 List
*options
; /* options from WITH clause */
2729 OnCommitAction oncommit
; /* what do we do at COMMIT? */
2730 char *tablespacename
; /* table space to use, or NULL */
2731 char *accessMethod
; /* table access method */
2732 bool if_not_exists
; /* just do nothing if it already exists? */
2736 * Definitions for constraints in CreateStmt
2738 * Note that column defaults are treated as a type of constraint,
2739 * even though that's a bit odd semantically.
2741 * For constraints that use expressions (CONSTR_CHECK, CONSTR_DEFAULT)
2742 * we may have the expression in either "raw" form (an untransformed
2743 * parse tree) or "cooked" form (the nodeToString representation of
2744 * an executable expression tree), depending on how this Constraint
2745 * node was created (by parsing, or by inheritance from an existing
2746 * relation). We should never have both in the same node!
2748 * FKCONSTR_ACTION_xxx values are stored into pg_constraint.confupdtype
2749 * and pg_constraint.confdeltype columns; FKCONSTR_MATCH_xxx values are
2750 * stored into pg_constraint.confmatchtype. Changing the code values may
2751 * require an initdb!
2753 * If skip_validation is true then we skip checking that the existing rows
2754 * in the table satisfy the constraint, and just install the catalog entries
2755 * for the constraint. A new FK constraint is marked as valid iff
2756 * initially_valid is true. (Usually skip_validation and initially_valid
2757 * are inverses, but we can set both true if the table is known empty.)
2759 * Constraint attributes (DEFERRABLE etc) are initially represented as
2760 * separate Constraint nodes for simplicity of parsing. parse_utilcmd.c makes
2761 * a pass through the constraints list to insert the info into the appropriate
2766 typedef enum ConstrType
/* types of constraints */
2768 CONSTR_NULL
, /* not standard SQL, but a lot of people
2779 CONSTR_ATTR_DEFERRABLE
, /* attributes for previous constraint node */
2780 CONSTR_ATTR_NOT_DEFERRABLE
,
2781 CONSTR_ATTR_DEFERRED
,
2782 CONSTR_ATTR_IMMEDIATE
,
2783 CONSTR_ATTR_ENFORCED
,
2784 CONSTR_ATTR_NOT_ENFORCED
,
2787 /* Foreign key action codes */
2788 #define FKCONSTR_ACTION_NOACTION 'a'
2789 #define FKCONSTR_ACTION_RESTRICT 'r'
2790 #define FKCONSTR_ACTION_CASCADE 'c'
2791 #define FKCONSTR_ACTION_SETNULL 'n'
2792 #define FKCONSTR_ACTION_SETDEFAULT 'd'
2794 /* Foreign key matchtype codes */
2795 #define FKCONSTR_MATCH_FULL 'f'
2796 #define FKCONSTR_MATCH_PARTIAL 'p'
2797 #define FKCONSTR_MATCH_SIMPLE 's'
2799 typedef struct Constraint
2802 ConstrType contype
; /* see above */
2803 char *conname
; /* Constraint name, or NULL if unnamed */
2804 bool deferrable
; /* DEFERRABLE? */
2805 bool initdeferred
; /* INITIALLY DEFERRED? */
2806 bool is_enforced
; /* enforced constraint? */
2807 bool skip_validation
; /* skip validation of existing rows? */
2808 bool initially_valid
; /* mark the new constraint as valid? */
2809 bool is_no_inherit
; /* is constraint non-inheritable? */
2810 Node
*raw_expr
; /* CHECK or DEFAULT expression, as
2811 * untransformed parse tree */
2812 char *cooked_expr
; /* CHECK or DEFAULT expression, as
2813 * nodeToString representation */
2814 char generated_when
; /* ALWAYS or BY DEFAULT */
2815 bool nulls_not_distinct
; /* null treatment for UNIQUE constraints */
2816 List
*keys
; /* String nodes naming referenced key
2817 * column(s); for UNIQUE/PK/NOT NULL */
2818 bool without_overlaps
; /* WITHOUT OVERLAPS specified */
2819 List
*including
; /* String nodes naming referenced nonkey
2820 * column(s); for UNIQUE/PK */
2821 List
*exclusions
; /* list of (IndexElem, operator name) pairs;
2822 * for exclusion constraints */
2823 List
*options
; /* options from WITH clause */
2824 char *indexname
; /* existing index to use; otherwise NULL */
2825 char *indexspace
; /* index tablespace; NULL for default */
2826 bool reset_default_tblspc
; /* reset default_tablespace prior to
2827 * creating the index */
2828 char *access_method
; /* index access method; NULL for default */
2829 Node
*where_clause
; /* partial index predicate */
2831 /* Fields used for FOREIGN KEY constraints: */
2832 RangeVar
*pktable
; /* Primary key table */
2833 List
*fk_attrs
; /* Attributes of foreign key */
2834 List
*pk_attrs
; /* Corresponding attrs in PK table */
2835 bool fk_with_period
; /* Last attribute of FK uses PERIOD */
2836 bool pk_with_period
; /* Last attribute of PK uses PERIOD */
2837 char fk_matchtype
; /* FULL, PARTIAL, SIMPLE */
2838 char fk_upd_action
; /* ON UPDATE action */
2839 char fk_del_action
; /* ON DELETE action */
2840 List
*fk_del_set_cols
; /* ON DELETE SET NULL/DEFAULT (col1, col2) */
2841 List
*old_conpfeqop
; /* pg_constraint.conpfeqop of my former self */
2842 Oid old_pktable_oid
; /* pg_constraint.confrelid of my former
2845 ParseLoc location
; /* token location, or -1 if unknown */
2848 /* ----------------------
2849 * Create/Drop Table Space Statements
2850 * ----------------------
2853 typedef struct CreateTableSpaceStmt
2856 char *tablespacename
;
2860 } CreateTableSpaceStmt
;
2862 typedef struct DropTableSpaceStmt
2865 char *tablespacename
;
2866 bool missing_ok
; /* skip error if missing? */
2867 } DropTableSpaceStmt
;
2869 typedef struct AlterTableSpaceOptionsStmt
2872 char *tablespacename
;
2875 } AlterTableSpaceOptionsStmt
;
2877 typedef struct AlterTableMoveAllStmt
2880 char *orig_tablespacename
;
2881 ObjectType objtype
; /* Object type to move */
2882 List
*roles
; /* List of roles to move objects of */
2883 char *new_tablespacename
;
2885 } AlterTableMoveAllStmt
;
2887 /* ----------------------
2888 * Create/Alter Extension Statements
2889 * ----------------------
2892 typedef struct CreateExtensionStmt
2896 bool if_not_exists
; /* just do nothing if it already exists? */
2897 List
*options
; /* List of DefElem nodes */
2898 } CreateExtensionStmt
;
2900 /* Only used for ALTER EXTENSION UPDATE; later might need an action field */
2901 typedef struct AlterExtensionStmt
2905 List
*options
; /* List of DefElem nodes */
2906 } AlterExtensionStmt
;
2908 typedef struct AlterExtensionContentsStmt
2911 char *extname
; /* Extension's name */
2912 int action
; /* +1 = add object, -1 = drop object */
2913 ObjectType objtype
; /* Object's type */
2914 Node
*object
; /* Qualified name of the object */
2915 } AlterExtensionContentsStmt
;
2917 /* ----------------------
2918 * Create/Alter FOREIGN DATA WRAPPER Statements
2919 * ----------------------
2922 typedef struct CreateFdwStmt
2925 char *fdwname
; /* foreign-data wrapper name */
2926 List
*func_options
; /* HANDLER/VALIDATOR options */
2927 List
*options
; /* generic options to FDW */
2930 typedef struct AlterFdwStmt
2933 char *fdwname
; /* foreign-data wrapper name */
2934 List
*func_options
; /* HANDLER/VALIDATOR options */
2935 List
*options
; /* generic options to FDW */
2938 /* ----------------------
2939 * Create/Alter FOREIGN SERVER Statements
2940 * ----------------------
2943 typedef struct CreateForeignServerStmt
2946 char *servername
; /* server name */
2947 char *servertype
; /* optional server type */
2948 char *version
; /* optional server version */
2949 char *fdwname
; /* FDW name */
2950 bool if_not_exists
; /* just do nothing if it already exists? */
2951 List
*options
; /* generic options to server */
2952 } CreateForeignServerStmt
;
2954 typedef struct AlterForeignServerStmt
2957 char *servername
; /* server name */
2958 char *version
; /* optional server version */
2959 List
*options
; /* generic options to server */
2960 bool has_version
; /* version specified */
2961 } AlterForeignServerStmt
;
2963 /* ----------------------
2964 * Create FOREIGN TABLE Statement
2965 * ----------------------
2968 typedef struct CreateForeignTableStmt
2973 } CreateForeignTableStmt
;
2975 /* ----------------------
2976 * Create/Drop USER MAPPING Statements
2977 * ----------------------
2980 typedef struct CreateUserMappingStmt
2983 RoleSpec
*user
; /* user role */
2984 char *servername
; /* server name */
2985 bool if_not_exists
; /* just do nothing if it already exists? */
2986 List
*options
; /* generic options to server */
2987 } CreateUserMappingStmt
;
2989 typedef struct AlterUserMappingStmt
2992 RoleSpec
*user
; /* user role */
2993 char *servername
; /* server name */
2994 List
*options
; /* generic options to server */
2995 } AlterUserMappingStmt
;
2997 typedef struct DropUserMappingStmt
3000 RoleSpec
*user
; /* user role */
3001 char *servername
; /* server name */
3002 bool missing_ok
; /* ignore missing mappings */
3003 } DropUserMappingStmt
;
3005 /* ----------------------
3006 * Import Foreign Schema Statement
3007 * ----------------------
3010 typedef enum ImportForeignSchemaType
3012 FDW_IMPORT_SCHEMA_ALL
, /* all relations wanted */
3013 FDW_IMPORT_SCHEMA_LIMIT_TO
, /* include only listed tables in import */
3014 FDW_IMPORT_SCHEMA_EXCEPT
, /* exclude listed tables from import */
3015 } ImportForeignSchemaType
;
3017 typedef struct ImportForeignSchemaStmt
3020 char *server_name
; /* FDW server name */
3021 char *remote_schema
; /* remote schema name to query */
3022 char *local_schema
; /* local schema to create objects in */
3023 ImportForeignSchemaType list_type
; /* type of table list */
3024 List
*table_list
; /* List of RangeVar */
3025 List
*options
; /* list of options to pass to FDW */
3026 } ImportForeignSchemaStmt
;
3028 /*----------------------
3029 * Create POLICY Statement
3030 *----------------------
3032 typedef struct CreatePolicyStmt
3035 char *policy_name
; /* Policy's name */
3036 RangeVar
*table
; /* the table name the policy applies to */
3037 char *cmd_name
; /* the command name the policy applies to */
3038 bool permissive
; /* restrictive or permissive policy */
3039 List
*roles
; /* the roles associated with the policy */
3040 Node
*qual
; /* the policy's condition */
3041 Node
*with_check
; /* the policy's WITH CHECK condition. */
3044 /*----------------------
3045 * Alter POLICY Statement
3046 *----------------------
3048 typedef struct AlterPolicyStmt
3051 char *policy_name
; /* Policy's name */
3052 RangeVar
*table
; /* the table name the policy applies to */
3053 List
*roles
; /* the roles associated with the policy */
3054 Node
*qual
; /* the policy's condition */
3055 Node
*with_check
; /* the policy's WITH CHECK condition. */
3058 /*----------------------
3059 * Create ACCESS METHOD Statement
3060 *----------------------
3062 typedef struct CreateAmStmt
3065 char *amname
; /* access method name */
3066 List
*handler_name
; /* handler function name */
3067 char amtype
; /* type of access method */
3070 /* ----------------------
3071 * Create TRIGGER Statement
3072 * ----------------------
3074 typedef struct CreateTrigStmt
3077 bool replace
; /* replace trigger if already exists */
3078 bool isconstraint
; /* This is a constraint trigger */
3079 char *trigname
; /* TRIGGER's name */
3080 RangeVar
*relation
; /* relation trigger is on */
3081 List
*funcname
; /* qual. name of function to call */
3082 List
*args
; /* list of String or NIL */
3083 bool row
; /* ROW/STATEMENT */
3084 /* timing uses the TRIGGER_TYPE bits defined in catalog/pg_trigger.h */
3085 int16 timing
; /* BEFORE, AFTER, or INSTEAD */
3086 /* events uses the TRIGGER_TYPE bits defined in catalog/pg_trigger.h */
3087 int16 events
; /* "OR" of INSERT/UPDATE/DELETE/TRUNCATE */
3088 List
*columns
; /* column names, or NIL for all columns */
3089 Node
*whenClause
; /* qual expression, or NULL if none */
3090 /* explicitly named transition data */
3091 List
*transitionRels
; /* TriggerTransition nodes, or NIL if none */
3092 /* The remaining fields are only used for constraint triggers */
3093 bool deferrable
; /* [NOT] DEFERRABLE */
3094 bool initdeferred
; /* INITIALLY {DEFERRED|IMMEDIATE} */
3095 RangeVar
*constrrel
; /* opposite relation, if RI trigger */
3098 /* ----------------------
3099 * Create EVENT TRIGGER Statement
3100 * ----------------------
3102 typedef struct CreateEventTrigStmt
3105 char *trigname
; /* TRIGGER's name */
3106 char *eventname
; /* event's identifier */
3107 List
*whenclause
; /* list of DefElems indicating filtering */
3108 List
*funcname
; /* qual. name of function to call */
3109 } CreateEventTrigStmt
;
3111 /* ----------------------
3112 * Alter EVENT TRIGGER Statement
3113 * ----------------------
3115 typedef struct AlterEventTrigStmt
3118 char *trigname
; /* TRIGGER's name */
3119 char tgenabled
; /* trigger's firing configuration WRT
3120 * session_replication_role */
3121 } AlterEventTrigStmt
;
3123 /* ----------------------
3124 * Create LANGUAGE Statements
3125 * ----------------------
3127 typedef struct CreatePLangStmt
3130 bool replace
; /* T => replace if already exists */
3131 char *plname
; /* PL name */
3132 List
*plhandler
; /* PL call handler function (qual. name) */
3133 List
*plinline
; /* optional inline function (qual. name) */
3134 List
*plvalidator
; /* optional validator function (qual. name) */
3135 bool pltrusted
; /* PL is trusted */
3138 /* ----------------------
3139 * Create/Alter/Drop Role Statements
3141 * Note: these node types are also used for the backwards-compatible
3142 * Create/Alter/Drop User/Group statements. In the ALTER and DROP cases
3143 * there's really no need to distinguish what the original spelling was,
3144 * but for CREATE we mark the type because the defaults vary.
3145 * ----------------------
3147 typedef enum RoleStmtType
3154 typedef struct CreateRoleStmt
3157 RoleStmtType stmt_type
; /* ROLE/USER/GROUP */
3158 char *role
; /* role name */
3159 List
*options
; /* List of DefElem nodes */
3162 typedef struct AlterRoleStmt
3165 RoleSpec
*role
; /* role */
3166 List
*options
; /* List of DefElem nodes */
3167 int action
; /* +1 = add members, -1 = drop members */
3170 typedef struct AlterRoleSetStmt
3173 RoleSpec
*role
; /* role */
3174 char *database
; /* database name, or NULL */
3175 VariableSetStmt
*setstmt
; /* SET or RESET subcommand */
3178 typedef struct DropRoleStmt
3181 List
*roles
; /* List of roles to remove */
3182 bool missing_ok
; /* skip error if a role is missing? */
3185 /* ----------------------
3186 * {Create|Alter} SEQUENCE Statement
3187 * ----------------------
3190 typedef struct CreateSeqStmt
3193 RangeVar
*sequence
; /* the sequence to create */
3195 Oid ownerId
; /* ID of owner, or InvalidOid for default */
3197 bool if_not_exists
; /* just do nothing if it already exists? */
3200 typedef struct AlterSeqStmt
3203 RangeVar
*sequence
; /* the sequence to alter */
3206 bool missing_ok
; /* skip error if a role is missing? */
3209 /* ----------------------
3210 * Create {Aggregate|Operator|Type} Statement
3211 * ----------------------
3213 typedef struct DefineStmt
3216 ObjectType kind
; /* aggregate, operator, type */
3217 bool oldstyle
; /* hack to signal old CREATE AGG syntax */
3218 List
*defnames
; /* qualified name (list of String) */
3219 List
*args
; /* a list of TypeName (if needed) */
3220 List
*definition
; /* a list of DefElem */
3221 bool if_not_exists
; /* just do nothing if it already exists? */
3222 bool replace
; /* replace if already exists? */
3225 /* ----------------------
3226 * Create Domain Statement
3227 * ----------------------
3229 typedef struct CreateDomainStmt
3232 List
*domainname
; /* qualified name (list of String) */
3233 TypeName
*typeName
; /* the base type */
3234 CollateClause
*collClause
; /* untransformed COLLATE spec, if any */
3235 List
*constraints
; /* constraints (list of Constraint nodes) */
3238 /* ----------------------
3239 * Create Operator Class Statement
3240 * ----------------------
3242 typedef struct CreateOpClassStmt
3245 List
*opclassname
; /* qualified name (list of String) */
3246 List
*opfamilyname
; /* qualified name (ditto); NIL if omitted */
3247 char *amname
; /* name of index AM opclass is for */
3248 TypeName
*datatype
; /* datatype of indexed column */
3249 List
*items
; /* List of CreateOpClassItem nodes */
3250 bool isDefault
; /* Should be marked as default for type? */
3251 } CreateOpClassStmt
;
3253 #define OPCLASS_ITEM_OPERATOR 1
3254 #define OPCLASS_ITEM_FUNCTION 2
3255 #define OPCLASS_ITEM_STORAGETYPE 3
3257 typedef struct CreateOpClassItem
3260 int itemtype
; /* see codes above */
3261 ObjectWithArgs
*name
; /* operator or function name and args */
3262 int number
; /* strategy num or support proc num */
3263 List
*order_family
; /* only used for ordering operators */
3264 List
*class_args
; /* amproclefttype/amprocrighttype or
3265 * amoplefttype/amoprighttype */
3266 /* fields used for a storagetype item: */
3267 TypeName
*storedtype
; /* datatype stored in index */
3268 } CreateOpClassItem
;
3270 /* ----------------------
3271 * Create Operator Family Statement
3272 * ----------------------
3274 typedef struct CreateOpFamilyStmt
3277 List
*opfamilyname
; /* qualified name (list of String) */
3278 char *amname
; /* name of index AM opfamily is for */
3279 } CreateOpFamilyStmt
;
3281 /* ----------------------
3282 * Alter Operator Family Statement
3283 * ----------------------
3285 typedef struct AlterOpFamilyStmt
3288 List
*opfamilyname
; /* qualified name (list of String) */
3289 char *amname
; /* name of index AM opfamily is for */
3290 bool isDrop
; /* ADD or DROP the items? */
3291 List
*items
; /* List of CreateOpClassItem nodes */
3292 } AlterOpFamilyStmt
;
3294 /* ----------------------
3295 * Drop Table|Sequence|View|Index|Type|Domain|Conversion|Schema Statement
3296 * ----------------------
3299 typedef struct DropStmt
3302 List
*objects
; /* list of names */
3303 ObjectType removeType
; /* object type */
3304 DropBehavior behavior
; /* RESTRICT or CASCADE behavior */
3305 bool missing_ok
; /* skip error if object is missing? */
3306 bool concurrent
; /* drop index concurrently? */
3309 /* ----------------------
3310 * Truncate Table Statement
3311 * ----------------------
3313 typedef struct TruncateStmt
3316 List
*relations
; /* relations (RangeVars) to be truncated */
3317 bool restart_seqs
; /* restart owned sequences? */
3318 DropBehavior behavior
; /* RESTRICT or CASCADE behavior */
3321 /* ----------------------
3322 * Comment On Statement
3323 * ----------------------
3325 typedef struct CommentStmt
3328 ObjectType objtype
; /* Object's type */
3329 Node
*object
; /* Qualified name of the object */
3330 char *comment
; /* Comment to insert, or NULL to remove */
3333 /* ----------------------
3334 * SECURITY LABEL Statement
3335 * ----------------------
3337 typedef struct SecLabelStmt
3340 ObjectType objtype
; /* Object's type */
3341 Node
*object
; /* Qualified name of the object */
3342 char *provider
; /* Label provider (or NULL) */
3343 char *label
; /* New security label to be assigned */
3346 /* ----------------------
3347 * Declare Cursor Statement
3349 * The "query" field is initially a raw parse tree, and is converted to a
3350 * Query node during parse analysis. Note that rewriting and planning
3351 * of the query are always postponed until execution.
3352 * ----------------------
3354 #define CURSOR_OPT_BINARY 0x0001 /* BINARY */
3355 #define CURSOR_OPT_SCROLL 0x0002 /* SCROLL explicitly given */
3356 #define CURSOR_OPT_NO_SCROLL 0x0004 /* NO SCROLL explicitly given */
3357 #define CURSOR_OPT_INSENSITIVE 0x0008 /* INSENSITIVE */
3358 #define CURSOR_OPT_ASENSITIVE 0x0010 /* ASENSITIVE */
3359 #define CURSOR_OPT_HOLD 0x0020 /* WITH HOLD */
3360 /* these planner-control flags do not correspond to any SQL grammar: */
3361 #define CURSOR_OPT_FAST_PLAN 0x0100 /* prefer fast-start plan */
3362 #define CURSOR_OPT_GENERIC_PLAN 0x0200 /* force use of generic plan */
3363 #define CURSOR_OPT_CUSTOM_PLAN 0x0400 /* force use of custom plan */
3364 #define CURSOR_OPT_PARALLEL_OK 0x0800 /* parallel mode OK */
3366 typedef struct DeclareCursorStmt
3369 char *portalname
; /* name of the portal (cursor) */
3370 int options
; /* bitmask of options (see above) */
3371 Node
*query
; /* the query (see comments above) */
3372 } DeclareCursorStmt
;
3374 /* ----------------------
3375 * Close Portal Statement
3376 * ----------------------
3378 typedef struct ClosePortalStmt
3381 char *portalname
; /* name of the portal (cursor) */
3382 /* NULL means CLOSE ALL */
3385 /* ----------------------
3386 * Fetch Statement (also Move)
3387 * ----------------------
3389 typedef enum FetchDirection
3391 /* for these, howMany is how many rows to fetch; FETCH_ALL means ALL */
3394 /* for these, howMany indicates a position; only one row is fetched */
3399 #define FETCH_ALL LONG_MAX
3401 typedef struct FetchStmt
3404 FetchDirection direction
; /* see above */
3405 long howMany
; /* number of rows, or position argument */
3406 char *portalname
; /* name of portal (cursor) */
3407 bool ismove
; /* true if MOVE */
3410 /* ----------------------
3411 * Create Index Statement
3413 * This represents creation of an index and/or an associated constraint.
3414 * If isconstraint is true, we should create a pg_constraint entry along
3415 * with the index. But if indexOid isn't InvalidOid, we are not creating an
3416 * index, just a UNIQUE/PKEY constraint using an existing index. isconstraint
3417 * must always be true in this case, and the fields describing the index
3418 * properties are empty.
3419 * ----------------------
3421 typedef struct IndexStmt
3424 char *idxname
; /* name of new index, or NULL for default */
3425 RangeVar
*relation
; /* relation to build index on */
3426 char *accessMethod
; /* name of access method (eg. btree) */
3427 char *tableSpace
; /* tablespace, or NULL for default */
3428 List
*indexParams
; /* columns to index: a list of IndexElem */
3429 List
*indexIncludingParams
; /* additional columns to index: a list
3431 List
*options
; /* WITH clause options: a list of DefElem */
3432 Node
*whereClause
; /* qualification (partial-index predicate) */
3433 List
*excludeOpNames
; /* exclusion operator names, or NIL if none */
3434 char *idxcomment
; /* comment to apply to index, or NULL */
3435 Oid indexOid
; /* OID of an existing index, if any */
3436 RelFileNumber oldNumber
; /* relfilenumber of existing storage, if any */
3437 SubTransactionId oldCreateSubid
; /* rd_createSubid of oldNumber */
3438 SubTransactionId oldFirstRelfilelocatorSubid
; /* rd_firstRelfilelocatorSubid
3440 bool unique
; /* is index unique? */
3441 bool nulls_not_distinct
; /* null treatment for UNIQUE constraints */
3442 bool primary
; /* is index a primary key? */
3443 bool isconstraint
; /* is it for a pkey/unique constraint? */
3444 bool iswithoutoverlaps
; /* is the constraint WITHOUT OVERLAPS? */
3445 bool deferrable
; /* is the constraint DEFERRABLE? */
3446 bool initdeferred
; /* is the constraint INITIALLY DEFERRED? */
3447 bool transformed
; /* true when transformIndexStmt is finished */
3448 bool concurrent
; /* should this be a concurrent index build? */
3449 bool if_not_exists
; /* just do nothing if index already exists? */
3450 bool reset_default_tblspc
; /* reset default_tablespace prior to
3454 /* ----------------------
3455 * Create Statistics Statement
3456 * ----------------------
3458 typedef struct CreateStatsStmt
3461 List
*defnames
; /* qualified name (list of String) */
3462 List
*stat_types
; /* stat types (list of String) */
3463 List
*exprs
; /* expressions to build statistics on */
3464 List
*relations
; /* rels to build stats on (list of RangeVar) */
3465 char *stxcomment
; /* comment to apply to stats, or NULL */
3466 bool transformed
; /* true when transformStatsStmt is finished */
3467 bool if_not_exists
; /* do nothing if stats name already exists */
3471 * StatsElem - statistics parameters (used in CREATE STATISTICS)
3473 * For a plain attribute, 'name' is the name of the referenced table column
3474 * and 'expr' is NULL. For an expression, 'name' is NULL and 'expr' is the
3477 typedef struct StatsElem
3480 char *name
; /* name of attribute to index, or NULL */
3481 Node
*expr
; /* expression to index, or NULL */
3485 /* ----------------------
3486 * Alter Statistics Statement
3487 * ----------------------
3489 typedef struct AlterStatsStmt
3492 List
*defnames
; /* qualified name (list of String) */
3493 Node
*stxstattarget
; /* statistics target */
3494 bool missing_ok
; /* skip error if statistics object is missing */
3497 /* ----------------------
3498 * Create Function Statement
3499 * ----------------------
3501 typedef struct CreateFunctionStmt
3504 bool is_procedure
; /* it's really CREATE PROCEDURE */
3505 bool replace
; /* T => replace if already exists */
3506 List
*funcname
; /* qualified name of function to create */
3507 List
*parameters
; /* a list of FunctionParameter */
3508 TypeName
*returnType
; /* the return type */
3509 List
*options
; /* a list of DefElem */
3511 } CreateFunctionStmt
;
3513 typedef enum FunctionParameterMode
3515 /* the assigned enum values appear in pg_proc, don't change 'em! */
3516 FUNC_PARAM_IN
= 'i', /* input only */
3517 FUNC_PARAM_OUT
= 'o', /* output only */
3518 FUNC_PARAM_INOUT
= 'b', /* both */
3519 FUNC_PARAM_VARIADIC
= 'v', /* variadic (always input) */
3520 FUNC_PARAM_TABLE
= 't', /* table function output column */
3521 /* this is not used in pg_proc: */
3522 FUNC_PARAM_DEFAULT
= 'd', /* default; effectively same as IN */
3523 } FunctionParameterMode
;
3525 typedef struct FunctionParameter
3528 char *name
; /* parameter name, or NULL if not given */
3529 TypeName
*argType
; /* TypeName for parameter type */
3530 FunctionParameterMode mode
; /* IN/OUT/etc */
3531 Node
*defexpr
; /* raw default expr, or NULL if not given */
3532 ParseLoc location
; /* token location, or -1 if unknown */
3533 } FunctionParameter
;
3535 typedef struct AlterFunctionStmt
3539 ObjectWithArgs
*func
; /* name and args of function */
3540 List
*actions
; /* list of DefElem */
3541 } AlterFunctionStmt
;
3543 /* ----------------------
3546 * DoStmt is the raw parser output, InlineCodeBlock is the execution-time API
3547 * ----------------------
3549 typedef struct DoStmt
3552 List
*args
; /* List of DefElem nodes */
3555 typedef struct InlineCodeBlock
3557 pg_node_attr(nodetag_only
) /* this is not a member of parse trees */
3560 char *source_text
; /* source text of anonymous code block */
3561 Oid langOid
; /* OID of selected language */
3562 bool langIsTrusted
; /* trusted property of the language */
3563 bool atomic
; /* atomic execution context */
3566 /* ----------------------
3569 * OUT-mode arguments are removed from the transformed funcexpr. The outargs
3570 * list contains copies of the expressions for all output arguments, in the
3571 * order of the procedure's declared arguments. (outargs is never evaluated,
3572 * but is useful to the caller as a reference for what to assign to.)
3573 * The transformed call state is not relevant in the query jumbling, only the
3575 * ----------------------
3577 typedef struct CallStmt
3580 /* from the parser */
3581 FuncCall
*funccall
pg_node_attr(query_jumble_ignore
);
3582 /* transformed call, with only input args */
3584 /* transformed output-argument expressions */
3588 typedef struct CallContext
3590 pg_node_attr(nodetag_only
) /* this is not a member of parse trees */
3596 /* ----------------------
3597 * Alter Object Rename Statement
3598 * ----------------------
3600 typedef struct RenameStmt
3603 ObjectType renameType
; /* OBJECT_TABLE, OBJECT_COLUMN, etc */
3604 ObjectType relationType
; /* if column name, associated relation type */
3605 RangeVar
*relation
; /* in case it's a table */
3606 Node
*object
; /* in case it's some other object */
3607 char *subname
; /* name of contained object (column, rule,
3609 char *newname
; /* the new name */
3610 DropBehavior behavior
; /* RESTRICT or CASCADE behavior */
3611 bool missing_ok
; /* skip error if missing? */
3614 /* ----------------------
3615 * ALTER object DEPENDS ON EXTENSION extname
3616 * ----------------------
3618 typedef struct AlterObjectDependsStmt
3621 ObjectType objectType
; /* OBJECT_FUNCTION, OBJECT_TRIGGER, etc */
3622 RangeVar
*relation
; /* in case a table is involved */
3623 Node
*object
; /* name of the object */
3624 String
*extname
; /* extension name */
3625 bool remove
; /* set true to remove dep rather than add */
3626 } AlterObjectDependsStmt
;
3628 /* ----------------------
3629 * ALTER object SET SCHEMA Statement
3630 * ----------------------
3632 typedef struct AlterObjectSchemaStmt
3635 ObjectType objectType
; /* OBJECT_TABLE, OBJECT_TYPE, etc */
3636 RangeVar
*relation
; /* in case it's a table */
3637 Node
*object
; /* in case it's some other object */
3638 char *newschema
; /* the new schema */
3639 bool missing_ok
; /* skip error if missing? */
3640 } AlterObjectSchemaStmt
;
3642 /* ----------------------
3643 * Alter Object Owner Statement
3644 * ----------------------
3646 typedef struct AlterOwnerStmt
3649 ObjectType objectType
; /* OBJECT_TABLE, OBJECT_TYPE, etc */
3650 RangeVar
*relation
; /* in case it's a table */
3651 Node
*object
; /* in case it's some other object */
3652 RoleSpec
*newowner
; /* the new owner */
3655 /* ----------------------
3656 * Alter Operator Set ( this-n-that )
3657 * ----------------------
3659 typedef struct AlterOperatorStmt
3662 ObjectWithArgs
*opername
; /* operator name and argument types */
3663 List
*options
; /* List of DefElem nodes */
3664 } AlterOperatorStmt
;
3666 /* ------------------------
3667 * Alter Type Set ( this-n-that )
3668 * ------------------------
3670 typedef struct AlterTypeStmt
3673 List
*typeName
; /* type name (possibly qualified) */
3674 List
*options
; /* List of DefElem nodes */
3677 /* ----------------------
3678 * Create Rule Statement
3679 * ----------------------
3681 typedef struct RuleStmt
3684 RangeVar
*relation
; /* relation the rule is for */
3685 char *rulename
; /* name of the rule */
3686 Node
*whereClause
; /* qualifications */
3687 CmdType event
; /* SELECT, INSERT, etc */
3688 bool instead
; /* is a 'do instead'? */
3689 List
*actions
; /* the action statements */
3690 bool replace
; /* OR REPLACE */
3693 /* ----------------------
3695 * ----------------------
3697 typedef struct NotifyStmt
3700 char *conditionname
; /* condition name to notify */
3701 char *payload
; /* the payload string, or NULL if none */
3704 /* ----------------------
3706 * ----------------------
3708 typedef struct ListenStmt
3711 char *conditionname
; /* condition name to listen on */
3714 /* ----------------------
3715 * Unlisten Statement
3716 * ----------------------
3718 typedef struct UnlistenStmt
3721 char *conditionname
; /* name to unlisten on, or NULL for all */
3724 /* ----------------------
3725 * {Begin|Commit|Rollback} Transaction Statement
3726 * ----------------------
3728 typedef enum TransactionStmtKind
3731 TRANS_STMT_START
, /* semantically identical to BEGIN */
3733 TRANS_STMT_ROLLBACK
,
3734 TRANS_STMT_SAVEPOINT
,
3736 TRANS_STMT_ROLLBACK_TO
,
3738 TRANS_STMT_COMMIT_PREPARED
,
3739 TRANS_STMT_ROLLBACK_PREPARED
,
3740 } TransactionStmtKind
;
3742 typedef struct TransactionStmt
3745 TransactionStmtKind kind
; /* see above */
3746 List
*options
; /* for BEGIN/START commands */
3747 /* for savepoint commands */
3748 char *savepoint_name
pg_node_attr(query_jumble_ignore
);
3749 /* for two-phase-commit related commands */
3750 char *gid
pg_node_attr(query_jumble_ignore
);
3751 bool chain
; /* AND CHAIN option */
3752 /* token location, or -1 if unknown */
3753 ParseLoc location
pg_node_attr(query_jumble_location
);
3756 /* ----------------------
3757 * Create Type Statement, composite types
3758 * ----------------------
3760 typedef struct CompositeTypeStmt
3763 RangeVar
*typevar
; /* the composite type to be created */
3764 List
*coldeflist
; /* list of ColumnDef nodes */
3765 } CompositeTypeStmt
;
3767 /* ----------------------
3768 * Create Type Statement, enum types
3769 * ----------------------
3771 typedef struct CreateEnumStmt
3774 List
*typeName
; /* qualified name (list of String) */
3775 List
*vals
; /* enum values (list of String) */
3778 /* ----------------------
3779 * Create Type Statement, range types
3780 * ----------------------
3782 typedef struct CreateRangeStmt
3785 List
*typeName
; /* qualified name (list of String) */
3786 List
*params
; /* range parameters (list of DefElem) */
3789 /* ----------------------
3790 * Alter Type Statement, enum types
3791 * ----------------------
3793 typedef struct AlterEnumStmt
3796 List
*typeName
; /* qualified name (list of String) */
3797 char *oldVal
; /* old enum value's name, if renaming */
3798 char *newVal
; /* new enum value's name */
3799 char *newValNeighbor
; /* neighboring enum value, if specified */
3800 bool newValIsAfter
; /* place new enum value after neighbor? */
3801 bool skipIfNewValExists
; /* no error if new already exists? */
3804 /* ----------------------
3805 * Create View Statement
3806 * ----------------------
3808 typedef enum ViewCheckOption
3812 CASCADED_CHECK_OPTION
,
3815 typedef struct ViewStmt
3818 RangeVar
*view
; /* the view to be created */
3819 List
*aliases
; /* target column names */
3820 Node
*query
; /* the SELECT query (as a raw parse tree) */
3821 bool replace
; /* replace an existing view? */
3822 List
*options
; /* options from WITH clause */
3823 ViewCheckOption withCheckOption
; /* WITH CHECK OPTION */
3826 /* ----------------------
3828 * ----------------------
3830 typedef struct LoadStmt
3833 char *filename
; /* file to load */
3836 /* ----------------------
3837 * Createdb Statement
3838 * ----------------------
3840 typedef struct CreatedbStmt
3843 char *dbname
; /* name of database to create */
3844 List
*options
; /* List of DefElem nodes */
3847 /* ----------------------
3849 * ----------------------
3851 typedef struct AlterDatabaseStmt
3854 char *dbname
; /* name of database to alter */
3855 List
*options
; /* List of DefElem nodes */
3856 } AlterDatabaseStmt
;
3858 typedef struct AlterDatabaseRefreshCollStmt
3862 } AlterDatabaseRefreshCollStmt
;
3864 typedef struct AlterDatabaseSetStmt
3867 char *dbname
; /* database name */
3868 VariableSetStmt
*setstmt
; /* SET or RESET subcommand */
3869 } AlterDatabaseSetStmt
;
3871 /* ----------------------
3873 * ----------------------
3875 typedef struct DropdbStmt
3878 char *dbname
; /* database to drop */
3879 bool missing_ok
; /* skip error if db is missing? */
3880 List
*options
; /* currently only FORCE is supported */
3883 /* ----------------------
3884 * Alter System Statement
3885 * ----------------------
3887 typedef struct AlterSystemStmt
3890 VariableSetStmt
*setstmt
; /* SET subcommand */
3893 /* ----------------------
3894 * Cluster Statement (support pbrown's cluster index implementation)
3895 * ----------------------
3897 typedef struct ClusterStmt
3900 RangeVar
*relation
; /* relation being indexed, or NULL if all */
3901 char *indexname
; /* original index defined */
3902 List
*params
; /* list of DefElem nodes */
3905 /* ----------------------
3906 * Vacuum and Analyze Statements
3908 * Even though these are nominally two statements, it's convenient to use
3909 * just one node type for both.
3910 * ----------------------
3912 typedef struct VacuumStmt
3915 List
*options
; /* list of DefElem nodes */
3916 List
*rels
; /* list of VacuumRelation, or NIL for all */
3917 bool is_vacuumcmd
; /* true for VACUUM, false for ANALYZE */
3921 * Info about a single target table of VACUUM/ANALYZE.
3923 * If the OID field is set, it always identifies the table to process.
3924 * Then the relation field can be NULL; if it isn't, it's used only to report
3925 * failure to open/lock the relation.
3927 typedef struct VacuumRelation
3930 RangeVar
*relation
; /* table name to process, or NULL */
3931 Oid oid
; /* table's OID; InvalidOid if not looked up */
3932 List
*va_cols
; /* list of column names, or NIL for all */
3935 /* ----------------------
3938 * The "query" field is initially a raw parse tree, and is converted to a
3939 * Query node during parse analysis. Note that rewriting and planning
3940 * of the query are always postponed until execution.
3941 * ----------------------
3943 typedef struct ExplainStmt
3946 Node
*query
; /* the query (see comments above) */
3947 List
*options
; /* list of DefElem nodes */
3950 /* ----------------------
3951 * CREATE TABLE AS Statement (a/k/a SELECT INTO)
3953 * A query written as CREATE TABLE AS will produce this node type natively.
3954 * A query written as SELECT ... INTO will be transformed to this form during
3956 * A query written as CREATE MATERIALIZED view will produce this node type,
3957 * during parse analysis, since it needs all the same data.
3959 * The "query" field is handled similarly to EXPLAIN, though note that it
3960 * can be a SELECT or an EXECUTE, but not other DML statements.
3961 * ----------------------
3963 typedef struct CreateTableAsStmt
3966 Node
*query
; /* the query (see comments above) */
3967 IntoClause
*into
; /* destination table */
3968 ObjectType objtype
; /* OBJECT_TABLE or OBJECT_MATVIEW */
3969 bool is_select_into
; /* it was written as SELECT INTO */
3970 bool if_not_exists
; /* just do nothing if it already exists? */
3971 } CreateTableAsStmt
;
3973 /* ----------------------
3974 * REFRESH MATERIALIZED VIEW Statement
3975 * ----------------------
3977 typedef struct RefreshMatViewStmt
3980 bool concurrent
; /* allow concurrent access? */
3981 bool skipData
; /* true for WITH NO DATA */
3982 RangeVar
*relation
; /* relation to insert into */
3983 } RefreshMatViewStmt
;
3985 /* ----------------------
3986 * Checkpoint Statement
3987 * ----------------------
3989 typedef struct CheckPointStmt
3994 /* ----------------------
3996 * ----------------------
3999 typedef enum DiscardMode
4007 typedef struct DiscardStmt
4013 /* ----------------------
4015 * ----------------------
4017 typedef struct LockStmt
4020 List
*relations
; /* relations to lock */
4021 int mode
; /* lock mode */
4022 bool nowait
; /* no wait mode */
4025 /* ----------------------
4026 * SET CONSTRAINTS Statement
4027 * ----------------------
4029 typedef struct ConstraintsSetStmt
4032 List
*constraints
; /* List of names as RangeVars */
4034 } ConstraintsSetStmt
;
4036 /* ----------------------
4038 * ----------------------
4040 typedef enum ReindexObjectType
4042 REINDEX_OBJECT_INDEX
, /* index */
4043 REINDEX_OBJECT_TABLE
, /* table or materialized view */
4044 REINDEX_OBJECT_SCHEMA
, /* schema */
4045 REINDEX_OBJECT_SYSTEM
, /* system catalogs */
4046 REINDEX_OBJECT_DATABASE
, /* database */
4047 } ReindexObjectType
;
4049 typedef struct ReindexStmt
4052 ReindexObjectType kind
; /* REINDEX_OBJECT_INDEX, REINDEX_OBJECT_TABLE,
4054 RangeVar
*relation
; /* Table or index to reindex */
4055 const char *name
; /* name of database to reindex */
4056 List
*params
; /* list of DefElem nodes */
4059 /* ----------------------
4060 * CREATE CONVERSION Statement
4061 * ----------------------
4063 typedef struct CreateConversionStmt
4066 List
*conversion_name
; /* Name of the conversion */
4067 char *for_encoding_name
; /* source encoding name */
4068 char *to_encoding_name
; /* destination encoding name */
4069 List
*func_name
; /* qualified conversion function name */
4070 bool def
; /* is this a default conversion? */
4071 } CreateConversionStmt
;
4073 /* ----------------------
4074 * CREATE CAST Statement
4075 * ----------------------
4077 typedef struct CreateCastStmt
4080 TypeName
*sourcetype
;
4081 TypeName
*targettype
;
4082 ObjectWithArgs
*func
;
4083 CoercionContext context
;
4087 /* ----------------------
4088 * CREATE TRANSFORM Statement
4089 * ----------------------
4091 typedef struct CreateTransformStmt
4095 TypeName
*type_name
;
4097 ObjectWithArgs
*fromsql
;
4098 ObjectWithArgs
*tosql
;
4099 } CreateTransformStmt
;
4101 /* ----------------------
4103 * ----------------------
4105 typedef struct PrepareStmt
4108 char *name
; /* Name of plan, arbitrary */
4109 List
*argtypes
; /* Types of parameters (List of TypeName) */
4110 Node
*query
; /* The query itself (as a raw parsetree) */
4114 /* ----------------------
4116 * ----------------------
4119 typedef struct ExecuteStmt
4122 char *name
; /* The name of the plan to execute */
4123 List
*params
; /* Values to assign to parameters */
4127 /* ----------------------
4128 * DEALLOCATE Statement
4129 * ----------------------
4131 typedef struct DeallocateStmt
4134 /* The name of the plan to remove, NULL if DEALLOCATE ALL */
4135 char *name
pg_node_attr(query_jumble_ignore
);
4138 * True if DEALLOCATE ALL. This is redundant with "name == NULL", but we
4139 * make it a separate field so that exactly this condition (and not the
4140 * precise name) will be accounted for in query jumbling.
4143 /* token location, or -1 if unknown */
4144 ParseLoc location
pg_node_attr(query_jumble_location
);
4148 * DROP OWNED statement
4150 typedef struct DropOwnedStmt
4154 DropBehavior behavior
;
4158 * REASSIGN OWNED statement
4160 typedef struct ReassignOwnedStmt
4165 } ReassignOwnedStmt
;
4168 * TS Dictionary stmts: DefineStmt, RenameStmt and DropStmt are default
4170 typedef struct AlterTSDictionaryStmt
4173 List
*dictname
; /* qualified name (list of String) */
4174 List
*options
; /* List of DefElem nodes */
4175 } AlterTSDictionaryStmt
;
4178 * TS Configuration stmts: DefineStmt, RenameStmt and DropStmt are default
4180 typedef enum AlterTSConfigType
4182 ALTER_TSCONFIG_ADD_MAPPING
,
4183 ALTER_TSCONFIG_ALTER_MAPPING_FOR_TOKEN
,
4184 ALTER_TSCONFIG_REPLACE_DICT
,
4185 ALTER_TSCONFIG_REPLACE_DICT_FOR_TOKEN
,
4186 ALTER_TSCONFIG_DROP_MAPPING
,
4187 } AlterTSConfigType
;
4189 typedef struct AlterTSConfigurationStmt
4192 AlterTSConfigType kind
; /* ALTER_TSCONFIG_ADD_MAPPING, etc */
4193 List
*cfgname
; /* qualified name (list of String) */
4196 * dicts will be non-NIL if ADD/ALTER MAPPING was specified. If dicts is
4197 * NIL, but tokentype isn't, DROP MAPPING was specified.
4199 List
*tokentype
; /* list of String */
4200 List
*dicts
; /* list of list of String */
4201 bool override
; /* if true - remove old variant */
4202 bool replace
; /* if true - replace dictionary by another */
4203 bool missing_ok
; /* for DROP - skip error if missing? */
4204 } AlterTSConfigurationStmt
;
4206 typedef struct PublicationTable
4209 RangeVar
*relation
; /* relation to be published */
4210 Node
*whereClause
; /* qualifications */
4211 List
*columns
; /* List of columns in a publication table */
4215 * Publication object type
4217 typedef enum PublicationObjSpecType
4219 PUBLICATIONOBJ_TABLE
, /* A table */
4220 PUBLICATIONOBJ_TABLES_IN_SCHEMA
, /* All tables in schema */
4221 PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA
, /* All tables in first element of
4223 PUBLICATIONOBJ_CONTINUATION
, /* Continuation of previous type */
4224 } PublicationObjSpecType
;
4226 typedef struct PublicationObjSpec
4229 PublicationObjSpecType pubobjtype
; /* type of this publication object */
4231 PublicationTable
*pubtable
;
4232 ParseLoc location
; /* token location, or -1 if unknown */
4233 } PublicationObjSpec
;
4235 typedef struct CreatePublicationStmt
4238 char *pubname
; /* Name of the publication */
4239 List
*options
; /* List of DefElem nodes */
4240 List
*pubobjects
; /* Optional list of publication objects */
4241 bool for_all_tables
; /* Special publication for all tables in db */
4242 } CreatePublicationStmt
;
4244 typedef enum AlterPublicationAction
4246 AP_AddObjects
, /* add objects to publication */
4247 AP_DropObjects
, /* remove objects from publication */
4248 AP_SetObjects
, /* set list of objects */
4249 } AlterPublicationAction
;
4251 typedef struct AlterPublicationStmt
4254 char *pubname
; /* Name of the publication */
4256 /* parameters used for ALTER PUBLICATION ... WITH */
4257 List
*options
; /* List of DefElem nodes */
4260 * Parameters used for ALTER PUBLICATION ... ADD/DROP/SET publication
4263 List
*pubobjects
; /* Optional list of publication objects */
4264 bool for_all_tables
; /* Special publication for all tables in db */
4265 AlterPublicationAction action
; /* What action to perform with the given
4267 } AlterPublicationStmt
;
4269 typedef struct CreateSubscriptionStmt
4272 char *subname
; /* Name of the subscription */
4273 char *conninfo
; /* Connection string to publisher */
4274 List
*publication
; /* One or more publication to subscribe to */
4275 List
*options
; /* List of DefElem nodes */
4276 } CreateSubscriptionStmt
;
4278 typedef enum AlterSubscriptionType
4280 ALTER_SUBSCRIPTION_OPTIONS
,
4281 ALTER_SUBSCRIPTION_CONNECTION
,
4282 ALTER_SUBSCRIPTION_SET_PUBLICATION
,
4283 ALTER_SUBSCRIPTION_ADD_PUBLICATION
,
4284 ALTER_SUBSCRIPTION_DROP_PUBLICATION
,
4285 ALTER_SUBSCRIPTION_REFRESH
,
4286 ALTER_SUBSCRIPTION_ENABLED
,
4287 ALTER_SUBSCRIPTION_SKIP
,
4288 } AlterSubscriptionType
;
4290 typedef struct AlterSubscriptionStmt
4293 AlterSubscriptionType kind
; /* ALTER_SUBSCRIPTION_OPTIONS, etc */
4294 char *subname
; /* Name of the subscription */
4295 char *conninfo
; /* Connection string to publisher */
4296 List
*publication
; /* One or more publication to subscribe to */
4297 List
*options
; /* List of DefElem nodes */
4298 } AlterSubscriptionStmt
;
4300 typedef struct DropSubscriptionStmt
4303 char *subname
; /* Name of the subscription */
4304 bool missing_ok
; /* Skip error if missing? */
4305 DropBehavior behavior
; /* RESTRICT or CASCADE behavior */
4306 } DropSubscriptionStmt
;
4308 #endif /* PARSENODES_H */