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