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