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