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