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