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