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