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