PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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-2017, PostgreSQL Global Development Group
16  * Portions Copyright (c) 1994, Regents of the University of California
17  *
18  * src/include/nodes/parsenodes.h
19  *
20  *-------------------------------------------------------------------------
21  */
22 #ifndef PARSENODES_H
23 #define PARSENODES_H
24 
25 #include "nodes/bitmapset.h"
26 #include "nodes/lockoptions.h"
27 #include "nodes/primnodes.h"
28 #include "nodes/value.h"
29 
30 typedef enum OverridingKind
31 {
36 
37 /* Possible sources of a Query */
38 typedef enum QuerySource
39 {
40  QSRC_ORIGINAL, /* original parsetree (explicit query) */
41  QSRC_PARSER, /* added by parse analysis (now unused) */
42  QSRC_INSTEAD_RULE, /* added by unconditional INSTEAD rule */
43  QSRC_QUAL_INSTEAD_RULE, /* added by conditional INSTEAD rule */
44  QSRC_NON_INSTEAD_RULE /* added by non-INSTEAD rule */
45 } QuerySource;
46 
47 /* Sort ordering options for ORDER BY and CREATE INDEX */
48 typedef enum SortByDir
49 {
53  SORTBY_USING /* not allowed in CREATE INDEX ... */
54 } SortByDir;
55 
56 typedef enum SortByNulls
57 {
61 } SortByNulls;
62 
63 /*
64  * Grantable rights are encoded so that we can OR them together in a bitmask.
65  * The present representation of AclItem limits us to 16 distinct rights,
66  * even though AclMode is defined as uint32. See utils/acl.h.
67  *
68  * Caution: changing these codes breaks stored ACLs, hence forces initdb.
69  */
70 typedef uint32 AclMode; /* a bitmask of privilege bits */
71 
72 #define ACL_INSERT (1<<0) /* for relations */
73 #define ACL_SELECT (1<<1)
74 #define ACL_UPDATE (1<<2)
75 #define ACL_DELETE (1<<3)
76 #define ACL_TRUNCATE (1<<4)
77 #define ACL_REFERENCES (1<<5)
78 #define ACL_TRIGGER (1<<6)
79 #define ACL_EXECUTE (1<<7) /* for functions */
80 #define ACL_USAGE (1<<8) /* for languages, namespaces, FDWs, and
81  * servers */
82 #define ACL_CREATE (1<<9) /* for namespaces and databases */
83 #define ACL_CREATE_TEMP (1<<10) /* for databases */
84 #define ACL_CONNECT (1<<11) /* for databases */
85 #define N_ACL_RIGHTS 12 /* 1 plus the last 1<<x */
86 #define ACL_NO_RIGHTS 0
87 /* Currently, SELECT ... FOR [KEY] UPDATE/SHARE requires UPDATE privileges */
88 #define ACL_SELECT_FOR_UPDATE ACL_UPDATE
89 
90 
91 /*****************************************************************************
92  * Query Tree
93  *****************************************************************************/
94 
95 /*
96  * Query -
97  * Parse analysis turns all statements into a Query tree
98  * for further processing by the rewriter and planner.
99  *
100  * Utility statements (i.e. non-optimizable statements) have the
101  * utilityStmt field set, and the rest of the Query is mostly dummy.
102  *
103  * Planning converts a Query tree into a Plan tree headed by a PlannedStmt
104  * node --- the Query structure is not used by the executor.
105  */
106 typedef struct Query
107 {
109 
110  CmdType commandType; /* select|insert|update|delete|utility */
111 
112  QuerySource querySource; /* where did I come from? */
113 
114  uint64 queryId; /* query identifier (can be set by plugins) */
115 
116  bool canSetTag; /* do I set the command result tag? */
117 
118  Node *utilityStmt; /* non-null if commandType == CMD_UTILITY */
119 
120  int resultRelation; /* rtable index of target relation for
121  * INSERT/UPDATE/DELETE; 0 for SELECT */
122 
123  bool hasAggs; /* has aggregates in tlist or havingQual */
124  bool hasWindowFuncs; /* has window functions in tlist */
125  bool hasTargetSRFs; /* has set-returning functions in tlist */
126  bool hasSubLinks; /* has subquery SubLink */
127  bool hasDistinctOn; /* distinctClause is from DISTINCT ON */
128  bool hasRecursive; /* WITH RECURSIVE was specified */
129  bool hasModifyingCTE; /* has INSERT/UPDATE/DELETE in WITH */
130  bool hasForUpdate; /* FOR [KEY] UPDATE/SHARE was specified */
131  bool hasRowSecurity; /* rewriter has applied some RLS policy */
132 
133  List *cteList; /* WITH list (of CommonTableExpr's) */
134 
135  List *rtable; /* list of range table entries */
136  FromExpr *jointree; /* table join tree (FROM and WHERE clauses) */
137 
138  List *targetList; /* target list (of TargetEntry) */
139 
140  OverridingKind override; /* OVERRIDING clause */
141 
142  OnConflictExpr *onConflict; /* ON CONFLICT DO [NOTHING | UPDATE] */
143 
144  List *returningList; /* return-values list (of TargetEntry) */
145 
146  List *groupClause; /* a list of SortGroupClause's */
147 
148  List *groupingSets; /* a list of GroupingSet's if present */
149 
150  Node *havingQual; /* qualifications applied to groups */
151 
152  List *windowClause; /* a list of WindowClause's */
153 
154  List *distinctClause; /* a list of SortGroupClause's */
155 
156  List *sortClause; /* a list of SortGroupClause's */
157 
158  Node *limitOffset; /* # of result tuples to skip (int8 expr) */
159  Node *limitCount; /* # of result tuples to return (int8 expr) */
160 
161  List *rowMarks; /* a list of RowMarkClause's */
162 
163  Node *setOperations; /* set-operation tree if this is top level of
164  * a UNION/INTERSECT/EXCEPT query */
165 
166  List *constraintDeps; /* a list of pg_constraint OIDs that the query
167  * depends on to be semantically valid */
168 
169  List *withCheckOptions; /* a list of WithCheckOption's, which are
170  * only added during rewrite and therefore
171  * are not written out as part of Query. */
172 
173  /*
174  * The following two fields identify the portion of the source text string
175  * containing this query. They are typically only populated in top-level
176  * Queries, not in sub-queries. When not set, they might both be zero, or
177  * both be -1 meaning "unknown".
178  */
179  int stmt_location; /* start location, or -1 if unknown */
180  int stmt_len; /* length in bytes; 0 means "rest of string" */
181 } Query;
182 
183 
184 /****************************************************************************
185  * Supporting data structures for Parse Trees
186  *
187  * Most of these node types appear in raw parsetrees output by the grammar,
188  * and get transformed to something else by the analyzer. A few of them
189  * are used as-is in transformed querytrees.
190  ****************************************************************************/
191 
192 /*
193  * TypeName - specifies a type in definitions
194  *
195  * For TypeName structures generated internally, it is often easier to
196  * specify the type by OID than by name. If "names" is NIL then the
197  * actual type OID is given by typeOid, otherwise typeOid is unused.
198  * Similarly, if "typmods" is NIL then the actual typmod is expected to
199  * be prespecified in typemod, otherwise typemod is unused.
200  *
201  * If pct_type is TRUE, then names is actually a field name and we look up
202  * the type of that field. Otherwise (the normal case), names is a type
203  * name possibly qualified with schema and database name.
204  */
205 typedef struct TypeName
206 {
208  List *names; /* qualified name (list of Value strings) */
209  Oid typeOid; /* type identified by OID */
210  bool setof; /* is a set? */
211  bool pct_type; /* %TYPE specified? */
212  List *typmods; /* type modifier expression(s) */
213  int32 typemod; /* prespecified type modifier */
214  List *arrayBounds; /* array bounds */
215  int location; /* token location, or -1 if unknown */
216 } TypeName;
217 
218 /*
219  * ColumnRef - specifies a reference to a column, or possibly a whole tuple
220  *
221  * The "fields" list must be nonempty. It can contain string Value nodes
222  * (representing names) and A_Star nodes (representing occurrence of a '*').
223  * Currently, A_Star must appear only as the last list element --- the grammar
224  * is responsible for enforcing this!
225  *
226  * Note: any array subscripting or selection of fields from composite columns
227  * is represented by an A_Indirection node above the ColumnRef. However,
228  * for simplicity in the normal case, initial field selection from a table
229  * name is represented within ColumnRef and not by adding A_Indirection.
230  */
231 typedef struct ColumnRef
232 {
234  List *fields; /* field names (Value strings) or A_Star */
235  int location; /* token location, or -1 if unknown */
236 } ColumnRef;
237 
238 /*
239  * ParamRef - specifies a $n parameter reference
240  */
241 typedef struct ParamRef
242 {
244  int number; /* the number of the parameter */
245  int location; /* token location, or -1 if unknown */
246 } ParamRef;
247 
248 /*
249  * A_Expr - infix, prefix, and postfix expressions
250  */
251 typedef enum A_Expr_Kind
252 {
253  AEXPR_OP, /* normal operator */
254  AEXPR_OP_ANY, /* scalar op ANY (array) */
255  AEXPR_OP_ALL, /* scalar op ALL (array) */
256  AEXPR_DISTINCT, /* IS DISTINCT FROM - name must be "=" */
257  AEXPR_NOT_DISTINCT, /* IS NOT DISTINCT FROM - name must be "=" */
258  AEXPR_NULLIF, /* NULLIF - name must be "=" */
259  AEXPR_OF, /* IS [NOT] OF - name must be "=" or "<>" */
260  AEXPR_IN, /* [NOT] IN - name must be "=" or "<>" */
261  AEXPR_LIKE, /* [NOT] LIKE - name must be "~~" or "!~~" */
262  AEXPR_ILIKE, /* [NOT] ILIKE - name must be "~~*" or "!~~*" */
263  AEXPR_SIMILAR, /* [NOT] SIMILAR - name must be "~" or "!~" */
264  AEXPR_BETWEEN, /* name must be "BETWEEN" */
265  AEXPR_NOT_BETWEEN, /* name must be "NOT BETWEEN" */
266  AEXPR_BETWEEN_SYM, /* name must be "BETWEEN SYMMETRIC" */
267  AEXPR_NOT_BETWEEN_SYM, /* name must be "NOT BETWEEN SYMMETRIC" */
268  AEXPR_PAREN /* nameless dummy node for parentheses */
269 } A_Expr_Kind;
270 
271 typedef struct A_Expr
272 {
274  A_Expr_Kind kind; /* see above */
275  List *name; /* possibly-qualified name of operator */
276  Node *lexpr; /* left argument, or NULL if none */
277  Node *rexpr; /* right argument, or NULL if none */
278  int location; /* token location, or -1 if unknown */
279 } A_Expr;
280 
281 /*
282  * A_Const - a literal constant
283  */
284 typedef struct A_Const
285 {
287  Value val; /* value (includes type info, see value.h) */
288  int location; /* token location, or -1 if unknown */
289 } A_Const;
290 
291 /*
292  * TypeCast - a CAST expression
293  */
294 typedef struct TypeCast
295 {
297  Node *arg; /* the expression being casted */
298  TypeName *typeName; /* the target type */
299  int location; /* token location, or -1 if unknown */
300 } TypeCast;
301 
302 /*
303  * CollateClause - a COLLATE expression
304  */
305 typedef struct CollateClause
306 {
308  Node *arg; /* input expression */
309  List *collname; /* possibly-qualified collation name */
310  int location; /* token location, or -1 if unknown */
311 } CollateClause;
312 
313 /*
314  * RoleSpec - a role name or one of a few special values.
315  */
316 typedef enum RoleSpecType
317 {
318  ROLESPEC_CSTRING, /* role name is stored as a C string */
319  ROLESPEC_CURRENT_USER, /* role spec is CURRENT_USER */
320  ROLESPEC_SESSION_USER, /* role spec is SESSION_USER */
321  ROLESPEC_PUBLIC /* role name is "public" */
322 } RoleSpecType;
323 
324 typedef struct RoleSpec
325 {
327  RoleSpecType roletype; /* Type of this rolespec */
328  char *rolename; /* filled only for ROLESPEC_CSTRING */
329  int location; /* token location, or -1 if unknown */
330 } RoleSpec;
331 
332 /*
333  * FuncCall - a function or aggregate invocation
334  *
335  * agg_order (if not NIL) indicates we saw 'foo(... ORDER BY ...)', or if
336  * agg_within_group is true, it was 'foo(...) WITHIN GROUP (ORDER BY ...)'.
337  * agg_star indicates we saw a 'foo(*)' construct, while agg_distinct
338  * indicates we saw 'foo(DISTINCT ...)'. In any of these cases, the
339  * construct *must* be an aggregate call. Otherwise, it might be either an
340  * aggregate or some other kind of function. However, if FILTER or OVER is
341  * present it had better be an aggregate or window function.
342  *
343  * Normally, you'd initialize this via makeFuncCall() and then only change the
344  * parts of the struct its defaults don't match afterwards, as needed.
345  */
346 typedef struct FuncCall
347 {
349  List *funcname; /* qualified name of function */
350  List *args; /* the arguments (list of exprs) */
351  List *agg_order; /* ORDER BY (list of SortBy) */
352  Node *agg_filter; /* FILTER clause, if any */
353  bool agg_within_group; /* ORDER BY appeared in WITHIN GROUP */
354  bool agg_star; /* argument was really '*' */
355  bool agg_distinct; /* arguments were labeled DISTINCT */
356  bool func_variadic; /* last argument was labeled VARIADIC */
357  struct WindowDef *over; /* OVER clause, if any */
358  int location; /* token location, or -1 if unknown */
359 } FuncCall;
360 
361 /*
362  * A_Star - '*' representing all columns of a table or compound field
363  *
364  * This can appear within ColumnRef.fields, A_Indirection.indirection, and
365  * ResTarget.indirection lists.
366  */
367 typedef struct A_Star
368 {
370 } A_Star;
371 
372 /*
373  * A_Indices - array subscript or slice bounds ([idx] or [lidx:uidx])
374  *
375  * In slice case, either or both of lidx and uidx can be NULL (omitted).
376  * In non-slice case, uidx holds the single subscript and lidx is always NULL.
377  */
378 typedef struct A_Indices
379 {
381  bool is_slice; /* true if slice (i.e., colon present) */
382  Node *lidx; /* slice lower bound, if any */
383  Node *uidx; /* subscript, or slice upper bound if any */
384 } A_Indices;
385 
386 /*
387  * A_Indirection - select a field and/or array element from an expression
388  *
389  * The indirection list can contain A_Indices nodes (representing
390  * subscripting), string Value nodes (representing field selection --- the
391  * string value is the name of the field to select), and A_Star nodes
392  * (representing selection of all fields of a composite type).
393  * For example, a complex selection operation like
394  * (foo).field1[42][7].field2
395  * would be represented with a single A_Indirection node having a 4-element
396  * indirection list.
397  *
398  * Currently, A_Star must appear only as the last list element --- the grammar
399  * is responsible for enforcing this!
400  */
401 typedef struct A_Indirection
402 {
404  Node *arg; /* the thing being selected from */
405  List *indirection; /* subscripts and/or field names and/or * */
406 } A_Indirection;
407 
408 /*
409  * A_ArrayExpr - an ARRAY[] construct
410  */
411 typedef struct A_ArrayExpr
412 {
414  List *elements; /* array element expressions */
415  int location; /* token location, or -1 if unknown */
416 } A_ArrayExpr;
417 
418 /*
419  * ResTarget -
420  * result target (used in target list of pre-transformed parse trees)
421  *
422  * In a SELECT target list, 'name' is the column label from an
423  * 'AS ColumnLabel' clause, or NULL if there was none, and 'val' is the
424  * value expression itself. The 'indirection' field is not used.
425  *
426  * INSERT uses ResTarget in its target-column-names list. Here, 'name' is
427  * the name of the destination column, 'indirection' stores any subscripts
428  * attached to the destination, and 'val' is not used.
429  *
430  * In an UPDATE target list, 'name' is the name of the destination column,
431  * 'indirection' stores any subscripts attached to the destination, and
432  * 'val' is the expression to assign.
433  *
434  * See A_Indirection for more info about what can appear in 'indirection'.
435  */
436 typedef struct ResTarget
437 {
439  char *name; /* column name or NULL */
440  List *indirection; /* subscripts, field names, and '*', or NIL */
441  Node *val; /* the value expression to compute or assign */
442  int location; /* token location, or -1 if unknown */
443 } ResTarget;
444 
445 /*
446  * MultiAssignRef - element of a row source expression for UPDATE
447  *
448  * In an UPDATE target list, when we have SET (a,b,c) = row-valued-expression,
449  * we generate separate ResTarget items for each of a,b,c. Their "val" trees
450  * are MultiAssignRef nodes numbered 1..n, linking to a common copy of the
451  * row-valued-expression (which parse analysis will process only once, when
452  * handling the MultiAssignRef with colno=1).
453  */
454 typedef struct MultiAssignRef
455 {
457  Node *source; /* the row-valued expression */
458  int colno; /* column number for this target (1..n) */
459  int ncolumns; /* number of targets in the construct */
461 
462 /*
463  * SortBy - for ORDER BY clause
464  */
465 typedef struct SortBy
466 {
468  Node *node; /* expression to sort on */
469  SortByDir sortby_dir; /* ASC/DESC/USING/default */
470  SortByNulls sortby_nulls; /* NULLS FIRST/LAST */
471  List *useOp; /* name of op to use, if SORTBY_USING */
472  int location; /* operator location, or -1 if none/unknown */
473 } SortBy;
474 
475 /*
476  * WindowDef - raw representation of WINDOW and OVER clauses
477  *
478  * For entries in a WINDOW list, "name" is the window name being defined.
479  * For OVER clauses, we use "name" for the "OVER window" syntax, or "refname"
480  * for the "OVER (window)" syntax, which is subtly different --- the latter
481  * implies overriding the window frame clause.
482  */
483 typedef struct WindowDef
484 {
486  char *name; /* window's own name */
487  char *refname; /* referenced window name, if any */
488  List *partitionClause; /* PARTITION BY expression list */
489  List *orderClause; /* ORDER BY (list of SortBy) */
490  int frameOptions; /* frame_clause options, see below */
491  Node *startOffset; /* expression for starting bound, if any */
492  Node *endOffset; /* expression for ending bound, if any */
493  int location; /* parse location, or -1 if none/unknown */
494 } WindowDef;
495 
496 /*
497  * frameOptions is an OR of these bits. The NONDEFAULT and BETWEEN bits are
498  * used so that ruleutils.c can tell which properties were specified and
499  * which were defaulted; the correct behavioral bits must be set either way.
500  * The START_foo and END_foo options must come in pairs of adjacent bits for
501  * the convenience of gram.y, even though some of them are useless/invalid.
502  * We will need more bits (and fields) to cover the full SQL:2008 option set.
503  */
504 #define FRAMEOPTION_NONDEFAULT 0x00001 /* any specified? */
505 #define FRAMEOPTION_RANGE 0x00002 /* RANGE behavior */
506 #define FRAMEOPTION_ROWS 0x00004 /* ROWS behavior */
507 #define FRAMEOPTION_BETWEEN 0x00008 /* BETWEEN given? */
508 #define FRAMEOPTION_START_UNBOUNDED_PRECEDING 0x00010 /* start is U. P. */
509 #define FRAMEOPTION_END_UNBOUNDED_PRECEDING 0x00020 /* (disallowed) */
510 #define FRAMEOPTION_START_UNBOUNDED_FOLLOWING 0x00040 /* (disallowed) */
511 #define FRAMEOPTION_END_UNBOUNDED_FOLLOWING 0x00080 /* end is U. F. */
512 #define FRAMEOPTION_START_CURRENT_ROW 0x00100 /* start is C. R. */
513 #define FRAMEOPTION_END_CURRENT_ROW 0x00200 /* end is C. R. */
514 #define FRAMEOPTION_START_VALUE_PRECEDING 0x00400 /* start is V. P. */
515 #define FRAMEOPTION_END_VALUE_PRECEDING 0x00800 /* end is V. P. */
516 #define FRAMEOPTION_START_VALUE_FOLLOWING 0x01000 /* start is V. F. */
517 #define FRAMEOPTION_END_VALUE_FOLLOWING 0x02000 /* end is V. F. */
518 
519 #define FRAMEOPTION_START_VALUE \
520  (FRAMEOPTION_START_VALUE_PRECEDING | FRAMEOPTION_START_VALUE_FOLLOWING)
521 #define FRAMEOPTION_END_VALUE \
522  (FRAMEOPTION_END_VALUE_PRECEDING | FRAMEOPTION_END_VALUE_FOLLOWING)
523 
524 #define FRAMEOPTION_DEFAULTS \
525  (FRAMEOPTION_RANGE | FRAMEOPTION_START_UNBOUNDED_PRECEDING | \
526  FRAMEOPTION_END_CURRENT_ROW)
527 
528 /*
529  * RangeSubselect - subquery appearing in a FROM clause
530  */
531 typedef struct RangeSubselect
532 {
534  bool lateral; /* does it have LATERAL prefix? */
535  Node *subquery; /* the untransformed sub-select clause */
536  Alias *alias; /* table alias & optional column aliases */
538 
539 /*
540  * RangeFunction - function call appearing in a FROM clause
541  *
542  * functions is a List because we use this to represent the construct
543  * ROWS FROM(func1(...), func2(...), ...). Each element of this list is a
544  * two-element sublist, the first element being the untransformed function
545  * call tree, and the second element being a possibly-empty list of ColumnDef
546  * nodes representing any columndef list attached to that function within the
547  * ROWS FROM() syntax.
548  *
549  * alias and coldeflist represent any alias and/or columndef list attached
550  * at the top level. (We disallow coldeflist appearing both here and
551  * per-function, but that's checked in parse analysis, not by the grammar.)
552  */
553 typedef struct RangeFunction
554 {
556  bool lateral; /* does it have LATERAL prefix? */
557  bool ordinality; /* does it have WITH ORDINALITY suffix? */
558  bool is_rowsfrom; /* is result of ROWS FROM() syntax? */
559  List *functions; /* per-function information, see above */
560  Alias *alias; /* table alias & optional column aliases */
561  List *coldeflist; /* list of ColumnDef nodes to describe result
562  * of function returning RECORD */
563 } RangeFunction;
564 
565 /*
566  * RangeTableFunc - raw form of "table functions" such as XMLTABLE
567  */
568 typedef struct RangeTableFunc
569 {
571  bool lateral; /* does it have LATERAL prefix? */
572  Node *docexpr; /* document expression */
573  Node *rowexpr; /* row generator expression */
574  List *namespaces; /* list of namespaces as ResTarget */
575  List *columns; /* list of RangeTableFuncCol */
576  Alias *alias; /* table alias & optional column aliases */
577  int location; /* token location, or -1 if unknown */
579 
580 /*
581  * RangeTableFuncCol - one column in a RangeTableFunc->columns
582  *
583  * If for_ordinality is true (FOR ORDINALITY), then the column is an int4
584  * column and the rest of the fields are ignored.
585  */
586 typedef struct RangeTableFuncCol
587 {
589  char *colname; /* name of generated column */
590  TypeName *typeName; /* type of generated column */
591  bool for_ordinality; /* does it have FOR ORDINALITY? */
592  bool is_not_null; /* does it have NOT NULL? */
593  Node *colexpr; /* column filter expression */
594  Node *coldefexpr; /* column default value expression */
595  int location; /* token location, or -1 if unknown */
597 
598 /*
599  * RangeTableSample - TABLESAMPLE appearing in a raw FROM clause
600  *
601  * This node, appearing only in raw parse trees, represents
602  * <relation> TABLESAMPLE <method> (<params>) REPEATABLE (<num>)
603  * Currently, the <relation> can only be a RangeVar, but we might in future
604  * allow RangeSubselect and other options. Note that the RangeTableSample
605  * is wrapped around the node representing the <relation>, rather than being
606  * a subfield of it.
607  */
608 typedef struct RangeTableSample
609 {
611  Node *relation; /* relation to be sampled */
612  List *method; /* sampling method name (possibly qualified) */
613  List *args; /* argument(s) for sampling method */
614  Node *repeatable; /* REPEATABLE expression, or NULL if none */
615  int location; /* method name location, or -1 if unknown */
617 
618 /*
619  * ColumnDef - column definition (used in various creates)
620  *
621  * If the column has a default value, we may have the value expression
622  * in either "raw" form (an untransformed parse tree) or "cooked" form
623  * (a post-parse-analysis, executable expression tree), depending on
624  * how this ColumnDef node was created (by parsing, or by inheritance
625  * from an existing relation). We should never have both in the same node!
626  *
627  * Similarly, we may have a COLLATE specification in either raw form
628  * (represented as a CollateClause with arg==NULL) or cooked form
629  * (the collation's OID).
630  *
631  * The constraints list may contain a CONSTR_DEFAULT item in a raw
632  * parsetree produced by gram.y, but transformCreateStmt will remove
633  * the item and set raw_default instead. CONSTR_DEFAULT items
634  * should not appear in any subsequent processing.
635  */
636 typedef struct ColumnDef
637 {
639  char *colname; /* name of column */
640  TypeName *typeName; /* type of column */
641  int inhcount; /* number of times column is inherited */
642  bool is_local; /* column has local (non-inherited) def'n */
643  bool is_not_null; /* NOT NULL constraint specified? */
644  bool is_from_type; /* column definition came from table type */
645  bool is_from_parent; /* column def came from partition parent */
646  char storage; /* attstorage setting, or 0 for default */
647  Node *raw_default; /* default value (untransformed parse tree) */
648  Node *cooked_default; /* default value (transformed expr tree) */
649  char identity; /* attidentity setting */
650  CollateClause *collClause; /* untransformed COLLATE spec, if any */
651  Oid collOid; /* collation OID (InvalidOid if not set) */
652  List *constraints; /* other constraints on column */
653  List *fdwoptions; /* per-column FDW options */
654  int location; /* parse location, or -1 if none/unknown */
655 } ColumnDef;
656 
657 /*
658  * TableLikeClause - CREATE TABLE ( ... LIKE ... ) clause
659  */
660 typedef struct TableLikeClause
661 {
664  bits32 options; /* OR of TableLikeOption flags */
666 
667 typedef enum TableLikeOption
668 {
677 
678 /*
679  * IndexElem - index parameters (used in CREATE INDEX, and in ON CONFLICT)
680  *
681  * For a plain index attribute, 'name' is the name of the table column to
682  * index, and 'expr' is NULL. For an index expression, 'name' is NULL and
683  * 'expr' is the expression tree.
684  */
685 typedef struct IndexElem
686 {
688  char *name; /* name of attribute to index, or NULL */
689  Node *expr; /* expression to index, or NULL */
690  char *indexcolname; /* name for index column; NULL = default */
691  List *collation; /* name of collation; NIL = default */
692  List *opclass; /* name of desired opclass; NIL = default */
693  SortByDir ordering; /* ASC/DESC/default */
694  SortByNulls nulls_ordering; /* FIRST/LAST/default */
695 } IndexElem;
696 
697 /*
698  * DefElem - a generic "name = value" option definition
699  *
700  * In some contexts the name can be qualified. Also, certain SQL commands
701  * allow a SET/ADD/DROP action to be attached to option settings, so it's
702  * convenient to carry a field for that too. (Note: currently, it is our
703  * practice that the grammar allows namespace and action only in statements
704  * where they are relevant; C code can just ignore those fields in other
705  * statements.)
706  */
707 typedef enum DefElemAction
708 {
709  DEFELEM_UNSPEC, /* no action given */
713 } DefElemAction;
714 
715 typedef struct DefElem
716 {
718  char *defnamespace; /* NULL if unqualified name */
719  char *defname;
720  Node *arg; /* a (Value *) or a (TypeName *) */
721  DefElemAction defaction; /* unspecified action, or SET/ADD/DROP */
722  int location; /* token location, or -1 if unknown */
723 } DefElem;
724 
725 /*
726  * LockingClause - raw representation of FOR [NO KEY] UPDATE/[KEY] SHARE
727  * options
728  *
729  * Note: lockedRels == NIL means "all relations in query". Otherwise it
730  * is a list of RangeVar nodes. (We use RangeVar mainly because it carries
731  * a location field --- currently, parse analysis insists on unqualified
732  * names in LockingClause.)
733  */
734 typedef struct LockingClause
735 {
737  List *lockedRels; /* FOR [KEY] UPDATE/SHARE relations */
739  LockWaitPolicy waitPolicy; /* NOWAIT and SKIP LOCKED */
740 } LockingClause;
741 
742 /*
743  * XMLSERIALIZE (in raw parse tree only)
744  */
745 typedef struct XmlSerialize
746 {
748  XmlOptionType xmloption; /* DOCUMENT or CONTENT */
751  int location; /* token location, or -1 if unknown */
752 } XmlSerialize;
753 
754 /* Partitioning related definitions */
755 
756 /*
757  * PartitionElem - parse-time representation of a single partition key
758  *
759  * expr can be either a raw expression tree or a parse-analyzed expression.
760  * We don't store these on-disk, though.
761  */
762 typedef struct PartitionElem
763 {
765  char *name; /* name of column to partition on, or NULL */
766  Node *expr; /* expression to partition on, or NULL */
767  List *collation; /* name of collation; NIL = default */
768  List *opclass; /* name of desired opclass; NIL = default */
769  int location; /* token location, or -1 if unknown */
770 } PartitionElem;
771 
772 /*
773  * PartitionSpec - parse-time representation of a partition key specification
774  *
775  * This represents the key space we will be partitioning on.
776  */
777 typedef struct PartitionSpec
778 {
780  char *strategy; /* partitioning strategy ('list' or 'range') */
781  List *partParams; /* List of PartitionElems */
782  int location; /* token location, or -1 if unknown */
783 } PartitionSpec;
784 
785 /* Internal codes for partitioning strategies */
786 #define PARTITION_STRATEGY_LIST 'l'
787 #define PARTITION_STRATEGY_RANGE 'r'
788 
789 /*
790  * PartitionBoundSpec - a partition bound specification
791  *
792  * This represents the portion of the partition key space assigned to a
793  * particular partition. These are stored on disk in pg_class.relpartbound.
794  */
795 typedef struct PartitionBoundSpec
796 {
798 
799  char strategy; /* see PARTITION_STRATEGY codes above */
800  bool is_default; /* is it a default partition bound? */
801 
802  /* Partitioning info for LIST strategy: */
803  List *listdatums; /* List of Consts (or A_Consts in raw tree) */
804 
805  /* Partitioning info for RANGE strategy: */
806  List *lowerdatums; /* List of PartitionRangeDatums */
807  List *upperdatums; /* List of PartitionRangeDatums */
808 
809  int location; /* token location, or -1 if unknown */
811 
812 /*
813  * PartitionRangeDatum - one of the values in a range partition bound
814  *
815  * This can be MINVALUE, MAXVALUE or a specific bounded value.
816  */
818 {
819  PARTITION_RANGE_DATUM_MINVALUE = -1, /* less than any other value */
820  PARTITION_RANGE_DATUM_VALUE = 0, /* a specific (bounded) value */
821  PARTITION_RANGE_DATUM_MAXVALUE = 1 /* greater than any other value */
823 
824 typedef struct PartitionRangeDatum
825 {
827 
829  Node *value; /* Const (or A_Const in raw tree), if kind is
830  * PARTITION_RANGE_DATUM_VALUE, else NULL */
831 
832  int location; /* token location, or -1 if unknown */
834 
835 /*
836  * PartitionCmd - info for ALTER TABLE ATTACH/DETACH PARTITION commands
837  */
838 typedef struct PartitionCmd
839 {
841  RangeVar *name; /* name of partition to attach/detach */
842  PartitionBoundSpec *bound; /* FOR VALUES, if attaching */
843 } PartitionCmd;
844 
845 /****************************************************************************
846  * Nodes for a Query tree
847  ****************************************************************************/
848 
849 /*--------------------
850  * RangeTblEntry -
851  * A range table is a List of RangeTblEntry nodes.
852  *
853  * A range table entry may represent a plain relation, a sub-select in
854  * FROM, or the result of a JOIN clause. (Only explicit JOIN syntax
855  * produces an RTE, not the implicit join resulting from multiple FROM
856  * items. This is because we only need the RTE to deal with SQL features
857  * like outer joins and join-output-column aliasing.) Other special
858  * RTE types also exist, as indicated by RTEKind.
859  *
860  * Note that we consider RTE_RELATION to cover anything that has a pg_class
861  * entry. relkind distinguishes the sub-cases.
862  *
863  * alias is an Alias node representing the AS alias-clause attached to the
864  * FROM expression, or NULL if no clause.
865  *
866  * eref is the table reference name and column reference names (either
867  * real or aliases). Note that system columns (OID etc) are not included
868  * in the column list.
869  * eref->aliasname is required to be present, and should generally be used
870  * to identify the RTE for error messages etc.
871  *
872  * In RELATION RTEs, the colnames in both alias and eref are indexed by
873  * physical attribute number; this means there must be colname entries for
874  * dropped columns. When building an RTE we insert empty strings ("") for
875  * dropped columns. Note however that a stored rule may have nonempty
876  * colnames for columns dropped since the rule was created (and for that
877  * matter the colnames might be out of date due to column renamings).
878  * The same comments apply to FUNCTION RTEs when a function's return type
879  * is a named composite type.
880  *
881  * In JOIN RTEs, the colnames in both alias and eref are one-to-one with
882  * joinaliasvars entries. A JOIN RTE will omit columns of its inputs when
883  * those columns are known to be dropped at parse time. Again, however,
884  * a stored rule might contain entries for columns dropped since the rule
885  * was created. (This is only possible for columns not actually referenced
886  * in the rule.) When loading a stored rule, we replace the joinaliasvars
887  * items for any such columns with null pointers. (We can't simply delete
888  * them from the joinaliasvars list, because that would affect the attnums
889  * of Vars referencing the rest of the list.)
890  *
891  * inh is TRUE for relation references that should be expanded to include
892  * inheritance children, if the rel has any. This *must* be FALSE for
893  * RTEs other than RTE_RELATION entries.
894  *
895  * inFromCl marks those range variables that are listed in the FROM clause.
896  * It's false for RTEs that are added to a query behind the scenes, such
897  * as the NEW and OLD variables for a rule, or the subqueries of a UNION.
898  * This flag is not used anymore during parsing, since the parser now uses
899  * a separate "namespace" data structure to control visibility, but it is
900  * needed by ruleutils.c to determine whether RTEs should be shown in
901  * decompiled queries.
902  *
903  * requiredPerms and checkAsUser specify run-time access permissions
904  * checks to be performed at query startup. The user must have *all*
905  * of the permissions that are OR'd together in requiredPerms (zero
906  * indicates no permissions checking). If checkAsUser is not zero,
907  * then do the permissions checks using the access rights of that user,
908  * not the current effective user ID. (This allows rules to act as
909  * setuid gateways.) Permissions checks only apply to RELATION RTEs.
910  *
911  * For SELECT/INSERT/UPDATE permissions, if the user doesn't have
912  * table-wide permissions then it is sufficient to have the permissions
913  * on all columns identified in selectedCols (for SELECT) and/or
914  * insertedCols and/or updatedCols (INSERT with ON CONFLICT DO UPDATE may
915  * have all 3). selectedCols, insertedCols and updatedCols are bitmapsets,
916  * which cannot have negative integer members, so we subtract
917  * FirstLowInvalidHeapAttributeNumber from column numbers before storing
918  * them in these fields. A whole-row Var reference is represented by
919  * setting the bit for InvalidAttrNumber.
920  *
921  * securityQuals is a list of security barrier quals (boolean expressions),
922  * to be tested in the listed order before returning a row from the
923  * relation. It is always NIL in parser output. Entries are added by the
924  * rewriter to implement security-barrier views and/or row-level security.
925  * Note that the planner turns each boolean expression into an implicitly
926  * AND'ed sublist, as is its usual habit with qualification expressions.
927  *--------------------
928  */
929 typedef enum RTEKind
930 {
931  RTE_RELATION, /* ordinary relation reference */
932  RTE_SUBQUERY, /* subquery in FROM */
933  RTE_JOIN, /* join */
934  RTE_FUNCTION, /* function in FROM */
935  RTE_TABLEFUNC, /* TableFunc(.., column list) */
936  RTE_VALUES, /* VALUES (<exprlist>), (<exprlist>), ... */
937  RTE_CTE, /* common table expr (WITH list element) */
938  RTE_NAMEDTUPLESTORE /* tuplestore, e.g. for AFTER triggers */
939 } RTEKind;
940 
941 typedef struct RangeTblEntry
942 {
944 
945  RTEKind rtekind; /* see above */
946 
947  /*
948  * XXX the fields applicable to only some rte kinds should be merged into
949  * a union. I didn't do this yet because the diffs would impact a lot of
950  * code that is being actively worked on. FIXME someday.
951  */
952 
953  /*
954  * Fields valid for a plain relation RTE (else zero):
955  *
956  * As a special case, RTE_NAMEDTUPLESTORE can also set relid to indicate
957  * that the tuple format of the tuplestore is the same as the referenced
958  * relation. This allows plans referencing AFTER trigger transition
959  * tables to be invalidated if the underlying table is altered.
960  */
961  Oid relid; /* OID of the relation */
962  char relkind; /* relation kind (see pg_class.relkind) */
963  struct TableSampleClause *tablesample; /* sampling info, or NULL */
964 
965  /*
966  * Fields valid for a subquery RTE (else NULL):
967  */
968  Query *subquery; /* the sub-query */
969  bool security_barrier; /* is from security_barrier view? */
970 
971  /*
972  * Fields valid for a join RTE (else NULL/zero):
973  *
974  * joinaliasvars is a list of (usually) Vars corresponding to the columns
975  * of the join result. An alias Var referencing column K of the join
976  * result can be replaced by the K'th element of joinaliasvars --- but to
977  * simplify the task of reverse-listing aliases correctly, we do not do
978  * that until planning time. In detail: an element of joinaliasvars can
979  * be a Var of one of the join's input relations, or such a Var with an
980  * implicit coercion to the join's output column type, or a COALESCE
981  * expression containing the two input column Vars (possibly coerced).
982  * Within a Query loaded from a stored rule, it is also possible for
983  * joinaliasvars items to be null pointers, which are placeholders for
984  * (necessarily unreferenced) columns dropped since the rule was made.
985  * Also, once planning begins, joinaliasvars items can be almost anything,
986  * as a result of subquery-flattening substitutions.
987  */
988  JoinType jointype; /* type of join */
989  List *joinaliasvars; /* list of alias-var expansions */
990 
991  /*
992  * Fields valid for a function RTE (else NIL/zero):
993  *
994  * When funcordinality is true, the eref->colnames list includes an alias
995  * for the ordinality column. The ordinality column is otherwise
996  * implicit, and must be accounted for "by hand" in places such as
997  * expandRTE().
998  */
999  List *functions; /* list of RangeTblFunction nodes */
1000  bool funcordinality; /* is this called WITH ORDINALITY? */
1001 
1002  /*
1003  * Fields valid for a TableFunc RTE (else NULL):
1004  */
1006 
1007  /*
1008  * Fields valid for a values RTE (else NIL):
1009  */
1010  List *values_lists; /* list of expression lists */
1011 
1012  /*
1013  * Fields valid for a CTE RTE (else NULL/zero):
1014  */
1015  char *ctename; /* name of the WITH list item */
1016  Index ctelevelsup; /* number of query levels up */
1017  bool self_reference; /* is this a recursive self-reference? */
1018 
1019  /*
1020  * Fields valid for table functions, values, CTE and ENR RTEs (else NIL):
1021  *
1022  * We need these for CTE RTEs so that the types of self-referential
1023  * columns are well-defined. For VALUES RTEs, storing these explicitly
1024  * saves having to re-determine the info by scanning the values_lists. For
1025  * ENRs, we store the types explicitly here (we could get the information
1026  * from the catalogs if 'relid' was supplied, but we'd still need these
1027  * for TupleDesc-based ENRs, so we might as well always store the type
1028  * info here).
1029  *
1030  * For ENRs only, we have to consider the possibility of dropped columns.
1031  * A dropped column is included in these lists, but it will have zeroes in
1032  * all three lists (as well as an empty-string entry in eref). Testing
1033  * for zero coltype is the standard way to detect a dropped column.
1034  */
1035  List *coltypes; /* OID list of column type OIDs */
1036  List *coltypmods; /* integer list of column typmods */
1037  List *colcollations; /* OID list of column collation OIDs */
1038 
1039  /*
1040  * Fields valid for ENR RTEs (else NULL/zero):
1041  */
1042  char *enrname; /* name of ephemeral named relation */
1043  double enrtuples; /* estimated or actual from caller */
1044 
1045  /*
1046  * Fields valid in all RTEs:
1047  */
1048  Alias *alias; /* user-written alias clause, if any */
1049  Alias *eref; /* expanded reference names */
1050  bool lateral; /* subquery, function, or values is LATERAL? */
1051  bool inh; /* inheritance requested? */
1052  bool inFromCl; /* present in FROM clause? */
1053  AclMode requiredPerms; /* bitmask of required access permissions */
1054  Oid checkAsUser; /* if valid, check access as this role */
1055  Bitmapset *selectedCols; /* columns needing SELECT permission */
1056  Bitmapset *insertedCols; /* columns needing INSERT permission */
1057  Bitmapset *updatedCols; /* columns needing UPDATE permission */
1058  List *securityQuals; /* security barrier quals to apply, if any */
1059 } RangeTblEntry;
1060 
1061 /*
1062  * RangeTblFunction -
1063  * RangeTblEntry subsidiary data for one function in a FUNCTION RTE.
1064  *
1065  * If the function had a column definition list (required for an
1066  * otherwise-unspecified RECORD result), funccolnames lists the names given
1067  * in the definition list, funccoltypes lists their declared column types,
1068  * funccoltypmods lists their typmods, funccolcollations their collations.
1069  * Otherwise, those fields are NIL.
1070  *
1071  * Notice we don't attempt to store info about the results of functions
1072  * returning named composite types, because those can change from time to
1073  * time. We do however remember how many columns we thought the type had
1074  * (including dropped columns!), so that we can successfully ignore any
1075  * columns added after the query was parsed.
1076  */
1077 typedef struct RangeTblFunction
1078 {
1080 
1081  Node *funcexpr; /* expression tree for func call */
1082  int funccolcount; /* number of columns it contributes to RTE */
1083  /* These fields record the contents of a column definition list, if any: */
1084  List *funccolnames; /* column names (list of String) */
1085  List *funccoltypes; /* OID list of column type OIDs */
1086  List *funccoltypmods; /* integer list of column typmods */
1087  List *funccolcollations; /* OID list of column collation OIDs */
1088  /* This is set during planning for use by the executor: */
1089  Bitmapset *funcparams; /* PARAM_EXEC Param IDs affecting this func */
1091 
1092 /*
1093  * TableSampleClause - TABLESAMPLE appearing in a transformed FROM clause
1094  *
1095  * Unlike RangeTableSample, this is a subnode of the relevant RangeTblEntry.
1096  */
1097 typedef struct TableSampleClause
1098 {
1100  Oid tsmhandler; /* OID of the tablesample handler function */
1101  List *args; /* tablesample argument expression(s) */
1102  Expr *repeatable; /* REPEATABLE expression, or NULL if none */
1104 
1105 /*
1106  * WithCheckOption -
1107  * representation of WITH CHECK OPTION checks to be applied to new tuples
1108  * when inserting/updating an auto-updatable view, or RLS WITH CHECK
1109  * policies to be applied when inserting/updating a relation with RLS.
1110  */
1111 typedef enum WCOKind
1112 {
1113  WCO_VIEW_CHECK, /* WCO on an auto-updatable view */
1114  WCO_RLS_INSERT_CHECK, /* RLS INSERT WITH CHECK policy */
1115  WCO_RLS_UPDATE_CHECK, /* RLS UPDATE WITH CHECK policy */
1116  WCO_RLS_CONFLICT_CHECK /* RLS ON CONFLICT DO UPDATE USING policy */
1117 } WCOKind;
1118 
1119 typedef struct WithCheckOption
1120 {
1122  WCOKind kind; /* kind of WCO */
1123  char *relname; /* name of relation that specified the WCO */
1124  char *polname; /* name of RLS policy being checked */
1125  Node *qual; /* constraint qual to check */
1126  bool cascaded; /* true for a cascaded WCO on a view */
1127 } WithCheckOption;
1128 
1129 /*
1130  * SortGroupClause -
1131  * representation of ORDER BY, GROUP BY, PARTITION BY,
1132  * DISTINCT, DISTINCT ON items
1133  *
1134  * You might think that ORDER BY is only interested in defining ordering,
1135  * and GROUP/DISTINCT are only interested in defining equality. However,
1136  * one way to implement grouping is to sort and then apply a "uniq"-like
1137  * filter. So it's also interesting to keep track of possible sort operators
1138  * for GROUP/DISTINCT, and in particular to try to sort for the grouping
1139  * in a way that will also yield a requested ORDER BY ordering. So we need
1140  * to be able to compare ORDER BY and GROUP/DISTINCT lists, which motivates
1141  * the decision to give them the same representation.
1142  *
1143  * tleSortGroupRef must match ressortgroupref of exactly one entry of the
1144  * query's targetlist; that is the expression to be sorted or grouped by.
1145  * eqop is the OID of the equality operator.
1146  * sortop is the OID of the ordering operator (a "<" or ">" operator),
1147  * or InvalidOid if not available.
1148  * nulls_first means about what you'd expect. If sortop is InvalidOid
1149  * then nulls_first is meaningless and should be set to false.
1150  * hashable is TRUE if eqop is hashable (note this condition also depends
1151  * on the datatype of the input expression).
1152  *
1153  * In an ORDER BY item, all fields must be valid. (The eqop isn't essential
1154  * here, but it's cheap to get it along with the sortop, and requiring it
1155  * to be valid eases comparisons to grouping items.) Note that this isn't
1156  * actually enough information to determine an ordering: if the sortop is
1157  * collation-sensitive, a collation OID is needed too. We don't store the
1158  * collation in SortGroupClause because it's not available at the time the
1159  * parser builds the SortGroupClause; instead, consult the exposed collation
1160  * of the referenced targetlist expression to find out what it is.
1161  *
1162  * In a grouping item, eqop must be valid. If the eqop is a btree equality
1163  * operator, then sortop should be set to a compatible ordering operator.
1164  * We prefer to set eqop/sortop/nulls_first to match any ORDER BY item that
1165  * the query presents for the same tlist item. If there is none, we just
1166  * use the default ordering op for the datatype.
1167  *
1168  * If the tlist item's type has a hash opclass but no btree opclass, then
1169  * we will set eqop to the hash equality operator, sortop to InvalidOid,
1170  * and nulls_first to false. A grouping item of this kind can only be
1171  * implemented by hashing, and of course it'll never match an ORDER BY item.
1172  *
1173  * The hashable flag is provided since we generally have the requisite
1174  * information readily available when the SortGroupClause is constructed,
1175  * and it's relatively expensive to get it again later. Note there is no
1176  * need for a "sortable" flag since OidIsValid(sortop) serves the purpose.
1177  *
1178  * A query might have both ORDER BY and DISTINCT (or DISTINCT ON) clauses.
1179  * In SELECT DISTINCT, the distinctClause list is as long or longer than the
1180  * sortClause list, while in SELECT DISTINCT ON it's typically shorter.
1181  * The two lists must match up to the end of the shorter one --- the parser
1182  * rearranges the distinctClause if necessary to make this true. (This
1183  * restriction ensures that only one sort step is needed to both satisfy the
1184  * ORDER BY and set up for the Unique step. This is semantically necessary
1185  * for DISTINCT ON, and presents no real drawback for DISTINCT.)
1186  */
1187 typedef struct SortGroupClause
1188 {
1190  Index tleSortGroupRef; /* reference into targetlist */
1191  Oid eqop; /* the equality operator ('=' op) */
1192  Oid sortop; /* the ordering operator ('<' op), or 0 */
1193  bool nulls_first; /* do NULLs come before normal values? */
1194  bool hashable; /* can eqop be implemented by hashing? */
1195 } SortGroupClause;
1196 
1197 /*
1198  * GroupingSet -
1199  * representation of CUBE, ROLLUP and GROUPING SETS clauses
1200  *
1201  * In a Query with grouping sets, the groupClause contains a flat list of
1202  * SortGroupClause nodes for each distinct expression used. The actual
1203  * structure of the GROUP BY clause is given by the groupingSets tree.
1204  *
1205  * In the raw parser output, GroupingSet nodes (of all types except SIMPLE
1206  * which is not used) are potentially mixed in with the expressions in the
1207  * groupClause of the SelectStmt. (An expression can't contain a GroupingSet,
1208  * but a list may mix GroupingSet and expression nodes.) At this stage, the
1209  * content of each node is a list of expressions, some of which may be RowExprs
1210  * which represent sublists rather than actual row constructors, and nested
1211  * GroupingSet nodes where legal in the grammar. The structure directly
1212  * reflects the query syntax.
1213  *
1214  * In parse analysis, the transformed expressions are used to build the tlist
1215  * and groupClause list (of SortGroupClause nodes), and the groupingSets tree
1216  * is eventually reduced to a fixed format:
1217  *
1218  * EMPTY nodes represent (), and obviously have no content
1219  *
1220  * SIMPLE nodes represent a list of one or more expressions to be treated as an
1221  * atom by the enclosing structure; the content is an integer list of
1222  * ressortgroupref values (see SortGroupClause)
1223  *
1224  * CUBE and ROLLUP nodes contain a list of one or more SIMPLE nodes.
1225  *
1226  * SETS nodes contain a list of EMPTY, SIMPLE, CUBE or ROLLUP nodes, but after
1227  * parse analysis they cannot contain more SETS nodes; enough of the syntactic
1228  * transforms of the spec have been applied that we no longer have arbitrarily
1229  * deep nesting (though we still preserve the use of cube/rollup).
1230  *
1231  * Note that if the groupingSets tree contains no SIMPLE nodes (only EMPTY
1232  * nodes at the leaves), then the groupClause will be empty, but this is still
1233  * an aggregation query (similar to using aggs or HAVING without GROUP BY).
1234  *
1235  * As an example, the following clause:
1236  *
1237  * GROUP BY GROUPING SETS ((a,b), CUBE(c,(d,e)))
1238  *
1239  * looks like this after raw parsing:
1240  *
1241  * SETS( RowExpr(a,b) , CUBE( c, RowExpr(d,e) ) )
1242  *
1243  * and parse analysis converts it to:
1244  *
1245  * SETS( SIMPLE(1,2), CUBE( SIMPLE(3), SIMPLE(4,5) ) )
1246  */
1247 typedef enum
1248 {
1254 } GroupingSetKind;
1255 
1256 typedef struct GroupingSet
1257 {
1262 } GroupingSet;
1263 
1264 /*
1265  * WindowClause -
1266  * transformed representation of WINDOW and OVER clauses
1267  *
1268  * A parsed Query's windowClause list contains these structs. "name" is set
1269  * if the clause originally came from WINDOW, and is NULL if it originally
1270  * was an OVER clause (but note that we collapse out duplicate OVERs).
1271  * partitionClause and orderClause are lists of SortGroupClause structs.
1272  * winref is an ID number referenced by WindowFunc nodes; it must be unique
1273  * among the members of a Query's windowClause list.
1274  * When refname isn't null, the partitionClause is always copied from there;
1275  * the orderClause might or might not be copied (see copiedOrder); the framing
1276  * options are never copied, per spec.
1277  */
1278 typedef struct WindowClause
1279 {
1281  char *name; /* window name (NULL in an OVER clause) */
1282  char *refname; /* referenced window name, if any */
1283  List *partitionClause; /* PARTITION BY list */
1284  List *orderClause; /* ORDER BY list */
1285  int frameOptions; /* frame_clause options, see WindowDef */
1286  Node *startOffset; /* expression for starting bound, if any */
1287  Node *endOffset; /* expression for ending bound, if any */
1288  Index winref; /* ID referenced by window functions */
1289  bool copiedOrder; /* did we copy orderClause from refname? */
1290 } WindowClause;
1291 
1292 /*
1293  * RowMarkClause -
1294  * parser output representation of FOR [KEY] UPDATE/SHARE clauses
1295  *
1296  * Query.rowMarks contains a separate RowMarkClause node for each relation
1297  * identified as a FOR [KEY] UPDATE/SHARE target. If one of these clauses
1298  * is applied to a subquery, we generate RowMarkClauses for all normal and
1299  * subquery rels in the subquery, but they are marked pushedDown = true to
1300  * distinguish them from clauses that were explicitly written at this query
1301  * level. Also, Query.hasForUpdate tells whether there were explicit FOR
1302  * UPDATE/SHARE/KEY SHARE clauses in the current query level.
1303  */
1304 typedef struct RowMarkClause
1305 {
1307  Index rti; /* range table index of target relation */
1309  LockWaitPolicy waitPolicy; /* NOWAIT and SKIP LOCKED */
1310  bool pushedDown; /* pushed down from higher query level? */
1311 } RowMarkClause;
1312 
1313 /*
1314  * WithClause -
1315  * representation of WITH clause
1316  *
1317  * Note: WithClause does not propagate into the Query representation;
1318  * but CommonTableExpr does.
1319  */
1320 typedef struct WithClause
1321 {
1323  List *ctes; /* list of CommonTableExprs */
1324  bool recursive; /* true = WITH RECURSIVE */
1325  int location; /* token location, or -1 if unknown */
1326 } WithClause;
1327 
1328 /*
1329  * InferClause -
1330  * ON CONFLICT unique index inference clause
1331  *
1332  * Note: InferClause does not propagate into the Query representation.
1333  */
1334 typedef struct InferClause
1335 {
1337  List *indexElems; /* IndexElems to infer unique index */
1338  Node *whereClause; /* qualification (partial-index predicate) */
1339  char *conname; /* Constraint name, or NULL if unnamed */
1340  int location; /* token location, or -1 if unknown */
1341 } InferClause;
1342 
1343 /*
1344  * OnConflictClause -
1345  * representation of ON CONFLICT clause
1346  *
1347  * Note: OnConflictClause does not propagate into the Query representation.
1348  */
1349 typedef struct OnConflictClause
1350 {
1352  OnConflictAction action; /* DO NOTHING or UPDATE? */
1353  InferClause *infer; /* Optional index inference clause */
1354  List *targetList; /* the target list (of ResTarget) */
1355  Node *whereClause; /* qualifications */
1356  int location; /* token location, or -1 if unknown */
1358 
1359 /*
1360  * CommonTableExpr -
1361  * representation of WITH list element
1362  *
1363  * We don't currently support the SEARCH or CYCLE clause.
1364  */
1365 typedef struct CommonTableExpr
1366 {
1368  char *ctename; /* query name (never qualified) */
1369  List *aliascolnames; /* optional list of column names */
1370  /* SelectStmt/InsertStmt/etc before parse analysis, Query afterwards: */
1371  Node *ctequery; /* the CTE's subquery */
1372  int location; /* token location, or -1 if unknown */
1373  /* These fields are set during parse analysis: */
1374  bool cterecursive; /* is this CTE actually recursive? */
1375  int cterefcount; /* number of RTEs referencing this CTE
1376  * (excluding internal self-references) */
1377  List *ctecolnames; /* list of output column names */
1378  List *ctecoltypes; /* OID list of output column type OIDs */
1379  List *ctecoltypmods; /* integer list of output column typmods */
1380  List *ctecolcollations; /* OID list of column collation OIDs */
1381 } CommonTableExpr;
1382 
1383 /* Convenience macro to get the output tlist of a CTE's query */
1384 #define GetCTETargetList(cte) \
1385  (AssertMacro(IsA((cte)->ctequery, Query)), \
1386  ((Query *) (cte)->ctequery)->commandType == CMD_SELECT ? \
1387  ((Query *) (cte)->ctequery)->targetList : \
1388  ((Query *) (cte)->ctequery)->returningList)
1389 
1390 /*
1391  * TriggerTransition -
1392  * representation of transition row or table naming clause
1393  *
1394  * Only transition tables are initially supported in the syntax, and only for
1395  * AFTER triggers, but other permutations are accepted by the parser so we can
1396  * give a meaningful message from C code.
1397  */
1398 typedef struct TriggerTransition
1399 {
1401  char *name;
1402  bool isNew;
1403  bool isTable;
1405 
1406 /*****************************************************************************
1407  * Raw Grammar Output Statements
1408  *****************************************************************************/
1409 
1410 /*
1411  * RawStmt --- container for any one statement's raw parse tree
1412  *
1413  * Parse analysis converts a raw parse tree headed by a RawStmt node into
1414  * an analyzed statement headed by a Query node. For optimizable statements,
1415  * the conversion is complex. For utility statements, the parser usually just
1416  * transfers the raw parse tree (sans RawStmt) into the utilityStmt field of
1417  * the Query node, and all the useful work happens at execution time.
1418  *
1419  * stmt_location/stmt_len identify the portion of the source text string
1420  * containing this raw statement (useful for multi-statement strings).
1421  */
1422 typedef struct RawStmt
1423 {
1425  Node *stmt; /* raw parse tree */
1426  int stmt_location; /* start location, or -1 if unknown */
1427  int stmt_len; /* length in bytes; 0 means "rest of string" */
1428 } RawStmt;
1429 
1430 /*****************************************************************************
1431  * Optimizable Statements
1432  *****************************************************************************/
1433 
1434 /* ----------------------
1435  * Insert Statement
1436  *
1437  * The source expression is represented by SelectStmt for both the
1438  * SELECT and VALUES cases. If selectStmt is NULL, then the query
1439  * is INSERT ... DEFAULT VALUES.
1440  * ----------------------
1441  */
1442 typedef struct InsertStmt
1443 {
1445  RangeVar *relation; /* relation to insert into */
1446  List *cols; /* optional: names of the target columns */
1447  Node *selectStmt; /* the source SELECT/VALUES, or NULL */
1448  OnConflictClause *onConflictClause; /* ON CONFLICT clause */
1449  List *returningList; /* list of expressions to return */
1450  WithClause *withClause; /* WITH clause */
1451  OverridingKind override; /* OVERRIDING clause */
1452 } InsertStmt;
1453 
1454 /* ----------------------
1455  * Delete Statement
1456  * ----------------------
1457  */
1458 typedef struct DeleteStmt
1459 {
1461  RangeVar *relation; /* relation to delete from */
1462  List *usingClause; /* optional using clause for more tables */
1463  Node *whereClause; /* qualifications */
1464  List *returningList; /* list of expressions to return */
1465  WithClause *withClause; /* WITH clause */
1466 } DeleteStmt;
1467 
1468 /* ----------------------
1469  * Update Statement
1470  * ----------------------
1471  */
1472 typedef struct UpdateStmt
1473 {
1475  RangeVar *relation; /* relation to update */
1476  List *targetList; /* the target list (of ResTarget) */
1477  Node *whereClause; /* qualifications */
1478  List *fromClause; /* optional from clause for more tables */
1479  List *returningList; /* list of expressions to return */
1480  WithClause *withClause; /* WITH clause */
1481 } UpdateStmt;
1482 
1483 /* ----------------------
1484  * Select Statement
1485  *
1486  * A "simple" SELECT is represented in the output of gram.y by a single
1487  * SelectStmt node; so is a VALUES construct. A query containing set
1488  * operators (UNION, INTERSECT, EXCEPT) is represented by a tree of SelectStmt
1489  * nodes, in which the leaf nodes are component SELECTs and the internal nodes
1490  * represent UNION, INTERSECT, or EXCEPT operators. Using the same node
1491  * type for both leaf and internal nodes allows gram.y to stick ORDER BY,
1492  * LIMIT, etc, clause values into a SELECT statement without worrying
1493  * whether it is a simple or compound SELECT.
1494  * ----------------------
1495  */
1496 typedef enum SetOperation
1497 {
1502 } SetOperation;
1503 
1504 typedef struct SelectStmt
1505 {
1507 
1508  /*
1509  * These fields are used only in "leaf" SelectStmts.
1510  */
1511  List *distinctClause; /* NULL, list of DISTINCT ON exprs, or
1512  * lcons(NIL,NIL) for all (SELECT DISTINCT) */
1513  IntoClause *intoClause; /* target for SELECT INTO */
1514  List *targetList; /* the target list (of ResTarget) */
1515  List *fromClause; /* the FROM clause */
1516  Node *whereClause; /* WHERE qualification */
1517  List *groupClause; /* GROUP BY clauses */
1518  Node *havingClause; /* HAVING conditional-expression */
1519  List *windowClause; /* WINDOW window_name AS (...), ... */
1520 
1521  /*
1522  * In a "leaf" node representing a VALUES list, the above fields are all
1523  * null, and instead this field is set. Note that the elements of the
1524  * sublists are just expressions, without ResTarget decoration. Also note
1525  * that a list element can be DEFAULT (represented as a SetToDefault
1526  * node), regardless of the context of the VALUES list. It's up to parse
1527  * analysis to reject that where not valid.
1528  */
1529  List *valuesLists; /* untransformed list of expression lists */
1530 
1531  /*
1532  * These fields are used in both "leaf" SelectStmts and upper-level
1533  * SelectStmts.
1534  */
1535  List *sortClause; /* sort clause (a list of SortBy's) */
1536  Node *limitOffset; /* # of result tuples to skip */
1537  Node *limitCount; /* # of result tuples to return */
1538  List *lockingClause; /* FOR UPDATE (list of LockingClause's) */
1539  WithClause *withClause; /* WITH clause */
1540 
1541  /*
1542  * These fields are used only in upper-level SelectStmts.
1543  */
1544  SetOperation op; /* type of set op */
1545  bool all; /* ALL specified? */
1546  struct SelectStmt *larg; /* left child */
1547  struct SelectStmt *rarg; /* right child */
1548  /* Eventually add fields for CORRESPONDING spec here */
1549 } SelectStmt;
1550 
1551 
1552 /* ----------------------
1553  * Set Operation node for post-analysis query trees
1554  *
1555  * After parse analysis, a SELECT with set operations is represented by a
1556  * top-level Query node containing the leaf SELECTs as subqueries in its
1557  * range table. Its setOperations field shows the tree of set operations,
1558  * with leaf SelectStmt nodes replaced by RangeTblRef nodes, and internal
1559  * nodes replaced by SetOperationStmt nodes. Information about the output
1560  * column types is added, too. (Note that the child nodes do not necessarily
1561  * produce these types directly, but we've checked that their output types
1562  * can be coerced to the output column type.) Also, if it's not UNION ALL,
1563  * information about the types' sort/group semantics is provided in the form
1564  * of a SortGroupClause list (same representation as, eg, DISTINCT).
1565  * The resolved common column collations are provided too; but note that if
1566  * it's not UNION ALL, it's okay for a column to not have a common collation,
1567  * so a member of the colCollations list could be InvalidOid even though the
1568  * column has a collatable type.
1569  * ----------------------
1570  */
1571 typedef struct SetOperationStmt
1572 {
1574  SetOperation op; /* type of set op */
1575  bool all; /* ALL specified? */
1576  Node *larg; /* left child */
1577  Node *rarg; /* right child */
1578  /* Eventually add fields for CORRESPONDING spec here */
1579 
1580  /* Fields derived during parse analysis: */
1581  List *colTypes; /* OID list of output column type OIDs */
1582  List *colTypmods; /* integer list of output column typmods */
1583  List *colCollations; /* OID list of output column collation OIDs */
1584  List *groupClauses; /* a list of SortGroupClause's */
1585  /* groupClauses is NIL if UNION ALL, but must be set otherwise */
1587 
1588 
1589 /*****************************************************************************
1590  * Other Statements (no optimizations required)
1591  *
1592  * These are not touched by parser/analyze.c except to put them into
1593  * the utilityStmt field of a Query. This is eventually passed to
1594  * ProcessUtility (by-passing rewriting and planning). Some of the
1595  * statements do need attention from parse analysis, and this is
1596  * done by routines in parser/parse_utilcmd.c after ProcessUtility
1597  * receives the command for execution.
1598  * DECLARE CURSOR, EXPLAIN, and CREATE TABLE AS are special cases:
1599  * they contain optimizable statements, which get processed normally
1600  * by parser/analyze.c.
1601  *****************************************************************************/
1602 
1603 /*
1604  * When a command can act on several kinds of objects with only one
1605  * parse structure required, use these constants to designate the
1606  * object type. Note that commands typically don't support all the types.
1607  */
1608 
1609 typedef enum ObjectType
1610 {
1615  OBJECT_ATTRIBUTE, /* type's attribute, when distinct from column */
1659 } ObjectType;
1660 
1661 /* ----------------------
1662  * Create Schema Statement
1663  *
1664  * NOTE: the schemaElts list contains raw parsetrees for component statements
1665  * of the schema, such as CREATE TABLE, GRANT, etc. These are analyzed and
1666  * executed after the schema itself is created.
1667  * ----------------------
1668  */
1669 typedef struct CreateSchemaStmt
1670 {
1672  char *schemaname; /* the name of the schema to create */
1673  RoleSpec *authrole; /* the owner of the created schema */
1674  List *schemaElts; /* schema components (list of parsenodes) */
1675  bool if_not_exists; /* just do nothing if schema already exists? */
1677 
1678 typedef enum DropBehavior
1679 {
1680  DROP_RESTRICT, /* drop fails if any dependent objects */
1681  DROP_CASCADE /* remove dependent objects too */
1682 } DropBehavior;
1683 
1684 /* ----------------------
1685  * Alter Table
1686  * ----------------------
1687  */
1688 typedef struct AlterTableStmt
1689 {
1691  RangeVar *relation; /* table to work on */
1692  List *cmds; /* list of subcommands */
1693  ObjectType relkind; /* type of object */
1694  bool missing_ok; /* skip error if table missing */
1695 } AlterTableStmt;
1696 
1697 typedef enum AlterTableType
1698 {
1699  AT_AddColumn, /* add column */
1700  AT_AddColumnRecurse, /* internal to commands/tablecmds.c */
1701  AT_AddColumnToView, /* implicitly via CREATE OR REPLACE VIEW */
1702  AT_ColumnDefault, /* alter column default */
1703  AT_DropNotNull, /* alter column drop not null */
1704  AT_SetNotNull, /* alter column set not null */
1705  AT_SetStatistics, /* alter column set statistics */
1706  AT_SetOptions, /* alter column set ( options ) */
1707  AT_ResetOptions, /* alter column reset ( options ) */
1708  AT_SetStorage, /* alter column set storage */
1709  AT_DropColumn, /* drop column */
1710  AT_DropColumnRecurse, /* internal to commands/tablecmds.c */
1711  AT_AddIndex, /* add index */
1712  AT_ReAddIndex, /* internal to commands/tablecmds.c */
1713  AT_AddConstraint, /* add constraint */
1714  AT_AddConstraintRecurse, /* internal to commands/tablecmds.c */
1715  AT_ReAddConstraint, /* internal to commands/tablecmds.c */
1716  AT_AlterConstraint, /* alter constraint */
1717  AT_ValidateConstraint, /* validate constraint */
1718  AT_ValidateConstraintRecurse, /* internal to commands/tablecmds.c */
1719  AT_ProcessedConstraint, /* pre-processed add constraint (local in
1720  * parser/parse_utilcmd.c) */
1721  AT_AddIndexConstraint, /* add constraint using existing index */
1722  AT_DropConstraint, /* drop constraint */
1723  AT_DropConstraintRecurse, /* internal to commands/tablecmds.c */
1724  AT_ReAddComment, /* internal to commands/tablecmds.c */
1725  AT_AlterColumnType, /* alter column type */
1726  AT_AlterColumnGenericOptions, /* alter column OPTIONS (...) */
1727  AT_ChangeOwner, /* change owner */
1728  AT_ClusterOn, /* CLUSTER ON */
1729  AT_DropCluster, /* SET WITHOUT CLUSTER */
1730  AT_SetLogged, /* SET LOGGED */
1731  AT_SetUnLogged, /* SET UNLOGGED */
1732  AT_AddOids, /* SET WITH OIDS */
1733  AT_AddOidsRecurse, /* internal to commands/tablecmds.c */
1734  AT_DropOids, /* SET WITHOUT OIDS */
1735  AT_SetTableSpace, /* SET TABLESPACE */
1736  AT_SetRelOptions, /* SET (...) -- AM specific parameters */
1737  AT_ResetRelOptions, /* RESET (...) -- AM specific parameters */
1738  AT_ReplaceRelOptions, /* replace reloption list in its entirety */
1739  AT_EnableTrig, /* ENABLE TRIGGER name */
1740  AT_EnableAlwaysTrig, /* ENABLE ALWAYS TRIGGER name */
1741  AT_EnableReplicaTrig, /* ENABLE REPLICA TRIGGER name */
1742  AT_DisableTrig, /* DISABLE TRIGGER name */
1743  AT_EnableTrigAll, /* ENABLE TRIGGER ALL */
1744  AT_DisableTrigAll, /* DISABLE TRIGGER ALL */
1745  AT_EnableTrigUser, /* ENABLE TRIGGER USER */
1746  AT_DisableTrigUser, /* DISABLE TRIGGER USER */
1747  AT_EnableRule, /* ENABLE RULE name */
1748  AT_EnableAlwaysRule, /* ENABLE ALWAYS RULE name */
1749  AT_EnableReplicaRule, /* ENABLE REPLICA RULE name */
1750  AT_DisableRule, /* DISABLE RULE name */
1751  AT_AddInherit, /* INHERIT parent */
1752  AT_DropInherit, /* NO INHERIT parent */
1753  AT_AddOf, /* OF <type_name> */
1754  AT_DropOf, /* NOT OF */
1755  AT_ReplicaIdentity, /* REPLICA IDENTITY */
1756  AT_EnableRowSecurity, /* ENABLE ROW SECURITY */
1757  AT_DisableRowSecurity, /* DISABLE ROW SECURITY */
1758  AT_ForceRowSecurity, /* FORCE ROW SECURITY */
1759  AT_NoForceRowSecurity, /* NO FORCE ROW SECURITY */
1760  AT_GenericOptions, /* OPTIONS (...) */
1761  AT_AttachPartition, /* ATTACH PARTITION */
1762  AT_DetachPartition, /* DETACH PARTITION */
1763  AT_AddIdentity, /* ADD IDENTITY */
1764  AT_SetIdentity, /* SET identity column options */
1765  AT_DropIdentity /* DROP IDENTITY */
1766 } AlterTableType;
1767 
1768 typedef struct ReplicaIdentityStmt
1769 {
1772  char *name;
1774 
1775 typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */
1776 {
1778  AlterTableType subtype; /* Type of table alteration to apply */
1779  char *name; /* column, constraint, or trigger to act on,
1780  * or tablespace */
1781  int16 num; /* attribute number for columns referenced by
1782  * number */
1784  Node *def; /* definition of new column, index,
1785  * constraint, or parent table */
1786  DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
1787  bool missing_ok; /* skip error if missing? */
1788 } AlterTableCmd;
1789 
1790 
1791 /* ----------------------
1792  * Alter Collation
1793  * ----------------------
1794  */
1795 typedef struct AlterCollationStmt
1796 {
1800 
1801 
1802 /* ----------------------
1803  * Alter Domain
1804  *
1805  * The fields are used in different ways by the different variants of
1806  * this command.
1807  * ----------------------
1808  */
1809 typedef struct AlterDomainStmt
1810 {
1812  char subtype; /*------------
1813  * T = alter column default
1814  * N = alter column drop not null
1815  * O = alter column set not null
1816  * C = add constraint
1817  * X = drop constraint
1818  *------------
1819  */
1820  List *typeName; /* domain to work on */
1821  char *name; /* column or constraint name to act on */
1822  Node *def; /* definition of default or constraint */
1823  DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
1824  bool missing_ok; /* skip error if missing? */
1825 } AlterDomainStmt;
1826 
1827 
1828 /* ----------------------
1829  * Grant|Revoke Statement
1830  * ----------------------
1831  */
1832 typedef enum GrantTargetType
1833 {
1834  ACL_TARGET_OBJECT, /* grant on specific named object(s) */
1835  ACL_TARGET_ALL_IN_SCHEMA, /* grant on all objects in given schema(s) */
1836  ACL_TARGET_DEFAULTS /* ALTER DEFAULT PRIVILEGES */
1837 } GrantTargetType;
1838 
1839 typedef enum GrantObjectType
1840 {
1841  ACL_OBJECT_COLUMN, /* column */
1842  ACL_OBJECT_RELATION, /* table, view */
1843  ACL_OBJECT_SEQUENCE, /* sequence */
1844  ACL_OBJECT_DATABASE, /* database */
1845  ACL_OBJECT_DOMAIN, /* domain */
1846  ACL_OBJECT_FDW, /* foreign-data wrapper */
1847  ACL_OBJECT_FOREIGN_SERVER, /* foreign server */
1848  ACL_OBJECT_FUNCTION, /* function */
1849  ACL_OBJECT_LANGUAGE, /* procedural language */
1850  ACL_OBJECT_LARGEOBJECT, /* largeobject */
1851  ACL_OBJECT_NAMESPACE, /* namespace */
1852  ACL_OBJECT_TABLESPACE, /* tablespace */
1853  ACL_OBJECT_TYPE /* type */
1854 } GrantObjectType;
1855 
1856 typedef struct GrantStmt
1857 {
1859  bool is_grant; /* true = GRANT, false = REVOKE */
1860  GrantTargetType targtype; /* type of the grant target */
1861  GrantObjectType objtype; /* kind of object being operated on */
1862  List *objects; /* list of RangeVar nodes, ObjectWithArgs
1863  * nodes, or plain names (as Value strings) */
1864  List *privileges; /* list of AccessPriv nodes */
1865  /* privileges == NIL denotes ALL PRIVILEGES */
1866  List *grantees; /* list of RoleSpec nodes */
1867  bool grant_option; /* grant or revoke grant option */
1868  DropBehavior behavior; /* drop behavior (for REVOKE) */
1869 } GrantStmt;
1870 
1871 /*
1872  * Note: ObjectWithArgs carries only the types of the input parameters of the
1873  * function. So it is sufficient to identify an existing function, but it
1874  * is not enough info to define a function nor to call it.
1875  */
1876 typedef struct ObjectWithArgs
1877 {
1879  List *objname; /* qualified name of function/operator */
1880  List *objargs; /* list of Typename nodes */
1881  bool args_unspecified; /* argument list was omitted, so name must
1882  * be unique (note that objargs == NIL
1883  * means zero args) */
1884 } ObjectWithArgs;
1885 
1886 /*
1887  * An access privilege, with optional list of column names
1888  * priv_name == NULL denotes ALL PRIVILEGES (only used with a column list)
1889  * cols == NIL denotes "all columns"
1890  * Note that simple "ALL PRIVILEGES" is represented as a NIL list, not
1891  * an AccessPriv with both fields null.
1892  */
1893 typedef struct AccessPriv
1894 {
1896  char *priv_name; /* string name of privilege */
1897  List *cols; /* list of Value strings */
1898 } AccessPriv;
1899 
1900 /* ----------------------
1901  * Grant/Revoke Role Statement
1902  *
1903  * Note: because of the parsing ambiguity with the GRANT <privileges>
1904  * statement, granted_roles is a list of AccessPriv; the execution code
1905  * should complain if any column lists appear. grantee_roles is a list
1906  * of role names, as Value strings.
1907  * ----------------------
1908  */
1909 typedef struct GrantRoleStmt
1910 {
1912  List *granted_roles; /* list of roles to be granted/revoked */
1913  List *grantee_roles; /* list of member roles to add/delete */
1914  bool is_grant; /* true = GRANT, false = REVOKE */
1915  bool admin_opt; /* with admin option */
1916  RoleSpec *grantor; /* set grantor to other than current role */
1917  DropBehavior behavior; /* drop behavior (for REVOKE) */
1918 } GrantRoleStmt;
1919 
1920 /* ----------------------
1921  * Alter Default Privileges Statement
1922  * ----------------------
1923  */
1925 {
1927  List *options; /* list of DefElem */
1928  GrantStmt *action; /* GRANT/REVOKE action (with objects=NIL) */
1930 
1931 /* ----------------------
1932  * Copy Statement
1933  *
1934  * We support "COPY relation FROM file", "COPY relation TO file", and
1935  * "COPY (query) TO file". In any given CopyStmt, exactly one of "relation"
1936  * and "query" must be non-NULL.
1937  * ----------------------
1938  */
1939 typedef struct CopyStmt
1940 {
1942  RangeVar *relation; /* the relation to copy */
1943  Node *query; /* the query (SELECT or DML statement with
1944  * RETURNING) to copy, as a raw parse tree */
1945  List *attlist; /* List of column names (as Strings), or NIL
1946  * for all columns */
1947  bool is_from; /* TO or FROM */
1948  bool is_program; /* is 'filename' a program to popen? */
1949  char *filename; /* filename, or NULL for STDIN/STDOUT */
1950  List *options; /* List of DefElem nodes */
1951 } CopyStmt;
1952 
1953 /* ----------------------
1954  * SET Statement (includes RESET)
1955  *
1956  * "SET var TO DEFAULT" and "RESET var" are semantically equivalent, but we
1957  * preserve the distinction in VariableSetKind for CreateCommandTag().
1958  * ----------------------
1959  */
1960 typedef enum
1961 {
1962  VAR_SET_VALUE, /* SET var = value */
1963  VAR_SET_DEFAULT, /* SET var TO DEFAULT */
1964  VAR_SET_CURRENT, /* SET var FROM CURRENT */
1965  VAR_SET_MULTI, /* special case for SET TRANSACTION ... */
1966  VAR_RESET, /* RESET var */
1967  VAR_RESET_ALL /* RESET ALL */
1968 } VariableSetKind;
1969 
1970 typedef struct VariableSetStmt
1971 {
1974  char *name; /* variable to be set */
1975  List *args; /* List of A_Const nodes */
1976  bool is_local; /* SET LOCAL? */
1977 } VariableSetStmt;
1978 
1979 /* ----------------------
1980  * Show Statement
1981  * ----------------------
1982  */
1983 typedef struct VariableShowStmt
1984 {
1986  char *name;
1988 
1989 /* ----------------------
1990  * Create Table Statement
1991  *
1992  * NOTE: in the raw gram.y output, ColumnDef and Constraint nodes are
1993  * intermixed in tableElts, and constraints is NIL. After parse analysis,
1994  * tableElts contains just ColumnDefs, and constraints contains just
1995  * Constraint nodes (in fact, only CONSTR_CHECK nodes, in the present
1996  * implementation).
1997  * ----------------------
1998  */
1999 
2000 typedef struct CreateStmt
2001 {
2003  RangeVar *relation; /* relation to create */
2004  List *tableElts; /* column definitions (list of ColumnDef) */
2005  List *inhRelations; /* relations to inherit from (list of
2006  * inhRelation) */
2007  PartitionBoundSpec *partbound; /* FOR VALUES clause */
2008  PartitionSpec *partspec; /* PARTITION BY clause */
2009  TypeName *ofTypename; /* OF typename */
2010  List *constraints; /* constraints (list of Constraint nodes) */
2011  List *options; /* options from WITH clause */
2012  OnCommitAction oncommit; /* what do we do at COMMIT? */
2013  char *tablespacename; /* table space to use, or NULL */
2014  bool if_not_exists; /* just do nothing if it already exists? */
2015 } CreateStmt;
2016 
2017 /* ----------
2018  * Definitions for constraints in CreateStmt
2019  *
2020  * Note that column defaults are treated as a type of constraint,
2021  * even though that's a bit odd semantically.
2022  *
2023  * For constraints that use expressions (CONSTR_CHECK, CONSTR_DEFAULT)
2024  * we may have the expression in either "raw" form (an untransformed
2025  * parse tree) or "cooked" form (the nodeToString representation of
2026  * an executable expression tree), depending on how this Constraint
2027  * node was created (by parsing, or by inheritance from an existing
2028  * relation). We should never have both in the same node!
2029  *
2030  * FKCONSTR_ACTION_xxx values are stored into pg_constraint.confupdtype
2031  * and pg_constraint.confdeltype columns; FKCONSTR_MATCH_xxx values are
2032  * stored into pg_constraint.confmatchtype. Changing the code values may
2033  * require an initdb!
2034  *
2035  * If skip_validation is true then we skip checking that the existing rows
2036  * in the table satisfy the constraint, and just install the catalog entries
2037  * for the constraint. A new FK constraint is marked as valid iff
2038  * initially_valid is true. (Usually skip_validation and initially_valid
2039  * are inverses, but we can set both true if the table is known empty.)
2040  *
2041  * Constraint attributes (DEFERRABLE etc) are initially represented as
2042  * separate Constraint nodes for simplicity of parsing. parse_utilcmd.c makes
2043  * a pass through the constraints list to insert the info into the appropriate
2044  * Constraint node.
2045  * ----------
2046  */
2047 
2048 typedef enum ConstrType /* types of constraints */
2049 {
2050  CONSTR_NULL, /* not standard SQL, but a lot of people
2051  * expect it */
2060  CONSTR_ATTR_DEFERRABLE, /* attributes for previous constraint node */
2064 } ConstrType;
2065 
2066 /* Foreign key action codes */
2067 #define FKCONSTR_ACTION_NOACTION 'a'
2068 #define FKCONSTR_ACTION_RESTRICT 'r'
2069 #define FKCONSTR_ACTION_CASCADE 'c'
2070 #define FKCONSTR_ACTION_SETNULL 'n'
2071 #define FKCONSTR_ACTION_SETDEFAULT 'd'
2072 
2073 /* Foreign key matchtype codes */
2074 #define FKCONSTR_MATCH_FULL 'f'
2075 #define FKCONSTR_MATCH_PARTIAL 'p'
2076 #define FKCONSTR_MATCH_SIMPLE 's'
2077 
2078 typedef struct Constraint
2079 {
2081  ConstrType contype; /* see above */
2082 
2083  /* Fields used for most/all constraint types: */
2084  char *conname; /* Constraint name, or NULL if unnamed */
2085  bool deferrable; /* DEFERRABLE? */
2086  bool initdeferred; /* INITIALLY DEFERRED? */
2087  int location; /* token location, or -1 if unknown */
2088 
2089  /* Fields used for constraints with expressions (CHECK and DEFAULT): */
2090  bool is_no_inherit; /* is constraint non-inheritable? */
2091  Node *raw_expr; /* expr, as untransformed parse tree */
2092  char *cooked_expr; /* expr, as nodeToString representation */
2094 
2095  /* Fields used for unique constraints (UNIQUE and PRIMARY KEY): */
2096  List *keys; /* String nodes naming referenced column(s) */
2097 
2098  /* Fields used for EXCLUSION constraints: */
2099  List *exclusions; /* list of (IndexElem, operator name) pairs */
2100 
2101  /* Fields used for index constraints (UNIQUE, PRIMARY KEY, EXCLUSION): */
2102  List *options; /* options from WITH clause */
2103  char *indexname; /* existing index to use; otherwise NULL */
2104  char *indexspace; /* index tablespace; NULL for default */
2105  /* These could be, but currently are not, used for UNIQUE/PKEY: */
2106  char *access_method; /* index access method; NULL for default */
2107  Node *where_clause; /* partial index predicate */
2108 
2109  /* Fields used for FOREIGN KEY constraints: */
2110  RangeVar *pktable; /* Primary key table */
2111  List *fk_attrs; /* Attributes of foreign key */
2112  List *pk_attrs; /* Corresponding attrs in PK table */
2113  char fk_matchtype; /* FULL, PARTIAL, SIMPLE */
2114  char fk_upd_action; /* ON UPDATE action */
2115  char fk_del_action; /* ON DELETE action */
2116  List *old_conpfeqop; /* pg_constraint.conpfeqop of my former self */
2117  Oid old_pktable_oid; /* pg_constraint.confrelid of my former
2118  * self */
2119 
2120  /* Fields used for constraints that allow a NOT VALID specification */
2121  bool skip_validation; /* skip validation of existing rows? */
2122  bool initially_valid; /* mark the new constraint as valid? */
2123 } Constraint;
2124 
2125 /* ----------------------
2126  * Create/Drop Table Space Statements
2127  * ----------------------
2128  */
2129 
2130 typedef struct CreateTableSpaceStmt
2131 {
2135  char *location;
2138 
2139 typedef struct DropTableSpaceStmt
2140 {
2143  bool missing_ok; /* skip error if missing? */
2145 
2147 {
2151  bool isReset;
2153 
2155 {
2158  ObjectType objtype; /* Object type to move */
2159  List *roles; /* List of roles to move objects of */
2161  bool nowait;
2163 
2164 /* ----------------------
2165  * Create/Alter Extension Statements
2166  * ----------------------
2167  */
2168 
2169 typedef struct CreateExtensionStmt
2170 {
2172  char *extname;
2173  bool if_not_exists; /* just do nothing if it already exists? */
2174  List *options; /* List of DefElem nodes */
2176 
2177 /* Only used for ALTER EXTENSION UPDATE; later might need an action field */
2178 typedef struct AlterExtensionStmt
2179 {
2181  char *extname;
2182  List *options; /* List of DefElem nodes */
2184 
2186 {
2188  char *extname; /* Extension's name */
2189  int action; /* +1 = add object, -1 = drop object */
2190  ObjectType objtype; /* Object's type */
2191  Node *object; /* Qualified name of the object */
2193 
2194 /* ----------------------
2195  * Create/Alter FOREIGN DATA WRAPPER Statements
2196  * ----------------------
2197  */
2198 
2199 typedef struct CreateFdwStmt
2200 {
2202  char *fdwname; /* foreign-data wrapper name */
2203  List *func_options; /* HANDLER/VALIDATOR options */
2204  List *options; /* generic options to FDW */
2205 } CreateFdwStmt;
2206 
2207 typedef struct AlterFdwStmt
2208 {
2210  char *fdwname; /* foreign-data wrapper name */
2211  List *func_options; /* HANDLER/VALIDATOR options */
2212  List *options; /* generic options to FDW */
2213 } AlterFdwStmt;
2214 
2215 /* ----------------------
2216  * Create/Alter FOREIGN SERVER Statements
2217  * ----------------------
2218  */
2219 
2221 {
2223  char *servername; /* server name */
2224  char *servertype; /* optional server type */
2225  char *version; /* optional server version */
2226  char *fdwname; /* FDW name */
2227  bool if_not_exists; /* just do nothing if it already exists? */
2228  List *options; /* generic options to server */
2230 
2232 {
2234  char *servername; /* server name */
2235  char *version; /* optional server version */
2236  List *options; /* generic options to server */
2237  bool has_version; /* version specified */
2239 
2240 /* ----------------------
2241  * Create FOREIGN TABLE Statement
2242  * ----------------------
2243  */
2244 
2246 {
2248  char *servername;
2251 
2252 /* ----------------------
2253  * Create/Drop USER MAPPING Statements
2254  * ----------------------
2255  */
2256 
2258 {
2260  RoleSpec *user; /* user role */
2261  char *servername; /* server name */
2262  bool if_not_exists; /* just do nothing if it already exists? */
2263  List *options; /* generic options to server */
2265 
2266 typedef struct AlterUserMappingStmt
2267 {
2269  RoleSpec *user; /* user role */
2270  char *servername; /* server name */
2271  List *options; /* generic options to server */
2273 
2274 typedef struct DropUserMappingStmt
2275 {
2277  RoleSpec *user; /* user role */
2278  char *servername; /* server name */
2279  bool missing_ok; /* ignore missing mappings */
2281 
2282 /* ----------------------
2283  * Import Foreign Schema Statement
2284  * ----------------------
2285  */
2286 
2288 {
2289  FDW_IMPORT_SCHEMA_ALL, /* all relations wanted */
2290  FDW_IMPORT_SCHEMA_LIMIT_TO, /* include only listed tables in import */
2291  FDW_IMPORT_SCHEMA_EXCEPT /* exclude listed tables from import */
2293 
2295 {
2297  char *server_name; /* FDW server name */
2298  char *remote_schema; /* remote schema name to query */
2299  char *local_schema; /* local schema to create objects in */
2300  ImportForeignSchemaType list_type; /* type of table list */
2301  List *table_list; /* List of RangeVar */
2302  List *options; /* list of options to pass to FDW */
2304 
2305 /*----------------------
2306  * Create POLICY Statement
2307  *----------------------
2308  */
2309 typedef struct CreatePolicyStmt
2310 {
2312  char *policy_name; /* Policy's name */
2313  RangeVar *table; /* the table name the policy applies to */
2314  char *cmd_name; /* the command name the policy applies to */
2315  bool permissive; /* restrictive or permissive policy */
2316  List *roles; /* the roles associated with the policy */
2317  Node *qual; /* the policy's condition */
2318  Node *with_check; /* the policy's WITH CHECK condition. */
2320 
2321 /*----------------------
2322  * Alter POLICY Statement
2323  *----------------------
2324  */
2325 typedef struct AlterPolicyStmt
2326 {
2328  char *policy_name; /* Policy's name */
2329  RangeVar *table; /* the table name the policy applies to */
2330  List *roles; /* the roles associated with the policy */
2331  Node *qual; /* the policy's condition */
2332  Node *with_check; /* the policy's WITH CHECK condition. */
2333 } AlterPolicyStmt;
2334 
2335 /*----------------------
2336  * Create ACCESS METHOD Statement
2337  *----------------------
2338  */
2339 typedef struct CreateAmStmt
2340 {
2342  char *amname; /* access method name */
2343  List *handler_name; /* handler function name */
2344  char amtype; /* type of access method */
2345 } CreateAmStmt;
2346 
2347 /* ----------------------
2348  * Create TRIGGER Statement
2349  * ----------------------
2350  */
2351 typedef struct CreateTrigStmt
2352 {
2354  char *trigname; /* TRIGGER's name */
2355  RangeVar *relation; /* relation trigger is on */
2356  List *funcname; /* qual. name of function to call */
2357  List *args; /* list of (T_String) Values or NIL */
2358  bool row; /* ROW/STATEMENT */
2359  /* timing uses the TRIGGER_TYPE bits defined in catalog/pg_trigger.h */
2360  int16 timing; /* BEFORE, AFTER, or INSTEAD */
2361  /* events uses the TRIGGER_TYPE bits defined in catalog/pg_trigger.h */
2362  int16 events; /* "OR" of INSERT/UPDATE/DELETE/TRUNCATE */
2363  List *columns; /* column names, or NIL for all columns */
2364  Node *whenClause; /* qual expression, or NULL if none */
2365  bool isconstraint; /* This is a constraint trigger */
2366  /* explicitly named transition data */
2367  List *transitionRels; /* TriggerTransition nodes, or NIL if none */
2368  /* The remaining fields are only used for constraint triggers */
2369  bool deferrable; /* [NOT] DEFERRABLE */
2370  bool initdeferred; /* INITIALLY {DEFERRED|IMMEDIATE} */
2371  RangeVar *constrrel; /* opposite relation, if RI trigger */
2372 } CreateTrigStmt;
2373 
2374 /* ----------------------
2375  * Create EVENT TRIGGER Statement
2376  * ----------------------
2377  */
2378 typedef struct CreateEventTrigStmt
2379 {
2381  char *trigname; /* TRIGGER's name */
2382  char *eventname; /* event's identifier */
2383  List *whenclause; /* list of DefElems indicating filtering */
2384  List *funcname; /* qual. name of function to call */
2386 
2387 /* ----------------------
2388  * Alter EVENT TRIGGER Statement
2389  * ----------------------
2390  */
2391 typedef struct AlterEventTrigStmt
2392 {
2394  char *trigname; /* TRIGGER's name */
2395  char tgenabled; /* trigger's firing configuration WRT
2396  * session_replication_role */
2398 
2399 /* ----------------------
2400  * Create/Drop PROCEDURAL LANGUAGE Statements
2401  * Create PROCEDURAL LANGUAGE Statements
2402  * ----------------------
2403  */
2404 typedef struct CreatePLangStmt
2405 {
2407  bool replace; /* T => replace if already exists */
2408  char *plname; /* PL name */
2409  List *plhandler; /* PL call handler function (qual. name) */
2410  List *plinline; /* optional inline function (qual. name) */
2411  List *plvalidator; /* optional validator function (qual. name) */
2412  bool pltrusted; /* PL is trusted */
2413 } CreatePLangStmt;
2414 
2415 /* ----------------------
2416  * Create/Alter/Drop Role Statements
2417  *
2418  * Note: these node types are also used for the backwards-compatible
2419  * Create/Alter/Drop User/Group statements. In the ALTER and DROP cases
2420  * there's really no need to distinguish what the original spelling was,
2421  * but for CREATE we mark the type because the defaults vary.
2422  * ----------------------
2423  */
2424 typedef enum RoleStmtType
2425 {
2429 } RoleStmtType;
2430 
2431 typedef struct CreateRoleStmt
2432 {
2434  RoleStmtType stmt_type; /* ROLE/USER/GROUP */
2435  char *role; /* role name */
2436  List *options; /* List of DefElem nodes */
2437 } CreateRoleStmt;
2438 
2439 typedef struct AlterRoleStmt
2440 {
2442  RoleSpec *role; /* role */
2443  List *options; /* List of DefElem nodes */
2444  int action; /* +1 = add members, -1 = drop members */
2445 } AlterRoleStmt;
2446 
2447 typedef struct AlterRoleSetStmt
2448 {
2450  RoleSpec *role; /* role */
2451  char *database; /* database name, or NULL */
2452  VariableSetStmt *setstmt; /* SET or RESET subcommand */
2454 
2455 typedef struct DropRoleStmt
2456 {
2458  List *roles; /* List of roles to remove */
2459  bool missing_ok; /* skip error if a role is missing? */
2460 } DropRoleStmt;
2461 
2462 /* ----------------------
2463  * {Create|Alter} SEQUENCE Statement
2464  * ----------------------
2465  */
2466 
2467 typedef struct CreateSeqStmt
2468 {
2470  RangeVar *sequence; /* the sequence to create */
2472  Oid ownerId; /* ID of owner, or InvalidOid for default */
2474  bool if_not_exists; /* just do nothing if it already exists? */
2475 } CreateSeqStmt;
2476 
2477 typedef struct AlterSeqStmt
2478 {
2480  RangeVar *sequence; /* the sequence to alter */
2483  bool missing_ok; /* skip error if a role is missing? */
2484 } AlterSeqStmt;
2485 
2486 /* ----------------------
2487  * Create {Aggregate|Operator|Type} Statement
2488  * ----------------------
2489  */
2490 typedef struct DefineStmt
2491 {
2493  ObjectType kind; /* aggregate, operator, type */
2494  bool oldstyle; /* hack to signal old CREATE AGG syntax */
2495  List *defnames; /* qualified name (list of Value strings) */
2496  List *args; /* a list of TypeName (if needed) */
2497  List *definition; /* a list of DefElem */
2498  bool if_not_exists; /* just do nothing if it already exists? */
2499 } DefineStmt;
2500 
2501 /* ----------------------
2502  * Create Domain Statement
2503  * ----------------------
2504  */
2505 typedef struct CreateDomainStmt
2506 {
2508  List *domainname; /* qualified name (list of Value strings) */
2509  TypeName *typeName; /* the base type */
2510  CollateClause *collClause; /* untransformed COLLATE spec, if any */
2511  List *constraints; /* constraints (list of Constraint nodes) */
2513 
2514 /* ----------------------
2515  * Create Operator Class Statement
2516  * ----------------------
2517  */
2518 typedef struct CreateOpClassStmt
2519 {
2521  List *opclassname; /* qualified name (list of Value strings) */
2522  List *opfamilyname; /* qualified name (ditto); NIL if omitted */
2523  char *amname; /* name of index AM opclass is for */
2524  TypeName *datatype; /* datatype of indexed column */
2525  List *items; /* List of CreateOpClassItem nodes */
2526  bool isDefault; /* Should be marked as default for type? */
2528 
2529 #define OPCLASS_ITEM_OPERATOR 1
2530 #define OPCLASS_ITEM_FUNCTION 2
2531 #define OPCLASS_ITEM_STORAGETYPE 3
2532 
2533 typedef struct CreateOpClassItem
2534 {
2536  int itemtype; /* see codes above */
2537  ObjectWithArgs *name; /* operator or function name and args */
2538  int number; /* strategy num or support proc num */
2539  List *order_family; /* only used for ordering operators */
2540  List *class_args; /* amproclefttype/amprocrighttype or
2541  * amoplefttype/amoprighttype */
2542  /* fields used for a storagetype item: */
2543  TypeName *storedtype; /* datatype stored in index */
2545 
2546 /* ----------------------
2547  * Create Operator Family Statement
2548  * ----------------------
2549  */
2550 typedef struct CreateOpFamilyStmt
2551 {
2553  List *opfamilyname; /* qualified name (list of Value strings) */
2554  char *amname; /* name of index AM opfamily is for */
2556 
2557 /* ----------------------
2558  * Alter Operator Family Statement
2559  * ----------------------
2560  */
2561 typedef struct AlterOpFamilyStmt
2562 {
2564  List *opfamilyname; /* qualified name (list of Value strings) */
2565  char *amname; /* name of index AM opfamily is for */
2566  bool isDrop; /* ADD or DROP the items? */
2567  List *items; /* List of CreateOpClassItem nodes */
2569 
2570 /* ----------------------
2571  * Drop Table|Sequence|View|Index|Type|Domain|Conversion|Schema Statement
2572  * ----------------------
2573  */
2574 
2575 typedef struct DropStmt
2576 {
2578  List *objects; /* list of names */
2579  ObjectType removeType; /* object type */
2580  DropBehavior behavior; /* RESTRICT or CASCADE behavior */
2581  bool missing_ok; /* skip error if object is missing? */
2582  bool concurrent; /* drop index concurrently? */
2583 } DropStmt;
2584 
2585 /* ----------------------
2586  * Truncate Table Statement
2587  * ----------------------
2588  */
2589 typedef struct TruncateStmt
2590 {
2592  List *relations; /* relations (RangeVars) to be truncated */
2593  bool restart_seqs; /* restart owned sequences? */
2594  DropBehavior behavior; /* RESTRICT or CASCADE behavior */
2595 } TruncateStmt;
2596 
2597 /* ----------------------
2598  * Comment On Statement
2599  * ----------------------
2600  */
2601 typedef struct CommentStmt
2602 {
2604  ObjectType objtype; /* Object's type */
2605  Node *object; /* Qualified name of the object */
2606  char *comment; /* Comment to insert, or NULL to remove */
2607 } CommentStmt;
2608 
2609 /* ----------------------
2610  * SECURITY LABEL Statement
2611  * ----------------------
2612  */
2613 typedef struct SecLabelStmt
2614 {
2616  ObjectType objtype; /* Object's type */
2617  Node *object; /* Qualified name of the object */
2618  char *provider; /* Label provider (or NULL) */
2619  char *label; /* New security label to be assigned */
2620 } SecLabelStmt;
2621 
2622 /* ----------------------
2623  * Declare Cursor Statement
2624  *
2625  * The "query" field is initially a raw parse tree, and is converted to a
2626  * Query node during parse analysis. Note that rewriting and planning
2627  * of the query are always postponed until execution.
2628  * ----------------------
2629  */
2630 #define CURSOR_OPT_BINARY 0x0001 /* BINARY */
2631 #define CURSOR_OPT_SCROLL 0x0002 /* SCROLL explicitly given */
2632 #define CURSOR_OPT_NO_SCROLL 0x0004 /* NO SCROLL explicitly given */
2633 #define CURSOR_OPT_INSENSITIVE 0x0008 /* INSENSITIVE */
2634 #define CURSOR_OPT_HOLD 0x0010 /* WITH HOLD */
2635 /* these planner-control flags do not correspond to any SQL grammar: */
2636 #define CURSOR_OPT_FAST_PLAN 0x0020 /* prefer fast-start plan */
2637 #define CURSOR_OPT_GENERIC_PLAN 0x0040 /* force use of generic plan */
2638 #define CURSOR_OPT_CUSTOM_PLAN 0x0080 /* force use of custom plan */
2639 #define CURSOR_OPT_PARALLEL_OK 0x0100 /* parallel mode OK */
2640 
2641 typedef struct DeclareCursorStmt
2642 {
2644  char *portalname; /* name of the portal (cursor) */
2645  int options; /* bitmask of options (see above) */
2646  Node *query; /* the query (see comments above) */
2648 
2649 /* ----------------------
2650  * Close Portal Statement
2651  * ----------------------
2652  */
2653 typedef struct ClosePortalStmt
2654 {
2656  char *portalname; /* name of the portal (cursor) */
2657  /* NULL means CLOSE ALL */
2658 } ClosePortalStmt;
2659 
2660 /* ----------------------
2661  * Fetch Statement (also Move)
2662  * ----------------------
2663  */
2664 typedef enum FetchDirection
2665 {
2666  /* for these, howMany is how many rows to fetch; FETCH_ALL means ALL */
2669  /* for these, howMany indicates a position; only one row is fetched */
2672 } FetchDirection;
2673 
2674 #define FETCH_ALL LONG_MAX
2675 
2676 typedef struct FetchStmt
2677 {
2679  FetchDirection direction; /* see above */
2680  long howMany; /* number of rows, or position argument */
2681  char *portalname; /* name of portal (cursor) */
2682  bool ismove; /* TRUE if MOVE */
2683 } FetchStmt;
2684 
2685 /* ----------------------
2686  * Create Index Statement
2687  *
2688  * This represents creation of an index and/or an associated constraint.
2689  * If isconstraint is true, we should create a pg_constraint entry along
2690  * with the index. But if indexOid isn't InvalidOid, we are not creating an
2691  * index, just a UNIQUE/PKEY constraint using an existing index. isconstraint
2692  * must always be true in this case, and the fields describing the index
2693  * properties are empty.
2694  * ----------------------
2695  */
2696 typedef struct IndexStmt
2697 {
2699  char *idxname; /* name of new index, or NULL for default */
2700  RangeVar *relation; /* relation to build index on */
2701  char *accessMethod; /* name of access method (eg. btree) */
2702  char *tableSpace; /* tablespace, or NULL for default */
2703  List *indexParams; /* columns to index: a list of IndexElem */
2704  List *options; /* WITH clause options: a list of DefElem */
2705  Node *whereClause; /* qualification (partial-index predicate) */
2706  List *excludeOpNames; /* exclusion operator names, or NIL if none */
2707  char *idxcomment; /* comment to apply to index, or NULL */
2708  Oid indexOid; /* OID of an existing index, if any */
2709  Oid oldNode; /* relfilenode of existing storage, if any */
2710  bool unique; /* is index unique? */
2711  bool primary; /* is index a primary key? */
2712  bool isconstraint; /* is it for a pkey/unique constraint? */
2713  bool deferrable; /* is the constraint DEFERRABLE? */
2714  bool initdeferred; /* is the constraint INITIALLY DEFERRED? */
2715  bool transformed; /* true when transformIndexStmt is finished */
2716  bool concurrent; /* should this be a concurrent index build? */
2717  bool if_not_exists; /* just do nothing if index already exists? */
2718 } IndexStmt;
2719 
2720 /* ----------------------
2721  * Create Statistics Statement
2722  * ----------------------
2723  */
2724 typedef struct CreateStatsStmt
2725 {
2727  List *defnames; /* qualified name (list of Value strings) */
2728  List *stat_types; /* stat types (list of Value strings) */
2729  List *exprs; /* expressions to build statistics on */
2730  List *relations; /* rels to build stats on (list of RangeVar) */
2731  bool if_not_exists; /* do nothing if stats name already exists */
2732 } CreateStatsStmt;
2733 
2734 /* ----------------------
2735  * Create Function Statement
2736  * ----------------------
2737  */
2738 typedef struct CreateFunctionStmt
2739 {
2741  bool replace; /* T => replace if already exists */
2742  List *funcname; /* qualified name of function to create */
2743  List *parameters; /* a list of FunctionParameter */
2744  TypeName *returnType; /* the return type */
2745  List *options; /* a list of DefElem */
2746  List *withClause; /* a list of DefElem */
2748 
2750 {
2751  /* the assigned enum values appear in pg_proc, don't change 'em! */
2752  FUNC_PARAM_IN = 'i', /* input only */
2753  FUNC_PARAM_OUT = 'o', /* output only */
2754  FUNC_PARAM_INOUT = 'b', /* both */
2755  FUNC_PARAM_VARIADIC = 'v', /* variadic (always input) */
2756  FUNC_PARAM_TABLE = 't' /* table function output column */
2758 
2759 typedef struct FunctionParameter
2760 {
2762  char *name; /* parameter name, or NULL if not given */
2763  TypeName *argType; /* TypeName for parameter type */
2764  FunctionParameterMode mode; /* IN/OUT/etc */
2765  Node *defexpr; /* raw default expr, or NULL if not given */
2767 
2768 typedef struct AlterFunctionStmt
2769 {
2771  ObjectWithArgs *func; /* name and args of function */
2772  List *actions; /* list of DefElem */
2774 
2775 /* ----------------------
2776  * DO Statement
2777  *
2778  * DoStmt is the raw parser output, InlineCodeBlock is the execution-time API
2779  * ----------------------
2780  */
2781 typedef struct DoStmt
2782 {
2784  List *args; /* List of DefElem nodes */
2785 } DoStmt;
2786 
2787 typedef struct InlineCodeBlock
2788 {
2790  char *source_text; /* source text of anonymous code block */
2791  Oid langOid; /* OID of selected language */
2792  bool langIsTrusted; /* trusted property of the language */
2793 } InlineCodeBlock;
2794 
2795 /* ----------------------
2796  * Alter Object Rename Statement
2797  * ----------------------
2798  */
2799 typedef struct RenameStmt
2800 {
2802  ObjectType renameType; /* OBJECT_TABLE, OBJECT_COLUMN, etc */
2803  ObjectType relationType; /* if column name, associated relation type */
2804  RangeVar *relation; /* in case it's a table */
2805  Node *object; /* in case it's some other object */
2806  char *subname; /* name of contained object (column, rule,
2807  * trigger, etc) */
2808  char *newname; /* the new name */
2809  DropBehavior behavior; /* RESTRICT or CASCADE behavior */
2810  bool missing_ok; /* skip error if missing? */
2811 } RenameStmt;
2812 
2813 /* ----------------------
2814  * ALTER object DEPENDS ON EXTENSION extname
2815  * ----------------------
2816  */
2818 {
2820  ObjectType objectType; /* OBJECT_FUNCTION, OBJECT_TRIGGER, etc */
2821  RangeVar *relation; /* in case a table is involved */
2822  Node *object; /* name of the object */
2823  Value *extname; /* extension name */
2825 
2826 /* ----------------------
2827  * ALTER object SET SCHEMA Statement
2828  * ----------------------
2829  */
2831 {
2833  ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
2834  RangeVar *relation; /* in case it's a table */
2835  Node *object; /* in case it's some other object */
2836  char *newschema; /* the new schema */
2837  bool missing_ok; /* skip error if missing? */
2839 
2840 /* ----------------------
2841  * Alter Object Owner Statement
2842  * ----------------------
2843  */
2844 typedef struct AlterOwnerStmt
2845 {
2847  ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
2848  RangeVar *relation; /* in case it's a table */
2849  Node *object; /* in case it's some other object */
2850  RoleSpec *newowner; /* the new owner */
2851 } AlterOwnerStmt;
2852 
2853 
2854 /* ----------------------
2855  * Alter Operator Set Restrict, Join
2856  * ----------------------
2857  */
2858 typedef struct AlterOperatorStmt
2859 {
2861  ObjectWithArgs *opername; /* operator name and argument types */
2862  List *options; /* List of DefElem nodes */
2864 
2865 
2866 /* ----------------------
2867  * Create Rule Statement
2868  * ----------------------
2869  */
2870 typedef struct RuleStmt
2871 {
2873  RangeVar *relation; /* relation the rule is for */
2874  char *rulename; /* name of the rule */
2875  Node *whereClause; /* qualifications */
2876  CmdType event; /* SELECT, INSERT, etc */
2877  bool instead; /* is a 'do instead'? */
2878  List *actions; /* the action statements */
2879  bool replace; /* OR REPLACE */
2880 } RuleStmt;
2881 
2882 /* ----------------------
2883  * Notify Statement
2884  * ----------------------
2885  */
2886 typedef struct NotifyStmt
2887 {
2889  char *conditionname; /* condition name to notify */
2890  char *payload; /* the payload string, or NULL if none */
2891 } NotifyStmt;
2892 
2893 /* ----------------------
2894  * Listen Statement
2895  * ----------------------
2896  */
2897 typedef struct ListenStmt
2898 {
2900  char *conditionname; /* condition name to listen on */
2901 } ListenStmt;
2902 
2903 /* ----------------------
2904  * Unlisten Statement
2905  * ----------------------
2906  */
2907 typedef struct UnlistenStmt
2908 {
2910  char *conditionname; /* name to unlisten on, or NULL for all */
2911 } UnlistenStmt;
2912 
2913 /* ----------------------
2914  * {Begin|Commit|Rollback} Transaction Statement
2915  * ----------------------
2916  */
2918 {
2920  TRANS_STMT_START, /* semantically identical to BEGIN */
2930 
2931 typedef struct TransactionStmt
2932 {
2934  TransactionStmtKind kind; /* see above */
2935  List *options; /* for BEGIN/START and savepoint commands */
2936  char *gid; /* for two-phase-commit related commands */
2937 } TransactionStmt;
2938 
2939 /* ----------------------
2940  * Create Type Statement, composite types
2941  * ----------------------
2942  */
2943 typedef struct CompositeTypeStmt
2944 {
2946  RangeVar *typevar; /* the composite type to be created */
2947  List *coldeflist; /* list of ColumnDef nodes */
2949 
2950 /* ----------------------
2951  * Create Type Statement, enum types
2952  * ----------------------
2953  */
2954 typedef struct CreateEnumStmt
2955 {
2957  List *typeName; /* qualified name (list of Value strings) */
2958  List *vals; /* enum values (list of Value strings) */
2959 } CreateEnumStmt;
2960 
2961 /* ----------------------
2962  * Create Type Statement, range types
2963  * ----------------------
2964  */
2965 typedef struct CreateRangeStmt
2966 {
2968  List *typeName; /* qualified name (list of Value strings) */
2969  List *params; /* range parameters (list of DefElem) */
2970 } CreateRangeStmt;
2971 
2972 /* ----------------------
2973  * Alter Type Statement, enum types
2974  * ----------------------
2975  */
2976 typedef struct AlterEnumStmt
2977 {
2979  List *typeName; /* qualified name (list of Value strings) */
2980  char *oldVal; /* old enum value's name, if renaming */
2981  char *newVal; /* new enum value's name */
2982  char *newValNeighbor; /* neighboring enum value, if specified */
2983  bool newValIsAfter; /* place new enum value after neighbor? */
2984  bool skipIfNewValExists; /* no error if new already exists? */
2985 } AlterEnumStmt;
2986 
2987 /* ----------------------
2988  * Create View Statement
2989  * ----------------------
2990  */
2991 typedef enum ViewCheckOption
2992 {
2996 } ViewCheckOption;
2997 
2998 typedef struct ViewStmt
2999 {
3001  RangeVar *view; /* the view to be created */
3002  List *aliases; /* target column names */
3003  Node *query; /* the SELECT query (as a raw parse tree) */
3004  bool replace; /* replace an existing view? */
3005  List *options; /* options from WITH clause */
3006  ViewCheckOption withCheckOption; /* WITH CHECK OPTION */
3007 } ViewStmt;
3008 
3009 /* ----------------------
3010  * Load Statement
3011  * ----------------------
3012  */
3013 typedef struct LoadStmt
3014 {
3016  char *filename; /* file to load */
3017 } LoadStmt;
3018 
3019 /* ----------------------
3020  * Createdb Statement
3021  * ----------------------
3022  */
3023 typedef struct CreatedbStmt
3024 {
3026  char *dbname; /* name of database to create */
3027  List *options; /* List of DefElem nodes */
3028 } CreatedbStmt;
3029 
3030 /* ----------------------
3031  * Alter Database
3032  * ----------------------
3033  */
3034 typedef struct AlterDatabaseStmt
3035 {
3037  char *dbname; /* name of database to alter */
3038  List *options; /* List of DefElem nodes */
3040 
3041 typedef struct AlterDatabaseSetStmt
3042 {
3044  char *dbname; /* database name */
3045  VariableSetStmt *setstmt; /* SET or RESET subcommand */
3047 
3048 /* ----------------------
3049  * Dropdb Statement
3050  * ----------------------
3051  */
3052 typedef struct DropdbStmt
3053 {
3055  char *dbname; /* database to drop */
3056  bool missing_ok; /* skip error if db is missing? */
3057 } DropdbStmt;
3058 
3059 /* ----------------------
3060  * Alter System Statement
3061  * ----------------------
3062  */
3063 typedef struct AlterSystemStmt
3064 {
3066  VariableSetStmt *setstmt; /* SET subcommand */
3067 } AlterSystemStmt;
3068 
3069 /* ----------------------
3070  * Cluster Statement (support pbrown's cluster index implementation)
3071  * ----------------------
3072  */
3073 typedef struct ClusterStmt
3074 {
3076  RangeVar *relation; /* relation being indexed, or NULL if all */
3077  char *indexname; /* original index defined */
3078  bool verbose; /* print progress info */
3079 } ClusterStmt;
3080 
3081 /* ----------------------
3082  * Vacuum and Analyze Statements
3083  *
3084  * Even though these are nominally two statements, it's convenient to use
3085  * just one node type for both. Note that at least one of VACOPT_VACUUM
3086  * and VACOPT_ANALYZE must be set in options.
3087  * ----------------------
3088  */
3089 typedef enum VacuumOption
3090 {
3091  VACOPT_VACUUM = 1 << 0, /* do VACUUM */
3092  VACOPT_ANALYZE = 1 << 1, /* do ANALYZE */
3093  VACOPT_VERBOSE = 1 << 2, /* print progress info */
3094  VACOPT_FREEZE = 1 << 3, /* FREEZE option */
3095  VACOPT_FULL = 1 << 4, /* FULL (non-concurrent) vacuum */
3096  VACOPT_NOWAIT = 1 << 5, /* don't wait to get lock (autovacuum only) */
3097  VACOPT_SKIPTOAST = 1 << 6, /* don't process the TOAST table, if any */
3098  VACOPT_DISABLE_PAGE_SKIPPING = 1 << 7 /* don't skip any pages */
3099 } VacuumOption;
3100 
3101 /*
3102  * Info about a single target table of VACUUM/ANALYZE.
3103  *
3104  * If the OID field is set, it always identifies the table to process.
3105  * Then the relation field can be NULL; if it isn't, it's used only to report
3106  * failure to open/lock the relation.
3107  */
3108 typedef struct VacuumRelation
3109 {
3111  RangeVar *relation; /* table name to process, or NULL */
3112  Oid oid; /* table's OID; InvalidOid if not looked up */
3113  List *va_cols; /* list of column names, or NIL for all */
3114 } VacuumRelation;
3115 
3116 typedef struct VacuumStmt
3117 {
3119  int options; /* OR of VacuumOption flags */
3120  List *rels; /* list of VacuumRelation, or NIL for all */
3121 } VacuumStmt;
3122 
3123 /* ----------------------
3124  * Explain Statement
3125  *
3126  * The "query" field is initially a raw parse tree, and is converted to a
3127  * Query node during parse analysis. Note that rewriting and planning
3128  * of the query are always postponed until execution.
3129  * ----------------------
3130  */
3131 typedef struct ExplainStmt
3132 {
3134  Node *query; /* the query (see comments above) */
3135  List *options; /* list of DefElem nodes */
3136 } ExplainStmt;
3137 
3138 /* ----------------------
3139  * CREATE TABLE AS Statement (a/k/a SELECT INTO)
3140  *
3141  * A query written as CREATE TABLE AS will produce this node type natively.
3142  * A query written as SELECT ... INTO will be transformed to this form during
3143  * parse analysis.
3144  * A query written as CREATE MATERIALIZED view will produce this node type,
3145  * during parse analysis, since it needs all the same data.
3146  *
3147  * The "query" field is handled similarly to EXPLAIN, though note that it
3148  * can be a SELECT or an EXECUTE, but not other DML statements.
3149  * ----------------------
3150  */
3151 typedef struct CreateTableAsStmt
3152 {
3154  Node *query; /* the query (see comments above) */
3155  IntoClause *into; /* destination table */
3156  ObjectType relkind; /* OBJECT_TABLE or OBJECT_MATVIEW */
3157  bool is_select_into; /* it was written as SELECT INTO */
3158  bool if_not_exists; /* just do nothing if it already exists? */
3160 
3161 /* ----------------------
3162  * REFRESH MATERIALIZED VIEW Statement
3163  * ----------------------
3164  */
3165 typedef struct RefreshMatViewStmt
3166 {
3168  bool concurrent; /* allow concurrent access? */
3169  bool skipData; /* true for WITH NO DATA */
3170  RangeVar *relation; /* relation to insert into */
3172 
3173 /* ----------------------
3174  * Checkpoint Statement
3175  * ----------------------
3176  */
3177 typedef struct CheckPointStmt
3178 {
3180 } CheckPointStmt;
3181 
3182 /* ----------------------
3183  * Discard Statement
3184  * ----------------------
3185  */
3186 
3187 typedef enum DiscardMode
3188 {
3193 } DiscardMode;
3194 
3195 typedef struct DiscardStmt
3196 {
3199 } DiscardStmt;
3200 
3201 /* ----------------------
3202  * LOCK Statement
3203  * ----------------------
3204  */
3205 typedef struct LockStmt
3206 {
3208  List *relations; /* relations to lock */
3209  int mode; /* lock mode */
3210  bool nowait; /* no wait mode */
3211 } LockStmt;
3212 
3213 /* ----------------------
3214  * SET CONSTRAINTS Statement
3215  * ----------------------
3216  */
3217 typedef struct ConstraintsSetStmt
3218 {
3220  List *constraints; /* List of names as RangeVars */
3221  bool deferred;
3223 
3224 /* ----------------------
3225  * REINDEX Statement
3226  * ----------------------
3227  */
3228 
3229 /* Reindex options */
3230 #define REINDEXOPT_VERBOSE 1 << 0 /* print progress info */
3231 
3232 typedef enum ReindexObjectType
3233 {
3235  REINDEX_OBJECT_TABLE, /* table or materialized view */
3237  REINDEX_OBJECT_SYSTEM, /* system catalogs */
3240 
3241 typedef struct ReindexStmt
3242 {
3244  ReindexObjectType kind; /* REINDEX_OBJECT_INDEX, REINDEX_OBJECT_TABLE,
3245  * etc. */
3246  RangeVar *relation; /* Table or index to reindex */
3247  const char *name; /* name of database to reindex */
3248  int options; /* Reindex options flags */
3249 } ReindexStmt;
3250 
3251 /* ----------------------
3252  * CREATE CONVERSION Statement
3253  * ----------------------
3254  */
3255 typedef struct CreateConversionStmt
3256 {
3258  List *conversion_name; /* Name of the conversion */
3259  char *for_encoding_name; /* source encoding name */
3260  char *to_encoding_name; /* destination encoding name */
3261  List *func_name; /* qualified conversion function name */
3262  bool def; /* is this a default conversion? */
3264 
3265 /* ----------------------
3266  * CREATE CAST Statement
3267  * ----------------------
3268  */
3269 typedef struct CreateCastStmt
3270 {
3276  bool inout;
3277 } CreateCastStmt;
3278 
3279 /* ----------------------
3280  * CREATE TRANSFORM Statement
3281  * ----------------------
3282  */
3283 typedef struct CreateTransformStmt
3284 {
3286  bool replace;
3288  char *lang;
3292 
3293 /* ----------------------
3294  * PREPARE Statement
3295  * ----------------------
3296  */
3297 typedef struct PrepareStmt
3298 {
3300  char *name; /* Name of plan, arbitrary */
3301  List *argtypes; /* Types of parameters (List of TypeName) */
3302  Node *query; /* The query itself (as a raw parsetree) */
3303 } PrepareStmt;
3304 
3305 
3306 /* ----------------------
3307  * EXECUTE Statement
3308  * ----------------------
3309  */
3310 
3311 typedef struct ExecuteStmt
3312 {
3314  char *name; /* The name of the plan to execute */
3315  List *params; /* Values to assign to parameters */
3316 } ExecuteStmt;
3317 
3318 
3319 /* ----------------------
3320  * DEALLOCATE Statement
3321  * ----------------------
3322  */
3323 typedef struct DeallocateStmt
3324 {
3326  char *name; /* The name of the plan to remove */
3327  /* NULL means DEALLOCATE ALL */
3328 } DeallocateStmt;
3329 
3330 /*
3331  * DROP OWNED statement
3332  */
3333 typedef struct DropOwnedStmt
3334 {
3338 } DropOwnedStmt;
3339 
3340 /*
3341  * REASSIGN OWNED statement
3342  */
3343 typedef struct ReassignOwnedStmt
3344 {
3349 
3350 /*
3351  * TS Dictionary stmts: DefineStmt, RenameStmt and DropStmt are default
3352  */
3354 {
3356  List *dictname; /* qualified name (list of Value strings) */
3357  List *options; /* List of DefElem nodes */
3359 
3360 /*
3361  * TS Configuration stmts: DefineStmt, RenameStmt and DropStmt are default
3362  */
3363 typedef enum AlterTSConfigType
3364 {
3371 
3373 {
3375  AlterTSConfigType kind; /* ALTER_TSCONFIG_ADD_MAPPING, etc */
3376  List *cfgname; /* qualified name (list of Value strings) */
3377 
3378  /*
3379  * dicts will be non-NIL if ADD/ALTER MAPPING was specified. If dicts is
3380  * NIL, but tokentype isn't, DROP MAPPING was specified.
3381  */
3382  List *tokentype; /* list of Value strings */
3383  List *dicts; /* list of list of Value strings */
3384  bool override; /* if true - remove old variant */
3385  bool replace; /* if true - replace dictionary by another */
3386  bool missing_ok; /* for DROP - skip error if missing? */
3388 
3389 
3391 {
3393  char *pubname; /* Name of of the publication */
3394  List *options; /* List of DefElem nodes */
3395  List *tables; /* Optional list of tables to add */
3396  bool for_all_tables; /* Special publication for all tables in db */
3398 
3399 typedef struct AlterPublicationStmt
3400 {
3402  char *pubname; /* Name of of the publication */
3403 
3404  /* parameters used for ALTER PUBLICATION ... WITH */
3405  List *options; /* List of DefElem nodes */
3406 
3407  /* parameters used for ALTER PUBLICATION ... ADD/DROP TABLE */
3408  List *tables; /* List of tables to add/drop */
3409  bool for_all_tables; /* Special publication for all tables in db */
3410  DefElemAction tableAction; /* What action to perform with the tables */
3412 
3414 {
3416  char *subname; /* Name of of the subscription */
3417  char *conninfo; /* Connection string to publisher */
3418  List *publication; /* One or more publication to subscribe to */
3419  List *options; /* List of DefElem nodes */
3421 
3423 {
3430 
3432 {
3434  AlterSubscriptionType kind; /* ALTER_SUBSCRIPTION_OPTIONS, etc */
3435  char *subname; /* Name of of the subscription */
3436  char *conninfo; /* Connection string to publisher */
3437  List *publication; /* One or more publication to subscribe to */
3438  List *options; /* List of DefElem nodes */
3440 
3441 typedef struct DropSubscriptionStmt
3442 {
3444  char *subname; /* Name of of the subscription */
3445  bool missing_ok; /* Skip error if missing? */
3446  DropBehavior behavior; /* RESTRICT or CASCADE behavior */
3448 
3449 #endif /* PARSENODES_H */
struct CreateFdwStmt CreateFdwStmt
bool deferrable
Definition: parsenodes.h:2713
RangeVar * relation
Definition: parsenodes.h:2003
ObjectType objtype
Definition: parsenodes.h:2604
bool replace
Definition: parsenodes.h:3004
List * lockedRels
Definition: parsenodes.h:737
RoleSpec * newowner
Definition: parsenodes.h:2850
struct FetchStmt FetchStmt
signed short int16
Definition: c.h:245
List * indirection
Definition: parsenodes.h:440
Node * limitOffset
Definition: parsenodes.h:158
struct AlterDatabaseSetStmt AlterDatabaseSetStmt
List * partitionClause
Definition: parsenodes.h:488
SortByDir
Definition: parsenodes.h:48
char * refname
Definition: parsenodes.h:1282
NodeTag type
Definition: parsenodes.h:2888
struct SelectStmt * larg
Definition: parsenodes.h:1546
bool primary
Definition: parsenodes.h:2711
bool copiedOrder
Definition: parsenodes.h:1289
OnCommitAction oncommit
Definition: parsenodes.h:2012
TypeName * sourcetype
Definition: parsenodes.h:3272
ConstrType
Definition: parsenodes.h:2048
RoleSpec * role
Definition: parsenodes.h:2442
NodeTag type
Definition: parsenodes.h:3335
List * fromClause
Definition: parsenodes.h:1478
struct DropTableSpaceStmt DropTableSpaceStmt
struct ViewStmt ViewStmt
List * inhRelations
Definition: parsenodes.h:2005
NodeTag type
Definition: parsenodes.h:3243
bool nowait
Definition: parsenodes.h:3210
struct CreateSchemaStmt CreateSchemaStmt
Alias * alias
Definition: parsenodes.h:560
Oid typeOid
Definition: parsenodes.h:209
ObjectType objtype
Definition: parsenodes.h:2616
List * keys
Definition: parsenodes.h:2096
GrantObjectType
Definition: parsenodes.h:1839
struct CreateForeignTableStmt CreateForeignTableStmt
NodeTag type
Definition: parsenodes.h:2591
NodeTag type
Definition: parsenodes.h:3000
List * exclusions
Definition: parsenodes.h:2099
struct TableLikeClause TableLikeClause
ObjectWithArgs * tosql
Definition: parsenodes.h:3290
List * joinaliasvars
Definition: parsenodes.h:989
Node * val
Definition: parsenodes.h:441
SortByDir ordering
Definition: parsenodes.h:693
Node * subquery
Definition: parsenodes.h:535
NodeTag type
Definition: parsenodes.h:2783
int stmt_location
Definition: parsenodes.h:179
Node * object
Definition: parsenodes.h:2617
char generated_when
Definition: parsenodes.h:2093
NodeTag type
Definition: parsenodes.h:2577
List * sortClause
Definition: parsenodes.h:156
struct CreateExtensionStmt CreateExtensionStmt
List * old_conpfeqop
Definition: parsenodes.h:2116
struct WindowDef WindowDef
struct FuncCall FuncCall
FetchDirection
Definition: parsenodes.h:2664
List * content
Definition: parsenodes.h:1260
List * names
Definition: parsenodes.h:208
IntoClause * intoClause
Definition: parsenodes.h:1513
A_Expr_Kind kind
Definition: parsenodes.h:274
struct DeclareCursorStmt DeclareCursorStmt
List * options
Definition: parsenodes.h:2704
struct CopyStmt CopyStmt
char storage
Definition: parsenodes.h:646
DropBehavior behavior
Definition: parsenodes.h:1823
VariableSetKind kind
Definition: parsenodes.h:1973
List * attlist
Definition: parsenodes.h:1945
struct VacuumStmt VacuumStmt
List * fromClause
Definition: parsenodes.h:1515
char * subname
Definition: parsenodes.h:2806
SortByDir sortby_dir
Definition: parsenodes.h:469
RangeVar * relation
Definition: parsenodes.h:3111
NodeTag type
Definition: parsenodes.h:3133
Alias * alias
Definition: parsenodes.h:1048
List * partParams
Definition: parsenodes.h:781
NodeTag type
Definition: parsenodes.h:2978
NodeTag type
Definition: parsenodes.h:467
bool is_local
Definition: parsenodes.h:642
ObjectType renameType
Definition: parsenodes.h:2802
struct AlterDomainStmt AlterDomainStmt
struct CreateCastStmt CreateCastStmt
RangeVar * relation
Definition: parsenodes.h:1461
FromExpr * jointree
Definition: parsenodes.h:136
TransactionStmtKind
Definition: parsenodes.h:2917
char * name
Definition: parsenodes.h:439
struct LoadStmt LoadStmt
int frameOptions
Definition: parsenodes.h:490
OnConflictExpr * onConflict
Definition: parsenodes.h:142
NodeTag type
Definition: parsenodes.h:348
TypeName * storedtype
Definition: parsenodes.h:2543
struct A_Indices A_Indices
struct AlterExtensionContentsStmt AlterExtensionContentsStmt
struct AlterObjectSchemaStmt AlterObjectSchemaStmt
RoleStmtType
Definition: parsenodes.h:2424
char identity
Definition: parsenodes.h:649
PartitionRangeDatumKind
Definition: parsenodes.h:817
struct ColumnDef ColumnDef
struct VariableShowStmt VariableShowStmt
char * tableSpace
Definition: parsenodes.h:2702
NodeTag type
Definition: parsenodes.h:840
struct PartitionSpec PartitionSpec
Node * limitOffset
Definition: parsenodes.h:1536
List * constraintDeps
Definition: parsenodes.h:166
struct WithCheckOption WithCheckOption
struct CompositeTypeStmt CompositeTypeStmt
char fk_matchtype
Definition: parsenodes.h:2113
List * constraints
Definition: parsenodes.h:652
Node * whenClause
Definition: parsenodes.h:2364
List * securityQuals
Definition: parsenodes.h:1058
List * withCheckOptions
Definition: parsenodes.h:169
RoleStmtType stmt_type
Definition: parsenodes.h:2434
Node * agg_filter
Definition: parsenodes.h:352
struct DropUserMappingStmt DropUserMappingStmt
Node * raw_expr
Definition: parsenodes.h:2091
struct CreateRoleStmt CreateRoleStmt
struct A_Indirection A_Indirection
struct RoleSpec RoleSpec
List * objects
Definition: parsenodes.h:2578
bool missing_ok
Definition: parsenodes.h:2581
struct DeallocateStmt DeallocateStmt
struct InferClause InferClause
struct GrantRoleStmt GrantRoleStmt
bool if_not_exists
Definition: parsenodes.h:2474
struct TypeName TypeName
List * coltypmods
Definition: parsenodes.h:1036
struct AlterRoleSetStmt AlterRoleSetStmt
bool is_from_parent
Definition: parsenodes.h:645
List * useOp
Definition: parsenodes.h:471
bool hasAggs
Definition: parsenodes.h:123
char * name
Definition: parsenodes.h:486
struct CommonTableExpr CommonTableExpr
struct WindowClause WindowClause
struct AlterForeignServerStmt AlterForeignServerStmt
struct PartitionElem PartitionElem
ObjectType objectType
Definition: parsenodes.h:2847
List * columns
Definition: parsenodes.h:575
NodeTag type
Definition: parsenodes.h:243
int resultRelation
Definition: parsenodes.h:120
struct AccessPriv AccessPriv
List * indexElems
Definition: parsenodes.h:1337
RangeVar * typevar
Definition: parsenodes.h:2946
char * defnamespace
Definition: parsenodes.h:718
struct CreateStmt CreateStmt
Index tleSortGroupRef
Definition: parsenodes.h:1190
QuerySource
Definition: parsenodes.h:38
PartitionRangeDatumKind kind
Definition: parsenodes.h:828
Node * whereClause
Definition: parsenodes.h:2705
AlterTSConfigType
Definition: parsenodes.h:3363
char * provider
Definition: parsenodes.h:2618
bool grant_option
Definition: parsenodes.h:1867
List * groupingSets
Definition: parsenodes.h:148
DefElemAction defaction
Definition: parsenodes.h:721
NodeTag type
Definition: parsenodes.h:233
Definition: nodes.h:510
struct AlterCollationStmt AlterCollationStmt
struct RangeTableSample RangeTableSample
NodeTag type
Definition: parsenodes.h:2899
struct RenameStmt RenameStmt
NodeTag type
Definition: parsenodes.h:3118
bool initdeferred
Definition: parsenodes.h:2086
char * filename
Definition: parsenodes.h:3016
AlterTableType subtype
Definition: parsenodes.h:1778
List * actions
Definition: parsenodes.h:2878
List * granted_roles
Definition: parsenodes.h:1912
char * comment
Definition: parsenodes.h:2606
List * targetList
Definition: parsenodes.h:1476
List * options
Definition: parsenodes.h:3135
RoleSpec * role
Definition: parsenodes.h:2450
AclMode requiredPerms
Definition: parsenodes.h:1053
List * roles
Definition: parsenodes.h:2458
List * pk_attrs
Definition: parsenodes.h:2112
List * cols
Definition: parsenodes.h:1897
TypeName * typeName
Definition: parsenodes.h:750
char * conname
Definition: parsenodes.h:2084
struct AlterOpFamilyStmt AlterOpFamilyStmt
bool is_not_null
Definition: parsenodes.h:643
NodeTag type
Definition: parsenodes.h:1258
struct DropStmt DropStmt
Node * object
Definition: parsenodes.h:2605
NodeTag type
Definition: parsenodes.h:1280
bool funcordinality
Definition: parsenodes.h:1000
NodeTag type
Definition: parsenodes.h:3015
int location
Definition: parsenodes.h:358
char * newname
Definition: parsenodes.h:2808
struct SetOperationStmt SetOperationStmt
unsigned int Oid
Definition: postgres_ext.h:31
NodeTag
Definition: nodes.h:26
List * rowMarks
Definition: parsenodes.h:161
Node * utilityStmt
Definition: parsenodes.h:118
bool is_program
Definition: parsenodes.h:1948
struct CreateDomainStmt CreateDomainStmt
struct TransactionStmt TransactionStmt
struct PrepareStmt PrepareStmt
ReindexObjectType
Definition: parsenodes.h:3232
struct LockingClause LockingClause
List * colcollations
Definition: parsenodes.h:1037
CoercionContext
Definition: primnodes.h:420
WithClause * withClause
Definition: parsenodes.h:1450
struct RangeFunction RangeFunction
RangeVar * relation
Definition: parsenodes.h:3170
List * agg_order
Definition: parsenodes.h:351
List * values_lists
Definition: parsenodes.h:1010
ObjectType removeType
Definition: parsenodes.h:2579
bool instead
Definition: parsenodes.h:2877
OnCommitAction
Definition: primnodes.h:47
LockClauseStrength strength
Definition: parsenodes.h:1308
bool hasDistinctOn
Definition: parsenodes.h:127
RangeVar * table
Definition: parsenodes.h:2329
Node * whereClause
Definition: parsenodes.h:1477
List * options
Definition: parsenodes.h:2481
struct VacuumRelation VacuumRelation
RangeVar * view
Definition: parsenodes.h:3001
signed int int32
Definition: c.h:246
OnConflictClause * onConflictClause
Definition: parsenodes.h:1448
struct TruncateStmt TruncateStmt
struct CreatePLangStmt CreatePLangStmt
List * options
Definition: parsenodes.h:2102
List * windowClause
Definition: parsenodes.h:152
DropBehavior behavior
Definition: parsenodes.h:3446
JoinType
Definition: nodes.h:674
List * targetList
Definition: parsenodes.h:138
RoleSpec * newowner
Definition: parsenodes.h:1783
NodeTag type
Definition: parsenodes.h:2080
int location
Definition: parsenodes.h:299
VariableSetStmt * setstmt
Definition: parsenodes.h:3045
bool hasRecursive
Definition: parsenodes.h:128
int location
Definition: parsenodes.h:235
NodeTag type
Definition: parsenodes.h:1444
struct ParamRef ParamRef
int location
Definition: parsenodes.h:442
NodeTag type
Definition: parsenodes.h:2209
struct CreateEventTrigStmt CreateEventTrigStmt
GroupingSetKind kind
Definition: parsenodes.h:1259
struct SelectStmt SelectStmt
struct LockStmt LockStmt
List * constraints
Definition: parsenodes.h:2010
AlterSubscriptionType
Definition: parsenodes.h:3422
bool if_not_exists
Definition: parsenodes.h:2014
struct A_Expr A_Expr
struct ListenStmt ListenStmt
PartitionBoundSpec * partbound
Definition: parsenodes.h:2007
Node * cooked_default
Definition: parsenodes.h:648
struct AlterEventTrigStmt AlterEventTrigStmt
NodeTag type
Definition: parsenodes.h:1911
WithClause * withClause
Definition: parsenodes.h:1465
struct RuleStmt RuleStmt
RangeVar * constrrel
Definition: parsenodes.h:2371
Node * query
Definition: parsenodes.h:3134
NodeTag type
Definition: parsenodes.h:3313
Oid indexOid
Definition: parsenodes.h:2708
struct ClusterStmt ClusterStmt
Node * expr
Definition: parsenodes.h:689
char * newValNeighbor
Definition: parsenodes.h:2982
struct DropOwnedStmt DropOwnedStmt
uint32 AclMode
Definition: parsenodes.h:70
struct CreatedbStmt CreatedbStmt
RangeVar * relation
Definition: parsenodes.h:2700
DropBehavior behavior
Definition: parsenodes.h:2594
struct ColumnRef ColumnRef
bool is_slice
Definition: parsenodes.h:381
List * distinctClause
Definition: parsenodes.h:1511
Bitmapset * selectedCols
Definition: parsenodes.h:1055
RoleSpec * authrole
Definition: parsenodes.h:1673
List * returningList
Definition: parsenodes.h:1464
Node * startOffset
Definition: parsenodes.h:491
char * indexname
Definition: parsenodes.h:3077
NodeTag type
Definition: parsenodes.h:2341
NodeTag type
Definition: parsenodes.h:307
struct AlterTSConfigurationStmt AlterTSConfigurationStmt
SetOperation
Definition: parsenodes.h:1496
AlterTableType
Definition: parsenodes.h:1697
List * options
Definition: parsenodes.h:2204
List * rtable
Definition: parsenodes.h:135
NodeTag type
Definition: parsenodes.h:2698
struct AlterEnumStmt AlterEnumStmt
CollateClause * collClause
Definition: parsenodes.h:2510
List * distinctClause
Definition: parsenodes.h:154
struct CreateTableSpaceStmt CreateTableSpaceStmt
bool missing_ok
Definition: parsenodes.h:2810
List * args
Definition: parsenodes.h:2496
SortByNulls nulls_ordering
Definition: parsenodes.h:694
struct OnConflictClause OnConflictClause
char * policy_name
Definition: parsenodes.h:2328
List * aliases
Definition: parsenodes.h:3002
struct FunctionParameter FunctionParameter
struct UpdateStmt UpdateStmt
bool concurrent
Definition: parsenodes.h:2582
struct WindowDef * over
Definition: parsenodes.h:357
NodeTag type
Definition: parsenodes.h:1306
struct CreateFunctionStmt CreateFunctionStmt
TableFunc * tablefunc
Definition: parsenodes.h:1005
List * partitionClause
Definition: parsenodes.h:1283
struct A_ArrayExpr A_ArrayExpr
struct TriggerTransition TriggerTransition
List * coldeflist
Definition: parsenodes.h:561
Node * selectStmt
Definition: parsenodes.h:1447
bool deferrable
Definition: parsenodes.h:2085
int location
Definition: parsenodes.h:493
struct CreateTransformStmt CreateTransformStmt
char * label
Definition: parsenodes.h:2619
char * amname
Definition: parsenodes.h:2342
RangeVar * relation
Definition: parsenodes.h:1942
struct Query Query
struct CreateForeignServerStmt CreateForeignServerStmt
bool setof
Definition: parsenodes.h:210
GrantTargetType
Definition: parsenodes.h:1832
struct AlterFdwStmt AlterFdwStmt
struct A_Star A_Star
RangeVar * relation
Definition: parsenodes.h:3246
Node * endOffset
Definition: parsenodes.h:492
List * cols
Definition: parsenodes.h:1446
NodeTag type
Definition: parsenodes.h:1506
struct IndexStmt IndexStmt
RTEKind
Definition: parsenodes.h:929
List * relations
Definition: parsenodes.h:2592
List * typeName
Definition: parsenodes.h:2979
VariableSetStmt * setstmt
Definition: parsenodes.h:3066
NodeTag type
Definition: parsenodes.h:326