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