PostgreSQL Source Code  git master
parsenodes.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * parsenodes.h
4  * definitions for parse tree nodes
5  *
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.
13  *
14  *
15  * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
16  * Portions Copyright (c) 1994, Regents of the University of California
17  *
18  * src/include/nodes/parsenodes.h
19  *
20  *-------------------------------------------------------------------------
21  */
22 #ifndef PARSENODES_H
23 #define PARSENODES_H
24 
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"
31 
32 
33 typedef enum OverridingKind
34 {
39 
40 /* Possible sources of a Query */
41 typedef enum QuerySource
42 {
43  QSRC_ORIGINAL, /* original parsetree (explicit query) */
44  QSRC_PARSER, /* added by parse analysis (now unused) */
45  QSRC_INSTEAD_RULE, /* added by unconditional INSTEAD rule */
46  QSRC_QUAL_INSTEAD_RULE, /* added by conditional INSTEAD rule */
47  QSRC_NON_INSTEAD_RULE /* added by non-INSTEAD rule */
49 
50 /* Sort ordering options for ORDER BY and CREATE INDEX */
51 typedef enum SortByDir
52 {
56  SORTBY_USING /* not allowed in CREATE INDEX ... */
58 
59 typedef enum SortByNulls
60 {
65 
66 /* Options for [ ALL | DISTINCT ] */
67 typedef enum SetQuantifier
68 {
73 
74 /*
75  * Grantable rights are encoded so that we can OR them together in a bitmask.
76  * The present representation of AclItem limits us to 32 distinct rights,
77  * even though AclMode is defined as uint64. See utils/acl.h.
78  *
79  * Caution: changing these codes breaks stored ACLs, hence forces initdb.
80  */
81 typedef uint64 AclMode; /* a bitmask of privilege bits */
82 
83 #define ACL_INSERT (1<<0) /* for relations */
84 #define ACL_SELECT (1<<1)
85 #define ACL_UPDATE (1<<2)
86 #define ACL_DELETE (1<<3)
87 #define ACL_TRUNCATE (1<<4)
88 #define ACL_REFERENCES (1<<5)
89 #define ACL_TRIGGER (1<<6)
90 #define ACL_EXECUTE (1<<7) /* for functions */
91 #define ACL_USAGE (1<<8) /* for languages, namespaces, FDWs, and
92  * servers */
93 #define ACL_CREATE (1<<9) /* for namespaces and databases */
94 #define ACL_CREATE_TEMP (1<<10) /* for databases */
95 #define ACL_CONNECT (1<<11) /* for databases */
96 #define ACL_SET (1<<12) /* for configuration parameters */
97 #define ACL_ALTER_SYSTEM (1<<13) /* for configuration parameters */
98 #define ACL_VACUUM (1<<14) /* for relations */
99 #define ACL_ANALYZE (1<<15) /* for relations */
100 #define N_ACL_RIGHTS 16 /* 1 plus the last 1<<x */
101 #define ACL_NO_RIGHTS 0
102 /* Currently, SELECT ... FOR [KEY] UPDATE/SHARE requires UPDATE privileges */
103 #define ACL_SELECT_FOR_UPDATE ACL_UPDATE
104 
105 
106 /*****************************************************************************
107  * Query Tree
108  *****************************************************************************/
109 
110 /*
111  * Query -
112  * Parse analysis turns all statements into a Query tree
113  * for further processing by the rewriter and planner.
114  *
115  * Utility statements (i.e. non-optimizable statements) have the
116  * utilityStmt field set, and the rest of the Query is mostly dummy.
117  *
118  * Planning converts a Query tree into a Plan tree headed by a PlannedStmt
119  * node --- the Query structure is not used by the executor.
120  */
121 typedef struct Query
122 {
123  NodeTag type;
124 
125  CmdType commandType; /* select|insert|update|delete|merge|utility */
126 
127  QuerySource querySource; /* where did I come from? */
128 
129  /*
130  * query identifier (can be set by plugins); ignored for equal, as it
131  * might not be set; also not stored
132  */
133  uint64 queryId pg_node_attr(equal_ignore, read_write_ignore, read_as(0));
134 
135  bool canSetTag; /* do I set the command result tag? */
136 
137  Node *utilityStmt; /* non-null if commandType == CMD_UTILITY */
138 
139  int resultRelation; /* rtable index of target relation for
140  * INSERT/UPDATE/DELETE/MERGE; 0 for SELECT */
141 
142  bool hasAggs; /* has aggregates in tlist or havingQual */
143  bool hasWindowFuncs; /* has window functions in tlist */
144  bool hasTargetSRFs; /* has set-returning functions in tlist */
145  bool hasSubLinks; /* has subquery SubLink */
146  bool hasDistinctOn; /* distinctClause is from DISTINCT ON */
147  bool hasRecursive; /* WITH RECURSIVE was specified */
148  bool hasModifyingCTE; /* has INSERT/UPDATE/DELETE in WITH */
149  bool hasForUpdate; /* FOR [KEY] UPDATE/SHARE was specified */
150  bool hasRowSecurity; /* rewriter has applied some RLS policy */
151 
152  bool isReturn; /* is a RETURN statement */
153 
154  List *cteList; /* WITH list (of CommonTableExpr's) */
155 
156  List *rtable; /* list of range table entries */
157  List *rteperminfos; /* list of RTEPermissionInfo nodes for the
158  * rtable entries having perminfoindex > 0 */
159  FromExpr *jointree; /* table join tree (FROM and WHERE clauses);
160  * also USING clause for MERGE */
161 
162  List *mergeActionList; /* list of actions for MERGE (only) */
163  bool mergeUseOuterJoin; /* whether to use outer join */
164 
165  List *targetList; /* target list (of TargetEntry) */
166 
167  OverridingKind override; /* OVERRIDING clause */
168 
169  OnConflictExpr *onConflict; /* ON CONFLICT DO [NOTHING | UPDATE] */
170 
171  List *returningList; /* return-values list (of TargetEntry) */
172 
173  List *groupClause; /* a list of SortGroupClause's */
174  bool groupDistinct; /* is the group by clause distinct? */
175 
176  List *groupingSets; /* a list of GroupingSet's if present */
177 
178  Node *havingQual; /* qualifications applied to groups */
179 
180  List *windowClause; /* a list of WindowClause's */
181 
182  List *distinctClause; /* a list of SortGroupClause's */
183 
184  List *sortClause; /* a list of SortGroupClause's */
185 
186  Node *limitOffset; /* # of result tuples to skip (int8 expr) */
187  Node *limitCount; /* # of result tuples to return (int8 expr) */
188  LimitOption limitOption; /* limit type */
189 
190  List *rowMarks; /* a list of RowMarkClause's */
191 
192  Node *setOperations; /* set-operation tree if this is top level of
193  * a UNION/INTERSECT/EXCEPT query */
194 
195  List *constraintDeps; /* a list of pg_constraint OIDs that the query
196  * depends on to be semantically valid */
197 
198  List *withCheckOptions; /* a list of WithCheckOption's (added
199  * during rewrite) */
200 
201  /*
202  * The following two fields identify the portion of the source text string
203  * containing this query. They are typically only populated in top-level
204  * Queries, not in sub-queries. When not set, they might both be zero, or
205  * both be -1 meaning "unknown".
206  */
207  int stmt_location; /* start location, or -1 if unknown */
208  int stmt_len; /* length in bytes; 0 means "rest of string" */
209 } Query;
210 
211 
212 /****************************************************************************
213  * Supporting data structures for Parse Trees
214  *
215  * Most of these node types appear in raw parsetrees output by the grammar,
216  * and get transformed to something else by the analyzer. A few of them
217  * are used as-is in transformed querytrees.
218  ****************************************************************************/
219 
220 /*
221  * TypeName - specifies a type in definitions
222  *
223  * For TypeName structures generated internally, it is often easier to
224  * specify the type by OID than by name. If "names" is NIL then the
225  * actual type OID is given by typeOid, otherwise typeOid is unused.
226  * Similarly, if "typmods" is NIL then the actual typmod is expected to
227  * be prespecified in typemod, otherwise typemod is unused.
228  *
229  * If pct_type is true, then names is actually a field name and we look up
230  * the type of that field. Otherwise (the normal case), names is a type
231  * name possibly qualified with schema and database name.
232  */
233 typedef struct TypeName
234 {
236  List *names; /* qualified name (list of String nodes) */
237  Oid typeOid; /* type identified by OID */
238  bool setof; /* is a set? */
239  bool pct_type; /* %TYPE specified? */
240  List *typmods; /* type modifier expression(s) */
241  int32 typemod; /* prespecified type modifier */
242  List *arrayBounds; /* array bounds */
243  int location; /* token location, or -1 if unknown */
244 } TypeName;
245 
246 /*
247  * ColumnRef - specifies a reference to a column, or possibly a whole tuple
248  *
249  * The "fields" list must be nonempty. It can contain String nodes
250  * (representing names) and A_Star nodes (representing occurrence of a '*').
251  * Currently, A_Star must appear only as the last list element --- the grammar
252  * is responsible for enforcing this!
253  *
254  * Note: any container subscripting or selection of fields from composite columns
255  * is represented by an A_Indirection node above the ColumnRef. However,
256  * for simplicity in the normal case, initial field selection from a table
257  * name is represented within ColumnRef and not by adding A_Indirection.
258  */
259 typedef struct ColumnRef
260 {
262  List *fields; /* field names (String nodes) or A_Star */
263  int location; /* token location, or -1 if unknown */
264 } ColumnRef;
265 
266 /*
267  * ParamRef - specifies a $n parameter reference
268  */
269 typedef struct ParamRef
270 {
272  int number; /* the number of the parameter */
273  int location; /* token location, or -1 if unknown */
274 } ParamRef;
275 
276 /*
277  * A_Expr - infix, prefix, and postfix expressions
278  */
279 typedef enum A_Expr_Kind
280 {
281  AEXPR_OP, /* normal operator */
282  AEXPR_OP_ANY, /* scalar op ANY (array) */
283  AEXPR_OP_ALL, /* scalar op ALL (array) */
284  AEXPR_DISTINCT, /* IS DISTINCT FROM - name must be "=" */
285  AEXPR_NOT_DISTINCT, /* IS NOT DISTINCT FROM - name must be "=" */
286  AEXPR_NULLIF, /* NULLIF - name must be "=" */
287  AEXPR_IN, /* [NOT] IN - name must be "=" or "<>" */
288  AEXPR_LIKE, /* [NOT] LIKE - name must be "~~" or "!~~" */
289  AEXPR_ILIKE, /* [NOT] ILIKE - name must be "~~*" or "!~~*" */
290  AEXPR_SIMILAR, /* [NOT] SIMILAR - name must be "~" or "!~" */
291  AEXPR_BETWEEN, /* name must be "BETWEEN" */
292  AEXPR_NOT_BETWEEN, /* name must be "NOT BETWEEN" */
293  AEXPR_BETWEEN_SYM, /* name must be "BETWEEN SYMMETRIC" */
294  AEXPR_NOT_BETWEEN_SYM /* name must be "NOT BETWEEN SYMMETRIC" */
295 } A_Expr_Kind;
296 
297 typedef struct A_Expr
298 {
299  pg_node_attr(custom_read_write)
300 
302  A_Expr_Kind kind; /* see above */
303  List *name; /* possibly-qualified name of operator */
304  Node *lexpr; /* left argument, or NULL if none */
305  Node *rexpr; /* right argument, or NULL if none */
306  int location; /* token location, or -1 if unknown */
307 } A_Expr;
308 
309 /*
310  * A_Const - a literal constant
311  *
312  * Value nodes are inline for performance. You can treat 'val' as a node,
313  * as in IsA(&val, Integer). 'val' is not valid if isnull is true.
314  */
315 union ValUnion
316 {
317  Node node;
318  Integer ival;
319  Float fval;
320  Boolean boolval;
321  String sval;
322  BitString bsval;
323 };
324 
325 typedef struct A_Const
326 {
327  pg_node_attr(custom_copy_equal, custom_read_write)
328 
329  NodeTag type;
330  union ValUnion val;
331  bool isnull; /* SQL NULL constant */
332  int location; /* token location, or -1 if unknown */
333 } A_Const;
334 
335 /*
336  * TypeCast - a CAST expression
337  */
338 typedef struct TypeCast
339 {
341  Node *arg; /* the expression being casted */
342  TypeName *typeName; /* the target type */
343  int location; /* token location, or -1 if unknown */
344 } TypeCast;
345 
346 /*
347  * CollateClause - a COLLATE expression
348  */
349 typedef struct CollateClause
350 {
352  Node *arg; /* input expression */
353  List *collname; /* possibly-qualified collation name */
354  int location; /* token location, or -1 if unknown */
355 } CollateClause;
356 
357 /*
358  * RoleSpec - a role name or one of a few special values.
359  */
360 typedef enum RoleSpecType
361 {
362  ROLESPEC_CSTRING, /* role name is stored as a C string */
363  ROLESPEC_CURRENT_ROLE, /* role spec is CURRENT_ROLE */
364  ROLESPEC_CURRENT_USER, /* role spec is CURRENT_USER */
365  ROLESPEC_SESSION_USER, /* role spec is SESSION_USER */
366  ROLESPEC_PUBLIC /* role name is "public" */
367 } RoleSpecType;
368 
369 typedef struct RoleSpec
370 {
372  RoleSpecType roletype; /* Type of this rolespec */
373  char *rolename; /* filled only for ROLESPEC_CSTRING */
374  int location; /* token location, or -1 if unknown */
375 } RoleSpec;
376 
377 /*
378  * FuncCall - a function or aggregate invocation
379  *
380  * agg_order (if not NIL) indicates we saw 'foo(... ORDER BY ...)', or if
381  * agg_within_group is true, it was 'foo(...) WITHIN GROUP (ORDER BY ...)'.
382  * agg_star indicates we saw a 'foo(*)' construct, while agg_distinct
383  * indicates we saw 'foo(DISTINCT ...)'. In any of these cases, the
384  * construct *must* be an aggregate call. Otherwise, it might be either an
385  * aggregate or some other kind of function. However, if FILTER or OVER is
386  * present it had better be an aggregate or window function.
387  *
388  * Normally, you'd initialize this via makeFuncCall() and then only change the
389  * parts of the struct its defaults don't match afterwards, as needed.
390  */
391 typedef struct FuncCall
392 {
394  List *funcname; /* qualified name of function */
395  List *args; /* the arguments (list of exprs) */
396  List *agg_order; /* ORDER BY (list of SortBy) */
397  Node *agg_filter; /* FILTER clause, if any */
398  struct WindowDef *over; /* OVER clause, if any */
399  bool agg_within_group; /* ORDER BY appeared in WITHIN GROUP */
400  bool agg_star; /* argument was really '*' */
401  bool agg_distinct; /* arguments were labeled DISTINCT */
402  bool func_variadic; /* last argument was labeled VARIADIC */
403  CoercionForm funcformat; /* how to display this node */
404  int location; /* token location, or -1 if unknown */
405 } FuncCall;
406 
407 /*
408  * A_Star - '*' representing all columns of a table or compound field
409  *
410  * This can appear within ColumnRef.fields, A_Indirection.indirection, and
411  * ResTarget.indirection lists.
412  */
413 typedef struct A_Star
414 {
416 } A_Star;
417 
418 /*
419  * A_Indices - array subscript or slice bounds ([idx] or [lidx:uidx])
420  *
421  * In slice case, either or both of lidx and uidx can be NULL (omitted).
422  * In non-slice case, uidx holds the single subscript and lidx is always NULL.
423  */
424 typedef struct A_Indices
425 {
427  bool is_slice; /* true if slice (i.e., colon present) */
428  Node *lidx; /* slice lower bound, if any */
429  Node *uidx; /* subscript, or slice upper bound if any */
430 } A_Indices;
431 
432 /*
433  * A_Indirection - select a field and/or array element from an expression
434  *
435  * The indirection list can contain A_Indices nodes (representing
436  * subscripting), String nodes (representing field selection --- the
437  * string value is the name of the field to select), and A_Star nodes
438  * (representing selection of all fields of a composite type).
439  * For example, a complex selection operation like
440  * (foo).field1[42][7].field2
441  * would be represented with a single A_Indirection node having a 4-element
442  * indirection list.
443  *
444  * Currently, A_Star must appear only as the last list element --- the grammar
445  * is responsible for enforcing this!
446  */
447 typedef struct A_Indirection
448 {
450  Node *arg; /* the thing being selected from */
451  List *indirection; /* subscripts and/or field names and/or * */
452 } A_Indirection;
453 
454 /*
455  * A_ArrayExpr - an ARRAY[] construct
456  */
457 typedef struct A_ArrayExpr
458 {
460  List *elements; /* array element expressions */
461  int location; /* token location, or -1 if unknown */
462 } A_ArrayExpr;
463 
464 /*
465  * ResTarget -
466  * result target (used in target list of pre-transformed parse trees)
467  *
468  * In a SELECT target list, 'name' is the column label from an
469  * 'AS ColumnLabel' clause, or NULL if there was none, and 'val' is the
470  * value expression itself. The 'indirection' field is not used.
471  *
472  * INSERT uses ResTarget in its target-column-names list. Here, 'name' is
473  * the name of the destination column, 'indirection' stores any subscripts
474  * attached to the destination, and 'val' is not used.
475  *
476  * In an UPDATE target list, 'name' is the name of the destination column,
477  * 'indirection' stores any subscripts attached to the destination, and
478  * 'val' is the expression to assign.
479  *
480  * See A_Indirection for more info about what can appear in 'indirection'.
481  */
482 typedef struct ResTarget
483 {
485  char *name; /* column name or NULL */
486  List *indirection; /* subscripts, field names, and '*', or NIL */
487  Node *val; /* the value expression to compute or assign */
488  int location; /* token location, or -1 if unknown */
489 } ResTarget;
490 
491 /*
492  * MultiAssignRef - element of a row source expression for UPDATE
493  *
494  * In an UPDATE target list, when we have SET (a,b,c) = row-valued-expression,
495  * we generate separate ResTarget items for each of a,b,c. Their "val" trees
496  * are MultiAssignRef nodes numbered 1..n, linking to a common copy of the
497  * row-valued-expression (which parse analysis will process only once, when
498  * handling the MultiAssignRef with colno=1).
499  */
500 typedef struct MultiAssignRef
501 {
503  Node *source; /* the row-valued expression */
504  int colno; /* column number for this target (1..n) */
505  int ncolumns; /* number of targets in the construct */
507 
508 /*
509  * SortBy - for ORDER BY clause
510  */
511 typedef struct SortBy
512 {
514  Node *node; /* expression to sort on */
515  SortByDir sortby_dir; /* ASC/DESC/USING/default */
516  SortByNulls sortby_nulls; /* NULLS FIRST/LAST */
517  List *useOp; /* name of op to use, if SORTBY_USING */
518  int location; /* operator location, or -1 if none/unknown */
519 } SortBy;
520 
521 /*
522  * WindowDef - raw representation of WINDOW and OVER clauses
523  *
524  * For entries in a WINDOW list, "name" is the window name being defined.
525  * For OVER clauses, we use "name" for the "OVER window" syntax, or "refname"
526  * for the "OVER (window)" syntax, which is subtly different --- the latter
527  * implies overriding the window frame clause.
528  */
529 typedef struct WindowDef
530 {
532  char *name; /* window's own name */
533  char *refname; /* referenced window name, if any */
534  List *partitionClause; /* PARTITION BY expression list */
535  List *orderClause; /* ORDER BY (list of SortBy) */
536  int frameOptions; /* frame_clause options, see below */
537  Node *startOffset; /* expression for starting bound, if any */
538  Node *endOffset; /* expression for ending bound, if any */
539  int location; /* parse location, or -1 if none/unknown */
540 } WindowDef;
541 
542 /*
543  * frameOptions is an OR of these bits. The NONDEFAULT and BETWEEN bits are
544  * used so that ruleutils.c can tell which properties were specified and
545  * which were defaulted; the correct behavioral bits must be set either way.
546  * The START_foo and END_foo options must come in pairs of adjacent bits for
547  * the convenience of gram.y, even though some of them are useless/invalid.
548  */
549 #define FRAMEOPTION_NONDEFAULT 0x00001 /* any specified? */
550 #define FRAMEOPTION_RANGE 0x00002 /* RANGE behavior */
551 #define FRAMEOPTION_ROWS 0x00004 /* ROWS behavior */
552 #define FRAMEOPTION_GROUPS 0x00008 /* GROUPS behavior */
553 #define FRAMEOPTION_BETWEEN 0x00010 /* BETWEEN given? */
554 #define FRAMEOPTION_START_UNBOUNDED_PRECEDING 0x00020 /* start is U. P. */
555 #define FRAMEOPTION_END_UNBOUNDED_PRECEDING 0x00040 /* (disallowed) */
556 #define FRAMEOPTION_START_UNBOUNDED_FOLLOWING 0x00080 /* (disallowed) */
557 #define FRAMEOPTION_END_UNBOUNDED_FOLLOWING 0x00100 /* end is U. F. */
558 #define FRAMEOPTION_START_CURRENT_ROW 0x00200 /* start is C. R. */
559 #define FRAMEOPTION_END_CURRENT_ROW 0x00400 /* end is C. R. */
560 #define FRAMEOPTION_START_OFFSET_PRECEDING 0x00800 /* start is O. P. */
561 #define FRAMEOPTION_END_OFFSET_PRECEDING 0x01000 /* end is O. P. */
562 #define FRAMEOPTION_START_OFFSET_FOLLOWING 0x02000 /* start is O. F. */
563 #define FRAMEOPTION_END_OFFSET_FOLLOWING 0x04000 /* end is O. F. */
564 #define FRAMEOPTION_EXCLUDE_CURRENT_ROW 0x08000 /* omit C.R. */
565 #define FRAMEOPTION_EXCLUDE_GROUP 0x10000 /* omit C.R. & peers */
566 #define FRAMEOPTION_EXCLUDE_TIES 0x20000 /* omit C.R.'s peers */
567 
568 #define FRAMEOPTION_START_OFFSET \
569  (FRAMEOPTION_START_OFFSET_PRECEDING | FRAMEOPTION_START_OFFSET_FOLLOWING)
570 #define FRAMEOPTION_END_OFFSET \
571  (FRAMEOPTION_END_OFFSET_PRECEDING | FRAMEOPTION_END_OFFSET_FOLLOWING)
572 #define FRAMEOPTION_EXCLUSION \
573  (FRAMEOPTION_EXCLUDE_CURRENT_ROW | FRAMEOPTION_EXCLUDE_GROUP | \
574  FRAMEOPTION_EXCLUDE_TIES)
575 
576 #define FRAMEOPTION_DEFAULTS \
577  (FRAMEOPTION_RANGE | FRAMEOPTION_START_UNBOUNDED_PRECEDING | \
578  FRAMEOPTION_END_CURRENT_ROW)
579 
580 /*
581  * RangeSubselect - subquery appearing in a FROM clause
582  */
583 typedef struct RangeSubselect
584 {
586  bool lateral; /* does it have LATERAL prefix? */
587  Node *subquery; /* the untransformed sub-select clause */
588  Alias *alias; /* table alias & optional column aliases */
590 
591 /*
592  * RangeFunction - function call appearing in a FROM clause
593  *
594  * functions is a List because we use this to represent the construct
595  * ROWS FROM(func1(...), func2(...), ...). Each element of this list is a
596  * two-element sublist, the first element being the untransformed function
597  * call tree, and the second element being a possibly-empty list of ColumnDef
598  * nodes representing any columndef list attached to that function within the
599  * ROWS FROM() syntax.
600  *
601  * alias and coldeflist represent any alias and/or columndef list attached
602  * at the top level. (We disallow coldeflist appearing both here and
603  * per-function, but that's checked in parse analysis, not by the grammar.)
604  */
605 typedef struct RangeFunction
606 {
608  bool lateral; /* does it have LATERAL prefix? */
609  bool ordinality; /* does it have WITH ORDINALITY suffix? */
610  bool is_rowsfrom; /* is result of ROWS FROM() syntax? */
611  List *functions; /* per-function information, see above */
612  Alias *alias; /* table alias & optional column aliases */
613  List *coldeflist; /* list of ColumnDef nodes to describe result
614  * of function returning RECORD */
615 } RangeFunction;
616 
617 /*
618  * RangeTableFunc - raw form of "table functions" such as XMLTABLE
619  */
620 typedef struct RangeTableFunc
621 {
623  bool lateral; /* does it have LATERAL prefix? */
624  Node *docexpr; /* document expression */
625  Node *rowexpr; /* row generator expression */
626  List *namespaces; /* list of namespaces as ResTarget */
627  List *columns; /* list of RangeTableFuncCol */
628  Alias *alias; /* table alias & optional column aliases */
629  int location; /* token location, or -1 if unknown */
631 
632 /*
633  * RangeTableFuncCol - one column in a RangeTableFunc->columns
634  *
635  * If for_ordinality is true (FOR ORDINALITY), then the column is an int4
636  * column and the rest of the fields are ignored.
637  */
638 typedef struct RangeTableFuncCol
639 {
641  char *colname; /* name of generated column */
642  TypeName *typeName; /* type of generated column */
643  bool for_ordinality; /* does it have FOR ORDINALITY? */
644  bool is_not_null; /* does it have NOT NULL? */
645  Node *colexpr; /* column filter expression */
646  Node *coldefexpr; /* column default value expression */
647  int location; /* token location, or -1 if unknown */
649 
650 /*
651  * RangeTableSample - TABLESAMPLE appearing in a raw FROM clause
652  *
653  * This node, appearing only in raw parse trees, represents
654  * <relation> TABLESAMPLE <method> (<params>) REPEATABLE (<num>)
655  * Currently, the <relation> can only be a RangeVar, but we might in future
656  * allow RangeSubselect and other options. Note that the RangeTableSample
657  * is wrapped around the node representing the <relation>, rather than being
658  * a subfield of it.
659  */
660 typedef struct RangeTableSample
661 {
663  Node *relation; /* relation to be sampled */
664  List *method; /* sampling method name (possibly qualified) */
665  List *args; /* argument(s) for sampling method */
666  Node *repeatable; /* REPEATABLE expression, or NULL if none */
667  int location; /* method name location, or -1 if unknown */
669 
670 /*
671  * ColumnDef - column definition (used in various creates)
672  *
673  * If the column has a default value, we may have the value expression
674  * in either "raw" form (an untransformed parse tree) or "cooked" form
675  * (a post-parse-analysis, executable expression tree), depending on
676  * how this ColumnDef node was created (by parsing, or by inheritance
677  * from an existing relation). We should never have both in the same node!
678  *
679  * Similarly, we may have a COLLATE specification in either raw form
680  * (represented as a CollateClause with arg==NULL) or cooked form
681  * (the collation's OID).
682  *
683  * The constraints list may contain a CONSTR_DEFAULT item in a raw
684  * parsetree produced by gram.y, but transformCreateStmt will remove
685  * the item and set raw_default instead. CONSTR_DEFAULT items
686  * should not appear in any subsequent processing.
687  */
688 typedef struct ColumnDef
689 {
691  char *colname; /* name of column */
692  TypeName *typeName; /* type of column */
693  char *compression; /* compression method for column */
694  int inhcount; /* number of times column is inherited */
695  bool is_local; /* column has local (non-inherited) def'n */
696  bool is_not_null; /* NOT NULL constraint specified? */
697  bool is_from_type; /* column definition came from table type */
698  char storage; /* attstorage setting, or 0 for default */
699  char *storage_name; /* attstorage setting name or NULL for default */
700  Node *raw_default; /* default value (untransformed parse tree) */
701  Node *cooked_default; /* default value (transformed expr tree) */
702  char identity; /* attidentity setting */
703  RangeVar *identitySequence; /* to store identity sequence name for
704  * ALTER TABLE ... ADD COLUMN */
705  char generated; /* attgenerated setting */
706  CollateClause *collClause; /* untransformed COLLATE spec, if any */
707  Oid collOid; /* collation OID (InvalidOid if not set) */
708  List *constraints; /* other constraints on column */
709  List *fdwoptions; /* per-column FDW options */
710  int location; /* parse location, or -1 if none/unknown */
711 } ColumnDef;
712 
713 /*
714  * TableLikeClause - CREATE TABLE ( ... LIKE ... ) clause
715  */
716 typedef struct TableLikeClause
717 {
719  RangeVar *relation;
720  bits32 options; /* OR of TableLikeOption flags */
721  Oid relationOid; /* If table has been looked up, its OID */
723 
724 typedef enum TableLikeOption
725 {
734  CREATE_TABLE_LIKE_STORAGE = 1 << 8,
737 
738 /*
739  * IndexElem - index parameters (used in CREATE INDEX, and in ON CONFLICT)
740  *
741  * For a plain index attribute, 'name' is the name of the table column to
742  * index, and 'expr' is NULL. For an index expression, 'name' is NULL and
743  * 'expr' is the expression tree.
744  */
745 typedef struct IndexElem
746 {
748  char *name; /* name of attribute to index, or NULL */
749  Node *expr; /* expression to index, or NULL */
750  char *indexcolname; /* name for index column; NULL = default */
751  List *collation; /* name of collation; NIL = default */
752  List *opclass; /* name of desired opclass; NIL = default */
753  List *opclassopts; /* opclass-specific options, or NIL */
754  SortByDir ordering; /* ASC/DESC/default */
755  SortByNulls nulls_ordering; /* FIRST/LAST/default */
756 } IndexElem;
757 
758 /*
759  * DefElem - a generic "name = value" option definition
760  *
761  * In some contexts the name can be qualified. Also, certain SQL commands
762  * allow a SET/ADD/DROP action to be attached to option settings, so it's
763  * convenient to carry a field for that too. (Note: currently, it is our
764  * practice that the grammar allows namespace and action only in statements
765  * where they are relevant; C code can just ignore those fields in other
766  * statements.)
767  */
768 typedef enum DefElemAction
769 {
770  DEFELEM_UNSPEC, /* no action given */
772  DEFELEM_ADD,
774 } DefElemAction;
775 
776 typedef struct DefElem
777 {
779  char *defnamespace; /* NULL if unqualified name */
780  char *defname;
781  Node *arg; /* typically Integer, Float, String, or
782  * TypeName */
783  DefElemAction defaction; /* unspecified action, or SET/ADD/DROP */
784  int location; /* token location, or -1 if unknown */
785 } DefElem;
786 
787 /*
788  * LockingClause - raw representation of FOR [NO KEY] UPDATE/[KEY] SHARE
789  * options
790  *
791  * Note: lockedRels == NIL means "all relations in query". Otherwise it
792  * is a list of RangeVar nodes. (We use RangeVar mainly because it carries
793  * a location field --- currently, parse analysis insists on unqualified
794  * names in LockingClause.)
795  */
796 typedef struct LockingClause
797 {
799  List *lockedRels; /* FOR [KEY] UPDATE/SHARE relations */
801  LockWaitPolicy waitPolicy; /* NOWAIT and SKIP LOCKED */
802 } LockingClause;
803 
804 /*
805  * XMLSERIALIZE (in raw parse tree only)
806  */
807 typedef struct XmlSerialize
808 {
810  XmlOptionType xmloption; /* DOCUMENT or CONTENT */
811  Node *expr;
812  TypeName *typeName;
813  int location; /* token location, or -1 if unknown */
814 } XmlSerialize;
815 
816 /* Partitioning related definitions */
817 
818 /*
819  * PartitionElem - parse-time representation of a single partition key
820  *
821  * expr can be either a raw expression tree or a parse-analyzed expression.
822  * We don't store these on-disk, though.
823  */
824 typedef struct PartitionElem
825 {
827  char *name; /* name of column to partition on, or NULL */
828  Node *expr; /* expression to partition on, or NULL */
829  List *collation; /* name of collation; NIL = default */
830  List *opclass; /* name of desired opclass; NIL = default */
831  int location; /* token location, or -1 if unknown */
832 } PartitionElem;
833 
834 typedef enum PartitionStrategy
835 {
840 
841 /*
842  * PartitionSpec - parse-time representation of a partition key specification
843  *
844  * This represents the key space we will be partitioning on.
845  */
846 typedef struct PartitionSpec
847 {
850  List *partParams; /* List of PartitionElems */
851  int location; /* token location, or -1 if unknown */
852 } PartitionSpec;
853 
854 /*
855  * PartitionBoundSpec - a partition bound specification
856  *
857  * This represents the portion of the partition key space assigned to a
858  * particular partition. These are stored on disk in pg_class.relpartbound.
859  */
860 struct PartitionBoundSpec
861 {
862  NodeTag type;
863 
864  char strategy; /* see PARTITION_STRATEGY codes above */
865  bool is_default; /* is it a default partition bound? */
866 
867  /* Partitioning info for HASH strategy: */
868  int modulus;
869  int remainder;
870 
871  /* Partitioning info for LIST strategy: */
872  List *listdatums; /* List of Consts (or A_Consts in raw tree) */
873 
874  /* Partitioning info for RANGE strategy: */
875  List *lowerdatums; /* List of PartitionRangeDatums */
876  List *upperdatums; /* List of PartitionRangeDatums */
877 
878  int location; /* token location, or -1 if unknown */
879 };
880 
881 /*
882  * PartitionRangeDatum - one of the values in a range partition bound
883  *
884  * This can be MINVALUE, MAXVALUE or a specific bounded value.
885  */
886 typedef enum PartitionRangeDatumKind
887 {
888  PARTITION_RANGE_DATUM_MINVALUE = -1, /* less than any other value */
889  PARTITION_RANGE_DATUM_VALUE = 0, /* a specific (bounded) value */
890  PARTITION_RANGE_DATUM_MAXVALUE = 1 /* greater than any other value */
892 
893 typedef struct PartitionRangeDatum
894 {
895  NodeTag type;
896 
898  Node *value; /* Const (or A_Const in raw tree), if kind is
899  * PARTITION_RANGE_DATUM_VALUE, else NULL */
900 
901  int location; /* token location, or -1 if unknown */
903 
904 /*
905  * PartitionCmd - info for ALTER TABLE/INDEX ATTACH/DETACH PARTITION commands
906  */
907 typedef struct PartitionCmd
908 {
910  RangeVar *name; /* name of partition to attach/detach */
911  PartitionBoundSpec *bound; /* FOR VALUES, if attaching */
912  bool concurrent;
913 } PartitionCmd;
914 
915 /****************************************************************************
916  * Nodes for a Query tree
917  ****************************************************************************/
918 
919 /*--------------------
920  * RangeTblEntry -
921  * A range table is a List of RangeTblEntry nodes.
922  *
923  * A range table entry may represent a plain relation, a sub-select in
924  * FROM, or the result of a JOIN clause. (Only explicit JOIN syntax
925  * produces an RTE, not the implicit join resulting from multiple FROM
926  * items. This is because we only need the RTE to deal with SQL features
927  * like outer joins and join-output-column aliasing.) Other special
928  * RTE types also exist, as indicated by RTEKind.
929  *
930  * Note that we consider RTE_RELATION to cover anything that has a pg_class
931  * entry. relkind distinguishes the sub-cases.
932  *
933  * alias is an Alias node representing the AS alias-clause attached to the
934  * FROM expression, or NULL if no clause.
935  *
936  * eref is the table reference name and column reference names (either
937  * real or aliases). Note that system columns (OID etc) are not included
938  * in the column list.
939  * eref->aliasname is required to be present, and should generally be used
940  * to identify the RTE for error messages etc.
941  *
942  * In RELATION RTEs, the colnames in both alias and eref are indexed by
943  * physical attribute number; this means there must be colname entries for
944  * dropped columns. When building an RTE we insert empty strings ("") for
945  * dropped columns. Note however that a stored rule may have nonempty
946  * colnames for columns dropped since the rule was created (and for that
947  * matter the colnames might be out of date due to column renamings).
948  * The same comments apply to FUNCTION RTEs when a function's return type
949  * is a named composite type.
950  *
951  * In JOIN RTEs, the colnames in both alias and eref are one-to-one with
952  * joinaliasvars entries. A JOIN RTE will omit columns of its inputs when
953  * those columns are known to be dropped at parse time. Again, however,
954  * a stored rule might contain entries for columns dropped since the rule
955  * was created. (This is only possible for columns not actually referenced
956  * in the rule.) When loading a stored rule, we replace the joinaliasvars
957  * items for any such columns with null pointers. (We can't simply delete
958  * them from the joinaliasvars list, because that would affect the attnums
959  * of Vars referencing the rest of the list.)
960  *
961  * inh is true for relation references that should be expanded to include
962  * inheritance children, if the rel has any. This *must* be false for
963  * RTEs other than RTE_RELATION entries.
964  *
965  * inFromCl marks those range variables that are listed in the FROM clause.
966  * It's false for RTEs that are added to a query behind the scenes, such
967  * as the NEW and OLD variables for a rule, or the subqueries of a UNION.
968  * This flag is not used during parsing (except in transformLockingClause,
969  * q.v.); the parser now uses a separate "namespace" data structure to
970  * control visibility. But it is needed by ruleutils.c to determine
971  * whether RTEs should be shown in decompiled queries.
972  *
973  * securityQuals is a list of security barrier quals (boolean expressions),
974  * to be tested in the listed order before returning a row from the
975  * relation. It is always NIL in parser output. Entries are added by the
976  * rewriter to implement security-barrier views and/or row-level security.
977  * Note that the planner turns each boolean expression into an implicitly
978  * AND'ed sublist, as is its usual habit with qualification expressions.
979  *--------------------
980  */
981 typedef enum RTEKind
982 {
983  RTE_RELATION, /* ordinary relation reference */
984  RTE_SUBQUERY, /* subquery in FROM */
985  RTE_JOIN, /* join */
986  RTE_FUNCTION, /* function in FROM */
987  RTE_TABLEFUNC, /* TableFunc(.., column list) */
988  RTE_VALUES, /* VALUES (<exprlist>), (<exprlist>), ... */
989  RTE_CTE, /* common table expr (WITH list element) */
990  RTE_NAMEDTUPLESTORE, /* tuplestore, e.g. for AFTER triggers */
991  RTE_RESULT /* RTE represents an empty FROM clause; such
992  * RTEs are added by the planner, they're not
993  * present during parsing or rewriting */
994 } RTEKind;
995 
996 typedef struct RangeTblEntry
997 {
998  pg_node_attr(custom_read_write)
999 
1000  NodeTag type;
1002  RTEKind rtekind; /* see above */
1003 
1004  /*
1005  * XXX the fields applicable to only some rte kinds should be merged into
1006  * a union. I didn't do this yet because the diffs would impact a lot of
1007  * code that is being actively worked on. FIXME someday.
1008  */
1009 
1010  /*
1011  * Fields valid for a plain relation RTE (else zero):
1012  *
1013  * As a special case, RTE_NAMEDTUPLESTORE can also set relid to indicate
1014  * that the tuple format of the tuplestore is the same as the referenced
1015  * relation. This allows plans referencing AFTER trigger transition
1016  * tables to be invalidated if the underlying table is altered.
1017  *
1018  * rellockmode is really LOCKMODE, but it's declared int to avoid having
1019  * to include lock-related headers here. It must be RowExclusiveLock if
1020  * the RTE is an INSERT/UPDATE/DELETE/MERGE target, else RowShareLock if
1021  * the RTE is a SELECT FOR UPDATE/FOR SHARE target, else AccessShareLock.
1022  *
1023  * Note: in some cases, rule expansion may result in RTEs that are marked
1024  * with RowExclusiveLock even though they are not the target of the
1025  * current query; this happens if a DO ALSO rule simply scans the original
1026  * target table. We leave such RTEs with their original lockmode so as to
1027  * avoid getting an additional, lesser lock.
1028  *
1029  * perminfoindex is 1-based index of the RTEPermissionInfo belonging to
1030  * this RTE in the containing struct's list of same; 0 if permissions need
1031  * not be checked for this RTE.
1032  */
1033  Oid relid; /* OID of the relation */
1034  char relkind; /* relation kind (see pg_class.relkind) */
1035  int rellockmode; /* lock level that query requires on the rel */
1036  struct TableSampleClause *tablesample; /* sampling info, or NULL */
1037  Index perminfoindex;
1038 
1039  /*
1040  * Fields valid for a subquery RTE (else NULL):
1041  */
1042  Query *subquery; /* the sub-query */
1043  bool security_barrier; /* is from security_barrier view? */
1044 
1045  /*
1046  * Fields valid for a join RTE (else NULL/zero):
1047  *
1048  * joinaliasvars is a list of (usually) Vars corresponding to the columns
1049  * of the join result. An alias Var referencing column K of the join
1050  * result can be replaced by the K'th element of joinaliasvars --- but to
1051  * simplify the task of reverse-listing aliases correctly, we do not do
1052  * that until planning time. In detail: an element of joinaliasvars can
1053  * be a Var of one of the join's input relations, or such a Var with an
1054  * implicit coercion to the join's output column type, or a COALESCE
1055  * expression containing the two input column Vars (possibly coerced).
1056  * Elements beyond the first joinmergedcols entries are always just Vars,
1057  * and are never referenced from elsewhere in the query (that is, join
1058  * alias Vars are generated only for merged columns). We keep these
1059  * entries only because they're needed in expandRTE() and similar code.
1060  *
1061  * Within a Query loaded from a stored rule, it is possible for non-merged
1062  * joinaliasvars items to be null pointers, which are placeholders for
1063  * (necessarily unreferenced) columns dropped since the rule was made.
1064  * Also, once planning begins, joinaliasvars items can be almost anything,
1065  * as a result of subquery-flattening substitutions.
1066  *
1067  * joinleftcols is an integer list of physical column numbers of the left
1068  * join input rel that are included in the join; likewise joinrighttcols
1069  * for the right join input rel. (Which rels those are can be determined
1070  * from the associated JoinExpr.) If the join is USING/NATURAL, then the
1071  * first joinmergedcols entries in each list identify the merged columns.
1072  * The merged columns come first in the join output, then remaining
1073  * columns of the left input, then remaining columns of the right.
1074  *
1075  * Note that input columns could have been dropped after creation of a
1076  * stored rule, if they are not referenced in the query (in particular,
1077  * merged columns could not be dropped); this is not accounted for in
1078  * joinleftcols/joinrighttcols.
1079  */
1080  JoinType jointype; /* type of join */
1081  int joinmergedcols; /* number of merged (JOIN USING) columns */
1082  List *joinaliasvars; /* list of alias-var expansions */
1083  List *joinleftcols; /* left-side input column numbers */
1084  List *joinrightcols; /* right-side input column numbers */
1085 
1086  /*
1087  * join_using_alias is an alias clause attached directly to JOIN/USING. It
1088  * is different from the alias field (below) in that it does not hide the
1089  * range variables of the tables being joined.
1090  */
1091  Alias *join_using_alias;
1092 
1093  /*
1094  * Fields valid for a function RTE (else NIL/zero):
1095  *
1096  * When funcordinality is true, the eref->colnames list includes an alias
1097  * for the ordinality column. The ordinality column is otherwise
1098  * implicit, and must be accounted for "by hand" in places such as
1099  * expandRTE().
1100  */
1101  List *functions; /* list of RangeTblFunction nodes */
1102  bool funcordinality; /* is this called WITH ORDINALITY? */
1103 
1104  /*
1105  * Fields valid for a TableFunc RTE (else NULL):
1106  */
1107  TableFunc *tablefunc;
1108 
1109  /*
1110  * Fields valid for a values RTE (else NIL):
1111  */
1112  List *values_lists; /* list of expression lists */
1113 
1114  /*
1115  * Fields valid for a CTE RTE (else NULL/zero):
1116  */
1117  char *ctename; /* name of the WITH list item */
1118  Index ctelevelsup; /* number of query levels up */
1119  bool self_reference; /* is this a recursive self-reference? */
1120 
1121  /*
1122  * Fields valid for CTE, VALUES, ENR, and TableFunc RTEs (else NIL):
1123  *
1124  * We need these for CTE RTEs so that the types of self-referential
1125  * columns are well-defined. For VALUES RTEs, storing these explicitly
1126  * saves having to re-determine the info by scanning the values_lists. For
1127  * ENRs, we store the types explicitly here (we could get the information
1128  * from the catalogs if 'relid' was supplied, but we'd still need these
1129  * for TupleDesc-based ENRs, so we might as well always store the type
1130  * info here). For TableFuncs, these fields are redundant with data in
1131  * the TableFunc node, but keeping them here allows some code sharing with
1132  * the other cases.
1133  *
1134  * For ENRs only, we have to consider the possibility of dropped columns.
1135  * A dropped column is included in these lists, but it will have zeroes in
1136  * all three lists (as well as an empty-string entry in eref). Testing
1137  * for zero coltype is the standard way to detect a dropped column.
1138  */
1139  List *coltypes; /* OID list of column type OIDs */
1140  List *coltypmods; /* integer list of column typmods */
1141  List *colcollations; /* OID list of column collation OIDs */
1142 
1143  /*
1144  * Fields valid for ENR RTEs (else NULL/zero):
1145  */
1146  char *enrname; /* name of ephemeral named relation */
1147  Cardinality enrtuples; /* estimated or actual from caller */
1148 
1149  /*
1150  * Fields valid in all RTEs:
1151  */
1152  Alias *alias; /* user-written alias clause, if any */
1153  Alias *eref; /* expanded reference names */
1154  bool lateral; /* subquery, function, or values is LATERAL? */
1155  bool inh; /* inheritance requested? */
1156  bool inFromCl; /* present in FROM clause? */
1157  Bitmapset *extraUpdatedCols; /* generated columns being updated */
1158  List *securityQuals; /* security barrier quals to apply, if any */
1159 } RangeTblEntry;
1160 
1161 /*
1162  * RTEPermissionInfo
1163  * Per-relation information for permission checking. Added to the Query
1164  * node by the parser when adding the corresponding RTE to the query
1165  * range table and subsequently editorialized on by the rewriter if
1166  * needed after rule expansion.
1167  *
1168  * Only the relations directly mentioned in the query are checked for
1169  * accesss permissions by the core executor, so only their RTEPermissionInfos
1170  * are present in the Query. However, extensions may want to check inheritance
1171  * children too, depending on the value of rte->inh, so it's copied in 'inh'
1172  * for their perusal.
1173  *
1174  * requiredPerms and checkAsUser specify run-time access permissions checks
1175  * to be performed at query startup. The user must have *all* of the
1176  * permissions that are OR'd together in requiredPerms (never 0!). If
1177  * checkAsUser is not zero, then do the permissions checks using the access
1178  * rights of that user, not the current effective user ID. (This allows rules
1179  * to act as setuid gateways.)
1180  *
1181  * For SELECT/INSERT/UPDATE permissions, if the user doesn't have table-wide
1182  * permissions then it is sufficient to have the permissions on all columns
1183  * identified in selectedCols (for SELECT) and/or insertedCols and/or
1184  * updatedCols (INSERT with ON CONFLICT DO UPDATE may have all 3).
1185  * selectedCols, insertedCols and updatedCols are bitmapsets, which cannot have
1186  * negative integer members, so we subtract FirstLowInvalidHeapAttributeNumber
1187  * from column numbers before storing them in these fields. A whole-row Var
1188  * reference is represented by setting the bit for InvalidAttrNumber.
1189  *
1190  * updatedCols is also used in some other places, for example, to determine
1191  * which triggers to fire and in FDWs to know which changed columns they need
1192  * to ship off.
1193  *
1194  * Generated columns that are caused to be updated by an update to a base
1195  * column are listed in extraUpdatedCols. This is not considered for
1196  * permission checking, but it is useful in those places that want to know the
1197  * full set of columns being updated as opposed to only the ones the user
1198  * explicitly mentioned in the query. (There is currently no need for an
1199  * extraInsertedCols, but it could exist.) Note that extraUpdatedCols is
1200  * populated during query rewrite, NOT in the parser, since generated columns
1201  * could be added after a rule has been parsed and stored.
1202  */
1203 typedef struct RTEPermissionInfo
1205  NodeTag type;
1207  Oid relid; /* relation OID */
1208  bool inh; /* separately check inheritance children? */
1209  AclMode requiredPerms; /* bitmask of required access permissions */
1210  Oid checkAsUser; /* if valid, check access as this role */
1211  Bitmapset *selectedCols; /* columns needing SELECT permission */
1212  Bitmapset *insertedCols; /* columns needing INSERT permission */
1213  Bitmapset *updatedCols; /* columns needing UPDATE permission */
1215 
1216 /*
1217  * RangeTblFunction -
1218  * RangeTblEntry subsidiary data for one function in a FUNCTION RTE.
1219  *
1220  * If the function had a column definition list (required for an
1221  * otherwise-unspecified RECORD result), funccolnames lists the names given
1222  * in the definition list, funccoltypes lists their declared column types,
1223  * funccoltypmods lists their typmods, funccolcollations their collations.
1224  * Otherwise, those fields are NIL.
1225  *
1226  * Notice we don't attempt to store info about the results of functions
1227  * returning named composite types, because those can change from time to
1228  * time. We do however remember how many columns we thought the type had
1229  * (including dropped columns!), so that we can successfully ignore any
1230  * columns added after the query was parsed.
1231  */
1232 typedef struct RangeTblFunction
1234  NodeTag type;
1236  Node *funcexpr; /* expression tree for func call */
1237  int funccolcount; /* number of columns it contributes to RTE */
1238  /* These fields record the contents of a column definition list, if any: */
1239  List *funccolnames; /* column names (list of String) */
1240  List *funccoltypes; /* OID list of column type OIDs */
1241  List *funccoltypmods; /* integer list of column typmods */
1242  List *funccolcollations; /* OID list of column collation OIDs */
1243  /* This is set during planning for use by the executor: */
1244  Bitmapset *funcparams; /* PARAM_EXEC Param IDs affecting this func */
1246 
1247 /*
1248  * TableSampleClause - TABLESAMPLE appearing in a transformed FROM clause
1249  *
1250  * Unlike RangeTableSample, this is a subnode of the relevant RangeTblEntry.
1251  */
1252 typedef struct TableSampleClause
1255  Oid tsmhandler; /* OID of the tablesample handler function */
1256  List *args; /* tablesample argument expression(s) */
1257  Expr *repeatable; /* REPEATABLE expression, or NULL if none */
1259 
1260 /*
1261  * WithCheckOption -
1262  * representation of WITH CHECK OPTION checks to be applied to new tuples
1263  * when inserting/updating an auto-updatable view, or RLS WITH CHECK
1264  * policies to be applied when inserting/updating a relation with RLS.
1265  */
1266 typedef enum WCOKind
1268  WCO_VIEW_CHECK, /* WCO on an auto-updatable view */
1269  WCO_RLS_INSERT_CHECK, /* RLS INSERT WITH CHECK policy */
1270  WCO_RLS_UPDATE_CHECK, /* RLS UPDATE WITH CHECK policy */
1271  WCO_RLS_CONFLICT_CHECK, /* RLS ON CONFLICT DO UPDATE USING policy */
1272  WCO_RLS_MERGE_UPDATE_CHECK, /* RLS MERGE UPDATE USING policy */
1273  WCO_RLS_MERGE_DELETE_CHECK /* RLS MERGE DELETE USING policy */
1274 } WCOKind;
1276 typedef struct WithCheckOption
1279  WCOKind kind; /* kind of WCO */
1280  char *relname; /* name of relation that specified the WCO */
1281  char *polname; /* name of RLS policy being checked */
1282  Node *qual; /* constraint qual to check */
1283  bool cascaded; /* true for a cascaded WCO on a view */
1284 } WithCheckOption;
1285 
1286 /*
1287  * SortGroupClause -
1288  * representation of ORDER BY, GROUP BY, PARTITION BY,
1289  * DISTINCT, DISTINCT ON items
1290  *
1291  * You might think that ORDER BY is only interested in defining ordering,
1292  * and GROUP/DISTINCT are only interested in defining equality. However,
1293  * one way to implement grouping is to sort and then apply a "uniq"-like
1294  * filter. So it's also interesting to keep track of possible sort operators
1295  * for GROUP/DISTINCT, and in particular to try to sort for the grouping
1296  * in a way that will also yield a requested ORDER BY ordering. So we need
1297  * to be able to compare ORDER BY and GROUP/DISTINCT lists, which motivates
1298  * the decision to give them the same representation.
1299  *
1300  * tleSortGroupRef must match ressortgroupref of exactly one entry of the
1301  * query's targetlist; that is the expression to be sorted or grouped by.
1302  * eqop is the OID of the equality operator.
1303  * sortop is the OID of the ordering operator (a "<" or ">" operator),
1304  * or InvalidOid if not available.
1305  * nulls_first means about what you'd expect. If sortop is InvalidOid
1306  * then nulls_first is meaningless and should be set to false.
1307  * hashable is true if eqop is hashable (note this condition also depends
1308  * on the datatype of the input expression).
1309  *
1310  * In an ORDER BY item, all fields must be valid. (The eqop isn't essential
1311  * here, but it's cheap to get it along with the sortop, and requiring it
1312  * to be valid eases comparisons to grouping items.) Note that this isn't
1313  * actually enough information to determine an ordering: if the sortop is
1314  * collation-sensitive, a collation OID is needed too. We don't store the
1315  * collation in SortGroupClause because it's not available at the time the
1316  * parser builds the SortGroupClause; instead, consult the exposed collation
1317  * of the referenced targetlist expression to find out what it is.
1318  *
1319  * In a grouping item, eqop must be valid. If the eqop is a btree equality
1320  * operator, then sortop should be set to a compatible ordering operator.
1321  * We prefer to set eqop/sortop/nulls_first to match any ORDER BY item that
1322  * the query presents for the same tlist item. If there is none, we just
1323  * use the default ordering op for the datatype.
1324  *
1325  * If the tlist item's type has a hash opclass but no btree opclass, then
1326  * we will set eqop to the hash equality operator, sortop to InvalidOid,
1327  * and nulls_first to false. A grouping item of this kind can only be
1328  * implemented by hashing, and of course it'll never match an ORDER BY item.
1329  *
1330  * The hashable flag is provided since we generally have the requisite
1331  * information readily available when the SortGroupClause is constructed,
1332  * and it's relatively expensive to get it again later. Note there is no
1333  * need for a "sortable" flag since OidIsValid(sortop) serves the purpose.
1334  *
1335  * A query might have both ORDER BY and DISTINCT (or DISTINCT ON) clauses.
1336  * In SELECT DISTINCT, the distinctClause list is as long or longer than the
1337  * sortClause list, while in SELECT DISTINCT ON it's typically shorter.
1338  * The two lists must match up to the end of the shorter one --- the parser
1339  * rearranges the distinctClause if necessary to make this true. (This
1340  * restriction ensures that only one sort step is needed to both satisfy the
1341  * ORDER BY and set up for the Unique step. This is semantically necessary
1342  * for DISTINCT ON, and presents no real drawback for DISTINCT.)
1343  */
1344 typedef struct SortGroupClause
1347  Index tleSortGroupRef; /* reference into targetlist */
1348  Oid eqop; /* the equality operator ('=' op) */
1349  Oid sortop; /* the ordering operator ('<' op), or 0 */
1350  bool nulls_first; /* do NULLs come before normal values? */
1351  bool hashable; /* can eqop be implemented by hashing? */
1352 } SortGroupClause;
1353 
1354 /*
1355  * GroupingSet -
1356  * representation of CUBE, ROLLUP and GROUPING SETS clauses
1357  *
1358  * In a Query with grouping sets, the groupClause contains a flat list of
1359  * SortGroupClause nodes for each distinct expression used. The actual
1360  * structure of the GROUP BY clause is given by the groupingSets tree.
1361  *
1362  * In the raw parser output, GroupingSet nodes (of all types except SIMPLE
1363  * which is not used) are potentially mixed in with the expressions in the
1364  * groupClause of the SelectStmt. (An expression can't contain a GroupingSet,
1365  * but a list may mix GroupingSet and expression nodes.) At this stage, the
1366  * content of each node is a list of expressions, some of which may be RowExprs
1367  * which represent sublists rather than actual row constructors, and nested
1368  * GroupingSet nodes where legal in the grammar. The structure directly
1369  * reflects the query syntax.
1370  *
1371  * In parse analysis, the transformed expressions are used to build the tlist
1372  * and groupClause list (of SortGroupClause nodes), and the groupingSets tree
1373  * is eventually reduced to a fixed format:
1374  *
1375  * EMPTY nodes represent (), and obviously have no content
1376  *
1377  * SIMPLE nodes represent a list of one or more expressions to be treated as an
1378  * atom by the enclosing structure; the content is an integer list of
1379  * ressortgroupref values (see SortGroupClause)
1380  *
1381  * CUBE and ROLLUP nodes contain a list of one or more SIMPLE nodes.
1382  *
1383  * SETS nodes contain a list of EMPTY, SIMPLE, CUBE or ROLLUP nodes, but after
1384  * parse analysis they cannot contain more SETS nodes; enough of the syntactic
1385  * transforms of the spec have been applied that we no longer have arbitrarily
1386  * deep nesting (though we still preserve the use of cube/rollup).
1387  *
1388  * Note that if the groupingSets tree contains no SIMPLE nodes (only EMPTY
1389  * nodes at the leaves), then the groupClause will be empty, but this is still
1390  * an aggregation query (similar to using aggs or HAVING without GROUP BY).
1391  *
1392  * As an example, the following clause:
1393  *
1394  * GROUP BY GROUPING SETS ((a,b), CUBE(c,(d,e)))
1395  *
1396  * looks like this after raw parsing:
1397  *
1398  * SETS( RowExpr(a,b) , CUBE( c, RowExpr(d,e) ) )
1399  *
1400  * and parse analysis converts it to:
1401  *
1402  * SETS( SIMPLE(1,2), CUBE( SIMPLE(3), SIMPLE(4,5) ) )
1403  */
1404 typedef enum GroupingSetKind
1411 } GroupingSetKind;
1413 typedef struct GroupingSet
1417  List *content;
1419 } GroupingSet;
1420 
1421 /*
1422  * WindowClause -
1423  * transformed representation of WINDOW and OVER clauses
1424  *
1425  * A parsed Query's windowClause list contains these structs. "name" is set
1426  * if the clause originally came from WINDOW, and is NULL if it originally
1427  * was an OVER clause (but note that we collapse out duplicate OVERs).
1428  * partitionClause and orderClause are lists of SortGroupClause structs.
1429  * If we have RANGE with offset PRECEDING/FOLLOWING, the semantics of that are
1430  * specified by startInRangeFunc/inRangeColl/inRangeAsc/inRangeNullsFirst
1431  * for the start offset, or endInRangeFunc/inRange* for the end offset.
1432  * winref is an ID number referenced by WindowFunc nodes; it must be unique
1433  * among the members of a Query's windowClause list.
1434  * When refname isn't null, the partitionClause is always copied from there;
1435  * the orderClause might or might not be copied (see copiedOrder); the framing
1436  * options are never copied, per spec.
1437  */
1438 typedef struct WindowClause
1441  char *name; /* window name (NULL in an OVER clause) */
1442  char *refname; /* referenced window name, if any */
1443  List *partitionClause; /* PARTITION BY list */
1444  List *orderClause; /* ORDER BY list */
1445  int frameOptions; /* frame_clause options, see WindowDef */
1446  Node *startOffset; /* expression for starting bound, if any */
1447  Node *endOffset; /* expression for ending bound, if any */
1448  List *runCondition; /* qual to help short-circuit execution */
1449  Oid startInRangeFunc; /* in_range function for startOffset */
1450  Oid endInRangeFunc; /* in_range function for endOffset */
1451  Oid inRangeColl; /* collation for in_range tests */
1452  bool inRangeAsc; /* use ASC sort order for in_range tests? */
1453  bool inRangeNullsFirst; /* nulls sort first for in_range tests? */
1454  Index winref; /* ID referenced by window functions */
1455  bool copiedOrder; /* did we copy orderClause from refname? */
1456 } WindowClause;
1457 
1458 /*
1459  * RowMarkClause -
1460  * parser output representation of FOR [KEY] UPDATE/SHARE clauses
1461  *
1462  * Query.rowMarks contains a separate RowMarkClause node for each relation
1463  * identified as a FOR [KEY] UPDATE/SHARE target. If one of these clauses
1464  * is applied to a subquery, we generate RowMarkClauses for all normal and
1465  * subquery rels in the subquery, but they are marked pushedDown = true to
1466  * distinguish them from clauses that were explicitly written at this query
1467  * level. Also, Query.hasForUpdate tells whether there were explicit FOR
1468  * UPDATE/SHARE/KEY SHARE clauses in the current query level.
1469  */
1470 typedef struct RowMarkClause
1473  Index rti; /* range table index of target relation */
1475  LockWaitPolicy waitPolicy; /* NOWAIT and SKIP LOCKED */
1476  bool pushedDown; /* pushed down from higher query level? */
1477 } RowMarkClause;
1478 
1479 /*
1480  * WithClause -
1481  * representation of WITH clause
1482  *
1483  * Note: WithClause does not propagate into the Query representation;
1484  * but CommonTableExpr does.
1485  */
1486 typedef struct WithClause
1489  List *ctes; /* list of CommonTableExprs */
1490  bool recursive; /* true = WITH RECURSIVE */
1491  int location; /* token location, or -1 if unknown */
1492 } WithClause;
1493 
1494 /*
1495  * InferClause -
1496  * ON CONFLICT unique index inference clause
1497  *
1498  * Note: InferClause does not propagate into the Query representation.
1499  */
1500 typedef struct InferClause
1503  List *indexElems; /* IndexElems to infer unique index */
1504  Node *whereClause; /* qualification (partial-index predicate) */
1505  char *conname; /* Constraint name, or NULL if unnamed */
1506  int location; /* token location, or -1 if unknown */
1507 } InferClause;
1508 
1509 /*
1510  * OnConflictClause -
1511  * representation of ON CONFLICT clause
1512  *
1513  * Note: OnConflictClause does not propagate into the Query representation.
1514  */
1515 typedef struct OnConflictClause
1518  OnConflictAction action; /* DO NOTHING or UPDATE? */
1519  InferClause *infer; /* Optional index inference clause */
1520  List *targetList; /* the target list (of ResTarget) */
1521  Node *whereClause; /* qualifications */
1522  int location; /* token location, or -1 if unknown */
1524 
1525 /*
1526  * CommonTableExpr -
1527  * representation of WITH list element
1528  */
1530 typedef enum CTEMaterialize
1532  CTEMaterializeDefault, /* no option specified */
1533  CTEMaterializeAlways, /* MATERIALIZED */
1534  CTEMaterializeNever /* NOT MATERIALIZED */
1535 } CTEMaterialize;
1537 typedef struct CTESearchClause
1540  List *search_col_list;
1541  bool search_breadth_first;
1542  char *search_seq_column;
1544 } CTESearchClause;
1546 typedef struct CTECycleClause
1549  List *cycle_col_list;
1550  char *cycle_mark_column;
1551  Node *cycle_mark_value;
1552  Node *cycle_mark_default;
1553  char *cycle_path_column;
1554  int location;
1555  /* These fields are set during parse analysis: */
1556  Oid cycle_mark_type; /* common type of _value and _default */
1557  int cycle_mark_typmod;
1558  Oid cycle_mark_collation;
1559  Oid cycle_mark_neop; /* <> operator for type */
1560 } CTECycleClause;
1562 typedef struct CommonTableExpr
1565  char *ctename; /* query name (never qualified) */
1566  List *aliascolnames; /* optional list of column names */
1567  CTEMaterialize ctematerialized; /* is this an optimization fence? */
1568  /* SelectStmt/InsertStmt/etc before parse analysis, Query afterwards: */
1569  Node *ctequery; /* the CTE's subquery */
1570  CTESearchClause *search_clause;
1571  CTECycleClause *cycle_clause;
1572  int location; /* token location, or -1 if unknown */
1573  /* These fields are set during parse analysis: */
1574  bool cterecursive; /* is this CTE actually recursive? */
1575  int cterefcount; /* number of RTEs referencing this CTE
1576  * (excluding internal self-references) */
1577  List *ctecolnames; /* list of output column names */
1578  List *ctecoltypes; /* OID list of output column type OIDs */
1579  List *ctecoltypmods; /* integer list of output column typmods */
1580  List *ctecolcollations; /* OID list of column collation OIDs */
1581 } CommonTableExpr;
1582 
1583 /* Convenience macro to get the output tlist of a CTE's query */
1584 #define GetCTETargetList(cte) \
1585  (AssertMacro(IsA((cte)->ctequery, Query)), \
1586  ((Query *) (cte)->ctequery)->commandType == CMD_SELECT ? \
1587  ((Query *) (cte)->ctequery)->targetList : \
1588  ((Query *) (cte)->ctequery)->returningList)
1589 
1590 /*
1591  * MergeWhenClause -
1592  * raw parser representation of a WHEN clause in a MERGE statement
1593  *
1594  * This is transformed into MergeAction by parse analysis
1595  */
1596 typedef struct MergeWhenClause
1599  bool matched; /* true=MATCHED, false=NOT MATCHED */
1600  CmdType commandType; /* INSERT/UPDATE/DELETE/DO NOTHING */
1601  OverridingKind override; /* OVERRIDING clause */
1602  Node *condition; /* WHEN conditions (raw parser) */
1603  List *targetList; /* INSERT/UPDATE targetlist */
1604  /* the following members are only used in INSERT actions */
1605  List *values; /* VALUES to INSERT, or NULL */
1606 } MergeWhenClause;
1607 
1608 /*
1609  * MergeAction -
1610  * Transformed representation of a WHEN clause in a MERGE statement
1611  */
1612 typedef struct MergeAction
1615  bool matched; /* true=MATCHED, false=NOT MATCHED */
1616  CmdType commandType; /* INSERT/UPDATE/DELETE/DO NOTHING */
1617  OverridingKind override; /* OVERRIDING clause */
1618  Node *qual; /* transformed WHEN conditions */
1619  List *targetList; /* the target list (of TargetEntry) */
1620  List *updateColnos; /* target attribute numbers of an UPDATE */
1621 } MergeAction;
1622 
1623 /*
1624  * TriggerTransition -
1625  * representation of transition row or table naming clause
1626  *
1627  * Only transition tables are initially supported in the syntax, and only for
1628  * AFTER triggers, but other permutations are accepted by the parser so we can
1629  * give a meaningful message from C code.
1630  */
1631 typedef struct TriggerTransition
1634  char *name;
1635  bool isNew;
1636  bool isTable;
1638 
1639 /*****************************************************************************
1640  * Raw Grammar Output Statements
1641  *****************************************************************************/
1642 
1643 /*
1644  * RawStmt --- container for any one statement's raw parse tree
1645  *
1646  * Parse analysis converts a raw parse tree headed by a RawStmt node into
1647  * an analyzed statement headed by a Query node. For optimizable statements,
1648  * the conversion is complex. For utility statements, the parser usually just
1649  * transfers the raw parse tree (sans RawStmt) into the utilityStmt field of
1650  * the Query node, and all the useful work happens at execution time.
1651  *
1652  * stmt_location/stmt_len identify the portion of the source text string
1653  * containing this raw statement (useful for multi-statement strings).
1654  */
1655 typedef struct RawStmt
1658  Node *stmt; /* raw parse tree */
1659  int stmt_location; /* start location, or -1 if unknown */
1660  int stmt_len; /* length in bytes; 0 means "rest of string" */
1661 } RawStmt;
1662 
1663 /*****************************************************************************
1664  * Optimizable Statements
1665  *****************************************************************************/
1666 
1667 /* ----------------------
1668  * Insert Statement
1669  *
1670  * The source expression is represented by SelectStmt for both the
1671  * SELECT and VALUES cases. If selectStmt is NULL, then the query
1672  * is INSERT ... DEFAULT VALUES.
1673  * ----------------------
1674  */
1675 typedef struct InsertStmt
1678  RangeVar *relation; /* relation to insert into */
1679  List *cols; /* optional: names of the target columns */
1680  Node *selectStmt; /* the source SELECT/VALUES, or NULL */
1681  OnConflictClause *onConflictClause; /* ON CONFLICT clause */
1682  List *returningList; /* list of expressions to return */
1683  WithClause *withClause; /* WITH clause */
1684  OverridingKind override; /* OVERRIDING clause */
1685 } InsertStmt;
1686 
1687 /* ----------------------
1688  * Delete Statement
1689  * ----------------------
1690  */
1691 typedef struct DeleteStmt
1694  RangeVar *relation; /* relation to delete from */
1695  List *usingClause; /* optional using clause for more tables */
1696  Node *whereClause; /* qualifications */
1697  List *returningList; /* list of expressions to return */
1698  WithClause *withClause; /* WITH clause */
1699 } DeleteStmt;
1700 
1701 /* ----------------------
1702  * Update Statement
1703  * ----------------------
1704  */
1705 typedef struct UpdateStmt
1708  RangeVar *relation; /* relation to update */
1709  List *targetList; /* the target list (of ResTarget) */
1710  Node *whereClause; /* qualifications */
1711  List *fromClause; /* optional from clause for more tables */
1712  List *returningList; /* list of expressions to return */
1713  WithClause *withClause; /* WITH clause */
1714 } UpdateStmt;
1715 
1716 /* ----------------------
1717  * Merge Statement
1718  * ----------------------
1719  */
1720 typedef struct MergeStmt
1723  RangeVar *relation; /* target relation to merge into */
1724  Node *sourceRelation; /* source relation */
1725  Node *joinCondition; /* join condition between source and target */
1726  List *mergeWhenClauses; /* list of MergeWhenClause(es) */
1727  WithClause *withClause; /* WITH clause */
1728 } MergeStmt;
1729 
1730 /* ----------------------
1731  * Select Statement
1732  *
1733  * A "simple" SELECT is represented in the output of gram.y by a single
1734  * SelectStmt node; so is a VALUES construct. A query containing set
1735  * operators (UNION, INTERSECT, EXCEPT) is represented by a tree of SelectStmt
1736  * nodes, in which the leaf nodes are component SELECTs and the internal nodes
1737  * represent UNION, INTERSECT, or EXCEPT operators. Using the same node
1738  * type for both leaf and internal nodes allows gram.y to stick ORDER BY,
1739  * LIMIT, etc, clause values into a SELECT statement without worrying
1740  * whether it is a simple or compound SELECT.
1741  * ----------------------
1742  */
1743 typedef enum SetOperation
1749 } SetOperation;
1751 typedef struct SelectStmt
1753  NodeTag type;
1754 
1755  /*
1756  * These fields are used only in "leaf" SelectStmts.
1757  */
1758  List *distinctClause; /* NULL, list of DISTINCT ON exprs, or
1759  * lcons(NIL,NIL) for all (SELECT DISTINCT) */
1760  IntoClause *intoClause; /* target for SELECT INTO */
1761  List *targetList; /* the target list (of ResTarget) */
1762  List *fromClause; /* the FROM clause */
1763  Node *whereClause; /* WHERE qualification */
1764  List *groupClause; /* GROUP BY clauses */
1765  bool groupDistinct; /* Is this GROUP BY DISTINCT? */
1766  Node *havingClause; /* HAVING conditional-expression */
1767  List *windowClause; /* WINDOW window_name AS (...), ... */
1768 
1769  /*
1770  * In a "leaf" node representing a VALUES list, the above fields are all
1771  * null, and instead this field is set. Note that the elements of the
1772  * sublists are just expressions, without ResTarget decoration. Also note
1773  * that a list element can be DEFAULT (represented as a SetToDefault
1774  * node), regardless of the context of the VALUES list. It's up to parse
1775  * analysis to reject that where not valid.
1776  */
1777  List *valuesLists; /* untransformed list of expression lists */
1778 
1779  /*
1780  * These fields are used in both "leaf" SelectStmts and upper-level
1781  * SelectStmts.
1782  */
1783  List *sortClause; /* sort clause (a list of SortBy's) */
1784  Node *limitOffset; /* # of result tuples to skip */
1785  Node *limitCount; /* # of result tuples to return */
1786  LimitOption limitOption; /* limit type */
1787  List *lockingClause; /* FOR UPDATE (list of LockingClause's) */
1788  WithClause *withClause; /* WITH clause */
1789 
1790  /*
1791  * These fields are used only in upper-level SelectStmts.
1792  */
1793  SetOperation op; /* type of set op */
1794  bool all; /* ALL specified? */
1795  struct SelectStmt *larg; /* left child */
1796  struct SelectStmt *rarg; /* right child */
1797  /* Eventually add fields for CORRESPONDING spec here */
1798 } SelectStmt;
1799 
1800 
1801 /* ----------------------
1802  * Set Operation node for post-analysis query trees
1803  *
1804  * After parse analysis, a SELECT with set operations is represented by a
1805  * top-level Query node containing the leaf SELECTs as subqueries in its
1806  * range table. Its setOperations field shows the tree of set operations,
1807  * with leaf SelectStmt nodes replaced by RangeTblRef nodes, and internal
1808  * nodes replaced by SetOperationStmt nodes. Information about the output
1809  * column types is added, too. (Note that the child nodes do not necessarily
1810  * produce these types directly, but we've checked that their output types
1811  * can be coerced to the output column type.) Also, if it's not UNION ALL,
1812  * information about the types' sort/group semantics is provided in the form
1813  * of a SortGroupClause list (same representation as, eg, DISTINCT).
1814  * The resolved common column collations are provided too; but note that if
1815  * it's not UNION ALL, it's okay for a column to not have a common collation,
1816  * so a member of the colCollations list could be InvalidOid even though the
1817  * column has a collatable type.
1818  * ----------------------
1819  */
1820 typedef struct SetOperationStmt
1823  SetOperation op; /* type of set op */
1824  bool all; /* ALL specified? */
1825  Node *larg; /* left child */
1826  Node *rarg; /* right child */
1827  /* Eventually add fields for CORRESPONDING spec here */
1828 
1829  /* Fields derived during parse analysis: */
1830  List *colTypes; /* OID list of output column type OIDs */
1831  List *colTypmods; /* integer list of output column typmods */
1832  List *colCollations; /* OID list of output column collation OIDs */
1833  List *groupClauses; /* a list of SortGroupClause's */
1834  /* groupClauses is NIL if UNION ALL, but must be set otherwise */
1836 
1837 
1838 /*
1839  * RETURN statement (inside SQL function body)
1840  */
1841 typedef struct ReturnStmt
1844  Node *returnval;
1845 } ReturnStmt;
1846 
1847 
1848 /* ----------------------
1849  * PL/pgSQL Assignment Statement
1850  *
1851  * Like SelectStmt, this is transformed into a SELECT Query.
1852  * However, the targetlist of the result looks more like an UPDATE.
1853  * ----------------------
1854  */
1855 typedef struct PLAssignStmt
1857  NodeTag type;
1859  char *name; /* initial column name */
1860  List *indirection; /* subscripts and field names, if any */
1861  int nnames; /* number of names to use in ColumnRef */
1862  SelectStmt *val; /* the PL/pgSQL expression to assign */
1863  int location; /* name's token location, or -1 if unknown */
1864 } PLAssignStmt;
1865 
1866 
1867 /*****************************************************************************
1868  * Other Statements (no optimizations required)
1869  *
1870  * These are not touched by parser/analyze.c except to put them into
1871  * the utilityStmt field of a Query. This is eventually passed to
1872  * ProcessUtility (by-passing rewriting and planning). Some of the
1873  * statements do need attention from parse analysis, and this is
1874  * done by routines in parser/parse_utilcmd.c after ProcessUtility
1875  * receives the command for execution.
1876  * DECLARE CURSOR, EXPLAIN, and CREATE TABLE AS are special cases:
1877  * they contain optimizable statements, which get processed normally
1878  * by parser/analyze.c.
1879  *****************************************************************************/
1880 
1881 /*
1882  * When a command can act on several kinds of objects with only one
1883  * parse structure required, use these constants to designate the
1884  * object type. Note that commands typically don't support all the types.
1885  */
1887 typedef enum ObjectType
1893  OBJECT_ATTRIBUTE, /* type's attribute, when distinct from column */
1941 } ObjectType;
1942 
1943 /* ----------------------
1944  * Create Schema Statement
1945  *
1946  * NOTE: the schemaElts list contains raw parsetrees for component statements
1947  * of the schema, such as CREATE TABLE, GRANT, etc. These are analyzed and
1948  * executed after the schema itself is created.
1949  * ----------------------
1950  */
1951 typedef struct CreateSchemaStmt
1954  char *schemaname; /* the name of the schema to create */
1955  RoleSpec *authrole; /* the owner of the created schema */
1956  List *schemaElts; /* schema components (list of parsenodes) */
1957  bool if_not_exists; /* just do nothing if schema already exists? */
1960 typedef enum DropBehavior
1962  DROP_RESTRICT, /* drop fails if any dependent objects */
1963  DROP_CASCADE /* remove dependent objects too */
1964 } DropBehavior;
1965 
1966 /* ----------------------
1967  * Alter Table
1968  * ----------------------
1969  */
1970 typedef struct AlterTableStmt
1973  RangeVar *relation; /* table to work on */
1974  List *cmds; /* list of subcommands */
1975  ObjectType objtype; /* type of object */
1976  bool missing_ok; /* skip error if table missing */
1977 } AlterTableStmt;
1979 typedef enum AlterTableType
1981  AT_AddColumn, /* add column */
1982  AT_AddColumnRecurse, /* internal to commands/tablecmds.c */
1983  AT_AddColumnToView, /* implicitly via CREATE OR REPLACE VIEW */
1984  AT_ColumnDefault, /* alter column default */
1985  AT_CookedColumnDefault, /* add a pre-cooked column default */
1986  AT_DropNotNull, /* alter column drop not null */
1987  AT_SetNotNull, /* alter column set not null */
1988  AT_DropExpression, /* alter column drop expression */
1989  AT_CheckNotNull, /* check column is already marked not null */
1990  AT_SetStatistics, /* alter column set statistics */
1991  AT_SetOptions, /* alter column set ( options ) */
1992  AT_ResetOptions, /* alter column reset ( options ) */
1993  AT_SetStorage, /* alter column set storage */
1994  AT_SetCompression, /* alter column set compression */
1995  AT_DropColumn, /* drop column */
1996  AT_DropColumnRecurse, /* internal to commands/tablecmds.c */
1997  AT_AddIndex, /* add index */
1998  AT_ReAddIndex, /* internal to commands/tablecmds.c */
1999  AT_AddConstraint, /* add constraint */
2000  AT_AddConstraintRecurse, /* internal to commands/tablecmds.c */
2001  AT_ReAddConstraint, /* internal to commands/tablecmds.c */
2002  AT_ReAddDomainConstraint, /* internal to commands/tablecmds.c */
2003  AT_AlterConstraint, /* alter constraint */
2004  AT_ValidateConstraint, /* validate constraint */
2005  AT_ValidateConstraintRecurse, /* internal to commands/tablecmds.c */
2006  AT_AddIndexConstraint, /* add constraint using existing index */
2007  AT_DropConstraint, /* drop constraint */
2008  AT_DropConstraintRecurse, /* internal to commands/tablecmds.c */
2009  AT_ReAddComment, /* internal to commands/tablecmds.c */
2010  AT_AlterColumnType, /* alter column type */
2011  AT_AlterColumnGenericOptions, /* alter column OPTIONS (...) */
2012  AT_ChangeOwner, /* change owner */
2013  AT_ClusterOn, /* CLUSTER ON */
2014  AT_DropCluster, /* SET WITHOUT CLUSTER */
2015  AT_SetLogged, /* SET LOGGED */
2016  AT_SetUnLogged, /* SET UNLOGGED */
2017  AT_DropOids, /* SET WITHOUT OIDS */
2018  AT_SetAccessMethod, /* SET ACCESS METHOD */
2019  AT_SetTableSpace, /* SET TABLESPACE */
2020  AT_SetRelOptions, /* SET (...) -- AM specific parameters */
2021  AT_ResetRelOptions, /* RESET (...) -- AM specific parameters */
2022  AT_ReplaceRelOptions, /* replace reloption list in its entirety */
2023  AT_EnableTrig, /* ENABLE TRIGGER name */
2024  AT_EnableAlwaysTrig, /* ENABLE ALWAYS TRIGGER name */
2025  AT_EnableReplicaTrig, /* ENABLE REPLICA TRIGGER name */
2026  AT_DisableTrig, /* DISABLE TRIGGER name */
2027  AT_EnableTrigAll, /* ENABLE TRIGGER ALL */
2028  AT_DisableTrigAll, /* DISABLE TRIGGER ALL */
2029  AT_EnableTrigUser, /* ENABLE TRIGGER USER */
2030  AT_DisableTrigUser, /* DISABLE TRIGGER USER */
2031  AT_EnableRule, /* ENABLE RULE name */
2032  AT_EnableAlwaysRule, /* ENABLE ALWAYS RULE name */
2033  AT_EnableReplicaRule, /* ENABLE REPLICA RULE name */
2034  AT_DisableRule, /* DISABLE RULE name */
2035  AT_AddInherit, /* INHERIT parent */
2036  AT_DropInherit, /* NO INHERIT parent */
2037  AT_AddOf, /* OF <type_name> */
2038  AT_DropOf, /* NOT OF */
2039  AT_ReplicaIdentity, /* REPLICA IDENTITY */
2040  AT_EnableRowSecurity, /* ENABLE ROW SECURITY */
2041  AT_DisableRowSecurity, /* DISABLE ROW SECURITY */
2042  AT_ForceRowSecurity, /* FORCE ROW SECURITY */
2043  AT_NoForceRowSecurity, /* NO FORCE ROW SECURITY */
2044  AT_GenericOptions, /* OPTIONS (...) */
2045  AT_AttachPartition, /* ATTACH PARTITION */
2046  AT_DetachPartition, /* DETACH PARTITION */
2047  AT_DetachPartitionFinalize, /* DETACH PARTITION FINALIZE */
2048  AT_AddIdentity, /* ADD IDENTITY */
2049  AT_SetIdentity, /* SET identity column options */
2050  AT_DropIdentity, /* DROP IDENTITY */
2051  AT_ReAddStatistics /* internal to commands/tablecmds.c */
2052 } AlterTableType;
2054 typedef struct ReplicaIdentityStmt
2057  char identity_type;
2058  char *name;
2061 typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */
2064  AlterTableType subtype; /* Type of table alteration to apply */
2065  char *name; /* column, constraint, or trigger to act on,
2066  * or tablespace */
2067  int16 num; /* attribute number for columns referenced by
2068  * number */
2069  RoleSpec *newowner;
2070  Node *def; /* definition of new column, index,
2071  * constraint, or parent table */
2072  DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
2073  bool missing_ok; /* skip error if missing? */
2074  bool recurse; /* exec-time recursion */
2075 } AlterTableCmd;
2076 
2077 
2078 /* ----------------------
2079  * Alter Collation
2080  * ----------------------
2081  */
2082 typedef struct AlterCollationStmt
2085  List *collname;
2087 
2088 
2089 /* ----------------------
2090  * Alter Domain
2091  *
2092  * The fields are used in different ways by the different variants of
2093  * this command.
2094  * ----------------------
2095  */
2096 typedef struct AlterDomainStmt
2099  char subtype; /*------------
2100  * T = alter column default
2101  * N = alter column drop not null
2102  * O = alter column set not null
2103  * C = add constraint
2104  * X = drop constraint
2105  *------------
2106  */
2107  List *typeName; /* domain to work on */
2108  char *name; /* column or constraint name to act on */
2109  Node *def; /* definition of default or constraint */
2110  DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
2111  bool missing_ok; /* skip error if missing? */
2112 } AlterDomainStmt;
2113 
2114 
2115 /* ----------------------
2116  * Grant|Revoke Statement
2117  * ----------------------
2118  */
2119 typedef enum GrantTargetType
2121  ACL_TARGET_OBJECT, /* grant on specific named object(s) */
2122  ACL_TARGET_ALL_IN_SCHEMA, /* grant on all objects in given schema(s) */
2123  ACL_TARGET_DEFAULTS /* ALTER DEFAULT PRIVILEGES */
2124 } GrantTargetType;
2126 typedef struct GrantStmt
2129  bool is_grant; /* true = GRANT, false = REVOKE */
2130  GrantTargetType targtype; /* type of the grant target */
2131  ObjectType objtype; /* kind of object being operated on */
2132  List *objects; /* list of RangeVar nodes, ObjectWithArgs
2133  * nodes, or plain names (as String values) */
2134  List *privileges; /* list of AccessPriv nodes */
2135  /* privileges == NIL denotes ALL PRIVILEGES */
2136  List *grantees; /* list of RoleSpec nodes */
2137  bool grant_option; /* grant or revoke grant option */
2138  RoleSpec *grantor;
2139  DropBehavior behavior; /* drop behavior (for REVOKE) */
2140 } GrantStmt;
2141 
2142 /*
2143  * ObjectWithArgs represents a function/procedure/operator name plus parameter
2144  * identification.
2145  *
2146  * objargs includes only the types of the input parameters of the object.
2147  * In some contexts, that will be all we have, and it's enough to look up
2148  * objects according to the traditional Postgres rules (i.e., when only input
2149  * arguments matter).
2150  *
2151  * objfuncargs, if not NIL, carries the full specification of the parameter
2152  * list, including parameter mode annotations.
2153  *
2154  * Some grammar productions can set args_unspecified = true instead of
2155  * providing parameter info. In this case, lookup will succeed only if
2156  * the object name is unique. Note that otherwise, NIL parameter lists
2157  * mean zero arguments.
2158  */
2159 typedef struct ObjectWithArgs
2162  List *objname; /* qualified name of function/operator */
2163  List *objargs; /* list of Typename nodes (input args only) */
2164  List *objfuncargs; /* list of FunctionParameter nodes */
2165  bool args_unspecified; /* argument list was omitted? */
2166 } ObjectWithArgs;
2167 
2168 /*
2169  * An access privilege, with optional list of column names
2170  * priv_name == NULL denotes ALL PRIVILEGES (only used with a column list)
2171  * cols == NIL denotes "all columns"
2172  * Note that simple "ALL PRIVILEGES" is represented as a NIL list, not
2173  * an AccessPriv with both fields null.
2174  */
2175 typedef struct AccessPriv
2178  char *priv_name; /* string name of privilege */
2179  List *cols; /* list of String */
2180 } AccessPriv;
2181 
2182 /* ----------------------
2183  * Grant/Revoke Role Statement
2184  *
2185  * Note: because of the parsing ambiguity with the GRANT <privileges>
2186  * statement, granted_roles is a list of AccessPriv; the execution code
2187  * should complain if any column lists appear. grantee_roles is a list
2188  * of role names, as String values.
2189  * ----------------------
2190  */
2191 typedef struct GrantRoleStmt
2194  List *granted_roles; /* list of roles to be granted/revoked */
2195  List *grantee_roles; /* list of member roles to add/delete */
2196  bool is_grant; /* true = GRANT, false = REVOKE */
2197  List *opt; /* options e.g. WITH GRANT OPTION */
2198  RoleSpec *grantor; /* set grantor to other than current role */
2199  DropBehavior behavior; /* drop behavior (for REVOKE) */
2200 } GrantRoleStmt;
2201 
2202 /* ----------------------
2203  * Alter Default Privileges Statement
2204  * ----------------------
2205  */
2206 typedef struct AlterDefaultPrivilegesStmt
2209  List *options; /* list of DefElem */
2210  GrantStmt *action; /* GRANT/REVOKE action (with objects=NIL) */
2212 
2213 /* ----------------------
2214  * Copy Statement
2215  *
2216  * We support "COPY relation FROM file", "COPY relation TO file", and
2217  * "COPY (query) TO file". In any given CopyStmt, exactly one of "relation"
2218  * and "query" must be non-NULL.
2219  * ----------------------
2220  */
2221 typedef struct CopyStmt
2224  RangeVar *relation; /* the relation to copy */
2225  Node *query; /* the query (SELECT or DML statement with
2226  * RETURNING) to copy, as a raw parse tree */
2227  List *attlist; /* List of column names (as Strings), or NIL
2228  * for all columns */
2229  bool is_from; /* TO or FROM */
2230  bool is_program; /* is 'filename' a program to popen? */
2231  char *filename; /* filename, or NULL for STDIN/STDOUT */
2232  List *options; /* List of DefElem nodes */
2233  Node *whereClause; /* WHERE condition (or NULL) */
2234 } CopyStmt;
2235 
2236 /* ----------------------
2237  * SET Statement (includes RESET)
2238  *
2239  * "SET var TO DEFAULT" and "RESET var" are semantically equivalent, but we
2240  * preserve the distinction in VariableSetKind for CreateCommandTag().
2241  * ----------------------
2242  */
2243 typedef enum VariableSetKind
2245  VAR_SET_VALUE, /* SET var = value */
2246  VAR_SET_DEFAULT, /* SET var TO DEFAULT */
2247  VAR_SET_CURRENT, /* SET var FROM CURRENT */
2248  VAR_SET_MULTI, /* special case for SET TRANSACTION ... */
2249  VAR_RESET, /* RESET var */
2250  VAR_RESET_ALL /* RESET ALL */
2251 } VariableSetKind;
2253 typedef struct VariableSetStmt
2257  char *name; /* variable to be set */
2258  List *args; /* List of A_Const nodes */
2259  bool is_local; /* SET LOCAL? */
2260 } VariableSetStmt;
2261 
2262 /* ----------------------
2263  * Show Statement
2264  * ----------------------
2265  */
2266 typedef struct VariableShowStmt
2269  char *name;
2271 
2272 /* ----------------------
2273  * Create Table Statement
2274  *
2275  * NOTE: in the raw gram.y output, ColumnDef and Constraint nodes are
2276  * intermixed in tableElts, and constraints is NIL. After parse analysis,
2277  * tableElts contains just ColumnDefs, and constraints contains just
2278  * Constraint nodes (in fact, only CONSTR_CHECK nodes, in the present
2279  * implementation).
2280  * ----------------------
2281  */
2283 typedef struct CreateStmt
2286  RangeVar *relation; /* relation to create */
2287  List *tableElts; /* column definitions (list of ColumnDef) */
2288  List *inhRelations; /* relations to inherit from (list of
2289  * RangeVar) */
2290  PartitionBoundSpec *partbound; /* FOR VALUES clause */
2291  PartitionSpec *partspec; /* PARTITION BY clause */
2292  TypeName *ofTypename; /* OF typename */
2293  List *constraints; /* constraints (list of Constraint nodes) */
2294  List *options; /* options from WITH clause */
2295  OnCommitAction oncommit; /* what do we do at COMMIT? */
2296  char *tablespacename; /* table space to use, or NULL */
2297  char *accessMethod; /* table access method */
2298  bool if_not_exists; /* just do nothing if it already exists? */
2299 } CreateStmt;
2300 
2301 /* ----------
2302  * Definitions for constraints in CreateStmt
2303  *
2304  * Note that column defaults are treated as a type of constraint,
2305  * even though that's a bit odd semantically.
2306  *
2307  * For constraints that use expressions (CONSTR_CHECK, CONSTR_DEFAULT)
2308  * we may have the expression in either "raw" form (an untransformed
2309  * parse tree) or "cooked" form (the nodeToString representation of
2310  * an executable expression tree), depending on how this Constraint
2311  * node was created (by parsing, or by inheritance from an existing
2312  * relation). We should never have both in the same node!
2313  *
2314  * FKCONSTR_ACTION_xxx values are stored into pg_constraint.confupdtype
2315  * and pg_constraint.confdeltype columns; FKCONSTR_MATCH_xxx values are
2316  * stored into pg_constraint.confmatchtype. Changing the code values may
2317  * require an initdb!
2318  *
2319  * If skip_validation is true then we skip checking that the existing rows
2320  * in the table satisfy the constraint, and just install the catalog entries
2321  * for the constraint. A new FK constraint is marked as valid iff
2322  * initially_valid is true. (Usually skip_validation and initially_valid
2323  * are inverses, but we can set both true if the table is known empty.)
2324  *
2325  * Constraint attributes (DEFERRABLE etc) are initially represented as
2326  * separate Constraint nodes for simplicity of parsing. parse_utilcmd.c makes
2327  * a pass through the constraints list to insert the info into the appropriate
2328  * Constraint node.
2329  * ----------
2330  */
2332 typedef enum ConstrType /* types of constraints */
2334  CONSTR_NULL, /* not standard SQL, but a lot of people
2335  * expect it */
2345  CONSTR_ATTR_DEFERRABLE, /* attributes for previous constraint node */
2349 } ConstrType;
2350 
2351 /* Foreign key action codes */
2352 #define FKCONSTR_ACTION_NOACTION 'a'
2353 #define FKCONSTR_ACTION_RESTRICT 'r'
2354 #define FKCONSTR_ACTION_CASCADE 'c'
2355 #define FKCONSTR_ACTION_SETNULL 'n'
2356 #define FKCONSTR_ACTION_SETDEFAULT 'd'
2357 
2358 /* Foreign key matchtype codes */
2359 #define FKCONSTR_MATCH_FULL 'f'
2360 #define FKCONSTR_MATCH_PARTIAL 'p'
2361 #define FKCONSTR_MATCH_SIMPLE 's'
2363 typedef struct Constraint
2365  pg_node_attr(custom_read_write)
2366 
2368  ConstrType contype; /* see above */
2369 
2370  /* Fields used for most/all constraint types: */
2371  char *conname; /* Constraint name, or NULL if unnamed */
2372  bool deferrable; /* DEFERRABLE? */
2373  bool initdeferred; /* INITIALLY DEFERRED? */
2374  int location; /* token location, or -1 if unknown */
2375 
2376  /* Fields used for constraints with expressions (CHECK and DEFAULT): */
2377  bool is_no_inherit; /* is constraint non-inheritable? */
2378  Node *raw_expr; /* expr, as untransformed parse tree */
2379  char *cooked_expr; /* expr, as nodeToString representation */
2380  char generated_when; /* ALWAYS or BY DEFAULT */
2381 
2382  /* Fields used for unique constraints (UNIQUE and PRIMARY KEY): */
2383  bool nulls_not_distinct; /* null treatment for UNIQUE constraints */
2384  List *keys; /* String nodes naming referenced key
2385  * column(s) */
2386  List *including; /* String nodes naming referenced nonkey
2387  * column(s) */
2388 
2389  /* Fields used for EXCLUSION constraints: */
2390  List *exclusions; /* list of (IndexElem, operator name) pairs */
2391 
2392  /* Fields used for index constraints (UNIQUE, PRIMARY KEY, EXCLUSION): */
2393  List *options; /* options from WITH clause */
2394  char *indexname; /* existing index to use; otherwise NULL */
2395  char *indexspace; /* index tablespace; NULL for default */
2396  bool reset_default_tblspc; /* reset default_tablespace prior to
2397  * creating the index */
2398  /* These could be, but currently are not, used for UNIQUE/PKEY: */
2399  char *access_method; /* index access method; NULL for default */
2400  Node *where_clause; /* partial index predicate */
2401 
2402  /* Fields used for FOREIGN KEY constraints: */
2403  RangeVar *pktable; /* Primary key table */
2404  List *fk_attrs; /* Attributes of foreign key */
2405  List *pk_attrs; /* Corresponding attrs in PK table */
2406  char fk_matchtype; /* FULL, PARTIAL, SIMPLE */
2407  char fk_upd_action; /* ON UPDATE action */
2408  char fk_del_action; /* ON DELETE action */
2409  List *fk_del_set_cols; /* ON DELETE SET NULL/DEFAULT (col1, col2) */
2410  List *old_conpfeqop; /* pg_constraint.conpfeqop of my former self */
2411  Oid old_pktable_oid; /* pg_constraint.confrelid of my former
2412  * self */
2413 
2414  /* Fields used for constraints that allow a NOT VALID specification */
2415  bool skip_validation; /* skip validation of existing rows? */
2416  bool initially_valid; /* mark the new constraint as valid? */
2417 } Constraint;
2418 
2419 /* ----------------------
2420  * Create/Drop Table Space Statements
2421  * ----------------------
2422  */
2424 typedef struct CreateTableSpaceStmt
2427  char *tablespacename;
2428  RoleSpec *owner;
2429  char *location;
2433 typedef struct DropTableSpaceStmt
2436  char *tablespacename;
2437  bool missing_ok; /* skip error if missing? */
2440 typedef struct AlterTableSpaceOptionsStmt
2443  char *tablespacename;
2445  bool isReset;
2448 typedef struct AlterTableMoveAllStmt
2451  char *orig_tablespacename;
2452  ObjectType objtype; /* Object type to move */
2453  List *roles; /* List of roles to move objects of */
2454  char *new_tablespacename;
2455  bool nowait;
2457 
2458 /* ----------------------
2459  * Create/Alter Extension Statements
2460  * ----------------------
2461  */
2463 typedef struct CreateExtensionStmt
2466  char *extname;
2467  bool if_not_exists; /* just do nothing if it already exists? */
2468  List *options; /* List of DefElem nodes */
2470 
2471 /* Only used for ALTER EXTENSION UPDATE; later might need an action field */
2472 typedef struct AlterExtensionStmt
2475  char *extname;
2476  List *options; /* List of DefElem nodes */
2479 typedef struct AlterExtensionContentsStmt
2482  char *extname; /* Extension's name */
2483  int action; /* +1 = add object, -1 = drop object */
2484  ObjectType objtype; /* Object's type */
2485  Node *object; /* Qualified name of the object */
2487 
2488 /* ----------------------
2489  * Create/Alter FOREIGN DATA WRAPPER Statements
2490  * ----------------------
2491  */
2493 typedef struct CreateFdwStmt
2496  char *fdwname; /* foreign-data wrapper name */
2497  List *func_options; /* HANDLER/VALIDATOR options */
2498  List *options; /* generic options to FDW */
2499 } CreateFdwStmt;
2501 typedef struct AlterFdwStmt
2504  char *fdwname; /* foreign-data wrapper name */
2505  List *func_options; /* HANDLER/VALIDATOR options */
2506  List *options; /* generic options to FDW */
2507 } AlterFdwStmt;
2508 
2509 /* ----------------------
2510  * Create/Alter FOREIGN SERVER Statements
2511  * ----------------------
2512  */
2514 typedef struct CreateForeignServerStmt
2517  char *servername; /* server name */
2518  char *servertype; /* optional server type */
2519  char *version; /* optional server version */
2520  char *fdwname; /* FDW name */
2521  bool if_not_exists; /* just do nothing if it already exists? */
2522  List *options; /* generic options to server */
2525 typedef struct AlterForeignServerStmt
2528  char *servername; /* server name */
2529  char *version; /* optional server version */
2530  List *options; /* generic options to server */
2531  bool has_version; /* version specified */
2533 
2534 /* ----------------------
2535  * Create FOREIGN TABLE Statement
2536  * ----------------------
2537  */
2539 typedef struct CreateForeignTableStmt
2542  char *servername;
2545 
2546 /* ----------------------
2547  * Create/Drop USER MAPPING Statements
2548  * ----------------------
2549  */
2551 typedef struct CreateUserMappingStmt
2554  RoleSpec *user; /* user role */
2555  char *servername; /* server name */
2556  bool if_not_exists; /* just do nothing if it already exists? */
2557  List *options; /* generic options to server */
2560 typedef struct AlterUserMappingStmt
2563  RoleSpec *user; /* user role */
2564  char *servername; /* server name */
2565  List *options; /* generic options to server */
2568 typedef struct DropUserMappingStmt
2571  RoleSpec *user; /* user role */
2572  char *servername; /* server name */
2573  bool missing_ok; /* ignore missing mappings */
2575 
2576 /* ----------------------
2577  * Import Foreign Schema Statement
2578  * ----------------------
2579  */
2581 typedef enum ImportForeignSchemaType
2583  FDW_IMPORT_SCHEMA_ALL, /* all relations wanted */
2584  FDW_IMPORT_SCHEMA_LIMIT_TO, /* include only listed tables in import */
2585  FDW_IMPORT_SCHEMA_EXCEPT /* exclude listed tables from import */
2588 typedef struct ImportForeignSchemaStmt
2591  char *server_name; /* FDW server name */
2592  char *remote_schema; /* remote schema name to query */
2593  char *local_schema; /* local schema to create objects in */
2594  ImportForeignSchemaType list_type; /* type of table list */
2595  List *table_list; /* List of RangeVar */
2596  List *options; /* list of options to pass to FDW */
2598 
2599 /*----------------------
2600  * Create POLICY Statement
2601  *----------------------
2602  */
2603 typedef struct CreatePolicyStmt
2606  char *policy_name; /* Policy's name */
2607  RangeVar *table; /* the table name the policy applies to */
2608  char *cmd_name; /* the command name the policy applies to */
2609  bool permissive; /* restrictive or permissive policy */
2610  List *roles; /* the roles associated with the policy */
2611  Node *qual; /* the policy's condition */
2612  Node *with_check; /* the policy's WITH CHECK condition. */
2614 
2615 /*----------------------
2616  * Alter POLICY Statement
2617  *----------------------
2618  */
2619 typedef struct AlterPolicyStmt
2622  char *policy_name; /* Policy's name */
2623  RangeVar *table; /* the table name the policy applies to */
2624  List *roles; /* the roles associated with the policy */
2625  Node *qual; /* the policy's condition */
2626  Node *with_check; /* the policy's WITH CHECK condition. */
2627 } AlterPolicyStmt;
2628 
2629 /*----------------------
2630  * Create ACCESS METHOD Statement
2631  *----------------------
2632  */
2633 typedef struct CreateAmStmt
2636  char *amname; /* access method name */
2637  List *handler_name; /* handler function name */
2638  char amtype; /* type of access method */
2639 } CreateAmStmt;
2640 
2641 /* ----------------------
2642  * Create TRIGGER Statement
2643  * ----------------------
2644  */
2645 typedef struct CreateTrigStmt
2648  bool replace; /* replace trigger if already exists */
2649  bool isconstraint; /* This is a constraint trigger */
2650  char *trigname; /* TRIGGER's name */
2651  RangeVar *relation; /* relation trigger is on */
2652  List *funcname; /* qual. name of function to call */
2653  List *args; /* list of String or NIL */
2654  bool row; /* ROW/STATEMENT */
2655  /* timing uses the TRIGGER_TYPE bits defined in catalog/pg_trigger.h */
2656  int16 timing; /* BEFORE, AFTER, or INSTEAD */
2657  /* events uses the TRIGGER_TYPE bits defined in catalog/pg_trigger.h */
2658  int16 events; /* "OR" of INSERT/UPDATE/DELETE/TRUNCATE */
2659  List *columns; /* column names, or NIL for all columns */
2660  Node *whenClause; /* qual expression, or NULL if none */
2661  /* explicitly named transition data */
2662  List *transitionRels; /* TriggerTransition nodes, or NIL if none */
2663  /* The remaining fields are only used for constraint triggers */
2664  bool deferrable; /* [NOT] DEFERRABLE */
2665  bool initdeferred; /* INITIALLY {DEFERRED|IMMEDIATE} */
2666  RangeVar *constrrel; /* opposite relation, if RI trigger */
2667 } CreateTrigStmt;
2668 
2669 /* ----------------------
2670  * Create EVENT TRIGGER Statement
2671  * ----------------------
2672  */
2673 typedef struct CreateEventTrigStmt
2676  char *trigname; /* TRIGGER's name */
2677  char *eventname; /* event's identifier */
2678  List *whenclause; /* list of DefElems indicating filtering */
2679  List *funcname; /* qual. name of function to call */
2681 
2682 /* ----------------------
2683  * Alter EVENT TRIGGER Statement
2684  * ----------------------
2685  */
2686 typedef struct AlterEventTrigStmt
2689  char *trigname; /* TRIGGER's name */
2690  char tgenabled; /* trigger's firing configuration WRT
2691  * session_replication_role */
2693 
2694 /* ----------------------
2695  * Create LANGUAGE Statements
2696  * ----------------------
2697  */
2698 typedef struct CreatePLangStmt
2701  bool replace; /* T => replace if already exists */
2702  char *plname; /* PL name */
2703  List *plhandler; /* PL call handler function (qual. name) */
2704  List *plinline; /* optional inline function (qual. name) */
2705  List *plvalidator; /* optional validator function (qual. name) */
2706  bool pltrusted; /* PL is trusted */
2707 } CreatePLangStmt;
2708 
2709 /* ----------------------
2710  * Create/Alter/Drop Role Statements
2711  *
2712  * Note: these node types are also used for the backwards-compatible
2713  * Create/Alter/Drop User/Group statements. In the ALTER and DROP cases
2714  * there's really no need to distinguish what the original spelling was,
2715  * but for CREATE we mark the type because the defaults vary.
2716  * ----------------------
2717  */
2718 typedef enum RoleStmtType
2721  ROLESTMT_USER,
2723 } RoleStmtType;
2725 typedef struct CreateRoleStmt
2728  RoleStmtType stmt_type; /* ROLE/USER/GROUP */
2729  char *role; /* role name */
2730  List *options; /* List of DefElem nodes */
2731 } CreateRoleStmt;
2733 typedef struct AlterRoleStmt
2736  RoleSpec *role; /* role */
2737  List *options; /* List of DefElem nodes */
2738  int action; /* +1 = add members, -1 = drop members */
2739 } AlterRoleStmt;
2741 typedef struct AlterRoleSetStmt
2744  RoleSpec *role; /* role */
2745  char *database; /* database name, or NULL */
2746  VariableSetStmt *setstmt; /* SET or RESET subcommand */
2749 typedef struct DropRoleStmt
2752  List *roles; /* List of roles to remove */
2753  bool missing_ok; /* skip error if a role is missing? */
2754 } DropRoleStmt;
2755 
2756 /* ----------------------
2757  * {Create|Alter} SEQUENCE Statement
2758  * ----------------------
2759  */
2761 typedef struct CreateSeqStmt
2764  RangeVar *sequence; /* the sequence to create */
2766  Oid ownerId; /* ID of owner, or InvalidOid for default */
2767  bool for_identity;
2768  bool if_not_exists; /* just do nothing if it already exists? */
2769 } CreateSeqStmt;
2771 typedef struct AlterSeqStmt
2774  RangeVar *sequence; /* the sequence to alter */
2776  bool for_identity;
2777  bool missing_ok; /* skip error if a role is missing? */
2778 } AlterSeqStmt;
2779 
2780 /* ----------------------
2781  * Create {Aggregate|Operator|Type} Statement
2782  * ----------------------
2783  */
2784 typedef struct DefineStmt
2787  ObjectType kind; /* aggregate, operator, type */
2788  bool oldstyle; /* hack to signal old CREATE AGG syntax */
2789  List *defnames; /* qualified name (list of String) */
2790  List *args; /* a list of TypeName (if needed) */
2791  List *definition; /* a list of DefElem */
2792  bool if_not_exists; /* just do nothing if it already exists? */
2793  bool replace; /* replace if already exists? */
2794 } DefineStmt;
2795 
2796 /* ----------------------
2797  * Create Domain Statement
2798  * ----------------------
2799  */
2800 typedef struct CreateDomainStmt
2803  List *domainname; /* qualified name (list of String) */
2804  TypeName *typeName; /* the base type */
2805  CollateClause *collClause; /* untransformed COLLATE spec, if any */
2806  List *constraints; /* constraints (list of Constraint nodes) */
2808 
2809 /* ----------------------
2810  * Create Operator Class Statement
2811  * ----------------------
2812  */
2813 typedef struct CreateOpClassStmt
2816  List *opclassname; /* qualified name (list of String) */
2817  List *opfamilyname; /* qualified name (ditto); NIL if omitted */
2818  char *amname; /* name of index AM opclass is for */
2819  TypeName *datatype; /* datatype of indexed column */
2820  List *items; /* List of CreateOpClassItem nodes */
2821  bool isDefault; /* Should be marked as default for type? */
2824 #define OPCLASS_ITEM_OPERATOR 1
2825 #define OPCLASS_ITEM_FUNCTION 2
2826 #define OPCLASS_ITEM_STORAGETYPE 3
2828 typedef struct CreateOpClassItem
2831  int itemtype; /* see codes above */
2832  ObjectWithArgs *name; /* operator or function name and args */
2833  int number; /* strategy num or support proc num */
2834  List *order_family; /* only used for ordering operators */
2835  List *class_args; /* amproclefttype/amprocrighttype or
2836  * amoplefttype/amoprighttype */
2837  /* fields used for a storagetype item: */
2838  TypeName *storedtype; /* datatype stored in index */
2840 
2841 /* ----------------------
2842  * Create Operator Family Statement
2843  * ----------------------
2844  */
2845 typedef struct CreateOpFamilyStmt
2848  List *opfamilyname; /* qualified name (list of String) */
2849  char *amname; /* name of index AM opfamily is for */
2851 
2852 /* ----------------------
2853  * Alter Operator Family Statement
2854  * ----------------------
2855  */
2856 typedef struct AlterOpFamilyStmt
2859  List *opfamilyname; /* qualified name (list of String) */
2860  char *amname; /* name of index AM opfamily is for */
2861  bool isDrop; /* ADD or DROP the items? */
2862  List *items; /* List of CreateOpClassItem nodes */
2864 
2865 /* ----------------------
2866  * Drop Table|Sequence|View|Index|Type|Domain|Conversion|Schema Statement
2867  * ----------------------
2868  */
2870 typedef struct DropStmt
2873  List *objects; /* list of names */
2874  ObjectType removeType; /* object type */
2875  DropBehavior behavior; /* RESTRICT or CASCADE behavior */
2876  bool missing_ok; /* skip error if object is missing? */
2877  bool concurrent; /* drop index concurrently? */
2878 } DropStmt;
2879 
2880 /* ----------------------
2881  * Truncate Table Statement
2882  * ----------------------
2883  */
2884 typedef struct TruncateStmt
2887  List *relations; /* relations (RangeVars) to be truncated */
2888  bool restart_seqs; /* restart owned sequences? */
2889  DropBehavior behavior; /* RESTRICT or CASCADE behavior */
2890 } TruncateStmt;
2891 
2892 /* ----------------------
2893  * Comment On Statement
2894  * ----------------------
2895  */
2896 typedef struct CommentStmt
2899  ObjectType objtype; /* Object's type */
2900  Node *object; /* Qualified name of the object */
2901  char *comment; /* Comment to insert, or NULL to remove */
2902 } CommentStmt;
2903 
2904 /* ----------------------
2905  * SECURITY LABEL Statement
2906  * ----------------------
2907  */
2908 typedef struct SecLabelStmt
2911  ObjectType objtype; /* Object's type */
2912  Node *object; /* Qualified name of the object */
2913  char *provider; /* Label provider (or NULL) */
2914  char *label; /* New security label to be assigned */
2915 } SecLabelStmt;
2916 
2917 /* ----------------------
2918  * Declare Cursor Statement
2919  *
2920  * The "query" field is initially a raw parse tree, and is converted to a
2921  * Query node during parse analysis. Note that rewriting and planning
2922  * of the query are always postponed until execution.
2923  * ----------------------
2924  */
2925 #define CURSOR_OPT_BINARY 0x0001 /* BINARY */
2926 #define CURSOR_OPT_SCROLL 0x0002 /* SCROLL explicitly given */
2927 #define CURSOR_OPT_NO_SCROLL 0x0004 /* NO SCROLL explicitly given */
2928 #define CURSOR_OPT_INSENSITIVE 0x0008 /* INSENSITIVE */
2929 #define CURSOR_OPT_ASENSITIVE 0x0010 /* ASENSITIVE */
2930 #define CURSOR_OPT_HOLD 0x0020 /* WITH HOLD */
2931 /* these planner-control flags do not correspond to any SQL grammar: */
2932 #define CURSOR_OPT_FAST_PLAN 0x0100 /* prefer fast-start plan */
2933 #define CURSOR_OPT_GENERIC_PLAN 0x0200 /* force use of generic plan */
2934 #define CURSOR_OPT_CUSTOM_PLAN 0x0400 /* force use of custom plan */
2935 #define CURSOR_OPT_PARALLEL_OK 0x0800 /* parallel mode OK */
2937 typedef struct DeclareCursorStmt
2940  char *portalname; /* name of the portal (cursor) */
2941  int options; /* bitmask of options (see above) */
2942  Node *query; /* the query (see comments above) */
2944 
2945 /* ----------------------
2946  * Close Portal Statement
2947  * ----------------------
2948  */
2949 typedef struct ClosePortalStmt
2952  char *portalname; /* name of the portal (cursor) */
2953  /* NULL means CLOSE ALL */
2954 } ClosePortalStmt;
2955 
2956 /* ----------------------
2957  * Fetch Statement (also Move)
2958  * ----------------------
2959  */
2960 typedef enum FetchDirection
2961 {
2962  /* for these, howMany is how many rows to fetch; FETCH_ALL means ALL */
2965  /* for these, howMany indicates a position; only one row is fetched */
2968 } FetchDirection;
2970 #define FETCH_ALL LONG_MAX
2972 typedef struct FetchStmt
2975  FetchDirection direction; /* see above */
2976  long howMany; /* number of rows, or position argument */
2977  char *portalname; /* name of portal (cursor) */
2978  bool ismove; /* true if MOVE */
2979 } FetchStmt;
2980 
2981 /* ----------------------
2982  * Create Index Statement
2983  *
2984  * This represents creation of an index and/or an associated constraint.
2985  * If isconstraint is true, we should create a pg_constraint entry along
2986  * with the index. But if indexOid isn't InvalidOid, we are not creating an
2987  * index, just a UNIQUE/PKEY constraint using an existing index. isconstraint
2988  * must always be true in this case, and the fields describing the index
2989  * properties are empty.
2990  * ----------------------
2991  */
2992 typedef struct IndexStmt
2995  char *idxname; /* name of new index, or NULL for default */
2996  RangeVar *relation; /* relation to build index on */
2997  char *accessMethod; /* name of access method (eg. btree) */
2998  char *tableSpace; /* tablespace, or NULL for default */
2999  List *indexParams; /* columns to index: a list of IndexElem */
3000  List *indexIncludingParams; /* additional columns to index: a list
3001  * of IndexElem */
3002  List *options; /* WITH clause options: a list of DefElem */
3003  Node *whereClause; /* qualification (partial-index predicate) */
3004  List *excludeOpNames; /* exclusion operator names, or NIL if none */
3005  char *idxcomment; /* comment to apply to index, or NULL */
3006  Oid indexOid; /* OID of an existing index, if any */
3007  RelFileNumber oldNumber; /* relfilenumber of existing storage, if any */
3008  SubTransactionId oldCreateSubid; /* rd_createSubid of oldNumber */
3009  SubTransactionId oldFirstRelfilelocatorSubid; /* rd_firstRelfilelocatorSubid
3010  * of oldNumber */
3011  bool unique; /* is index unique? */
3012  bool nulls_not_distinct; /* null treatment for UNIQUE constraints */
3013  bool primary; /* is index a primary key? */
3014  bool isconstraint; /* is it for a pkey/unique constraint? */
3015  bool deferrable; /* is the constraint DEFERRABLE? */
3016  bool initdeferred; /* is the constraint INITIALLY DEFERRED? */
3017  bool transformed; /* true when transformIndexStmt is finished */
3018  bool concurrent; /* should this be a concurrent index build? */
3019  bool if_not_exists; /* just do nothing if index already exists? */
3020  bool reset_default_tblspc; /* reset default_tablespace prior to
3021  * executing */
3022 } IndexStmt;
3023 
3024 /* ----------------------
3025  * Create Statistics Statement
3026  * ----------------------
3027  */
3028 typedef struct CreateStatsStmt
3031  List *defnames; /* qualified name (list of String) */
3032  List *stat_types; /* stat types (list of String) */
3033  List *exprs; /* expressions to build statistics on */
3034  List *relations; /* rels to build stats on (list of RangeVar) */
3035  char *stxcomment; /* comment to apply to stats, or NULL */
3036  bool transformed; /* true when transformStatsStmt is finished */
3037  bool if_not_exists; /* do nothing if stats name already exists */
3038 } CreateStatsStmt;
3039 
3040 /*
3041  * StatsElem - statistics parameters (used in CREATE STATISTICS)
3042  *
3043  * For a plain attribute, 'name' is the name of the referenced table column
3044  * and 'expr' is NULL. For an expression, 'name' is NULL and 'expr' is the
3045  * expression tree.
3046  */
3047 typedef struct StatsElem
3050  char *name; /* name of attribute to index, or NULL */
3051  Node *expr; /* expression to index, or NULL */
3052 } StatsElem;
3053 
3054 
3055 /* ----------------------
3056  * Alter Statistics Statement
3057  * ----------------------
3058  */
3059 typedef struct AlterStatsStmt
3062  List *defnames; /* qualified name (list of String) */
3063  int stxstattarget; /* statistics target */
3064  bool missing_ok; /* skip error if statistics object is missing */
3065 } AlterStatsStmt;
3066 
3067 /* ----------------------
3068  * Create Function Statement
3069  * ----------------------
3070  */
3071 typedef struct CreateFunctionStmt
3074  bool is_procedure; /* it's really CREATE PROCEDURE */
3075  bool replace; /* T => replace if already exists */
3076  List *funcname; /* qualified name of function to create */
3077  List *parameters; /* a list of FunctionParameter */
3078  TypeName *returnType; /* the return type */
3079  List *options; /* a list of DefElem */
3080  Node *sql_body;
3083 typedef enum FunctionParameterMode
3084 {
3085  /* the assigned enum values appear in pg_proc, don't change 'em! */
3086  FUNC_PARAM_IN = 'i', /* input only */
3087  FUNC_PARAM_OUT = 'o', /* output only */
3088  FUNC_PARAM_INOUT = 'b', /* both */
3089  FUNC_PARAM_VARIADIC = 'v', /* variadic (always input) */
3090  FUNC_PARAM_TABLE = 't', /* table function output column */
3091  /* this is not used in pg_proc: */
3092  FUNC_PARAM_DEFAULT = 'd' /* default; effectively same as IN */
3095 typedef struct FunctionParameter
3098  char *name; /* parameter name, or NULL if not given */
3099  TypeName *argType; /* TypeName for parameter type */
3100  FunctionParameterMode mode; /* IN/OUT/etc */
3101  Node *defexpr; /* raw default expr, or NULL if not given */
3104 typedef struct AlterFunctionStmt
3107  ObjectType objtype;
3108  ObjectWithArgs *func; /* name and args of function */
3109  List *actions; /* list of DefElem */
3111 
3112 /* ----------------------
3113  * DO Statement
3114  *
3115  * DoStmt is the raw parser output, InlineCodeBlock is the execution-time API
3116  * ----------------------
3117  */
3118 typedef struct DoStmt
3121  List *args; /* List of DefElem nodes */
3122 } DoStmt;
3124 typedef struct InlineCodeBlock
3126  pg_node_attr(nodetag_only) /* this is not a member of parse trees */
3127 
3129  char *source_text; /* source text of anonymous code block */
3130  Oid langOid; /* OID of selected language */
3131  bool langIsTrusted; /* trusted property of the language */
3132  bool atomic; /* atomic execution context */
3133 } InlineCodeBlock;
3134 
3135 /* ----------------------
3136  * CALL statement
3137  *
3138  * OUT-mode arguments are removed from the transformed funcexpr. The outargs
3139  * list contains copies of the expressions for all output arguments, in the
3140  * order of the procedure's declared arguments. (outargs is never evaluated,
3141  * but is useful to the caller as a reference for what to assign to.)
3142  * ----------------------
3143  */
3144 typedef struct CallStmt
3147  FuncCall *funccall; /* from the parser */
3148  FuncExpr *funcexpr; /* transformed call, with only input args */
3149  List *outargs; /* transformed output-argument expressions */
3150 } CallStmt;
3152 typedef struct CallContext
3154  pg_node_attr(nodetag_only) /* this is not a member of parse trees */
3155 
3157  bool atomic;
3158 } CallContext;
3159 
3160 /* ----------------------
3161  * Alter Object Rename Statement
3162  * ----------------------
3163  */
3164 typedef struct RenameStmt
3167  ObjectType renameType; /* OBJECT_TABLE, OBJECT_COLUMN, etc */
3168  ObjectType relationType; /* if column name, associated relation type */
3169  RangeVar *relation; /* in case it's a table */
3170  Node *object; /* in case it's some other object */
3171  char *subname; /* name of contained object (column, rule,
3172  * trigger, etc) */
3173  char *newname; /* the new name */
3174  DropBehavior behavior; /* RESTRICT or CASCADE behavior */
3175  bool missing_ok; /* skip error if missing? */
3176 } RenameStmt;
3177 
3178 /* ----------------------
3179  * ALTER object DEPENDS ON EXTENSION extname
3180  * ----------------------
3181  */
3182 typedef struct AlterObjectDependsStmt
3185  ObjectType objectType; /* OBJECT_FUNCTION, OBJECT_TRIGGER, etc */
3186  RangeVar *relation; /* in case a table is involved */
3187  Node *object; /* name of the object */
3188  String *extname; /* extension name */
3189  bool remove; /* set true to remove dep rather than add */
3191 
3192 /* ----------------------
3193  * ALTER object SET SCHEMA Statement
3194  * ----------------------
3195  */
3196 typedef struct AlterObjectSchemaStmt
3199  ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
3200  RangeVar *relation; /* in case it's a table */
3201  Node *object; /* in case it's some other object */
3202  char *newschema; /* the new schema */
3203  bool missing_ok; /* skip error if missing? */
3205 
3206 /* ----------------------
3207  * Alter Object Owner Statement
3208  * ----------------------
3209  */
3210 typedef struct AlterOwnerStmt
3213  ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
3214  RangeVar *relation; /* in case it's a table */
3215  Node *object; /* in case it's some other object */
3216  RoleSpec *newowner; /* the new owner */
3217 } AlterOwnerStmt;
3218 
3219 /* ----------------------
3220  * Alter Operator Set ( this-n-that )
3221  * ----------------------
3222  */
3223 typedef struct AlterOperatorStmt
3226  ObjectWithArgs *opername; /* operator name and argument types */
3227  List *options; /* List of DefElem nodes */
3229 
3230 /* ------------------------
3231  * Alter Type Set ( this-n-that )
3232  * ------------------------
3233  */
3234 typedef struct AlterTypeStmt
3237  List *typeName; /* type name (possibly qualified) */
3238  List *options; /* List of DefElem nodes */
3239 } AlterTypeStmt;
3240 
3241 /* ----------------------
3242  * Create Rule Statement
3243  * ----------------------
3244  */
3245 typedef struct RuleStmt
3248  RangeVar *relation; /* relation the rule is for */
3249  char *rulename; /* name of the rule */
3250  Node *whereClause; /* qualifications */
3251  CmdType event; /* SELECT, INSERT, etc */
3252  bool instead; /* is a 'do instead'? */
3253  List *actions; /* the action statements */
3254  bool replace; /* OR REPLACE */
3255 } RuleStmt;
3256 
3257 /* ----------------------
3258  * Notify Statement
3259  * ----------------------
3260  */
3261 typedef struct NotifyStmt
3264  char *conditionname; /* condition name to notify */
3265  char *payload; /* the payload string, or NULL if none */
3266 } NotifyStmt;
3267 
3268 /* ----------------------
3269  * Listen Statement
3270  * ----------------------
3271  */
3272 typedef struct ListenStmt
3275  char *conditionname; /* condition name to listen on */
3276 } ListenStmt;
3277 
3278 /* ----------------------
3279  * Unlisten Statement
3280  * ----------------------
3281  */
3282 typedef struct UnlistenStmt
3285  char *conditionname; /* name to unlisten on, or NULL for all */
3286 } UnlistenStmt;
3287 
3288 /* ----------------------
3289  * {Begin|Commit|Rollback} Transaction Statement
3290  * ----------------------
3291  */
3292 typedef enum TransactionStmtKind
3295  TRANS_STMT_START, /* semantically identical to BEGIN */
3306 typedef struct TransactionStmt
3309  TransactionStmtKind kind; /* see above */
3310  List *options; /* for BEGIN/START commands */
3311  char *savepoint_name; /* for savepoint commands */
3312  char *gid; /* for two-phase-commit related commands */
3313  bool chain; /* AND CHAIN option */
3314 } TransactionStmt;
3315 
3316 /* ----------------------
3317  * Create Type Statement, composite types
3318  * ----------------------
3319  */
3320 typedef struct CompositeTypeStmt
3323  RangeVar *typevar; /* the composite type to be created */
3324  List *coldeflist; /* list of ColumnDef nodes */
3326 
3327 /* ----------------------
3328  * Create Type Statement, enum types
3329  * ----------------------
3330  */
3331 typedef struct CreateEnumStmt
3334  List *typeName; /* qualified name (list of String) */
3335  List *vals; /* enum values (list of String) */
3336 } CreateEnumStmt;
3337 
3338 /* ----------------------
3339  * Create Type Statement, range types
3340  * ----------------------
3341  */
3342 typedef struct CreateRangeStmt
3345  List *typeName; /* qualified name (list of String) */
3346  List *params; /* range parameters (list of DefElem) */
3347 } CreateRangeStmt;
3348 
3349 /* ----------------------
3350  * Alter Type Statement, enum types
3351  * ----------------------
3352  */
3353 typedef struct AlterEnumStmt
3356  List *typeName; /* qualified name (list of String) */
3357  char *oldVal; /* old enum value's name, if renaming */
3358  char *newVal; /* new enum value's name */
3359  char *newValNeighbor; /* neighboring enum value, if specified */
3360  bool newValIsAfter; /* place new enum value after neighbor? */
3361  bool skipIfNewValExists; /* no error if new already exists? */
3362 } AlterEnumStmt;
3363 
3364 /* ----------------------
3365  * Create View Statement
3366  * ----------------------
3367  */
3368 typedef enum ViewCheckOption
3373 } ViewCheckOption;
3375 typedef struct ViewStmt
3378  RangeVar *view; /* the view to be created */
3379  List *aliases; /* target column names */
3380  Node *query; /* the SELECT query (as a raw parse tree) */
3381  bool replace; /* replace an existing view? */
3382  List *options; /* options from WITH clause */
3383  ViewCheckOption withCheckOption; /* WITH CHECK OPTION */
3384 } ViewStmt;
3385 
3386 /* ----------------------
3387  * Load Statement
3388  * ----------------------
3389  */
3390 typedef struct LoadStmt
3393  char *filename; /* file to load */
3394 } LoadStmt;
3395 
3396 /* ----------------------
3397  * Createdb Statement
3398  * ----------------------
3399  */
3400 typedef struct CreatedbStmt
3403  char *dbname; /* name of database to create */
3404  List *options; /* List of DefElem nodes */
3405 } CreatedbStmt;
3406 
3407 /* ----------------------
3408  * Alter Database
3409  * ----------------------
3410  */
3411 typedef struct AlterDatabaseStmt
3414  char *dbname; /* name of database to alter */
3415  List *options; /* List of DefElem nodes */
3418 typedef struct AlterDatabaseRefreshCollStmt
3421  char *dbname;
3424 typedef struct AlterDatabaseSetStmt
3427  char *dbname; /* database name */
3428  VariableSetStmt *setstmt; /* SET or RESET subcommand */
3430 
3431 /* ----------------------
3432  * Dropdb Statement
3433  * ----------------------
3434  */
3435 typedef struct DropdbStmt
3438  char *dbname; /* database to drop */
3439  bool missing_ok; /* skip error if db is missing? */
3440  List *options; /* currently only FORCE is supported */
3441 } DropdbStmt;
3442 
3443 /* ----------------------
3444  * Alter System Statement
3445  * ----------------------
3446  */
3447 typedef struct AlterSystemStmt
3450  VariableSetStmt *setstmt; /* SET subcommand */
3451 } AlterSystemStmt;
3452 
3453 /* ----------------------
3454  * Cluster Statement (support pbrown's cluster index implementation)
3455  * ----------------------
3456  */
3457 typedef struct ClusterStmt
3460  RangeVar *relation; /* relation being indexed, or NULL if all */
3461  char *indexname; /* original index defined */
3462  List *params; /* list of DefElem nodes */
3463 } ClusterStmt;
3464 
3465 /* ----------------------
3466  * Vacuum and Analyze Statements
3467  *
3468  * Even though these are nominally two statements, it's convenient to use
3469  * just one node type for both.
3470  * ----------------------
3471  */
3472 typedef struct VacuumStmt
3475  List *options; /* list of DefElem nodes */
3476  List *rels; /* list of VacuumRelation, or NIL for all */
3477  bool is_vacuumcmd; /* true for VACUUM, false for ANALYZE */
3478 } VacuumStmt;
3479 
3480 /*
3481  * Info about a single target table of VACUUM/ANALYZE.
3482  *
3483  * If the OID field is set, it always identifies the table to process.
3484  * Then the relation field can be NULL; if it isn't, it's used only to report
3485  * failure to open/lock the relation.
3486  */
3487 typedef struct VacuumRelation
3490  RangeVar *relation; /* table name to process, or NULL */
3491  Oid oid; /* table's OID; InvalidOid if not looked up */
3492  List *va_cols; /* list of column names, or NIL for all */
3493 } VacuumRelation;
3494 
3495 /* ----------------------
3496  * Explain Statement
3497  *
3498  * The "query" field is initially a raw parse tree, and is converted to a
3499  * Query node during parse analysis. Note that rewriting and planning
3500  * of the query are always postponed until execution.
3501  * ----------------------
3502  */
3503 typedef struct ExplainStmt
3506  Node *query; /* the query (see comments above) */
3507  List *options; /* list of DefElem nodes */
3508 } ExplainStmt;
3509 
3510 /* ----------------------
3511  * CREATE TABLE AS Statement (a/k/a SELECT INTO)
3512  *
3513  * A query written as CREATE TABLE AS will produce this node type natively.
3514  * A query written as SELECT ... INTO will be transformed to this form during
3515  * parse analysis.
3516  * A query written as CREATE MATERIALIZED view will produce this node type,
3517  * during parse analysis, since it needs all the same data.
3518  *
3519  * The "query" field is handled similarly to EXPLAIN, though note that it
3520  * can be a SELECT or an EXECUTE, but not other DML statements.
3521  * ----------------------
3522  */
3523 typedef struct CreateTableAsStmt
3526  Node *query; /* the query (see comments above) */
3527  IntoClause *into; /* destination table */
3528  ObjectType objtype; /* OBJECT_TABLE or OBJECT_MATVIEW */
3529  bool is_select_into; /* it was written as SELECT INTO */
3530  bool if_not_exists; /* just do nothing if it already exists? */
3532 
3533 /* ----------------------
3534  * REFRESH MATERIALIZED VIEW Statement
3535  * ----------------------
3536  */
3537 typedef struct RefreshMatViewStmt
3540  bool concurrent; /* allow concurrent access? */
3541  bool skipData; /* true for WITH NO DATA */
3542  RangeVar *relation; /* relation to insert into */
3544 
3545 /* ----------------------
3546  * Checkpoint Statement
3547  * ----------------------
3548  */
3549 typedef struct CheckPointStmt
3552 } CheckPointStmt;
3553 
3554 /* ----------------------
3555  * Discard Statement
3556  * ----------------------
3557  */
3559 typedef enum DiscardMode
3565 } DiscardMode;
3567 typedef struct DiscardStmt
3570  DiscardMode target;
3571 } DiscardStmt;
3572 
3573 /* ----------------------
3574  * LOCK Statement
3575  * ----------------------
3576  */
3577 typedef struct LockStmt
3580  List *relations; /* relations to lock */
3581  int mode; /* lock mode */
3582  bool nowait; /* no wait mode */
3583 } LockStmt;
3584 
3585 /* ----------------------
3586  * SET CONSTRAINTS Statement
3587  * ----------------------
3588  */
3589 typedef struct ConstraintsSetStmt
3592  List *constraints; /* List of names as RangeVars */
3593  bool deferred;
3595 
3596 /* ----------------------
3597  * REINDEX Statement
3598  * ----------------------
3599  */
3600 typedef enum ReindexObjectType
3603  REINDEX_OBJECT_TABLE, /* table or materialized view */
3605  REINDEX_OBJECT_SYSTEM, /* system catalogs */
3609 typedef struct ReindexStmt
3612  ReindexObjectType kind; /* REINDEX_OBJECT_INDEX, REINDEX_OBJECT_TABLE,
3613  * etc. */
3614  RangeVar *relation; /* Table or index to reindex */
3615  const char *name; /* name of database to reindex */
3616  List *params; /* list of DefElem nodes */
3617 } ReindexStmt;
3618 
3619 /* ----------------------
3620  * CREATE CONVERSION Statement
3621  * ----------------------
3622  */
3623 typedef struct CreateConversionStmt
3626  List *conversion_name; /* Name of the conversion */
3627  char *for_encoding_name; /* source encoding name */
3628  char *to_encoding_name; /* destination encoding name */
3629  List *func_name; /* qualified conversion function name */
3630  bool def; /* is this a default conversion? */
3632 
3633 /* ----------------------
3634  * CREATE CAST Statement
3635  * ----------------------
3636  */
3637 typedef struct CreateCastStmt
3640  TypeName *sourcetype;
3641  TypeName *targettype;
3644  bool inout;
3645 } CreateCastStmt;
3646 
3647 /* ----------------------
3648  * CREATE TRANSFORM Statement
3649  * ----------------------
3650  */
3651 typedef struct CreateTransformStmt
3654  bool replace;
3655  TypeName *type_name;
3656  char *lang;
3657  ObjectWithArgs *fromsql;
3660 
3661 /* ----------------------
3662  * PREPARE Statement
3663  * ----------------------
3664  */
3665 typedef struct PrepareStmt
3668  char *name; /* Name of plan, arbitrary */
3669  List *argtypes; /* Types of parameters (List of TypeName) */
3670  Node *query; /* The query itself (as a raw parsetree) */
3671 } PrepareStmt;
3672 
3673 
3674 /* ----------------------
3675  * EXECUTE Statement
3676  * ----------------------
3677  */
3679 typedef struct ExecuteStmt
3682  char *name; /* The name of the plan to execute */
3683  List *params; /* Values to assign to parameters */
3684 } ExecuteStmt;
3685 
3686 
3687 /* ----------------------
3688  * DEALLOCATE Statement
3689  * ----------------------
3690  */
3691 typedef struct DeallocateStmt
3694  char *name; /* The name of the plan to remove */
3695  /* NULL means DEALLOCATE ALL */
3696 } DeallocateStmt;
3697 
3698 /*
3699  * DROP OWNED statement
3700  */
3701 typedef struct DropOwnedStmt
3704  List *roles;
3705  DropBehavior behavior;
3706 } DropOwnedStmt;
3707 
3708 /*
3709  * REASSIGN OWNED statement
3710  */
3711 typedef struct ReassignOwnedStmt
3714  List *roles;
3715  RoleSpec *newrole;
3717 
3718 /*
3719  * TS Dictionary stmts: DefineStmt, RenameStmt and DropStmt are default
3720  */
3721 typedef struct AlterTSDictionaryStmt
3724  List *dictname; /* qualified name (list of String) */
3725  List *options; /* List of DefElem nodes */
3727 
3728 /*
3729  * TS Configuration stmts: DefineStmt, RenameStmt and DropStmt are default
3730  */
3731 typedef enum AlterTSConfigType
3740 typedef struct AlterTSConfigurationStmt
3743  AlterTSConfigType kind; /* ALTER_TSCONFIG_ADD_MAPPING, etc */
3744  List *cfgname; /* qualified name (list of String) */
3745 
3746  /*
3747  * dicts will be non-NIL if ADD/ALTER MAPPING was specified. If dicts is
3748  * NIL, but tokentype isn't, DROP MAPPING was specified.
3749  */
3750  List *tokentype; /* list of String */
3751  List *dicts; /* list of list of String */
3752  bool override; /* if true - remove old variant */
3753  bool replace; /* if true - replace dictionary by another */
3754  bool missing_ok; /* for DROP - skip error if missing? */
3757 typedef struct PublicationTable
3760  RangeVar *relation; /* relation to be published */
3761  Node *whereClause; /* qualifications */
3762  List *columns; /* List of columns in a publication table */
3764 
3765 /*
3766  * Publication object type
3767  */
3768 typedef enum PublicationObjSpecType
3770  PUBLICATIONOBJ_TABLE, /* A table */
3771  PUBLICATIONOBJ_TABLES_IN_SCHEMA, /* All tables in schema */
3772  PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA, /* All tables in first element of
3773  * search_path */
3774  PUBLICATIONOBJ_CONTINUATION /* Continuation of previous type */
3777 typedef struct PublicationObjSpec
3780  PublicationObjSpecType pubobjtype; /* type of this publication object */
3781  char *name;
3782  PublicationTable *pubtable;
3783  int location; /* token location, or -1 if unknown */
3786 typedef struct CreatePublicationStmt
3789  char *pubname; /* Name of the publication */
3790  List *options; /* List of DefElem nodes */
3791  List *pubobjects; /* Optional list of publication objects */
3792  bool for_all_tables; /* Special publication for all tables in db */
3795 typedef enum AlterPublicationAction
3797  AP_AddObjects, /* add objects to publication */
3798  AP_DropObjects, /* remove objects from publication */
3799  AP_SetObjects /* set list of objects */
3802 typedef struct AlterPublicationStmt
3805  char *pubname; /* Name of the publication */
3806 
3807  /* parameters used for ALTER PUBLICATION ... WITH */
3808  List *options; /* List of DefElem nodes */
3809 
3810  /*
3811  * Parameters used for ALTER PUBLICATION ... ADD/DROP/SET publication
3812  * objects.
3813  */
3814  List *pubobjects; /* Optional list of publication objects */
3815  bool for_all_tables; /* Special publication for all tables in db */
3816  AlterPublicationAction action; /* What action to perform with the given
3817  * objects */
3820 typedef struct CreateSubscriptionStmt
3823  char *subname; /* Name of the subscription */
3824  char *conninfo; /* Connection string to publisher */
3825  List *publication; /* One or more publication to subscribe to */
3826  List *options; /* List of DefElem nodes */
3829 typedef enum AlterSubscriptionType
3841 typedef struct AlterSubscriptionStmt
3844  AlterSubscriptionType kind; /* ALTER_SUBSCRIPTION_OPTIONS, etc */
3845  char *subname; /* Name of the subscription */
3846  char *conninfo; /* Connection string to publisher */
3847  List *publication; /* One or more publication to subscribe to */
3848  List *options; /* List of DefElem nodes */
3851 typedef struct DropSubscriptionStmt
3854  char *subname; /* Name of the subscription */
3855  bool missing_ok; /* Skip error if missing? */
3856  DropBehavior behavior; /* RESTRICT or CASCADE behavior */
3858 
3859 #endif /* PARSENODES_H */
static Datum values[MAXATTR]
Definition: bootstrap.c:156
#define PG_INT32_MAX
Definition: c.h:525
signed short int16
Definition: c.h:429
uint32 SubTransactionId
Definition: c.h:592
signed int int32
Definition: c.h:430
uint32 bits32
Definition: c.h:451
unsigned int Index
Definition: c.h:550
static struct @143 value
long val
Definition: informix.c:664
static JitProviderCallbacks provider
Definition: jit.c:43
LockWaitPolicy
Definition: lockoptions.h:37
LockClauseStrength
Definition: lockoptions.h:22
OnConflictAction
Definition: nodes.h:414
double Cardinality
Definition: nodes.h:252
CmdType
Definition: nodes.h:263
NodeTag
Definition: nodes.h:27
LimitOption
Definition: nodes.h:427
JoinType
Definition: nodes.h:288
struct AlterDatabaseRefreshCollStmt AlterDatabaseRefreshCollStmt
struct LoadStmt LoadStmt
RoleSpecType
Definition: parsenodes.h:360
@ ROLESPEC_CURRENT_USER
Definition: parsenodes.h:363
@ ROLESPEC_CSTRING
Definition: parsenodes.h:361
@ ROLESPEC_SESSION_USER
Definition: parsenodes.h:364
@ ROLESPEC_CURRENT_ROLE
Definition: parsenodes.h:362
@ ROLESPEC_PUBLIC
Definition: parsenodes.h:365
struct DropSubscriptionStmt DropSubscriptionStmt
struct CreateEnumStmt CreateEnumStmt
struct RoleSpec RoleSpec
struct CreateFunctionStmt CreateFunctionStmt
struct AlterOwnerStmt AlterOwnerStmt
struct ReturnStmt ReturnStmt
struct CreateAmStmt CreateAmStmt
AlterSubscriptionType
Definition: parsenodes.h:3829
@ ALTER_SUBSCRIPTION_ENABLED
Definition: parsenodes.h:3836
@ ALTER_SUBSCRIPTION_DROP_PUBLICATION
Definition: parsenodes.h:3834
@ ALTER_SUBSCRIPTION_SET_PUBLICATION
Definition: parsenodes.h:3832
@ ALTER_SUBSCRIPTION_REFRESH
Definition: parsenodes.h:3835
@ ALTER_SUBSCRIPTION_SKIP
Definition: parsenodes.h:3837
@ ALTER_SUBSCRIPTION_OPTIONS
Definition: parsenodes.h:3830
@ ALTER_SUBSCRIPTION_CONNECTION
Definition: parsenodes.h:3831
@ ALTER_SUBSCRIPTION_ADD_PUBLICATION
Definition: parsenodes.h:3833
struct TableLikeClause TableLikeClause
struct AlterSystemStmt AlterSystemStmt
struct CopyStmt CopyStmt
TransactionStmtKind
Definition: parsenodes.h:3292
@ TRANS_STMT_ROLLBACK_TO
Definition: parsenodes.h:3299
@ TRANS_STMT_START
Definition: parsenodes.h:3294
@ TRANS_STMT_SAVEPOINT
Definition: parsenodes.h:3297
@ TRANS_STMT_BEGIN
Definition: parsenodes.h:3293
@ TRANS_STMT_ROLLBACK
Definition: parsenodes.h:3296
@ TRANS_STMT_COMMIT_PREPARED
Definition: parsenodes.h:3301
@ TRANS_STMT_COMMIT
Definition: parsenodes.h:3295
@ TRANS_STMT_ROLLBACK_PREPARED
Definition: parsenodes.h:3302
@ TRANS_STMT_PREPARE
Definition: parsenodes.h:3300
@ TRANS_STMT_RELEASE
Definition: parsenodes.h:3298
struct GrantRoleStmt GrantRoleStmt
struct AlterTSDictionaryStmt AlterTSDictionaryStmt
struct OnConflictClause OnConflictClause
struct AlterOperatorStmt AlterOperatorStmt
WCOKind
Definition: parsenodes.h:1266
@ WCO_RLS_MERGE_UPDATE_CHECK
Definition: parsenodes.h:1271
@ WCO_RLS_CONFLICT_CHECK
Definition: parsenodes.h:1270
@ WCO_RLS_INSERT_CHECK
Definition: parsenodes.h:1268
@ WCO_VIEW_CHECK
Definition: parsenodes.h:1267
@ WCO_RLS_UPDATE_CHECK
Definition: parsenodes.h:1269
@ WCO_RLS_MERGE_DELETE_CHECK
Definition: parsenodes.h:1272
struct RangeTblFunction RangeTblFunction
struct A_Indirection A_Indirection
struct XmlSerialize XmlSerialize
SortByNulls
Definition: parsenodes.h:60
@ SORTBY_NULLS_DEFAULT
Definition: parsenodes.h:61
@ SORTBY_NULLS_LAST
Definition: parsenodes.h:63
@ SORTBY_NULLS_FIRST
Definition: parsenodes.h:62
struct DeallocateStmt DeallocateStmt
struct CreateSeqStmt CreateSeqStmt
struct DropTableSpaceStmt DropTableSpaceStmt
struct CreateExtensionStmt CreateExtensionStmt
struct A_Indices A_Indices
struct CreateTableSpaceStmt CreateTableSpaceStmt
GroupingSetKind
Definition: parsenodes.h:1404
@ GROUPING_SET_CUBE
Definition: parsenodes.h:1408
@ GROUPING_SET_SIMPLE
Definition: parsenodes.h:1406
@ GROUPING_SET_ROLLUP
Definition: parsenodes.h:1407
@ GROUPING_SET_SETS
Definition: parsenodes.h:1409
@ GROUPING_SET_EMPTY
Definition: parsenodes.h:1405
struct ReassignOwnedStmt ReassignOwnedStmt
struct ParamRef ParamRef
struct VacuumStmt VacuumStmt
struct NotifyStmt NotifyStmt
SetOperation
Definition: parsenodes.h:1743
@ SETOP_INTERSECT
Definition: parsenodes.h:1746
@ SETOP_UNION
Definition: parsenodes.h:1745
@ SETOP_EXCEPT
Definition: parsenodes.h:1747
@ SETOP_NONE
Definition: parsenodes.h:1744
struct TriggerTransition TriggerTransition
struct ClusterStmt ClusterStmt
struct MergeStmt MergeStmt
struct SelectStmt SelectStmt
struct DropdbStmt DropdbStmt
uint64 AclMode
Definition: parsenodes.h:81
struct FunctionParameter FunctionParameter
struct UnlistenStmt UnlistenStmt
struct InsertStmt InsertStmt
struct AlterFunctionStmt AlterFunctionStmt
struct StatsElem StatsElem
struct AlterRoleSetStmt AlterRoleSetStmt
struct CreateOpFamilyStmt CreateOpFamilyStmt
struct CreatePublicationStmt CreatePublicationStmt
struct CreateDomainStmt CreateDomainStmt
struct AlterDomainStmt AlterDomainStmt
struct AlterDefaultPrivilegesStmt AlterDefaultPrivilegesStmt
struct CreateStatsStmt CreateStatsStmt
struct UpdateStmt UpdateStmt
struct AlterObjectDependsStmt AlterObjectDependsStmt
struct IndexElem IndexElem
struct AlterCollationStmt AlterCollationStmt
A_Expr_Kind
Definition: parsenodes.h:279
@ AEXPR_BETWEEN
Definition: parsenodes.h:290
@ AEXPR_NULLIF
Definition: parsenodes.h:285
@ AEXPR_NOT_DISTINCT
Definition: parsenodes.h:284
@ AEXPR_BETWEEN_SYM
Definition: parsenodes.h:292
@ AEXPR_NOT_BETWEEN_SYM
Definition: parsenodes.h:293
@ AEXPR_ILIKE
Definition: parsenodes.h:288
@ AEXPR_IN
Definition: parsenodes.h:286
@ AEXPR_NOT_BETWEEN
Definition: parsenodes.h:291
@ AEXPR_DISTINCT
Definition: parsenodes.h:283
@ AEXPR_SIMILAR
Definition: parsenodes.h:289
@ AEXPR_LIKE
Definition: parsenodes.h:287
@ AEXPR_OP
Definition: parsenodes.h:280
@ AEXPR_OP_ANY
Definition: parsenodes.h:281
@ AEXPR_OP_ALL
Definition: parsenodes.h:282
FunctionParameterMode
Definition: parsenodes.h:3083
@ FUNC_PARAM_IN
Definition: parsenodes.h:3085
@ FUNC_PARAM_DEFAULT
Definition: parsenodes.h:3091
@ FUNC_PARAM_OUT
Definition: parsenodes.h:3086
@ FUNC_PARAM_INOUT
Definition: parsenodes.h:3087
@ FUNC_PARAM_TABLE
Definition: parsenodes.h:3089
@ FUNC_PARAM_VARIADIC
Definition: parsenodes.h:3088
struct CreateForeignTableStmt CreateForeignTableStmt
struct CreateOpClassStmt CreateOpClassStmt
AlterTSConfigType
Definition: parsenodes.h:3731
@ ALTER_TSCONFIG_ALTER_MAPPING_FOR_TOKEN
Definition: parsenodes.h:3733
@ ALTER_TSCONFIG_REPLACE_DICT_FOR_TOKEN
Definition: parsenodes.h:3735
@ ALTER_TSCONFIG_REPLACE_DICT
Definition: parsenodes.h:3734
@ ALTER_TSCONFIG_ADD_MAPPING
Definition: parsenodes.h:3732
@ ALTER_TSCONFIG_DROP_MAPPING
Definition: parsenodes.h:3736
struct AlterForeignServerStmt AlterForeignServerStmt
struct ColumnDef ColumnDef
struct CreatedbStmt CreatedbStmt
struct RTEPermissionInfo RTEPermissionInfo
struct AlterEventTrigStmt AlterEventTrigStmt
struct IndexStmt IndexStmt
struct PartitionCmd PartitionCmd
PublicationObjSpecType
Definition: parsenodes.h:3768
@ PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA
Definition: parsenodes.h:3771
@ PUBLICATIONOBJ_TABLES_IN_SCHEMA
Definition: parsenodes.h:3770
@ PUBLICATIONOBJ_TABLE
Definition: parsenodes.h:3769
@ PUBLICATIONOBJ_CONTINUATION
Definition: parsenodes.h:3773
PartitionStrategy
Definition: parsenodes.h:834
@ PARTITION_STRATEGY_HASH
Definition: parsenodes.h:837
@ PARTITION_STRATEGY_LIST
Definition: parsenodes.h:835
@ PARTITION_STRATEGY_RANGE
Definition: parsenodes.h:836
ImportForeignSchemaType
Definition: parsenodes.h:2581
@ FDW_IMPORT_SCHEMA_LIMIT_TO
Definition: parsenodes.h:2583
@ FDW_IMPORT_SCHEMA_ALL
Definition: parsenodes.h:2582
@ FDW_IMPORT_SCHEMA_EXCEPT
Definition: parsenodes.h:2584
struct AlterRoleStmt AlterRoleStmt
struct MergeWhenClause MergeWhenClause
struct WindowDef WindowDef
struct CommentStmt CommentStmt
AlterPublicationAction
Definition: parsenodes.h:3795
@ AP_DropObjects
Definition: parsenodes.h:3797
@ AP_SetObjects
Definition: parsenodes.h:3798
@ AP_AddObjects
Definition: parsenodes.h:3796
struct Query Query
QuerySource
Definition: parsenodes.h:42
@ QSRC_NON_INSTEAD_RULE
Definition: parsenodes.h:47
@ QSRC_PARSER
Definition: parsenodes.h:44
@ QSRC_QUAL_INSTEAD_RULE
Definition: parsenodes.h:46
@ QSRC_ORIGINAL
Definition: parsenodes.h:43
@ QSRC_INSTEAD_RULE
Definition: parsenodes.h:45
struct WithClause WithClause
struct AlterObjectSchemaStmt AlterObjectSchemaStmt
struct MultiAssignRef MultiAssignRef
struct ImportForeignSchemaStmt ImportForeignSchemaStmt
struct ReindexStmt ReindexStmt
struct CreateSubscriptionStmt CreateSubscriptionStmt
struct A_Const A_Const
struct DeleteStmt DeleteStmt
RTEKind
Definition: parsenodes.h:981
@ RTE_JOIN
Definition: parsenodes.h:984
@ RTE_CTE
Definition: parsenodes.h:988
@ RTE_NAMEDTUPLESTORE
Definition: parsenodes.h:989
@ RTE_VALUES
Definition: parsenodes.h:987
@ RTE_SUBQUERY
Definition: parsenodes.h:983
@ RTE_RESULT
Definition: parsenodes.h:990
@ RTE_FUNCTION
Definition: parsenodes.h:985
@ RTE_TABLEFUNC
Definition: parsenodes.h:986
@ RTE_RELATION
Definition: parsenodes.h:982
struct AlterSubscriptionStmt AlterSubscriptionStmt
struct AlterStatsStmt AlterStatsStmt
struct AlterPublicationStmt AlterPublicationStmt
struct RangeFunction RangeFunction
struct PLAssignStmt PLAssignStmt
DefElemAction
Definition: parsenodes.h:768
@ DEFELEM_UNSPEC
Definition: parsenodes.h:769
@ DEFELEM_DROP
Definition: parsenodes.h:772
@ DEFELEM_SET
Definition: parsenodes.h:770
@ DEFELEM_ADD
Definition: parsenodes.h:771
struct ColumnRef ColumnRef
ConstrType
Definition: parsenodes.h:2332
@ CONSTR_FOREIGN
Definition: parsenodes.h:2343
@ CONSTR_ATTR_DEFERRED
Definition: parsenodes.h:2346
@ CONSTR_IDENTITY
Definition: parsenodes.h:2337
@ CONSTR_UNIQUE
Definition: parsenodes.h:2341
@ CONSTR_ATTR_NOT_DEFERRABLE
Definition: parsenodes.h:2345
@ CONSTR_DEFAULT
Definition: parsenodes.h:2336
@ CONSTR_NOTNULL
Definition: parsenodes.h:2335
@ CONSTR_ATTR_IMMEDIATE
Definition: parsenodes.h:2347
@ CONSTR_CHECK
Definition: parsenodes.h:2339
@ CONSTR_NULL
Definition: parsenodes.h:2333
@ CONSTR_GENERATED
Definition: parsenodes.h:2338
@ CONSTR_EXCLUSION
Definition: parsenodes.h:2342
@ CONSTR_ATTR_DEFERRABLE
Definition: parsenodes.h:2344
@ CONSTR_PRIMARY
Definition: parsenodes.h:2340
PartitionRangeDatumKind
Definition: parsenodes.h:886
@ PARTITION_RANGE_DATUM_MAXVALUE
Definition: parsenodes.h:889
@ PARTITION_RANGE_DATUM_VALUE
Definition: parsenodes.h:888
@ PARTITION_RANGE_DATUM_MINVALUE
Definition: parsenodes.h:887
struct GroupingSet GroupingSet
struct CreatePolicyStmt CreatePolicyStmt
FetchDirection
Definition: parsenodes.h:2960
@ FETCH_RELATIVE
Definition: parsenodes.h:2966
@ FETCH_ABSOLUTE
Definition: parsenodes.h:2965
@ FETCH_FORWARD
Definition: parsenodes.h:2962
@ FETCH_BACKWARD
Definition: parsenodes.h:2963
VariableSetKind
Definition: parsenodes.h:2243
@ VAR_SET_DEFAULT
Definition: parsenodes.h:2245
@ VAR_RESET
Definition: parsenodes.h:2248
@ VAR_SET_MULTI
Definition: parsenodes.h:2247
@ VAR_SET_VALUE
Definition: parsenodes.h:2244
@ VAR_SET_CURRENT
Definition: parsenodes.h:2246
@ VAR_RESET_ALL
Definition: parsenodes.h:2249
DropBehavior
Definition: parsenodes.h:1960
@ DROP_CASCADE
Definition: parsenodes.h:1962
@ DROP_RESTRICT
Definition: parsenodes.h:1961
ObjectType
Definition: parsenodes.h:1887
@ OBJECT_EVENT_TRIGGER
Definition: parsenodes.h:1902
@ OBJECT_FDW
Definition: parsenodes.h:1904
@ OBJECT_TSPARSER
Definition: parsenodes.h:1935
@ OBJECT_COLLATION
Definition: parsenodes.h:1895
@ OBJECT_USER_MAPPING
Definition: parsenodes.h:1938
@ OBJECT_ACCESS_METHOD
Definition: parsenodes.h:1888
@ OBJECT_OPCLASS
Definition: parsenodes.h:1912
@ OBJECT_DEFACL
Definition: parsenodes.h:1899
@ OBJECT_AGGREGATE
Definition: parsenodes.h:1889
@ OBJECT_MATVIEW
Definition: parsenodes.h:1911
@ OBJECT_SCHEMA
Definition: parsenodes.h:1924
@ OBJECT_POLICY
Definition: parsenodes.h:1916
@ OBJECT_OPERATOR
Definition: parsenodes.h:1913
@ OBJECT_FOREIGN_TABLE
Definition: parsenodes.h:1906
@ OBJECT_TSCONFIGURATION
Definition: parsenodes.h:1933
@ OBJECT_OPFAMILY
Definition: parsenodes.h:1914
@ OBJECT_DOMAIN
Definition: parsenodes.h:1900
@ OBJECT_COLUMN
Definition: parsenodes.h:1894
@ OBJECT_TABLESPACE
Definition: parsenodes.h:1930
@ OBJECT_ROLE
Definition: parsenodes.h:1921
@ OBJECT_ROUTINE
Definition: parsenodes.h:1922
@ OBJECT_LARGEOBJECT
Definition: parsenodes.h:1910
@ OBJECT_PUBLICATION_NAMESPACE
Definition: parsenodes.h:1919
@ OBJECT_PROCEDURE
Definition: parsenodes.h:1917
@ OBJECT_EXTENSION
Definition: parsenodes.h:1903
@ OBJECT_INDEX
Definition: parsenodes.h:1908
@ OBJECT_DEFAULT
Definition: parsenodes.h:1898
@ OBJECT_DATABASE
Definition: parsenodes.h:1897
@ OBJECT_SEQUENCE
Definition: parsenodes.h:1925
@ OBJECT_TSTEMPLATE
Definition: parsenodes.h:1936
@ OBJECT_LANGUAGE
Definition: parsenodes.h:1909
@ OBJECT_AMOP
Definition: parsenodes.h:1890
@ OBJECT_PUBLICATION_REL
Definition: parsenodes.h:1920
@ OBJECT_FOREIGN_SERVER
Definition: parsenodes.h:1905
@ OBJECT_TSDICTIONARY
Definition: parsenodes.h:1934
@ OBJECT_ATTRIBUTE
Definition: parsenodes.h:1892
@ OBJECT_PUBLICATION
Definition: parsenodes.h:1918
@ OBJECT_RULE
Definition: parsenodes.h:1923
@ OBJECT_CONVERSION
Definition: parsenodes.h:1896
@ OBJECT_AMPROC
Definition: parsenodes.h:1891
@ OBJECT_TABLE
Definition: parsenodes.h:1929
@ OBJECT_VIEW
Definition: parsenodes.h:1939
@ OBJECT_PARAMETER_ACL
Definition: parsenodes.h:1915
@ OBJECT_TYPE
Definition: parsenodes.h:1937
@ OBJECT_FUNCTION
Definition: parsenodes.h:1907
@ OBJECT_TABCONSTRAINT
Definition: parsenodes.h:1928
@ OBJECT_DOMCONSTRAINT
Definition: parsenodes.h:1901
@ OBJECT_SUBSCRIPTION
Definition: parsenodes.h:1926
@ OBJECT_STATISTIC_EXT
Definition: parsenodes.h:1927
@ OBJECT_CAST
Definition: parsenodes.h:1893
@ OBJECT_TRIGGER
Definition: parsenodes.h:1932
@ OBJECT_TRANSFORM
Definition: parsenodes.h:1931
struct ListenStmt ListenStmt
struct A_Star A_Star
struct PublicationObjSpec PublicationObjSpec
struct AlterTableSpaceOptionsStmt AlterTableSpaceOptionsStmt
struct CreateRoleStmt CreateRoleStmt
struct AlterTableCmd AlterTableCmd
struct RangeTableSample RangeTableSample
struct DropUserMappingStmt DropUserMappingStmt
ReindexObjectType
Definition: parsenodes.h:3600
@ REINDEX_OBJECT_DATABASE
Definition: parsenodes.h:3605
@ REINDEX_OBJECT_INDEX
Definition: parsenodes.h:3601
@ REINDEX_OBJECT_SCHEMA
Definition: parsenodes.h:3603
@ REINDEX_OBJECT_SYSTEM
Definition: parsenodes.h:3604
@ REINDEX_OBJECT_TABLE
Definition: parsenodes.h:3602
struct CreateForeignServerStmt CreateForeignServerStmt
struct LockingClause LockingClause
AlterTableType
Definition: parsenodes.h:1979
@ AT_AddIndexConstraint
Definition: parsenodes.h:2005
@ AT_DropOf
Definition: parsenodes.h:2037
@ AT_CheckNotNull
Definition: parsenodes.h:1988
@ AT_SetOptions
Definition: parsenodes.h:1990
@ AT_DropIdentity
Definition: parsenodes.h:2049
@ AT_DisableTrigUser
Definition: parsenodes.h:2029
@ AT_DropNotNull
Definition: parsenodes.h:1985
@ AT_AddOf
Definition: parsenodes.h:2036
@ AT_ResetOptions
Definition: parsenodes.h:1991
@ AT_ReplicaIdentity
Definition: parsenodes.h:2038
@ AT_DropColumnRecurse
Definition: parsenodes.h:1995
@ AT_ReplaceRelOptions
Definition: parsenodes.h:2021
@ AT_EnableRowSecurity
Definition: parsenodes.h:2039
@ AT_AddColumnToView
Definition: parsenodes.h:1982
@ AT_ResetRelOptions
Definition: parsenodes.h:2020
@ AT_AddConstraintRecurse
Definition: parsenodes.h:1999
@ AT_EnableReplicaTrig
Definition: parsenodes.h:2024
@ AT_DropOids
Definition: parsenodes.h:2016
@ AT_SetIdentity
Definition: parsenodes.h:2048
@ AT_ReAddStatistics
Definition: parsenodes.h:2050
@ AT_SetUnLogged
Definition: parsenodes.h:2015
@ AT_DisableTrig
Definition: parsenodes.h:2025
@ AT_SetCompression
Definition: parsenodes.h:1993
@ AT_DropExpression
Definition: parsenodes.h:1987
@ AT_AddIndex
Definition: parsenodes.h:1996
@ AT_EnableReplicaRule
Definition: parsenodes.h:2032
@ AT_ReAddIndex
Definition: parsenodes.h:1997
@ AT_DropConstraint
Definition: parsenodes.h:2006
@ AT_SetNotNull
Definition: parsenodes.h:1986
@ AT_ClusterOn
Definition: parsenodes.h:2012
@ AT_AddIdentity
Definition: parsenodes.h:2047
@ AT_ForceRowSecurity
Definition: parsenodes.h:2041
@ AT_EnableAlwaysRule
Definition: parsenodes.h:2031
@ AT_SetAccessMethod
Definition: parsenodes.h:2017
@ AT_AlterColumnType
Definition: parsenodes.h:2009
@ AT_DetachPartitionFinalize
Definition: parsenodes.h:2046
@ AT_AddInherit
Definition: parsenodes.h:2034
@ AT_ReAddDomainConstraint
Definition: parsenodes.h:2001
@ AT_EnableTrig
Definition: parsenodes.h:2022
@ AT_AddColumnRecurse
Definition: parsenodes.h:1981
@ AT_DropColumn
Definition: parsenodes.h:1994
@ AT_ValidateConstraintRecurse
Definition: parsenodes.h:2004
@ AT_ReAddComment
Definition: parsenodes.h:2008
@ AT_AlterColumnGenericOptions
Definition: parsenodes.h:2010
@ AT_DisableTrigAll
Definition: parsenodes.h:2027
@ AT_EnableRule
Definition: parsenodes.h:2030
@ AT_NoForceRowSecurity
Definition: parsenodes.h:2042
@ AT_DetachPartition
Definition: parsenodes.h:2045
@ AT_SetStatistics
Definition: parsenodes.h:1989
@ AT_AttachPartition
Definition: parsenodes.h:2044
@ AT_AddConstraint
Definition: parsenodes.h:1998
@ AT_DropInherit
Definition: parsenodes.h:2035
@ AT_EnableAlwaysTrig
Definition: parsenodes.h:2023
@ AT_SetLogged
Definition: parsenodes.h:2014
@ AT_SetStorage
Definition: parsenodes.h:1992
@ AT_DisableRule
Definition: parsenodes.h:2033
@ AT_DisableRowSecurity
Definition: parsenodes.h:2040
@ AT_SetRelOptions
Definition: parsenodes.h:2019
@ AT_ChangeOwner
Definition: parsenodes.h:2011
@ AT_EnableTrigUser
Definition: parsenodes.h:2028
@ AT_ReAddConstraint
Definition: parsenodes.h:2000
@ AT_DropConstraintRecurse
Definition: parsenodes.h:2007
@ AT_SetTableSpace
Definition: parsenodes.h:2018
@ AT_GenericOptions
Definition: parsenodes.h:2043
@ AT_ColumnDefault
Definition: parsenodes.h:1983
@ AT_CookedColumnDefault
Definition: parsenodes.h:1984
@ AT_AlterConstraint
Definition: parsenodes.h:2002
@ AT_EnableTrigAll
Definition: parsenodes.h:2026
@ AT_DropCluster
Definition: parsenodes.h:2013
@ AT_ValidateConstraint
Definition: parsenodes.h:2003
@ AT_AddColumn
Definition: parsenodes.h:1980
struct WithCheckOption WithCheckOption
struct LockStmt LockStmt
GrantTargetType
Definition: parsenodes.h:2119
@ ACL_TARGET_DEFAULTS
Definition: parsenodes.h:2122
@ ACL_TARGET_OBJECT
Definition: parsenodes.h:2120
@ ACL_TARGET_ALL_IN_SCHEMA
Definition: parsenodes.h:2121
struct CreateEventTrigStmt CreateEventTrigStmt
struct DropOwnedStmt DropOwnedStmt
struct VariableShowStmt VariableShowStmt
struct CreateTransformStmt CreateTransformStmt
struct AlterUserMappingStmt AlterUserMappingStmt
struct PartitionRangeDatum PartitionRangeDatum
struct A_ArrayExpr A_ArrayExpr
struct RangeTableFunc RangeTableFunc
struct MergeAction MergeAction
struct InferClause InferClause
struct RangeSubselect RangeSubselect
struct DropStmt DropStmt
struct CreateOpClassItem CreateOpClassItem
struct PrepareStmt PrepareStmt
struct AlterOpFamilyStmt AlterOpFamilyStmt
struct ConstraintsSetStmt ConstraintsSetStmt
struct GrantStmt GrantStmt
OverridingKind
Definition: parsenodes.h:34
@ OVERRIDING_NOT_SET
Definition: parsenodes.h:35
@ OVERRIDING_SYSTEM_VALUE
Definition: parsenodes.h:37
@ OVERRIDING_USER_VALUE
Definition: parsenodes.h:36
struct SetOperationStmt SetOperationStmt
struct SortBy SortBy
struct ViewStmt ViewStmt
struct CreateTrigStmt CreateTrigStmt
struct CTECycleClause CTECycleClause
struct VacuumRelation VacuumRelation
struct RenameStmt RenameStmt
struct DefineStmt DefineStmt
struct CreateStmt CreateStmt
struct CreateSchemaStmt CreateSchemaStmt
DiscardMode
Definition: parsenodes.h:3559
@ DISCARD_ALL
Definition: parsenodes.h:3560
@ DISCARD_PLANS
Definition: parsenodes.h:3561
@ DISCARD_SEQUENCES
Definition: parsenodes.h:3562
@ DISCARD_TEMP
Definition: parsenodes.h:3563
struct VariableSetStmt VariableSetStmt
struct RawStmt RawStmt
struct CommonTableExpr CommonTableExpr
struct TableSampleClause TableSampleClause
struct AlterPolicyStmt AlterPolicyStmt
struct CreateConversionStmt CreateConversionStmt
struct ResTarget ResTarget
struct DropRoleStmt DropRoleStmt
struct DiscardStmt DiscardStmt
struct AlterExtensionStmt AlterExtensionStmt
struct AlterTableStmt AlterTableStmt
struct TypeCast TypeCast
struct PartitionElem PartitionElem
struct ClosePortalStmt ClosePortalStmt
struct AccessPriv AccessPriv
struct CreatePLangStmt CreatePLangStmt
struct CreateRangeStmt CreateRangeStmt
struct CreateUserMappingStmt CreateUserMappingStmt
SortByDir
Definition: parsenodes.h:52
@ SORTBY_USING
Definition: parsenodes.h:56
@ SORTBY_DESC
Definition: parsenodes.h:55
@ SORTBY_ASC
Definition: parsenodes.h:54
@ SORTBY_DEFAULT
Definition: parsenodes.h:53
struct AlterDatabaseSetStmt AlterDatabaseSetStmt
struct AlterTableMoveAllStmt AlterTableMoveAllStmt
struct AlterSeqStmt AlterSeqStmt
struct PublicationTable PublicationTable
struct RowMarkClause RowMarkClause
struct CreateTableAsStmt CreateTableAsStmt
struct TransactionStmt TransactionStmt
struct CreateFdwStmt CreateFdwStmt
struct DeclareCursorStmt DeclareCursorStmt
struct ExecuteStmt ExecuteStmt
struct WindowClause WindowClause
RoleStmtType
Definition: parsenodes.h:2718
@ ROLESTMT_ROLE
Definition: parsenodes.h:2719
@ ROLESTMT_USER
Definition: parsenodes.h:2720
@ ROLESTMT_GROUP
Definition: parsenodes.h:2721
struct RuleStmt RuleStmt
struct SecLabelStmt SecLabelStmt
struct AlterTSConfigurationStmt AlterTSConfigurationStmt
struct AlterDatabaseStmt AlterDatabaseStmt
struct AlterExtensionContentsStmt AlterExtensionContentsStmt
TableLikeOption
Definition: parsenodes.h:724
@ CREATE_TABLE_LIKE_COMMENTS
Definition: parsenodes.h:725
@ CREATE_TABLE_LIKE_GENERATED
Definition: parsenodes.h:729
@ CREATE_TABLE_LIKE_IDENTITY
Definition: parsenodes.h:730
@ CREATE_TABLE_LIKE_COMPRESSION
Definition: parsenodes.h:726
@ CREATE_TABLE_LIKE_STORAGE
Definition: parsenodes.h:733
@ CREATE_TABLE_LIKE_ALL
Definition: parsenodes.h:734
@ CREATE_TABLE_LIKE_INDEXES
Definition: parsenodes.h:731
@ CREATE_TABLE_LIKE_DEFAULTS
Definition: parsenodes.h:728
@ CREATE_TABLE_LIKE_STATISTICS
Definition: parsenodes.h:732
@ CREATE_TABLE_LIKE_CONSTRAINTS
Definition: parsenodes.h:727
struct TypeName TypeName
struct AlterEnumStmt AlterEnumStmt
struct CreateCastStmt CreateCastStmt
struct CheckPointStmt CheckPointStmt
struct RefreshMatViewStmt RefreshMatViewStmt
struct CallStmt CallStmt
struct TruncateStmt TruncateStmt
struct DefElem DefElem