PostgreSQL Source Code  git master
parsenodes.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * parsenodes.h
4  * definitions for parse tree nodes
5  *
6  * Many of the node types used in parsetrees include a "location" field.
7  * This is a byte (not character) offset in the original source text, to be
8  * used for positioning an error cursor when there is an error related to
9  * the node. Access to the original source text is needed to make use of
10  * the location. At the topmost (statement) level, we also provide a
11  * statement length, likewise measured in bytes, for convenience in
12  * identifying statement boundaries in multi-statement source strings.
13  *
14  *
15  * Portions Copyright (c) 1996-2022, 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 #include "partitioning/partdefs.h"
30 
31 
32 typedef enum OverridingKind
33 {
38 
39 /* Possible sources of a Query */
40 typedef enum QuerySource
41 {
42  QSRC_ORIGINAL, /* original parsetree (explicit query) */
43  QSRC_PARSER, /* added by parse analysis (now unused) */
44  QSRC_INSTEAD_RULE, /* added by unconditional INSTEAD rule */
45  QSRC_QUAL_INSTEAD_RULE, /* added by conditional INSTEAD rule */
46  QSRC_NON_INSTEAD_RULE /* added by non-INSTEAD rule */
48 
49 /* Sort ordering options for ORDER BY and CREATE INDEX */
50 typedef enum SortByDir
51 {
55  SORTBY_USING /* not allowed in CREATE INDEX ... */
57 
58 typedef enum SortByNulls
59 {
64 
65 /* Options for [ ALL | DISTINCT ] */
66 typedef enum SetQuantifier
67 {
72 
73 /*
74  * Grantable rights are encoded so that we can OR them together in a bitmask.
75  * The present representation of AclItem limits us to 16 distinct rights,
76  * even though AclMode is defined as uint32. See utils/acl.h.
77  *
78  * Caution: changing these codes breaks stored ACLs, hence forces initdb.
79  */
80 typedef uint32 AclMode; /* a bitmask of privilege bits */
81 
82 #define ACL_INSERT (1<<0) /* for relations */
83 #define ACL_SELECT (1<<1)
84 #define ACL_UPDATE (1<<2)
85 #define ACL_DELETE (1<<3)
86 #define ACL_TRUNCATE (1<<4)
87 #define ACL_REFERENCES (1<<5)
88 #define ACL_TRIGGER (1<<6)
89 #define ACL_EXECUTE (1<<7) /* for functions */
90 #define ACL_USAGE (1<<8) /* for languages, namespaces, FDWs, and
91  * servers */
92 #define ACL_CREATE (1<<9) /* for namespaces and databases */
93 #define ACL_CREATE_TEMP (1<<10) /* for databases */
94 #define ACL_CONNECT (1<<11) /* for databases */
95 #define N_ACL_RIGHTS 12 /* 1 plus the last 1<<x */
96 #define ACL_NO_RIGHTS 0
97 /* Currently, SELECT ... FOR [KEY] UPDATE/SHARE requires UPDATE privileges */
98 #define ACL_SELECT_FOR_UPDATE ACL_UPDATE
99 
100 
101 /*****************************************************************************
102  * Query Tree
103  *****************************************************************************/
104 
105 /*
106  * Query -
107  * Parse analysis turns all statements into a Query tree
108  * for further processing by the rewriter and planner.
109  *
110  * Utility statements (i.e. non-optimizable statements) have the
111  * utilityStmt field set, and the rest of the Query is mostly dummy.
112  *
113  * Planning converts a Query tree into a Plan tree headed by a PlannedStmt
114  * node --- the Query structure is not used by the executor.
115  */
116 typedef struct Query
117 {
118  NodeTag type;
119 
120  CmdType commandType; /* select|insert|update|delete|utility */
121 
122  QuerySource querySource; /* where did I come from? */
123 
124  uint64 queryId; /* query identifier (can be set by plugins) */
125 
126  bool canSetTag; /* do I set the command result tag? */
127 
128  Node *utilityStmt; /* non-null if commandType == CMD_UTILITY */
129 
130  int resultRelation; /* rtable index of target relation for
131  * INSERT/UPDATE/DELETE; 0 for SELECT */
132 
133  bool hasAggs; /* has aggregates in tlist or havingQual */
134  bool hasWindowFuncs; /* has window functions in tlist */
135  bool hasTargetSRFs; /* has set-returning functions in tlist */
136  bool hasSubLinks; /* has subquery SubLink */
137  bool hasDistinctOn; /* distinctClause is from DISTINCT ON */
138  bool hasRecursive; /* WITH RECURSIVE was specified */
139  bool hasModifyingCTE; /* has INSERT/UPDATE/DELETE in WITH */
140  bool hasForUpdate; /* FOR [KEY] UPDATE/SHARE was specified */
141  bool hasRowSecurity; /* rewriter has applied some RLS policy */
142 
143  bool isReturn; /* is a RETURN statement */
144 
145  List *cteList; /* WITH list (of CommonTableExpr's) */
146 
147  List *rtable; /* list of range table entries */
148  FromExpr *jointree; /* table join tree (FROM and WHERE clauses) */
149 
150  List *targetList; /* target list (of TargetEntry) */
151 
152  OverridingKind override; /* OVERRIDING clause */
153 
154  OnConflictExpr *onConflict; /* ON CONFLICT DO [NOTHING | UPDATE] */
155 
156  List *returningList; /* return-values list (of TargetEntry) */
157 
158  List *groupClause; /* a list of SortGroupClause's */
159  bool groupDistinct; /* is the group by clause distinct? */
160 
161  List *groupingSets; /* a list of GroupingSet's if present */
162 
163  Node *havingQual; /* qualifications applied to groups */
164 
165  List *windowClause; /* a list of WindowClause's */
166 
167  List *distinctClause; /* a list of SortGroupClause's */
168 
169  List *sortClause; /* a list of SortGroupClause's */
170 
171  Node *limitOffset; /* # of result tuples to skip (int8 expr) */
172  Node *limitCount; /* # of result tuples to return (int8 expr) */
173  LimitOption limitOption; /* limit type */
174 
175  List *rowMarks; /* a list of RowMarkClause's */
176 
177  Node *setOperations; /* set-operation tree if this is top level of
178  * a UNION/INTERSECT/EXCEPT query */
179 
180  List *constraintDeps; /* a list of pg_constraint OIDs that the query
181  * depends on to be semantically valid */
182 
183  List *withCheckOptions; /* a list of WithCheckOption's (added
184  * during rewrite) */
185 
186  /*
187  * The following two fields identify the portion of the source text string
188  * containing this query. They are typically only populated in top-level
189  * Queries, not in sub-queries. When not set, they might both be zero, or
190  * both be -1 meaning "unknown".
191  */
192  int stmt_location; /* start location, or -1 if unknown */
193  int stmt_len; /* length in bytes; 0 means "rest of string" */
194 } Query;
195 
196 
197 /****************************************************************************
198  * Supporting data structures for Parse Trees
199  *
200  * Most of these node types appear in raw parsetrees output by the grammar,
201  * and get transformed to something else by the analyzer. A few of them
202  * are used as-is in transformed querytrees.
203  ****************************************************************************/
204 
205 /*
206  * TypeName - specifies a type in definitions
207  *
208  * For TypeName structures generated internally, it is often easier to
209  * specify the type by OID than by name. If "names" is NIL then the
210  * actual type OID is given by typeOid, otherwise typeOid is unused.
211  * Similarly, if "typmods" is NIL then the actual typmod is expected to
212  * be prespecified in typemod, otherwise typemod is unused.
213  *
214  * If pct_type is true, then names is actually a field name and we look up
215  * the type of that field. Otherwise (the normal case), names is a type
216  * name possibly qualified with schema and database name.
217  */
218 typedef struct TypeName
219 {
221  List *names; /* qualified name (list of String nodes) */
222  Oid typeOid; /* type identified by OID */
223  bool setof; /* is a set? */
224  bool pct_type; /* %TYPE specified? */
225  List *typmods; /* type modifier expression(s) */
226  int32 typemod; /* prespecified type modifier */
227  List *arrayBounds; /* array bounds */
228  int location; /* token location, or -1 if unknown */
229 } TypeName;
230 
231 /*
232  * ColumnRef - specifies a reference to a column, or possibly a whole tuple
233  *
234  * The "fields" list must be nonempty. It can contain String nodes
235  * (representing names) and A_Star nodes (representing occurrence of a '*').
236  * Currently, A_Star must appear only as the last list element --- the grammar
237  * is responsible for enforcing this!
238  *
239  * Note: any container subscripting or selection of fields from composite columns
240  * is represented by an A_Indirection node above the ColumnRef. However,
241  * for simplicity in the normal case, initial field selection from a table
242  * name is represented within ColumnRef and not by adding A_Indirection.
243  */
244 typedef struct ColumnRef
245 {
247  List *fields; /* field names (String nodes) or A_Star */
248  int location; /* token location, or -1 if unknown */
249 } ColumnRef;
250 
251 /*
252  * ParamRef - specifies a $n parameter reference
253  */
254 typedef struct ParamRef
255 {
257  int number; /* the number of the parameter */
258  int location; /* token location, or -1 if unknown */
259 } ParamRef;
260 
261 /*
262  * A_Expr - infix, prefix, and postfix expressions
263  */
264 typedef enum A_Expr_Kind
265 {
266  AEXPR_OP, /* normal operator */
267  AEXPR_OP_ANY, /* scalar op ANY (array) */
268  AEXPR_OP_ALL, /* scalar op ALL (array) */
269  AEXPR_DISTINCT, /* IS DISTINCT FROM - name must be "=" */
270  AEXPR_NOT_DISTINCT, /* IS NOT DISTINCT FROM - name must be "=" */
271  AEXPR_NULLIF, /* NULLIF - name must be "=" */
272  AEXPR_IN, /* [NOT] IN - name must be "=" or "<>" */
273  AEXPR_LIKE, /* [NOT] LIKE - name must be "~~" or "!~~" */
274  AEXPR_ILIKE, /* [NOT] ILIKE - name must be "~~*" or "!~~*" */
275  AEXPR_SIMILAR, /* [NOT] SIMILAR - name must be "~" or "!~" */
276  AEXPR_BETWEEN, /* name must be "BETWEEN" */
277  AEXPR_NOT_BETWEEN, /* name must be "NOT BETWEEN" */
278  AEXPR_BETWEEN_SYM, /* name must be "BETWEEN SYMMETRIC" */
279  AEXPR_NOT_BETWEEN_SYM /* name must be "NOT BETWEEN SYMMETRIC" */
280 } A_Expr_Kind;
281 
282 typedef struct A_Expr
283 {
285  A_Expr_Kind kind; /* see above */
286  List *name; /* possibly-qualified name of operator */
287  Node *lexpr; /* left argument, or NULL if none */
288  Node *rexpr; /* right argument, or NULL if none */
289  int location; /* token location, or -1 if unknown */
290 } A_Expr;
291 
292 /*
293  * A_Const - a literal constant
294  */
295 typedef struct A_Const
296 {
297  NodeTag type;
298  /*
299  * Value nodes are inline for performance. You can treat 'val' as a node,
300  * as in IsA(&val, Integer). 'val' is not valid if isnull is true.
301  */
302  union ValUnion
303  {
310  } val;
311  bool isnull; /* SQL NULL constant */
312  int location; /* token location, or -1 if unknown */
313 } A_Const;
314 
315 /*
316  * TypeCast - a CAST expression
317  */
318 typedef struct TypeCast
319 {
321  Node *arg; /* the expression being casted */
322  TypeName *typeName; /* the target type */
323  int location; /* token location, or -1 if unknown */
324 } TypeCast;
325 
326 /*
327  * CollateClause - a COLLATE expression
328  */
329 typedef struct CollateClause
330 {
332  Node *arg; /* input expression */
333  List *collname; /* possibly-qualified collation name */
334  int location; /* token location, or -1 if unknown */
335 } CollateClause;
336 
337 /*
338  * RoleSpec - a role name or one of a few special values.
339  */
340 typedef enum RoleSpecType
341 {
342  ROLESPEC_CSTRING, /* role name is stored as a C string */
343  ROLESPEC_CURRENT_ROLE, /* role spec is CURRENT_ROLE */
344  ROLESPEC_CURRENT_USER, /* role spec is CURRENT_USER */
345  ROLESPEC_SESSION_USER, /* role spec is SESSION_USER */
346  ROLESPEC_PUBLIC /* role name is "public" */
347 } RoleSpecType;
348 
349 typedef struct RoleSpec
350 {
352  RoleSpecType roletype; /* Type of this rolespec */
353  char *rolename; /* filled only for ROLESPEC_CSTRING */
354  int location; /* token location, or -1 if unknown */
355 } RoleSpec;
356 
357 /*
358  * FuncCall - a function or aggregate invocation
359  *
360  * agg_order (if not NIL) indicates we saw 'foo(... ORDER BY ...)', or if
361  * agg_within_group is true, it was 'foo(...) WITHIN GROUP (ORDER BY ...)'.
362  * agg_star indicates we saw a 'foo(*)' construct, while agg_distinct
363  * indicates we saw 'foo(DISTINCT ...)'. In any of these cases, the
364  * construct *must* be an aggregate call. Otherwise, it might be either an
365  * aggregate or some other kind of function. However, if FILTER or OVER is
366  * present it had better be an aggregate or window function.
367  *
368  * Normally, you'd initialize this via makeFuncCall() and then only change the
369  * parts of the struct its defaults don't match afterwards, as needed.
370  */
371 typedef struct FuncCall
372 {
374  List *funcname; /* qualified name of function */
375  List *args; /* the arguments (list of exprs) */
376  List *agg_order; /* ORDER BY (list of SortBy) */
377  Node *agg_filter; /* FILTER clause, if any */
378  struct WindowDef *over; /* OVER clause, if any */
379  bool agg_within_group; /* ORDER BY appeared in WITHIN GROUP */
380  bool agg_star; /* argument was really '*' */
381  bool agg_distinct; /* arguments were labeled DISTINCT */
382  bool func_variadic; /* last argument was labeled VARIADIC */
383  CoercionForm funcformat; /* how to display this node */
384  int location; /* token location, or -1 if unknown */
385 } FuncCall;
386 
387 /*
388  * A_Star - '*' representing all columns of a table or compound field
389  *
390  * This can appear within ColumnRef.fields, A_Indirection.indirection, and
391  * ResTarget.indirection lists.
392  */
393 typedef struct A_Star
394 {
396 } A_Star;
397 
398 /*
399  * A_Indices - array subscript or slice bounds ([idx] or [lidx:uidx])
400  *
401  * In slice case, either or both of lidx and uidx can be NULL (omitted).
402  * In non-slice case, uidx holds the single subscript and lidx is always NULL.
403  */
404 typedef struct A_Indices
405 {
407  bool is_slice; /* true if slice (i.e., colon present) */
408  Node *lidx; /* slice lower bound, if any */
409  Node *uidx; /* subscript, or slice upper bound if any */
410 } A_Indices;
411 
412 /*
413  * A_Indirection - select a field and/or array element from an expression
414  *
415  * The indirection list can contain A_Indices nodes (representing
416  * subscripting), String nodes (representing field selection --- the
417  * string value is the name of the field to select), and A_Star nodes
418  * (representing selection of all fields of a composite type).
419  * For example, a complex selection operation like
420  * (foo).field1[42][7].field2
421  * would be represented with a single A_Indirection node having a 4-element
422  * indirection list.
423  *
424  * Currently, A_Star must appear only as the last list element --- the grammar
425  * is responsible for enforcing this!
426  */
427 typedef struct A_Indirection
428 {
430  Node *arg; /* the thing being selected from */
431  List *indirection; /* subscripts and/or field names and/or * */
432 } A_Indirection;
433 
434 /*
435  * A_ArrayExpr - an ARRAY[] construct
436  */
437 typedef struct A_ArrayExpr
438 {
440  List *elements; /* array element expressions */
441  int location; /* token location, or -1 if unknown */
442 } A_ArrayExpr;
443 
444 /*
445  * ResTarget -
446  * result target (used in target list of pre-transformed parse trees)
447  *
448  * In a SELECT target list, 'name' is the column label from an
449  * 'AS ColumnLabel' clause, or NULL if there was none, and 'val' is the
450  * value expression itself. The 'indirection' field is not used.
451  *
452  * INSERT uses ResTarget in its target-column-names list. Here, 'name' is
453  * the name of the destination column, 'indirection' stores any subscripts
454  * attached to the destination, and 'val' is not used.
455  *
456  * In an UPDATE target list, 'name' is the name of the destination column,
457  * 'indirection' stores any subscripts attached to the destination, and
458  * 'val' is the expression to assign.
459  *
460  * See A_Indirection for more info about what can appear in 'indirection'.
461  */
462 typedef struct ResTarget
463 {
465  char *name; /* column name or NULL */
466  List *indirection; /* subscripts, field names, and '*', or NIL */
467  Node *val; /* the value expression to compute or assign */
468  int location; /* token location, or -1 if unknown */
469 } ResTarget;
470 
471 /*
472  * MultiAssignRef - element of a row source expression for UPDATE
473  *
474  * In an UPDATE target list, when we have SET (a,b,c) = row-valued-expression,
475  * we generate separate ResTarget items for each of a,b,c. Their "val" trees
476  * are MultiAssignRef nodes numbered 1..n, linking to a common copy of the
477  * row-valued-expression (which parse analysis will process only once, when
478  * handling the MultiAssignRef with colno=1).
479  */
480 typedef struct MultiAssignRef
481 {
483  Node *source; /* the row-valued expression */
484  int colno; /* column number for this target (1..n) */
485  int ncolumns; /* number of targets in the construct */
487 
488 /*
489  * SortBy - for ORDER BY clause
490  */
491 typedef struct SortBy
492 {
494  Node *node; /* expression to sort on */
495  SortByDir sortby_dir; /* ASC/DESC/USING/default */
496  SortByNulls sortby_nulls; /* NULLS FIRST/LAST */
497  List *useOp; /* name of op to use, if SORTBY_USING */
498  int location; /* operator location, or -1 if none/unknown */
499 } SortBy;
500 
501 /*
502  * WindowDef - raw representation of WINDOW and OVER clauses
503  *
504  * For entries in a WINDOW list, "name" is the window name being defined.
505  * For OVER clauses, we use "name" for the "OVER window" syntax, or "refname"
506  * for the "OVER (window)" syntax, which is subtly different --- the latter
507  * implies overriding the window frame clause.
508  */
509 typedef struct WindowDef
510 {
512  char *name; /* window's own name */
513  char *refname; /* referenced window name, if any */
514  List *partitionClause; /* PARTITION BY expression list */
515  List *orderClause; /* ORDER BY (list of SortBy) */
516  int frameOptions; /* frame_clause options, see below */
517  Node *startOffset; /* expression for starting bound, if any */
518  Node *endOffset; /* expression for ending bound, if any */
519  int location; /* parse location, or -1 if none/unknown */
520 } WindowDef;
521 
522 /*
523  * frameOptions is an OR of these bits. The NONDEFAULT and BETWEEN bits are
524  * used so that ruleutils.c can tell which properties were specified and
525  * which were defaulted; the correct behavioral bits must be set either way.
526  * The START_foo and END_foo options must come in pairs of adjacent bits for
527  * the convenience of gram.y, even though some of them are useless/invalid.
528  */
529 #define FRAMEOPTION_NONDEFAULT 0x00001 /* any specified? */
530 #define FRAMEOPTION_RANGE 0x00002 /* RANGE behavior */
531 #define FRAMEOPTION_ROWS 0x00004 /* ROWS behavior */
532 #define FRAMEOPTION_GROUPS 0x00008 /* GROUPS behavior */
533 #define FRAMEOPTION_BETWEEN 0x00010 /* BETWEEN given? */
534 #define FRAMEOPTION_START_UNBOUNDED_PRECEDING 0x00020 /* start is U. P. */
535 #define FRAMEOPTION_END_UNBOUNDED_PRECEDING 0x00040 /* (disallowed) */
536 #define FRAMEOPTION_START_UNBOUNDED_FOLLOWING 0x00080 /* (disallowed) */
537 #define FRAMEOPTION_END_UNBOUNDED_FOLLOWING 0x00100 /* end is U. F. */
538 #define FRAMEOPTION_START_CURRENT_ROW 0x00200 /* start is C. R. */
539 #define FRAMEOPTION_END_CURRENT_ROW 0x00400 /* end is C. R. */
540 #define FRAMEOPTION_START_OFFSET_PRECEDING 0x00800 /* start is O. P. */
541 #define FRAMEOPTION_END_OFFSET_PRECEDING 0x01000 /* end is O. P. */
542 #define FRAMEOPTION_START_OFFSET_FOLLOWING 0x02000 /* start is O. F. */
543 #define FRAMEOPTION_END_OFFSET_FOLLOWING 0x04000 /* end is O. F. */
544 #define FRAMEOPTION_EXCLUDE_CURRENT_ROW 0x08000 /* omit C.R. */
545 #define FRAMEOPTION_EXCLUDE_GROUP 0x10000 /* omit C.R. & peers */
546 #define FRAMEOPTION_EXCLUDE_TIES 0x20000 /* omit C.R.'s peers */
547 
548 #define FRAMEOPTION_START_OFFSET \
549  (FRAMEOPTION_START_OFFSET_PRECEDING | FRAMEOPTION_START_OFFSET_FOLLOWING)
550 #define FRAMEOPTION_END_OFFSET \
551  (FRAMEOPTION_END_OFFSET_PRECEDING | FRAMEOPTION_END_OFFSET_FOLLOWING)
552 #define FRAMEOPTION_EXCLUSION \
553  (FRAMEOPTION_EXCLUDE_CURRENT_ROW | FRAMEOPTION_EXCLUDE_GROUP | \
554  FRAMEOPTION_EXCLUDE_TIES)
555 
556 #define FRAMEOPTION_DEFAULTS \
557  (FRAMEOPTION_RANGE | FRAMEOPTION_START_UNBOUNDED_PRECEDING | \
558  FRAMEOPTION_END_CURRENT_ROW)
559 
560 /*
561  * RangeSubselect - subquery appearing in a FROM clause
562  */
563 typedef struct RangeSubselect
564 {
566  bool lateral; /* does it have LATERAL prefix? */
567  Node *subquery; /* the untransformed sub-select clause */
568  Alias *alias; /* table alias & optional column aliases */
570 
571 /*
572  * RangeFunction - function call appearing in a FROM clause
573  *
574  * functions is a List because we use this to represent the construct
575  * ROWS FROM(func1(...), func2(...), ...). Each element of this list is a
576  * two-element sublist, the first element being the untransformed function
577  * call tree, and the second element being a possibly-empty list of ColumnDef
578  * nodes representing any columndef list attached to that function within the
579  * ROWS FROM() syntax.
580  *
581  * alias and coldeflist represent any alias and/or columndef list attached
582  * at the top level. (We disallow coldeflist appearing both here and
583  * per-function, but that's checked in parse analysis, not by the grammar.)
584  */
585 typedef struct RangeFunction
586 {
588  bool lateral; /* does it have LATERAL prefix? */
589  bool ordinality; /* does it have WITH ORDINALITY suffix? */
590  bool is_rowsfrom; /* is result of ROWS FROM() syntax? */
591  List *functions; /* per-function information, see above */
592  Alias *alias; /* table alias & optional column aliases */
593  List *coldeflist; /* list of ColumnDef nodes to describe result
594  * of function returning RECORD */
595 } RangeFunction;
596 
597 /*
598  * RangeTableFunc - raw form of "table functions" such as XMLTABLE
599  */
600 typedef struct RangeTableFunc
601 {
603  bool lateral; /* does it have LATERAL prefix? */
604  Node *docexpr; /* document expression */
605  Node *rowexpr; /* row generator expression */
606  List *namespaces; /* list of namespaces as ResTarget */
607  List *columns; /* list of RangeTableFuncCol */
608  Alias *alias; /* table alias & optional column aliases */
609  int location; /* token location, or -1 if unknown */
611 
612 /*
613  * RangeTableFuncCol - one column in a RangeTableFunc->columns
614  *
615  * If for_ordinality is true (FOR ORDINALITY), then the column is an int4
616  * column and the rest of the fields are ignored.
617  */
618 typedef struct RangeTableFuncCol
619 {
621  char *colname; /* name of generated column */
622  TypeName *typeName; /* type of generated column */
623  bool for_ordinality; /* does it have FOR ORDINALITY? */
624  bool is_not_null; /* does it have NOT NULL? */
625  Node *colexpr; /* column filter expression */
626  Node *coldefexpr; /* column default value expression */
627  int location; /* token location, or -1 if unknown */
629 
630 /*
631  * RangeTableSample - TABLESAMPLE appearing in a raw FROM clause
632  *
633  * This node, appearing only in raw parse trees, represents
634  * <relation> TABLESAMPLE <method> (<params>) REPEATABLE (<num>)
635  * Currently, the <relation> can only be a RangeVar, but we might in future
636  * allow RangeSubselect and other options. Note that the RangeTableSample
637  * is wrapped around the node representing the <relation>, rather than being
638  * a subfield of it.
639  */
640 typedef struct RangeTableSample
641 {
643  Node *relation; /* relation to be sampled */
644  List *method; /* sampling method name (possibly qualified) */
645  List *args; /* argument(s) for sampling method */
646  Node *repeatable; /* REPEATABLE expression, or NULL if none */
647  int location; /* method name location, or -1 if unknown */
649 
650 /*
651  * ColumnDef - column definition (used in various creates)
652  *
653  * If the column has a default value, we may have the value expression
654  * in either "raw" form (an untransformed parse tree) or "cooked" form
655  * (a post-parse-analysis, executable expression tree), depending on
656  * how this ColumnDef node was created (by parsing, or by inheritance
657  * from an existing relation). We should never have both in the same node!
658  *
659  * Similarly, we may have a COLLATE specification in either raw form
660  * (represented as a CollateClause with arg==NULL) or cooked form
661  * (the collation's OID).
662  *
663  * The constraints list may contain a CONSTR_DEFAULT item in a raw
664  * parsetree produced by gram.y, but transformCreateStmt will remove
665  * the item and set raw_default instead. CONSTR_DEFAULT items
666  * should not appear in any subsequent processing.
667  */
668 typedef struct ColumnDef
669 {
671  char *colname; /* name of column */
672  TypeName *typeName; /* type of column */
673  char *compression; /* compression method for column */
674  int inhcount; /* number of times column is inherited */
675  bool is_local; /* column has local (non-inherited) def'n */
676  bool is_not_null; /* NOT NULL constraint specified? */
677  bool is_from_type; /* column definition came from table type */
678  char storage; /* attstorage setting, or 0 for default */
679  Node *raw_default; /* default value (untransformed parse tree) */
680  Node *cooked_default; /* default value (transformed expr tree) */
681  char identity; /* attidentity setting */
682  RangeVar *identitySequence; /* to store identity sequence name for
683  * ALTER TABLE ... ADD COLUMN */
684  char generated; /* attgenerated setting */
685  CollateClause *collClause; /* untransformed COLLATE spec, if any */
686  Oid collOid; /* collation OID (InvalidOid if not set) */
687  List *constraints; /* other constraints on column */
688  List *fdwoptions; /* per-column FDW options */
689  int location; /* parse location, or -1 if none/unknown */
690 } ColumnDef;
691 
692 /*
693  * TableLikeClause - CREATE TABLE ( ... LIKE ... ) clause
694  */
695 typedef struct TableLikeClause
696 {
699  bits32 options; /* OR of TableLikeOption flags */
700  Oid relationOid; /* If table has been looked up, its OID */
702 
703 typedef enum TableLikeOption
704 {
713  CREATE_TABLE_LIKE_STORAGE = 1 << 8,
716 
717 /*
718  * IndexElem - index parameters (used in CREATE INDEX, and in ON CONFLICT)
719  *
720  * For a plain index attribute, 'name' is the name of the table column to
721  * index, and 'expr' is NULL. For an index expression, 'name' is NULL and
722  * 'expr' is the expression tree.
723  */
724 typedef struct IndexElem
725 {
727  char *name; /* name of attribute to index, or NULL */
728  Node *expr; /* expression to index, or NULL */
729  char *indexcolname; /* name for index column; NULL = default */
730  List *collation; /* name of collation; NIL = default */
731  List *opclass; /* name of desired opclass; NIL = default */
732  List *opclassopts; /* opclass-specific options, or NIL */
733  SortByDir ordering; /* ASC/DESC/default */
734  SortByNulls nulls_ordering; /* FIRST/LAST/default */
735 } IndexElem;
736 
737 /*
738  * DefElem - a generic "name = value" option definition
739  *
740  * In some contexts the name can be qualified. Also, certain SQL commands
741  * allow a SET/ADD/DROP action to be attached to option settings, so it's
742  * convenient to carry a field for that too. (Note: currently, it is our
743  * practice that the grammar allows namespace and action only in statements
744  * where they are relevant; C code can just ignore those fields in other
745  * statements.)
746  */
747 typedef enum DefElemAction
748 {
749  DEFELEM_UNSPEC, /* no action given */
751  DEFELEM_ADD,
753 } DefElemAction;
754 
755 typedef struct DefElem
756 {
758  char *defnamespace; /* NULL if unqualified name */
759  char *defname;
760  Node *arg; /* typically Integer, Float, String, or TypeName */
761  DefElemAction defaction; /* unspecified action, or SET/ADD/DROP */
762  int location; /* token location, or -1 if unknown */
763 } DefElem;
764 
765 /*
766  * LockingClause - raw representation of FOR [NO KEY] UPDATE/[KEY] SHARE
767  * options
768  *
769  * Note: lockedRels == NIL means "all relations in query". Otherwise it
770  * is a list of RangeVar nodes. (We use RangeVar mainly because it carries
771  * a location field --- currently, parse analysis insists on unqualified
772  * names in LockingClause.)
773  */
774 typedef struct LockingClause
775 {
777  List *lockedRels; /* FOR [KEY] UPDATE/SHARE relations */
779  LockWaitPolicy waitPolicy; /* NOWAIT and SKIP LOCKED */
780 } LockingClause;
781 
782 /*
783  * XMLSERIALIZE (in raw parse tree only)
784  */
785 typedef struct XmlSerialize
786 {
788  XmlOptionType xmloption; /* DOCUMENT or CONTENT */
791  int location; /* token location, or -1 if unknown */
792 } XmlSerialize;
793 
794 /* Partitioning related definitions */
795 
796 /*
797  * PartitionElem - parse-time representation of a single partition key
798  *
799  * expr can be either a raw expression tree or a parse-analyzed expression.
800  * We don't store these on-disk, though.
801  */
802 typedef struct PartitionElem
803 {
805  char *name; /* name of column to partition on, or NULL */
806  Node *expr; /* expression to partition on, or NULL */
807  List *collation; /* name of collation; NIL = default */
808  List *opclass; /* name of desired opclass; NIL = default */
809  int location; /* token location, or -1 if unknown */
810 } PartitionElem;
811 
812 /*
813  * PartitionSpec - parse-time representation of a partition key specification
814  *
815  * This represents the key space we will be partitioning on.
816  */
817 typedef struct PartitionSpec
818 {
820  char *strategy; /* partitioning strategy ('hash', 'list' or
821  * 'range') */
822  List *partParams; /* List of PartitionElems */
823  int location; /* token location, or -1 if unknown */
824 } PartitionSpec;
825 
826 /* Internal codes for partitioning strategies */
827 #define PARTITION_STRATEGY_HASH 'h'
828 #define PARTITION_STRATEGY_LIST 'l'
829 #define PARTITION_STRATEGY_RANGE 'r'
830 
831 /*
832  * PartitionBoundSpec - a partition bound specification
833  *
834  * This represents the portion of the partition key space assigned to a
835  * particular partition. These are stored on disk in pg_class.relpartbound.
836  */
837 struct PartitionBoundSpec
838 {
839  NodeTag type;
840 
841  char strategy; /* see PARTITION_STRATEGY codes above */
842  bool is_default; /* is it a default partition bound? */
843 
844  /* Partitioning info for HASH strategy: */
845  int modulus;
846  int remainder;
847 
848  /* Partitioning info for LIST strategy: */
849  List *listdatums; /* List of Consts (or A_Consts in raw tree) */
850 
851  /* Partitioning info for RANGE strategy: */
852  List *lowerdatums; /* List of PartitionRangeDatums */
853  List *upperdatums; /* List of PartitionRangeDatums */
854 
855  int location; /* token location, or -1 if unknown */
856 };
857 
858 /*
859  * PartitionRangeDatum - one of the values in a range partition bound
860  *
861  * This can be MINVALUE, MAXVALUE or a specific bounded value.
862  */
863 typedef enum PartitionRangeDatumKind
864 {
865  PARTITION_RANGE_DATUM_MINVALUE = -1, /* less than any other value */
866  PARTITION_RANGE_DATUM_VALUE = 0, /* a specific (bounded) value */
867  PARTITION_RANGE_DATUM_MAXVALUE = 1 /* greater than any other value */
869 
870 typedef struct PartitionRangeDatum
871 {
872  NodeTag type;
873 
875  Node *value; /* Const (or A_Const in raw tree), if kind is
876  * PARTITION_RANGE_DATUM_VALUE, else NULL */
877 
878  int location; /* token location, or -1 if unknown */
880 
881 /*
882  * PartitionCmd - info for ALTER TABLE/INDEX ATTACH/DETACH PARTITION commands
883  */
884 typedef struct PartitionCmd
885 {
887  RangeVar *name; /* name of partition to attach/detach */
888  PartitionBoundSpec *bound; /* FOR VALUES, if attaching */
890 } PartitionCmd;
891 
892 /****************************************************************************
893  * Nodes for a Query tree
894  ****************************************************************************/
895 
896 /*--------------------
897  * RangeTblEntry -
898  * A range table is a List of RangeTblEntry nodes.
899  *
900  * A range table entry may represent a plain relation, a sub-select in
901  * FROM, or the result of a JOIN clause. (Only explicit JOIN syntax
902  * produces an RTE, not the implicit join resulting from multiple FROM
903  * items. This is because we only need the RTE to deal with SQL features
904  * like outer joins and join-output-column aliasing.) Other special
905  * RTE types also exist, as indicated by RTEKind.
906  *
907  * Note that we consider RTE_RELATION to cover anything that has a pg_class
908  * entry. relkind distinguishes the sub-cases.
909  *
910  * alias is an Alias node representing the AS alias-clause attached to the
911  * FROM expression, or NULL if no clause.
912  *
913  * eref is the table reference name and column reference names (either
914  * real or aliases). Note that system columns (OID etc) are not included
915  * in the column list.
916  * eref->aliasname is required to be present, and should generally be used
917  * to identify the RTE for error messages etc.
918  *
919  * In RELATION RTEs, the colnames in both alias and eref are indexed by
920  * physical attribute number; this means there must be colname entries for
921  * dropped columns. When building an RTE we insert empty strings ("") for
922  * dropped columns. Note however that a stored rule may have nonempty
923  * colnames for columns dropped since the rule was created (and for that
924  * matter the colnames might be out of date due to column renamings).
925  * The same comments apply to FUNCTION RTEs when a function's return type
926  * is a named composite type.
927  *
928  * In JOIN RTEs, the colnames in both alias and eref are one-to-one with
929  * joinaliasvars entries. A JOIN RTE will omit columns of its inputs when
930  * those columns are known to be dropped at parse time. Again, however,
931  * a stored rule might contain entries for columns dropped since the rule
932  * was created. (This is only possible for columns not actually referenced
933  * in the rule.) When loading a stored rule, we replace the joinaliasvars
934  * items for any such columns with null pointers. (We can't simply delete
935  * them from the joinaliasvars list, because that would affect the attnums
936  * of Vars referencing the rest of the list.)
937  *
938  * inh is true for relation references that should be expanded to include
939  * inheritance children, if the rel has any. This *must* be false for
940  * RTEs other than RTE_RELATION entries.
941  *
942  * inFromCl marks those range variables that are listed in the FROM clause.
943  * It's false for RTEs that are added to a query behind the scenes, such
944  * as the NEW and OLD variables for a rule, or the subqueries of a UNION.
945  * This flag is not used during parsing (except in transformLockingClause,
946  * q.v.); the parser now uses a separate "namespace" data structure to
947  * control visibility. But it is needed by ruleutils.c to determine
948  * whether RTEs should be shown in decompiled queries.
949  *
950  * requiredPerms and checkAsUser specify run-time access permissions
951  * checks to be performed at query startup. The user must have *all*
952  * of the permissions that are OR'd together in requiredPerms (zero
953  * indicates no permissions checking). If checkAsUser is not zero,
954  * then do the permissions checks using the access rights of that user,
955  * not the current effective user ID. (This allows rules to act as
956  * setuid gateways.) Permissions checks only apply to RELATION RTEs.
957  *
958  * For SELECT/INSERT/UPDATE permissions, if the user doesn't have
959  * table-wide permissions then it is sufficient to have the permissions
960  * on all columns identified in selectedCols (for SELECT) and/or
961  * insertedCols and/or updatedCols (INSERT with ON CONFLICT DO UPDATE may
962  * have all 3). selectedCols, insertedCols and updatedCols are bitmapsets,
963  * which cannot have negative integer members, so we subtract
964  * FirstLowInvalidHeapAttributeNumber from column numbers before storing
965  * them in these fields. A whole-row Var reference is represented by
966  * setting the bit for InvalidAttrNumber.
967  *
968  * updatedCols is also used in some other places, for example, to determine
969  * which triggers to fire and in FDWs to know which changed columns they
970  * need to ship off.
971  *
972  * Generated columns that are caused to be updated by an update to a base
973  * column are listed in extraUpdatedCols. This is not considered for
974  * permission checking, but it is useful in those places that want to know
975  * the full set of columns being updated as opposed to only the ones the
976  * user explicitly mentioned in the query. (There is currently no need for
977  * an extraInsertedCols, but it could exist.) Note that extraUpdatedCols
978  * is populated during query rewrite, NOT in the parser, since generated
979  * columns could be added after a rule has been parsed and stored.
980  *
981  * securityQuals is a list of security barrier quals (boolean expressions),
982  * to be tested in the listed order before returning a row from the
983  * relation. It is always NIL in parser output. Entries are added by the
984  * rewriter to implement security-barrier views and/or row-level security.
985  * Note that the planner turns each boolean expression into an implicitly
986  * AND'ed sublist, as is its usual habit with qualification expressions.
987  *--------------------
988  */
989 typedef enum RTEKind
990 {
991  RTE_RELATION, /* ordinary relation reference */
992  RTE_SUBQUERY, /* subquery in FROM */
993  RTE_JOIN, /* join */
994  RTE_FUNCTION, /* function in FROM */
995  RTE_TABLEFUNC, /* TableFunc(.., column list) */
996  RTE_VALUES, /* VALUES (<exprlist>), (<exprlist>), ... */
997  RTE_CTE, /* common table expr (WITH list element) */
998  RTE_NAMEDTUPLESTORE, /* tuplestore, e.g. for AFTER triggers */
999  RTE_RESULT /* RTE represents an empty FROM clause; such
1000  * RTEs are added by the planner, they're not
1001  * present during parsing or rewriting */
1002 } RTEKind;
1004 typedef struct RangeTblEntry
1006  NodeTag type;
1008  RTEKind rtekind; /* see above */
1009 
1010  /*
1011  * XXX the fields applicable to only some rte kinds should be merged into
1012  * a union. I didn't do this yet because the diffs would impact a lot of
1013  * code that is being actively worked on. FIXME someday.
1014  */
1015 
1016  /*
1017  * Fields valid for a plain relation RTE (else zero):
1018  *
1019  * As a special case, RTE_NAMEDTUPLESTORE can also set relid to indicate
1020  * that the tuple format of the tuplestore is the same as the referenced
1021  * relation. This allows plans referencing AFTER trigger transition
1022  * tables to be invalidated if the underlying table is altered.
1023  *
1024  * rellockmode is really LOCKMODE, but it's declared int to avoid having
1025  * to include lock-related headers here. It must be RowExclusiveLock if
1026  * the RTE is an INSERT/UPDATE/DELETE target, else RowShareLock if the RTE
1027  * is a SELECT FOR UPDATE/FOR SHARE target, else AccessShareLock.
1028  *
1029  * Note: in some cases, rule expansion may result in RTEs that are marked
1030  * with RowExclusiveLock even though they are not the target of the
1031  * current query; this happens if a DO ALSO rule simply scans the original
1032  * target table. We leave such RTEs with their original lockmode so as to
1033  * avoid getting an additional, lesser lock.
1034  */
1035  Oid relid; /* OID of the relation */
1036  char relkind; /* relation kind (see pg_class.relkind) */
1037  int rellockmode; /* lock level that query requires on the rel */
1038  struct TableSampleClause *tablesample; /* sampling info, or NULL */
1039 
1040  /*
1041  * Fields valid for a subquery RTE (else NULL):
1042  */
1043  Query *subquery; /* the sub-query */
1044  bool security_barrier; /* is from security_barrier view? */
1045 
1046  /*
1047  * Fields valid for a join RTE (else NULL/zero):
1048  *
1049  * joinaliasvars is a list of (usually) Vars corresponding to the columns
1050  * of the join result. An alias Var referencing column K of the join
1051  * result can be replaced by the K'th element of joinaliasvars --- but to
1052  * simplify the task of reverse-listing aliases correctly, we do not do
1053  * that until planning time. In detail: an element of joinaliasvars can
1054  * be a Var of one of the join's input relations, or such a Var with an
1055  * implicit coercion to the join's output column type, or a COALESCE
1056  * expression containing the two input column Vars (possibly coerced).
1057  * Elements beyond the first joinmergedcols entries are always just Vars,
1058  * and are never referenced from elsewhere in the query (that is, join
1059  * alias Vars are generated only for merged columns). We keep these
1060  * entries only because they're needed in expandRTE() and similar code.
1061  *
1062  * Within a Query loaded from a stored rule, it is possible for non-merged
1063  * joinaliasvars items to be null pointers, which are placeholders for
1064  * (necessarily unreferenced) columns dropped since the rule was made.
1065  * Also, once planning begins, joinaliasvars items can be almost anything,
1066  * as a result of subquery-flattening substitutions.
1067  *
1068  * joinleftcols is an integer list of physical column numbers of the left
1069  * join input rel that are included in the join; likewise joinrighttcols
1070  * for the right join input rel. (Which rels those are can be determined
1071  * from the associated JoinExpr.) If the join is USING/NATURAL, then the
1072  * first joinmergedcols entries in each list identify the merged columns.
1073  * The merged columns come first in the join output, then remaining
1074  * columns of the left input, then remaining columns of the right.
1075  *
1076  * Note that input columns could have been dropped after creation of a
1077  * stored rule, if they are not referenced in the query (in particular,
1078  * merged columns could not be dropped); this is not accounted for in
1079  * joinleftcols/joinrighttcols.
1080  */
1081  JoinType jointype; /* type of join */
1082  int joinmergedcols; /* number of merged (JOIN USING) columns */
1083  List *joinaliasvars; /* list of alias-var expansions */
1084  List *joinleftcols; /* left-side input column numbers */
1085  List *joinrightcols; /* right-side input column numbers */
1086 
1087  /*
1088  * join_using_alias is an alias clause attached directly to JOIN/USING. It
1089  * is different from the alias field (below) in that it does not hide the
1090  * range variables of the tables being joined.
1091  */
1093 
1094  /*
1095  * Fields valid for a function RTE (else NIL/zero):
1096  *
1097  * When funcordinality is true, the eref->colnames list includes an alias
1098  * for the ordinality column. The ordinality column is otherwise
1099  * implicit, and must be accounted for "by hand" in places such as
1100  * expandRTE().
1101  */
1102  List *functions; /* list of RangeTblFunction nodes */
1103  bool funcordinality; /* is this called WITH ORDINALITY? */
1104 
1105  /*
1106  * Fields valid for a TableFunc RTE (else NULL):
1107  */
1109 
1110  /*
1111  * Fields valid for a values RTE (else NIL):
1112  */
1113  List *values_lists; /* list of expression lists */
1114 
1115  /*
1116  * Fields valid for a CTE RTE (else NULL/zero):
1117  */
1118  char *ctename; /* name of the WITH list item */
1119  Index ctelevelsup; /* number of query levels up */
1120  bool self_reference; /* is this a recursive self-reference? */
1121 
1122  /*
1123  * Fields valid for CTE, VALUES, ENR, and TableFunc RTEs (else NIL):
1124  *
1125  * We need these for CTE RTEs so that the types of self-referential
1126  * columns are well-defined. For VALUES RTEs, storing these explicitly
1127  * saves having to re-determine the info by scanning the values_lists. For
1128  * ENRs, we store the types explicitly here (we could get the information
1129  * from the catalogs if 'relid' was supplied, but we'd still need these
1130  * for TupleDesc-based ENRs, so we might as well always store the type
1131  * info here). For TableFuncs, these fields are redundant with data in
1132  * the TableFunc node, but keeping them here allows some code sharing with
1133  * the other cases.
1134  *
1135  * For ENRs only, we have to consider the possibility of dropped columns.
1136  * A dropped column is included in these lists, but it will have zeroes in
1137  * all three lists (as well as an empty-string entry in eref). Testing
1138  * for zero coltype is the standard way to detect a dropped column.
1139  */
1140  List *coltypes; /* OID list of column type OIDs */
1141  List *coltypmods; /* integer list of column typmods */
1142  List *colcollations; /* OID list of column collation OIDs */
1143 
1144  /*
1145  * Fields valid for ENR RTEs (else NULL/zero):
1146  */
1147  char *enrname; /* name of ephemeral named relation */
1148  Cardinality enrtuples; /* estimated or actual from caller */
1149 
1150  /*
1151  * Fields valid in all RTEs:
1152  */
1153  Alias *alias; /* user-written alias clause, if any */
1154  Alias *eref; /* expanded reference names */
1155  bool lateral; /* subquery, function, or values is LATERAL? */
1156  bool inh; /* inheritance requested? */
1157  bool inFromCl; /* present in FROM clause? */
1158  AclMode requiredPerms; /* bitmask of required access permissions */
1159  Oid checkAsUser; /* if valid, check access as this role */
1160  Bitmapset *selectedCols; /* columns needing SELECT permission */
1161  Bitmapset *insertedCols; /* columns needing INSERT permission */
1162  Bitmapset *updatedCols; /* columns needing UPDATE permission */
1163  Bitmapset *extraUpdatedCols; /* generated columns being updated */
1164  List *securityQuals; /* security barrier quals to apply, if any */
1165 } RangeTblEntry;
1166 
1167 /*
1168  * RangeTblFunction -
1169  * RangeTblEntry subsidiary data for one function in a FUNCTION RTE.
1170  *
1171  * If the function had a column definition list (required for an
1172  * otherwise-unspecified RECORD result), funccolnames lists the names given
1173  * in the definition list, funccoltypes lists their declared column types,
1174  * funccoltypmods lists their typmods, funccolcollations their collations.
1175  * Otherwise, those fields are NIL.
1176  *
1177  * Notice we don't attempt to store info about the results of functions
1178  * returning named composite types, because those can change from time to
1179  * time. We do however remember how many columns we thought the type had
1180  * (including dropped columns!), so that we can successfully ignore any
1181  * columns added after the query was parsed.
1182  */
1183 typedef struct RangeTblFunction
1185  NodeTag type;
1187  Node *funcexpr; /* expression tree for func call */
1188  int funccolcount; /* number of columns it contributes to RTE */
1189  /* These fields record the contents of a column definition list, if any: */
1190  List *funccolnames; /* column names (list of String) */
1191  List *funccoltypes; /* OID list of column type OIDs */
1192  List *funccoltypmods; /* integer list of column typmods */
1193  List *funccolcollations; /* OID list of column collation OIDs */
1194  /* This is set during planning for use by the executor: */
1195  Bitmapset *funcparams; /* PARAM_EXEC Param IDs affecting this func */
1197 
1198 /*
1199  * TableSampleClause - TABLESAMPLE appearing in a transformed FROM clause
1200  *
1201  * Unlike RangeTableSample, this is a subnode of the relevant RangeTblEntry.
1202  */
1203 typedef struct TableSampleClause
1206  Oid tsmhandler; /* OID of the tablesample handler function */
1207  List *args; /* tablesample argument expression(s) */
1208  Expr *repeatable; /* REPEATABLE expression, or NULL if none */
1210 
1211 /*
1212  * WithCheckOption -
1213  * representation of WITH CHECK OPTION checks to be applied to new tuples
1214  * when inserting/updating an auto-updatable view, or RLS WITH CHECK
1215  * policies to be applied when inserting/updating a relation with RLS.
1216  */
1217 typedef enum WCOKind
1219  WCO_VIEW_CHECK, /* WCO on an auto-updatable view */
1220  WCO_RLS_INSERT_CHECK, /* RLS INSERT WITH CHECK policy */
1221  WCO_RLS_UPDATE_CHECK, /* RLS UPDATE WITH CHECK policy */
1222  WCO_RLS_CONFLICT_CHECK /* RLS ON CONFLICT DO UPDATE USING policy */
1223 } WCOKind;
1225 typedef struct WithCheckOption
1228  WCOKind kind; /* kind of WCO */
1229  char *relname; /* name of relation that specified the WCO */
1230  char *polname; /* name of RLS policy being checked */
1231  Node *qual; /* constraint qual to check */
1232  bool cascaded; /* true for a cascaded WCO on a view */
1233 } WithCheckOption;
1234 
1235 /*
1236  * SortGroupClause -
1237  * representation of ORDER BY, GROUP BY, PARTITION BY,
1238  * DISTINCT, DISTINCT ON items
1239  *
1240  * You might think that ORDER BY is only interested in defining ordering,
1241  * and GROUP/DISTINCT are only interested in defining equality. However,
1242  * one way to implement grouping is to sort and then apply a "uniq"-like
1243  * filter. So it's also interesting to keep track of possible sort operators
1244  * for GROUP/DISTINCT, and in particular to try to sort for the grouping
1245  * in a way that will also yield a requested ORDER BY ordering. So we need
1246  * to be able to compare ORDER BY and GROUP/DISTINCT lists, which motivates
1247  * the decision to give them the same representation.
1248  *
1249  * tleSortGroupRef must match ressortgroupref of exactly one entry of the
1250  * query's targetlist; that is the expression to be sorted or grouped by.
1251  * eqop is the OID of the equality operator.
1252  * sortop is the OID of the ordering operator (a "<" or ">" operator),
1253  * or InvalidOid if not available.
1254  * nulls_first means about what you'd expect. If sortop is InvalidOid
1255  * then nulls_first is meaningless and should be set to false.
1256  * hashable is true if eqop is hashable (note this condition also depends
1257  * on the datatype of the input expression).
1258  *
1259  * In an ORDER BY item, all fields must be valid. (The eqop isn't essential
1260  * here, but it's cheap to get it along with the sortop, and requiring it
1261  * to be valid eases comparisons to grouping items.) Note that this isn't
1262  * actually enough information to determine an ordering: if the sortop is
1263  * collation-sensitive, a collation OID is needed too. We don't store the
1264  * collation in SortGroupClause because it's not available at the time the
1265  * parser builds the SortGroupClause; instead, consult the exposed collation
1266  * of the referenced targetlist expression to find out what it is.
1267  *
1268  * In a grouping item, eqop must be valid. If the eqop is a btree equality
1269  * operator, then sortop should be set to a compatible ordering operator.
1270  * We prefer to set eqop/sortop/nulls_first to match any ORDER BY item that
1271  * the query presents for the same tlist item. If there is none, we just
1272  * use the default ordering op for the datatype.
1273  *
1274  * If the tlist item's type has a hash opclass but no btree opclass, then
1275  * we will set eqop to the hash equality operator, sortop to InvalidOid,
1276  * and nulls_first to false. A grouping item of this kind can only be
1277  * implemented by hashing, and of course it'll never match an ORDER BY item.
1278  *
1279  * The hashable flag is provided since we generally have the requisite
1280  * information readily available when the SortGroupClause is constructed,
1281  * and it's relatively expensive to get it again later. Note there is no
1282  * need for a "sortable" flag since OidIsValid(sortop) serves the purpose.
1283  *
1284  * A query might have both ORDER BY and DISTINCT (or DISTINCT ON) clauses.
1285  * In SELECT DISTINCT, the distinctClause list is as long or longer than the
1286  * sortClause list, while in SELECT DISTINCT ON it's typically shorter.
1287  * The two lists must match up to the end of the shorter one --- the parser
1288  * rearranges the distinctClause if necessary to make this true. (This
1289  * restriction ensures that only one sort step is needed to both satisfy the
1290  * ORDER BY and set up for the Unique step. This is semantically necessary
1291  * for DISTINCT ON, and presents no real drawback for DISTINCT.)
1292  */
1293 typedef struct SortGroupClause
1296  Index tleSortGroupRef; /* reference into targetlist */
1297  Oid eqop; /* the equality operator ('=' op) */
1298  Oid sortop; /* the ordering operator ('<' op), or 0 */
1299  bool nulls_first; /* do NULLs come before normal values? */
1300  bool hashable; /* can eqop be implemented by hashing? */
1301 } SortGroupClause;
1302 
1303 /*
1304  * GroupingSet -
1305  * representation of CUBE, ROLLUP and GROUPING SETS clauses
1306  *
1307  * In a Query with grouping sets, the groupClause contains a flat list of
1308  * SortGroupClause nodes for each distinct expression used. The actual
1309  * structure of the GROUP BY clause is given by the groupingSets tree.
1310  *
1311  * In the raw parser output, GroupingSet nodes (of all types except SIMPLE
1312  * which is not used) are potentially mixed in with the expressions in the
1313  * groupClause of the SelectStmt. (An expression can't contain a GroupingSet,
1314  * but a list may mix GroupingSet and expression nodes.) At this stage, the
1315  * content of each node is a list of expressions, some of which may be RowExprs
1316  * which represent sublists rather than actual row constructors, and nested
1317  * GroupingSet nodes where legal in the grammar. The structure directly
1318  * reflects the query syntax.
1319  *
1320  * In parse analysis, the transformed expressions are used to build the tlist
1321  * and groupClause list (of SortGroupClause nodes), and the groupingSets tree
1322  * is eventually reduced to a fixed format:
1323  *
1324  * EMPTY nodes represent (), and obviously have no content
1325  *
1326  * SIMPLE nodes represent a list of one or more expressions to be treated as an
1327  * atom by the enclosing structure; the content is an integer list of
1328  * ressortgroupref values (see SortGroupClause)
1329  *
1330  * CUBE and ROLLUP nodes contain a list of one or more SIMPLE nodes.
1331  *
1332  * SETS nodes contain a list of EMPTY, SIMPLE, CUBE or ROLLUP nodes, but after
1333  * parse analysis they cannot contain more SETS nodes; enough of the syntactic
1334  * transforms of the spec have been applied that we no longer have arbitrarily
1335  * deep nesting (though we still preserve the use of cube/rollup).
1336  *
1337  * Note that if the groupingSets tree contains no SIMPLE nodes (only EMPTY
1338  * nodes at the leaves), then the groupClause will be empty, but this is still
1339  * an aggregation query (similar to using aggs or HAVING without GROUP BY).
1340  *
1341  * As an example, the following clause:
1342  *
1343  * GROUP BY GROUPING SETS ((a,b), CUBE(c,(d,e)))
1344  *
1345  * looks like this after raw parsing:
1346  *
1347  * SETS( RowExpr(a,b) , CUBE( c, RowExpr(d,e) ) )
1348  *
1349  * and parse analysis converts it to:
1350  *
1351  * SETS( SIMPLE(1,2), CUBE( SIMPLE(3), SIMPLE(4,5) ) )
1352  */
1353 typedef enum GroupingSetKind
1360 } GroupingSetKind;
1362 typedef struct GroupingSet
1368 } GroupingSet;
1369 
1370 /*
1371  * WindowClause -
1372  * transformed representation of WINDOW and OVER clauses
1373  *
1374  * A parsed Query's windowClause list contains these structs. "name" is set
1375  * if the clause originally came from WINDOW, and is NULL if it originally
1376  * was an OVER clause (but note that we collapse out duplicate OVERs).
1377  * partitionClause and orderClause are lists of SortGroupClause structs.
1378  * If we have RANGE with offset PRECEDING/FOLLOWING, the semantics of that are
1379  * specified by startInRangeFunc/inRangeColl/inRangeAsc/inRangeNullsFirst
1380  * for the start offset, or endInRangeFunc/inRange* for the end offset.
1381  * winref is an ID number referenced by WindowFunc nodes; it must be unique
1382  * among the members of a Query's windowClause list.
1383  * When refname isn't null, the partitionClause is always copied from there;
1384  * the orderClause might or might not be copied (see copiedOrder); the framing
1385  * options are never copied, per spec.
1386  */
1387 typedef struct WindowClause
1390  char *name; /* window name (NULL in an OVER clause) */
1391  char *refname; /* referenced window name, if any */
1392  List *partitionClause; /* PARTITION BY list */
1393  List *orderClause; /* ORDER BY list */
1394  int frameOptions; /* frame_clause options, see WindowDef */
1395  Node *startOffset; /* expression for starting bound, if any */
1396  Node *endOffset; /* expression for ending bound, if any */
1397  Oid startInRangeFunc; /* in_range function for startOffset */
1398  Oid endInRangeFunc; /* in_range function for endOffset */
1399  Oid inRangeColl; /* collation for in_range tests */
1400  bool inRangeAsc; /* use ASC sort order for in_range tests? */
1401  bool inRangeNullsFirst; /* nulls sort first for in_range tests? */
1402  Index winref; /* ID referenced by window functions */
1403  bool copiedOrder; /* did we copy orderClause from refname? */
1404 } WindowClause;
1405 
1406 /*
1407  * RowMarkClause -
1408  * parser output representation of FOR [KEY] UPDATE/SHARE clauses
1409  *
1410  * Query.rowMarks contains a separate RowMarkClause node for each relation
1411  * identified as a FOR [KEY] UPDATE/SHARE target. If one of these clauses
1412  * is applied to a subquery, we generate RowMarkClauses for all normal and
1413  * subquery rels in the subquery, but they are marked pushedDown = true to
1414  * distinguish them from clauses that were explicitly written at this query
1415  * level. Also, Query.hasForUpdate tells whether there were explicit FOR
1416  * UPDATE/SHARE/KEY SHARE clauses in the current query level.
1417  */
1418 typedef struct RowMarkClause
1421  Index rti; /* range table index of target relation */
1423  LockWaitPolicy waitPolicy; /* NOWAIT and SKIP LOCKED */
1424  bool pushedDown; /* pushed down from higher query level? */
1425 } RowMarkClause;
1426 
1427 /*
1428  * WithClause -
1429  * representation of WITH clause
1430  *
1431  * Note: WithClause does not propagate into the Query representation;
1432  * but CommonTableExpr does.
1433  */
1434 typedef struct WithClause
1437  List *ctes; /* list of CommonTableExprs */
1438  bool recursive; /* true = WITH RECURSIVE */
1439  int location; /* token location, or -1 if unknown */
1440 } WithClause;
1441 
1442 /*
1443  * InferClause -
1444  * ON CONFLICT unique index inference clause
1445  *
1446  * Note: InferClause does not propagate into the Query representation.
1447  */
1448 typedef struct InferClause
1451  List *indexElems; /* IndexElems to infer unique index */
1452  Node *whereClause; /* qualification (partial-index predicate) */
1453  char *conname; /* Constraint name, or NULL if unnamed */
1454  int location; /* token location, or -1 if unknown */
1455 } InferClause;
1456 
1457 /*
1458  * OnConflictClause -
1459  * representation of ON CONFLICT clause
1460  *
1461  * Note: OnConflictClause does not propagate into the Query representation.
1462  */
1463 typedef struct OnConflictClause
1466  OnConflictAction action; /* DO NOTHING or UPDATE? */
1467  InferClause *infer; /* Optional index inference clause */
1468  List *targetList; /* the target list (of ResTarget) */
1469  Node *whereClause; /* qualifications */
1470  int location; /* token location, or -1 if unknown */
1472 
1473 /*
1474  * CommonTableExpr -
1475  * representation of WITH list element
1476  */
1478 typedef enum CTEMaterialize
1480  CTEMaterializeDefault, /* no option specified */
1481  CTEMaterializeAlways, /* MATERIALIZED */
1482  CTEMaterializeNever /* NOT MATERIALIZED */
1483 } CTEMaterialize;
1485 typedef struct CTESearchClause
1492 } CTESearchClause;
1494 typedef struct CTECycleClause
1502  int location;
1503  /* These fields are set during parse analysis: */
1504  Oid cycle_mark_type; /* common type of _value and _default */
1507  Oid cycle_mark_neop; /* <> operator for type */
1508 } CTECycleClause;
1510 typedef struct CommonTableExpr
1513  char *ctename; /* query name (never qualified) */
1514  List *aliascolnames; /* optional list of column names */
1515  CTEMaterialize ctematerialized; /* is this an optimization fence? */
1516  /* SelectStmt/InsertStmt/etc before parse analysis, Query afterwards: */
1517  Node *ctequery; /* the CTE's subquery */
1520  int location; /* token location, or -1 if unknown */
1521  /* These fields are set during parse analysis: */
1522  bool cterecursive; /* is this CTE actually recursive? */
1523  int cterefcount; /* number of RTEs referencing this CTE
1524  * (excluding internal self-references) */
1525  List *ctecolnames; /* list of output column names */
1526  List *ctecoltypes; /* OID list of output column type OIDs */
1527  List *ctecoltypmods; /* integer list of output column typmods */
1528  List *ctecolcollations; /* OID list of column collation OIDs */
1529 } CommonTableExpr;
1530 
1531 /* Convenience macro to get the output tlist of a CTE's query */
1532 #define GetCTETargetList(cte) \
1533  (AssertMacro(IsA((cte)->ctequery, Query)), \
1534  ((Query *) (cte)->ctequery)->commandType == CMD_SELECT ? \
1535  ((Query *) (cte)->ctequery)->targetList : \
1536  ((Query *) (cte)->ctequery)->returningList)
1537 
1538 /*
1539  * TriggerTransition -
1540  * representation of transition row or table naming clause
1541  *
1542  * Only transition tables are initially supported in the syntax, and only for
1543  * AFTER triggers, but other permutations are accepted by the parser so we can
1544  * give a meaningful message from C code.
1545  */
1546 typedef struct TriggerTransition
1549  char *name;
1550  bool isNew;
1551  bool isTable;
1553 
1554 /*****************************************************************************
1555  * Raw Grammar Output Statements
1556  *****************************************************************************/
1557 
1558 /*
1559  * RawStmt --- container for any one statement's raw parse tree
1560  *
1561  * Parse analysis converts a raw parse tree headed by a RawStmt node into
1562  * an analyzed statement headed by a Query node. For optimizable statements,
1563  * the conversion is complex. For utility statements, the parser usually just
1564  * transfers the raw parse tree (sans RawStmt) into the utilityStmt field of
1565  * the Query node, and all the useful work happens at execution time.
1566  *
1567  * stmt_location/stmt_len identify the portion of the source text string
1568  * containing this raw statement (useful for multi-statement strings).
1569  */
1570 typedef struct RawStmt
1573  Node *stmt; /* raw parse tree */
1574  int stmt_location; /* start location, or -1 if unknown */
1575  int stmt_len; /* length in bytes; 0 means "rest of string" */
1576 } RawStmt;
1577 
1578 /*****************************************************************************
1579  * Optimizable Statements
1580  *****************************************************************************/
1581 
1582 /* ----------------------
1583  * Insert Statement
1584  *
1585  * The source expression is represented by SelectStmt for both the
1586  * SELECT and VALUES cases. If selectStmt is NULL, then the query
1587  * is INSERT ... DEFAULT VALUES.
1588  * ----------------------
1589  */
1590 typedef struct InsertStmt
1593  RangeVar *relation; /* relation to insert into */
1594  List *cols; /* optional: names of the target columns */
1595  Node *selectStmt; /* the source SELECT/VALUES, or NULL */
1596  OnConflictClause *onConflictClause; /* ON CONFLICT clause */
1597  List *returningList; /* list of expressions to return */
1598  WithClause *withClause; /* WITH clause */
1599  OverridingKind override; /* OVERRIDING clause */
1600 } InsertStmt;
1601 
1602 /* ----------------------
1603  * Delete Statement
1604  * ----------------------
1605  */
1606 typedef struct DeleteStmt
1609  RangeVar *relation; /* relation to delete from */
1610  List *usingClause; /* optional using clause for more tables */
1611  Node *whereClause; /* qualifications */
1612  List *returningList; /* list of expressions to return */
1613  WithClause *withClause; /* WITH clause */
1614 } DeleteStmt;
1615 
1616 /* ----------------------
1617  * Update Statement
1618  * ----------------------
1619  */
1620 typedef struct UpdateStmt
1623  RangeVar *relation; /* relation to update */
1624  List *targetList; /* the target list (of ResTarget) */
1625  Node *whereClause; /* qualifications */
1626  List *fromClause; /* optional from clause for more tables */
1627  List *returningList; /* list of expressions to return */
1628  WithClause *withClause; /* WITH clause */
1629 } UpdateStmt;
1630 
1631 /* ----------------------
1632  * Select Statement
1633  *
1634  * A "simple" SELECT is represented in the output of gram.y by a single
1635  * SelectStmt node; so is a VALUES construct. A query containing set
1636  * operators (UNION, INTERSECT, EXCEPT) is represented by a tree of SelectStmt
1637  * nodes, in which the leaf nodes are component SELECTs and the internal nodes
1638  * represent UNION, INTERSECT, or EXCEPT operators. Using the same node
1639  * type for both leaf and internal nodes allows gram.y to stick ORDER BY,
1640  * LIMIT, etc, clause values into a SELECT statement without worrying
1641  * whether it is a simple or compound SELECT.
1642  * ----------------------
1643  */
1644 typedef enum SetOperation
1650 } SetOperation;
1652 typedef struct SelectStmt
1654  NodeTag type;
1655 
1656  /*
1657  * These fields are used only in "leaf" SelectStmts.
1658  */
1659  List *distinctClause; /* NULL, list of DISTINCT ON exprs, or
1660  * lcons(NIL,NIL) for all (SELECT DISTINCT) */
1661  IntoClause *intoClause; /* target for SELECT INTO */
1662  List *targetList; /* the target list (of ResTarget) */
1663  List *fromClause; /* the FROM clause */
1664  Node *whereClause; /* WHERE qualification */
1665  List *groupClause; /* GROUP BY clauses */
1666  bool groupDistinct; /* Is this GROUP BY DISTINCT? */
1667  Node *havingClause; /* HAVING conditional-expression */
1668  List *windowClause; /* WINDOW window_name AS (...), ... */
1669 
1670  /*
1671  * In a "leaf" node representing a VALUES list, the above fields are all
1672  * null, and instead this field is set. Note that the elements of the
1673  * sublists are just expressions, without ResTarget decoration. Also note
1674  * that a list element can be DEFAULT (represented as a SetToDefault
1675  * node), regardless of the context of the VALUES list. It's up to parse
1676  * analysis to reject that where not valid.
1677  */
1678  List *valuesLists; /* untransformed list of expression lists */
1679 
1680  /*
1681  * These fields are used in both "leaf" SelectStmts and upper-level
1682  * SelectStmts.
1683  */
1684  List *sortClause; /* sort clause (a list of SortBy's) */
1685  Node *limitOffset; /* # of result tuples to skip */
1686  Node *limitCount; /* # of result tuples to return */
1687  LimitOption limitOption; /* limit type */
1688  List *lockingClause; /* FOR UPDATE (list of LockingClause's) */
1689  WithClause *withClause; /* WITH clause */
1690 
1691  /*
1692  * These fields are used only in upper-level SelectStmts.
1693  */
1694  SetOperation op; /* type of set op */
1695  bool all; /* ALL specified? */
1696  struct SelectStmt *larg; /* left child */
1697  struct SelectStmt *rarg; /* right child */
1698  /* Eventually add fields for CORRESPONDING spec here */
1699 } SelectStmt;
1700 
1701 
1702 /* ----------------------
1703  * Set Operation node for post-analysis query trees
1704  *
1705  * After parse analysis, a SELECT with set operations is represented by a
1706  * top-level Query node containing the leaf SELECTs as subqueries in its
1707  * range table. Its setOperations field shows the tree of set operations,
1708  * with leaf SelectStmt nodes replaced by RangeTblRef nodes, and internal
1709  * nodes replaced by SetOperationStmt nodes. Information about the output
1710  * column types is added, too. (Note that the child nodes do not necessarily
1711  * produce these types directly, but we've checked that their output types
1712  * can be coerced to the output column type.) Also, if it's not UNION ALL,
1713  * information about the types' sort/group semantics is provided in the form
1714  * of a SortGroupClause list (same representation as, eg, DISTINCT).
1715  * The resolved common column collations are provided too; but note that if
1716  * it's not UNION ALL, it's okay for a column to not have a common collation,
1717  * so a member of the colCollations list could be InvalidOid even though the
1718  * column has a collatable type.
1719  * ----------------------
1720  */
1721 typedef struct SetOperationStmt
1724  SetOperation op; /* type of set op */
1725  bool all; /* ALL specified? */
1726  Node *larg; /* left child */
1727  Node *rarg; /* right child */
1728  /* Eventually add fields for CORRESPONDING spec here */
1729 
1730  /* Fields derived during parse analysis: */
1731  List *colTypes; /* OID list of output column type OIDs */
1732  List *colTypmods; /* integer list of output column typmods */
1733  List *colCollations; /* OID list of output column collation OIDs */
1734  List *groupClauses; /* a list of SortGroupClause's */
1735  /* groupClauses is NIL if UNION ALL, but must be set otherwise */
1737 
1738 
1739 /*
1740  * RETURN statement (inside SQL function body)
1741  */
1742 typedef struct ReturnStmt
1746 } ReturnStmt;
1747 
1748 
1749 /* ----------------------
1750  * PL/pgSQL Assignment Statement
1751  *
1752  * Like SelectStmt, this is transformed into a SELECT Query.
1753  * However, the targetlist of the result looks more like an UPDATE.
1754  * ----------------------
1755  */
1756 typedef struct PLAssignStmt
1758  NodeTag type;
1760  char *name; /* initial column name */
1761  List *indirection; /* subscripts and field names, if any */
1762  int nnames; /* number of names to use in ColumnRef */
1763  SelectStmt *val; /* the PL/pgSQL expression to assign */
1764  int location; /* name's token location, or -1 if unknown */
1765 } PLAssignStmt;
1766 
1767 
1768 /*****************************************************************************
1769  * Other Statements (no optimizations required)
1770  *
1771  * These are not touched by parser/analyze.c except to put them into
1772  * the utilityStmt field of a Query. This is eventually passed to
1773  * ProcessUtility (by-passing rewriting and planning). Some of the
1774  * statements do need attention from parse analysis, and this is
1775  * done by routines in parser/parse_utilcmd.c after ProcessUtility
1776  * receives the command for execution.
1777  * DECLARE CURSOR, EXPLAIN, and CREATE TABLE AS are special cases:
1778  * they contain optimizable statements, which get processed normally
1779  * by parser/analyze.c.
1780  *****************************************************************************/
1781 
1782 /*
1783  * When a command can act on several kinds of objects with only one
1784  * parse structure required, use these constants to designate the
1785  * object type. Note that commands typically don't support all the types.
1786  */
1788 typedef enum ObjectType
1794  OBJECT_ATTRIBUTE, /* type's attribute, when distinct from column */
1841 } ObjectType;
1842 
1843 /* ----------------------
1844  * Create Schema Statement
1845  *
1846  * NOTE: the schemaElts list contains raw parsetrees for component statements
1847  * of the schema, such as CREATE TABLE, GRANT, etc. These are analyzed and
1848  * executed after the schema itself is created.
1849  * ----------------------
1850  */
1851 typedef struct CreateSchemaStmt
1854  char *schemaname; /* the name of the schema to create */
1855  RoleSpec *authrole; /* the owner of the created schema */
1856  List *schemaElts; /* schema components (list of parsenodes) */
1857  bool if_not_exists; /* just do nothing if schema already exists? */
1860 typedef enum DropBehavior
1862  DROP_RESTRICT, /* drop fails if any dependent objects */
1863  DROP_CASCADE /* remove dependent objects too */
1864 } DropBehavior;
1865 
1866 /* ----------------------
1867  * Alter Table
1868  * ----------------------
1869  */
1870 typedef struct AlterTableStmt
1873  RangeVar *relation; /* table to work on */
1874  List *cmds; /* list of subcommands */
1875  ObjectType objtype; /* type of object */
1876  bool missing_ok; /* skip error if table missing */
1877 } AlterTableStmt;
1879 typedef enum AlterTableType
1881  AT_AddColumn, /* add column */
1882  AT_AddColumnRecurse, /* internal to commands/tablecmds.c */
1883  AT_AddColumnToView, /* implicitly via CREATE OR REPLACE VIEW */
1884  AT_ColumnDefault, /* alter column default */
1885  AT_CookedColumnDefault, /* add a pre-cooked column default */
1886  AT_DropNotNull, /* alter column drop not null */
1887  AT_SetNotNull, /* alter column set not null */
1888  AT_DropExpression, /* alter column drop expression */
1889  AT_CheckNotNull, /* check column is already marked not null */
1890  AT_SetStatistics, /* alter column set statistics */
1891  AT_SetOptions, /* alter column set ( options ) */
1892  AT_ResetOptions, /* alter column reset ( options ) */
1893  AT_SetStorage, /* alter column set storage */
1894  AT_SetCompression, /* alter column set compression */
1895  AT_DropColumn, /* drop column */
1896  AT_DropColumnRecurse, /* internal to commands/tablecmds.c */
1897  AT_AddIndex, /* add index */
1898  AT_ReAddIndex, /* internal to commands/tablecmds.c */
1899  AT_AddConstraint, /* add constraint */
1900  AT_AddConstraintRecurse, /* internal to commands/tablecmds.c */
1901  AT_ReAddConstraint, /* internal to commands/tablecmds.c */
1902  AT_ReAddDomainConstraint, /* internal to commands/tablecmds.c */
1903  AT_AlterConstraint, /* alter constraint */
1904  AT_ValidateConstraint, /* validate constraint */
1905  AT_ValidateConstraintRecurse, /* internal to commands/tablecmds.c */
1906  AT_AddIndexConstraint, /* add constraint using existing index */
1907  AT_DropConstraint, /* drop constraint */
1908  AT_DropConstraintRecurse, /* internal to commands/tablecmds.c */
1909  AT_ReAddComment, /* internal to commands/tablecmds.c */
1910  AT_AlterColumnType, /* alter column type */
1911  AT_AlterColumnGenericOptions, /* alter column OPTIONS (...) */
1912  AT_ChangeOwner, /* change owner */
1913  AT_ClusterOn, /* CLUSTER ON */
1914  AT_DropCluster, /* SET WITHOUT CLUSTER */
1915  AT_SetLogged, /* SET LOGGED */
1916  AT_SetUnLogged, /* SET UNLOGGED */
1917  AT_DropOids, /* SET WITHOUT OIDS */
1918  AT_SetAccessMethod, /* SET ACCESS METHOD */
1919  AT_SetTableSpace, /* SET TABLESPACE */
1920  AT_SetRelOptions, /* SET (...) -- AM specific parameters */
1921  AT_ResetRelOptions, /* RESET (...) -- AM specific parameters */
1922  AT_ReplaceRelOptions, /* replace reloption list in its entirety */
1923  AT_EnableTrig, /* ENABLE TRIGGER name */
1924  AT_EnableAlwaysTrig, /* ENABLE ALWAYS TRIGGER name */
1925  AT_EnableReplicaTrig, /* ENABLE REPLICA TRIGGER name */
1926  AT_DisableTrig, /* DISABLE TRIGGER name */
1927  AT_EnableTrigAll, /* ENABLE TRIGGER ALL */
1928  AT_DisableTrigAll, /* DISABLE TRIGGER ALL */
1929  AT_EnableTrigUser, /* ENABLE TRIGGER USER */
1930  AT_DisableTrigUser, /* DISABLE TRIGGER USER */
1931  AT_EnableRule, /* ENABLE RULE name */
1932  AT_EnableAlwaysRule, /* ENABLE ALWAYS RULE name */
1933  AT_EnableReplicaRule, /* ENABLE REPLICA RULE name */
1934  AT_DisableRule, /* DISABLE RULE name */
1935  AT_AddInherit, /* INHERIT parent */
1936  AT_DropInherit, /* NO INHERIT parent */
1937  AT_AddOf, /* OF <type_name> */
1938  AT_DropOf, /* NOT OF */
1939  AT_ReplicaIdentity, /* REPLICA IDENTITY */
1940  AT_EnableRowSecurity, /* ENABLE ROW SECURITY */
1941  AT_DisableRowSecurity, /* DISABLE ROW SECURITY */
1942  AT_ForceRowSecurity, /* FORCE ROW SECURITY */
1943  AT_NoForceRowSecurity, /* NO FORCE ROW SECURITY */
1944  AT_GenericOptions, /* OPTIONS (...) */
1945  AT_AttachPartition, /* ATTACH PARTITION */
1946  AT_DetachPartition, /* DETACH PARTITION */
1947  AT_DetachPartitionFinalize, /* DETACH PARTITION FINALIZE */
1948  AT_AddIdentity, /* ADD IDENTITY */
1949  AT_SetIdentity, /* SET identity column options */
1950  AT_DropIdentity, /* DROP IDENTITY */
1951  AT_ReAddStatistics /* internal to commands/tablecmds.c */
1952 } AlterTableType;
1954 typedef struct ReplicaIdentityStmt
1958  char *name;
1961 typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */
1964  AlterTableType subtype; /* Type of table alteration to apply */
1965  char *name; /* column, constraint, or trigger to act on,
1966  * or tablespace */
1967  int16 num; /* attribute number for columns referenced by
1968  * number */
1970  Node *def; /* definition of new column, index,
1971  * constraint, or parent table */
1972  DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
1973  bool missing_ok; /* skip error if missing? */
1974 } AlterTableCmd;
1975 
1976 
1977 /* ----------------------
1978  * Alter Collation
1979  * ----------------------
1980  */
1981 typedef struct AlterCollationStmt
1986 
1987 
1988 /* ----------------------
1989  * Alter Domain
1990  *
1991  * The fields are used in different ways by the different variants of
1992  * this command.
1993  * ----------------------
1994  */
1995 typedef struct AlterDomainStmt
1998  char subtype; /*------------
1999  * T = alter column default
2000  * N = alter column drop not null
2001  * O = alter column set not null
2002  * C = add constraint
2003  * X = drop constraint
2004  *------------
2005  */
2006  List *typeName; /* domain to work on */
2007  char *name; /* column or constraint name to act on */
2008  Node *def; /* definition of default or constraint */
2009  DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
2010  bool missing_ok; /* skip error if missing? */
2011 } AlterDomainStmt;
2012 
2013 
2014 /* ----------------------
2015  * Grant|Revoke Statement
2016  * ----------------------
2017  */
2018 typedef enum GrantTargetType
2020  ACL_TARGET_OBJECT, /* grant on specific named object(s) */
2021  ACL_TARGET_ALL_IN_SCHEMA, /* grant on all objects in given schema(s) */
2022  ACL_TARGET_DEFAULTS /* ALTER DEFAULT PRIVILEGES */
2023 } GrantTargetType;
2025 typedef struct GrantStmt
2028  bool is_grant; /* true = GRANT, false = REVOKE */
2029  GrantTargetType targtype; /* type of the grant target */
2030  ObjectType objtype; /* kind of object being operated on */
2031  List *objects; /* list of RangeVar nodes, ObjectWithArgs
2032  * nodes, or plain names (as String values) */
2033  List *privileges; /* list of AccessPriv nodes */
2034  /* privileges == NIL denotes ALL PRIVILEGES */
2035  List *grantees; /* list of RoleSpec nodes */
2036  bool grant_option; /* grant or revoke grant option */
2038  DropBehavior behavior; /* drop behavior (for REVOKE) */
2039 } GrantStmt;
2040 
2041 /*
2042  * ObjectWithArgs represents a function/procedure/operator name plus parameter
2043  * identification.
2044  *
2045  * objargs includes only the types of the input parameters of the object.
2046  * In some contexts, that will be all we have, and it's enough to look up
2047  * objects according to the traditional Postgres rules (i.e., when only input
2048  * arguments matter).
2049  *
2050  * objfuncargs, if not NIL, carries the full specification of the parameter
2051  * list, including parameter mode annotations.
2052  *
2053  * Some grammar productions can set args_unspecified = true instead of
2054  * providing parameter info. In this case, lookup will succeed only if
2055  * the object name is unique. Note that otherwise, NIL parameter lists
2056  * mean zero arguments.
2057  */
2058 typedef struct ObjectWithArgs
2061  List *objname; /* qualified name of function/operator */
2062  List *objargs; /* list of Typename nodes (input args only) */
2063  List *objfuncargs; /* list of FunctionParameter nodes */
2064  bool args_unspecified; /* argument list was omitted? */
2065 } ObjectWithArgs;
2066 
2067 /*
2068  * An access privilege, with optional list of column names
2069  * priv_name == NULL denotes ALL PRIVILEGES (only used with a column list)
2070  * cols == NIL denotes "all columns"
2071  * Note that simple "ALL PRIVILEGES" is represented as a NIL list, not
2072  * an AccessPriv with both fields null.
2073  */
2074 typedef struct AccessPriv
2077  char *priv_name; /* string name of privilege */
2078  List *cols; /* list of String */
2079 } AccessPriv;
2080 
2081 /* ----------------------
2082  * Grant/Revoke Role Statement
2083  *
2084  * Note: because of the parsing ambiguity with the GRANT <privileges>
2085  * statement, granted_roles is a list of AccessPriv; the execution code
2086  * should complain if any column lists appear. grantee_roles is a list
2087  * of role names, as String values.
2088  * ----------------------
2089  */
2090 typedef struct GrantRoleStmt
2093  List *granted_roles; /* list of roles to be granted/revoked */
2094  List *grantee_roles; /* list of member roles to add/delete */
2095  bool is_grant; /* true = GRANT, false = REVOKE */
2096  bool admin_opt; /* with admin option */
2097  RoleSpec *grantor; /* set grantor to other than current role */
2098  DropBehavior behavior; /* drop behavior (for REVOKE) */
2099 } GrantRoleStmt;
2100 
2101 /* ----------------------
2102  * Alter Default Privileges Statement
2103  * ----------------------
2104  */
2105 typedef struct AlterDefaultPrivilegesStmt
2108  List *options; /* list of DefElem */
2109  GrantStmt *action; /* GRANT/REVOKE action (with objects=NIL) */
2111 
2112 /* ----------------------
2113  * Copy Statement
2114  *
2115  * We support "COPY relation FROM file", "COPY relation TO file", and
2116  * "COPY (query) TO file". In any given CopyStmt, exactly one of "relation"
2117  * and "query" must be non-NULL.
2118  * ----------------------
2119  */
2120 typedef struct CopyStmt
2123  RangeVar *relation; /* the relation to copy */
2124  Node *query; /* the query (SELECT or DML statement with
2125  * RETURNING) to copy, as a raw parse tree */
2126  List *attlist; /* List of column names (as Strings), or NIL
2127  * for all columns */
2128  bool is_from; /* TO or FROM */
2129  bool is_program; /* is 'filename' a program to popen? */
2130  char *filename; /* filename, or NULL for STDIN/STDOUT */
2131  List *options; /* List of DefElem nodes */
2132  Node *whereClause; /* WHERE condition (or NULL) */
2133 } CopyStmt;
2134 
2135 /* ----------------------
2136  * SET Statement (includes RESET)
2137  *
2138  * "SET var TO DEFAULT" and "RESET var" are semantically equivalent, but we
2139  * preserve the distinction in VariableSetKind for CreateCommandTag().
2140  * ----------------------
2141  */
2142 typedef enum VariableSetKind
2144  VAR_SET_VALUE, /* SET var = value */
2145  VAR_SET_DEFAULT, /* SET var TO DEFAULT */
2146  VAR_SET_CURRENT, /* SET var FROM CURRENT */
2147  VAR_SET_MULTI, /* special case for SET TRANSACTION ... */
2148  VAR_RESET, /* RESET var */
2149  VAR_RESET_ALL /* RESET ALL */
2150 } VariableSetKind;
2152 typedef struct VariableSetStmt
2156  char *name; /* variable to be set */
2157  List *args; /* List of A_Const nodes */
2158  bool is_local; /* SET LOCAL? */
2159 } VariableSetStmt;
2160 
2161 /* ----------------------
2162  * Show Statement
2163  * ----------------------
2164  */
2165 typedef struct VariableShowStmt
2168  char *name;
2170 
2171 /* ----------------------
2172  * Create Table Statement
2173  *
2174  * NOTE: in the raw gram.y output, ColumnDef and Constraint nodes are
2175  * intermixed in tableElts, and constraints is NIL. After parse analysis,
2176  * tableElts contains just ColumnDefs, and constraints contains just
2177  * Constraint nodes (in fact, only CONSTR_CHECK nodes, in the present
2178  * implementation).
2179  * ----------------------
2180  */
2182 typedef struct CreateStmt
2185  RangeVar *relation; /* relation to create */
2186  List *tableElts; /* column definitions (list of ColumnDef) */
2187  List *inhRelations; /* relations to inherit from (list of
2188  * RangeVar) */
2189  PartitionBoundSpec *partbound; /* FOR VALUES clause */
2190  PartitionSpec *partspec; /* PARTITION BY clause */
2191  TypeName *ofTypename; /* OF typename */
2192  List *constraints; /* constraints (list of Constraint nodes) */
2193  List *options; /* options from WITH clause */
2194  OnCommitAction oncommit; /* what do we do at COMMIT? */
2195  char *tablespacename; /* table space to use, or NULL */
2196  char *accessMethod; /* table access method */
2197  bool if_not_exists; /* just do nothing if it already exists? */
2198 } CreateStmt;
2199 
2200 /* ----------
2201  * Definitions for constraints in CreateStmt
2202  *
2203  * Note that column defaults are treated as a type of constraint,
2204  * even though that's a bit odd semantically.
2205  *
2206  * For constraints that use expressions (CONSTR_CHECK, CONSTR_DEFAULT)
2207  * we may have the expression in either "raw" form (an untransformed
2208  * parse tree) or "cooked" form (the nodeToString representation of
2209  * an executable expression tree), depending on how this Constraint
2210  * node was created (by parsing, or by inheritance from an existing
2211  * relation). We should never have both in the same node!
2212  *
2213  * FKCONSTR_ACTION_xxx values are stored into pg_constraint.confupdtype
2214  * and pg_constraint.confdeltype columns; FKCONSTR_MATCH_xxx values are
2215  * stored into pg_constraint.confmatchtype. Changing the code values may
2216  * require an initdb!
2217  *
2218  * If skip_validation is true then we skip checking that the existing rows
2219  * in the table satisfy the constraint, and just install the catalog entries
2220  * for the constraint. A new FK constraint is marked as valid iff
2221  * initially_valid is true. (Usually skip_validation and initially_valid
2222  * are inverses, but we can set both true if the table is known empty.)
2223  *
2224  * Constraint attributes (DEFERRABLE etc) are initially represented as
2225  * separate Constraint nodes for simplicity of parsing. parse_utilcmd.c makes
2226  * a pass through the constraints list to insert the info into the appropriate
2227  * Constraint node.
2228  * ----------
2229  */
2231 typedef enum ConstrType /* types of constraints */
2233  CONSTR_NULL, /* not standard SQL, but a lot of people
2234  * expect it */
2244  CONSTR_ATTR_DEFERRABLE, /* attributes for previous constraint node */
2248 } ConstrType;
2249 
2250 /* Foreign key action codes */
2251 #define FKCONSTR_ACTION_NOACTION 'a'
2252 #define FKCONSTR_ACTION_RESTRICT 'r'
2253 #define FKCONSTR_ACTION_CASCADE 'c'
2254 #define FKCONSTR_ACTION_SETNULL 'n'
2255 #define FKCONSTR_ACTION_SETDEFAULT 'd'
2256 
2257 /* Foreign key matchtype codes */
2258 #define FKCONSTR_MATCH_FULL 'f'
2259 #define FKCONSTR_MATCH_PARTIAL 'p'
2260 #define FKCONSTR_MATCH_SIMPLE 's'
2262 typedef struct Constraint
2265  ConstrType contype; /* see above */
2266 
2267  /* Fields used for most/all constraint types: */
2268  char *conname; /* Constraint name, or NULL if unnamed */
2269  bool deferrable; /* DEFERRABLE? */
2270  bool initdeferred; /* INITIALLY DEFERRED? */
2271  int location; /* token location, or -1 if unknown */
2272 
2273  /* Fields used for constraints with expressions (CHECK and DEFAULT): */
2274  bool is_no_inherit; /* is constraint non-inheritable? */
2275  Node *raw_expr; /* expr, as untransformed parse tree */
2276  char *cooked_expr; /* expr, as nodeToString representation */
2277  char generated_when; /* ALWAYS or BY DEFAULT */
2278 
2279  /* Fields used for unique constraints (UNIQUE and PRIMARY KEY): */
2280  List *keys; /* String nodes naming referenced key
2281  * column(s) */
2282  List *including; /* String nodes naming referenced nonkey
2283  * column(s) */
2284 
2285  /* Fields used for EXCLUSION constraints: */
2286  List *exclusions; /* list of (IndexElem, operator name) pairs */
2287 
2288  /* Fields used for index constraints (UNIQUE, PRIMARY KEY, EXCLUSION): */
2289  List *options; /* options from WITH clause */
2290  char *indexname; /* existing index to use; otherwise NULL */
2291  char *indexspace; /* index tablespace; NULL for default */
2292  bool reset_default_tblspc; /* reset default_tablespace prior to
2293  * creating the index */
2294  /* These could be, but currently are not, used for UNIQUE/PKEY: */
2295  char *access_method; /* index access method; NULL for default */
2296  Node *where_clause; /* partial index predicate */
2297 
2298  /* Fields used for FOREIGN KEY constraints: */
2299  RangeVar *pktable; /* Primary key table */
2300  List *fk_attrs; /* Attributes of foreign key */
2301  List *pk_attrs; /* Corresponding attrs in PK table */
2302  char fk_matchtype; /* FULL, PARTIAL, SIMPLE */
2303  char fk_upd_action; /* ON UPDATE action */
2304  char fk_del_action; /* ON DELETE action */
2305  List *fk_del_set_cols; /* ON DELETE SET NULL/DEFAULT (col1, col2) */
2306  List *old_conpfeqop; /* pg_constraint.conpfeqop of my former self */
2307  Oid old_pktable_oid; /* pg_constraint.confrelid of my former
2308  * self */
2309 
2310  /* Fields used for constraints that allow a NOT VALID specification */
2311  bool skip_validation; /* skip validation of existing rows? */
2312  bool initially_valid; /* mark the new constraint as valid? */
2313 } Constraint;
2314 
2315 /* ----------------------
2316  * Create/Drop Table Space Statements
2317  * ----------------------
2318  */
2320 typedef struct CreateTableSpaceStmt
2325  char *location;
2329 typedef struct DropTableSpaceStmt
2333  bool missing_ok; /* skip error if missing? */
2336 typedef struct AlterTableSpaceOptionsStmt
2341  bool isReset;
2344 typedef struct AlterTableMoveAllStmt
2348  ObjectType objtype; /* Object type to move */
2349  List *roles; /* List of roles to move objects of */
2351  bool nowait;
2353 
2354 /* ----------------------
2355  * Create/Alter Extension Statements
2356  * ----------------------
2357  */
2359 typedef struct CreateExtensionStmt
2362  char *extname;
2363  bool if_not_exists; /* just do nothing if it already exists? */
2364  List *options; /* List of DefElem nodes */
2366 
2367 /* Only used for ALTER EXTENSION UPDATE; later might need an action field */
2368 typedef struct AlterExtensionStmt
2371  char *extname;
2372  List *options; /* List of DefElem nodes */
2375 typedef struct AlterExtensionContentsStmt
2378  char *extname; /* Extension's name */
2379  int action; /* +1 = add object, -1 = drop object */
2380  ObjectType objtype; /* Object's type */
2381  Node *object; /* Qualified name of the object */
2383 
2384 /* ----------------------
2385  * Create/Alter FOREIGN DATA WRAPPER Statements
2386  * ----------------------
2387  */
2389 typedef struct CreateFdwStmt
2392  char *fdwname; /* foreign-data wrapper name */
2393  List *func_options; /* HANDLER/VALIDATOR options */
2394  List *options; /* generic options to FDW */
2395 } CreateFdwStmt;
2397 typedef struct AlterFdwStmt
2400  char *fdwname; /* foreign-data wrapper name */
2401  List *func_options; /* HANDLER/VALIDATOR options */
2402  List *options; /* generic options to FDW */
2403 } AlterFdwStmt;
2404 
2405 /* ----------------------
2406  * Create/Alter FOREIGN SERVER Statements
2407  * ----------------------
2408  */
2410 typedef struct CreateForeignServerStmt
2413  char *servername; /* server name */
2414  char *servertype; /* optional server type */
2415  char *version; /* optional server version */
2416  char *fdwname; /* FDW name */
2417  bool if_not_exists; /* just do nothing if it already exists? */
2418  List *options; /* generic options to server */
2421 typedef struct AlterForeignServerStmt
2424  char *servername; /* server name */
2425  char *version; /* optional server version */
2426  List *options; /* generic options to server */
2427  bool has_version; /* version specified */
2429 
2430 /* ----------------------
2431  * Create FOREIGN TABLE Statement
2432  * ----------------------
2433  */
2435 typedef struct CreateForeignTableStmt
2438  char *servername;
2441 
2442 /* ----------------------
2443  * Create/Drop USER MAPPING Statements
2444  * ----------------------
2445  */
2447 typedef struct CreateUserMappingStmt
2450  RoleSpec *user; /* user role */
2451  char *servername; /* server name */
2452  bool if_not_exists; /* just do nothing if it already exists? */
2453  List *options; /* generic options to server */
2456 typedef struct AlterUserMappingStmt
2459  RoleSpec *user; /* user role */
2460  char *servername; /* server name */
2461  List *options; /* generic options to server */
2464 typedef struct DropUserMappingStmt
2467  RoleSpec *user; /* user role */
2468  char *servername; /* server name */
2469  bool missing_ok; /* ignore missing mappings */
2471 
2472 /* ----------------------
2473  * Import Foreign Schema Statement
2474  * ----------------------
2475  */
2477 typedef enum ImportForeignSchemaType
2479  FDW_IMPORT_SCHEMA_ALL, /* all relations wanted */
2480  FDW_IMPORT_SCHEMA_LIMIT_TO, /* include only listed tables in import */
2481  FDW_IMPORT_SCHEMA_EXCEPT /* exclude listed tables from import */
2484 typedef struct ImportForeignSchemaStmt
2487  char *server_name; /* FDW server name */
2488  char *remote_schema; /* remote schema name to query */
2489  char *local_schema; /* local schema to create objects in */
2490  ImportForeignSchemaType list_type; /* type of table list */
2491  List *table_list; /* List of RangeVar */
2492  List *options; /* list of options to pass to FDW */
2494 
2495 /*----------------------
2496  * Create POLICY Statement
2497  *----------------------
2498  */
2499 typedef struct CreatePolicyStmt
2502  char *policy_name; /* Policy's name */
2503  RangeVar *table; /* the table name the policy applies to */
2504  char *cmd_name; /* the command name the policy applies to */
2505  bool permissive; /* restrictive or permissive policy */
2506  List *roles; /* the roles associated with the policy */
2507  Node *qual; /* the policy's condition */
2508  Node *with_check; /* the policy's WITH CHECK condition. */
2510 
2511 /*----------------------
2512  * Alter POLICY Statement
2513  *----------------------
2514  */
2515 typedef struct AlterPolicyStmt
2518  char *policy_name; /* Policy's name */
2519  RangeVar *table; /* the table name the policy applies to */
2520  List *roles; /* the roles associated with the policy */
2521  Node *qual; /* the policy's condition */
2522  Node *with_check; /* the policy's WITH CHECK condition. */
2523 } AlterPolicyStmt;
2524 
2525 /*----------------------
2526  * Create ACCESS METHOD Statement
2527  *----------------------
2528  */
2529 typedef struct CreateAmStmt
2532  char *amname; /* access method name */
2533  List *handler_name; /* handler function name */
2534  char amtype; /* type of access method */
2535 } CreateAmStmt;
2536 
2537 /* ----------------------
2538  * Create TRIGGER Statement
2539  * ----------------------
2540  */
2541 typedef struct CreateTrigStmt
2544  bool replace; /* replace trigger if already exists */
2545  bool isconstraint; /* This is a constraint trigger */
2546  char *trigname; /* TRIGGER's name */
2547  RangeVar *relation; /* relation trigger is on */
2548  List *funcname; /* qual. name of function to call */
2549  List *args; /* list of String or NIL */
2550  bool row; /* ROW/STATEMENT */
2551  /* timing uses the TRIGGER_TYPE bits defined in catalog/pg_trigger.h */
2552  int16 timing; /* BEFORE, AFTER, or INSTEAD */
2553  /* events uses the TRIGGER_TYPE bits defined in catalog/pg_trigger.h */
2554  int16 events; /* "OR" of INSERT/UPDATE/DELETE/TRUNCATE */
2555  List *columns; /* column names, or NIL for all columns */
2556  Node *whenClause; /* qual expression, or NULL if none */
2557  /* explicitly named transition data */
2558  List *transitionRels; /* TriggerTransition nodes, or NIL if none */
2559  /* The remaining fields are only used for constraint triggers */
2560  bool deferrable; /* [NOT] DEFERRABLE */
2561  bool initdeferred; /* INITIALLY {DEFERRED|IMMEDIATE} */
2562  RangeVar *constrrel; /* opposite relation, if RI trigger */
2563 } CreateTrigStmt;
2564 
2565 /* ----------------------
2566  * Create EVENT TRIGGER Statement
2567  * ----------------------
2568  */
2569 typedef struct CreateEventTrigStmt
2572  char *trigname; /* TRIGGER's name */
2573  char *eventname; /* event's identifier */
2574  List *whenclause; /* list of DefElems indicating filtering */
2575  List *funcname; /* qual. name of function to call */
2577 
2578 /* ----------------------
2579  * Alter EVENT TRIGGER Statement
2580  * ----------------------
2581  */
2582 typedef struct AlterEventTrigStmt
2585  char *trigname; /* TRIGGER's name */
2586  char tgenabled; /* trigger's firing configuration WRT
2587  * session_replication_role */
2589 
2590 /* ----------------------
2591  * Create LANGUAGE Statements
2592  * ----------------------
2593  */
2594 typedef struct CreatePLangStmt
2597  bool replace; /* T => replace if already exists */
2598  char *plname; /* PL name */
2599  List *plhandler; /* PL call handler function (qual. name) */
2600  List *plinline; /* optional inline function (qual. name) */
2601  List *plvalidator; /* optional validator function (qual. name) */
2602  bool pltrusted; /* PL is trusted */
2603 } CreatePLangStmt;
2604 
2605 /* ----------------------
2606  * Create/Alter/Drop Role Statements
2607  *
2608  * Note: these node types are also used for the backwards-compatible
2609  * Create/Alter/Drop User/Group statements. In the ALTER and DROP cases
2610  * there's really no need to distinguish what the original spelling was,
2611  * but for CREATE we mark the type because the defaults vary.
2612  * ----------------------
2613  */
2614 typedef enum RoleStmtType
2617  ROLESTMT_USER,
2619 } RoleStmtType;
2621 typedef struct CreateRoleStmt
2624  RoleStmtType stmt_type; /* ROLE/USER/GROUP */
2625  char *role; /* role name */
2626  List *options; /* List of DefElem nodes */
2627 } CreateRoleStmt;
2629 typedef struct AlterRoleStmt
2632  RoleSpec *role; /* role */
2633  List *options; /* List of DefElem nodes */
2634  int action; /* +1 = add members, -1 = drop members */
2635 } AlterRoleStmt;
2637 typedef struct AlterRoleSetStmt
2640  RoleSpec *role; /* role */
2641  char *database; /* database name, or NULL */
2642  VariableSetStmt *setstmt; /* SET or RESET subcommand */
2645 typedef struct DropRoleStmt
2648  List *roles; /* List of roles to remove */
2649  bool missing_ok; /* skip error if a role is missing? */
2650 } DropRoleStmt;
2651 
2652 /* ----------------------
2653  * {Create|Alter} SEQUENCE Statement
2654  * ----------------------
2655  */
2657 typedef struct CreateSeqStmt
2660  RangeVar *sequence; /* the sequence to create */
2662  Oid ownerId; /* ID of owner, or InvalidOid for default */
2664  bool if_not_exists; /* just do nothing if it already exists? */
2665 } CreateSeqStmt;
2667 typedef struct AlterSeqStmt
2670  RangeVar *sequence; /* the sequence to alter */
2673  bool missing_ok; /* skip error if a role is missing? */
2674 } AlterSeqStmt;
2675 
2676 /* ----------------------
2677  * Create {Aggregate|Operator|Type} Statement
2678  * ----------------------
2679  */
2680 typedef struct DefineStmt
2683  ObjectType kind; /* aggregate, operator, type */
2684  bool oldstyle; /* hack to signal old CREATE AGG syntax */
2685  List *defnames; /* qualified name (list of String) */
2686  List *args; /* a list of TypeName (if needed) */
2687  List *definition; /* a list of DefElem */
2688  bool if_not_exists; /* just do nothing if it already exists? */
2689  bool replace; /* replace if already exists? */
2690 } DefineStmt;
2691 
2692 /* ----------------------
2693  * Create Domain Statement
2694  * ----------------------
2695  */
2696 typedef struct CreateDomainStmt
2699  List *domainname; /* qualified name (list of String) */
2700  TypeName *typeName; /* the base type */
2701  CollateClause *collClause; /* untransformed COLLATE spec, if any */
2702  List *constraints; /* constraints (list of Constraint nodes) */
2704 
2705 /* ----------------------
2706  * Create Operator Class Statement
2707  * ----------------------
2708  */
2709 typedef struct CreateOpClassStmt
2712  List *opclassname; /* qualified name (list of String) */
2713  List *opfamilyname; /* qualified name (ditto); NIL if omitted */
2714  char *amname; /* name of index AM opclass is for */
2715  TypeName *datatype; /* datatype of indexed column */
2716  List *items; /* List of CreateOpClassItem nodes */
2717  bool isDefault; /* Should be marked as default for type? */
2720 #define OPCLASS_ITEM_OPERATOR 1
2721 #define OPCLASS_ITEM_FUNCTION 2
2722 #define OPCLASS_ITEM_STORAGETYPE 3
2724 typedef struct CreateOpClassItem
2727  int itemtype; /* see codes above */
2728  ObjectWithArgs *name; /* operator or function name and args */
2729  int number; /* strategy num or support proc num */
2730  List *order_family; /* only used for ordering operators */
2731  List *class_args; /* amproclefttype/amprocrighttype or
2732  * amoplefttype/amoprighttype */
2733  /* fields used for a storagetype item: */
2734  TypeName *storedtype; /* datatype stored in index */
2736 
2737 /* ----------------------
2738  * Create Operator Family Statement
2739  * ----------------------
2740  */
2741 typedef struct CreateOpFamilyStmt
2744  List *opfamilyname; /* qualified name (list of String) */
2745  char *amname; /* name of index AM opfamily is for */
2747 
2748 /* ----------------------
2749  * Alter Operator Family Statement
2750  * ----------------------
2751  */
2752 typedef struct AlterOpFamilyStmt
2755  List *opfamilyname; /* qualified name (list of String) */
2756  char *amname; /* name of index AM opfamily is for */
2757  bool isDrop; /* ADD or DROP the items? */
2758  List *items; /* List of CreateOpClassItem nodes */
2760 
2761 /* ----------------------
2762  * Drop Table|Sequence|View|Index|Type|Domain|Conversion|Schema Statement
2763  * ----------------------
2764  */
2766 typedef struct DropStmt
2769  List *objects; /* list of names */
2770  ObjectType removeType; /* object type */
2771  DropBehavior behavior; /* RESTRICT or CASCADE behavior */
2772  bool missing_ok; /* skip error if object is missing? */
2773  bool concurrent; /* drop index concurrently? */
2774 } DropStmt;
2775 
2776 /* ----------------------
2777  * Truncate Table Statement
2778  * ----------------------
2779  */
2780 typedef struct TruncateStmt
2783  List *relations; /* relations (RangeVars) to be truncated */
2784  bool restart_seqs; /* restart owned sequences? */
2785  DropBehavior behavior; /* RESTRICT or CASCADE behavior */
2786 } TruncateStmt;
2787 
2788 /* ----------------------
2789  * Comment On Statement
2790  * ----------------------
2791  */
2792 typedef struct CommentStmt
2795  ObjectType objtype; /* Object's type */
2796  Node *object; /* Qualified name of the object */
2797  char *comment; /* Comment to insert, or NULL to remove */
2798 } CommentStmt;
2799 
2800 /* ----------------------
2801  * SECURITY LABEL Statement
2802  * ----------------------
2803  */
2804 typedef struct SecLabelStmt
2807  ObjectType objtype; /* Object's type */
2808  Node *object; /* Qualified name of the object */
2809  char *provider; /* Label provider (or NULL) */
2810  char *label; /* New security label to be assigned */
2811 } SecLabelStmt;
2812 
2813 /* ----------------------
2814  * Declare Cursor Statement
2815  *
2816  * The "query" field is initially a raw parse tree, and is converted to a
2817  * Query node during parse analysis. Note that rewriting and planning
2818  * of the query are always postponed until execution.
2819  * ----------------------
2820  */
2821 #define CURSOR_OPT_BINARY 0x0001 /* BINARY */
2822 #define CURSOR_OPT_SCROLL 0x0002 /* SCROLL explicitly given */
2823 #define CURSOR_OPT_NO_SCROLL 0x0004 /* NO SCROLL explicitly given */
2824 #define CURSOR_OPT_INSENSITIVE 0x0008 /* INSENSITIVE */
2825 #define CURSOR_OPT_ASENSITIVE 0x0010 /* ASENSITIVE */
2826 #define CURSOR_OPT_HOLD 0x0020 /* WITH HOLD */
2827 /* these planner-control flags do not correspond to any SQL grammar: */
2828 #define CURSOR_OPT_FAST_PLAN 0x0100 /* prefer fast-start plan */
2829 #define CURSOR_OPT_GENERIC_PLAN 0x0200 /* force use of generic plan */
2830 #define CURSOR_OPT_CUSTOM_PLAN 0x0400 /* force use of custom plan */
2831 #define CURSOR_OPT_PARALLEL_OK 0x0800 /* parallel mode OK */
2833 typedef struct DeclareCursorStmt
2836  char *portalname; /* name of the portal (cursor) */
2837  int options; /* bitmask of options (see above) */
2838  Node *query; /* the query (see comments above) */
2840 
2841 /* ----------------------
2842  * Close Portal Statement
2843  * ----------------------
2844  */
2845 typedef struct ClosePortalStmt
2848  char *portalname; /* name of the portal (cursor) */
2849  /* NULL means CLOSE ALL */
2850 } ClosePortalStmt;
2851 
2852 /* ----------------------
2853  * Fetch Statement (also Move)
2854  * ----------------------
2855  */
2856 typedef enum FetchDirection
2857 {
2858  /* for these, howMany is how many rows to fetch; FETCH_ALL means ALL */
2861  /* for these, howMany indicates a position; only one row is fetched */
2864 } FetchDirection;
2866 #define FETCH_ALL LONG_MAX
2868 typedef struct FetchStmt
2871  FetchDirection direction; /* see above */
2872  long howMany; /* number of rows, or position argument */
2873  char *portalname; /* name of portal (cursor) */
2874  bool ismove; /* true if MOVE */
2875 } FetchStmt;
2876 
2877 /* ----------------------
2878  * Create Index Statement
2879  *
2880  * This represents creation of an index and/or an associated constraint.
2881  * If isconstraint is true, we should create a pg_constraint entry along
2882  * with the index. But if indexOid isn't InvalidOid, we are not creating an
2883  * index, just a UNIQUE/PKEY constraint using an existing index. isconstraint
2884  * must always be true in this case, and the fields describing the index
2885  * properties are empty.
2886  * ----------------------
2887  */
2888 typedef struct IndexStmt
2891  char *idxname; /* name of new index, or NULL for default */
2892  RangeVar *relation; /* relation to build index on */
2893  char *accessMethod; /* name of access method (eg. btree) */
2894  char *tableSpace; /* tablespace, or NULL for default */
2895  List *indexParams; /* columns to index: a list of IndexElem */
2896  List *indexIncludingParams; /* additional columns to index: a list
2897  * of IndexElem */
2898  List *options; /* WITH clause options: a list of DefElem */
2899  Node *whereClause; /* qualification (partial-index predicate) */
2900  List *excludeOpNames; /* exclusion operator names, or NIL if none */
2901  char *idxcomment; /* comment to apply to index, or NULL */
2902  Oid indexOid; /* OID of an existing index, if any */
2903  Oid oldNode; /* relfilenode of existing storage, if any */
2904  SubTransactionId oldCreateSubid; /* rd_createSubid of oldNode */
2905  SubTransactionId oldFirstRelfilenodeSubid; /* rd_firstRelfilenodeSubid of
2906  * oldNode */
2907  bool unique; /* is index unique? */
2908  bool primary; /* is index a primary key? */
2909  bool isconstraint; /* is it for a pkey/unique constraint? */
2910  bool deferrable; /* is the constraint DEFERRABLE? */
2911  bool initdeferred; /* is the constraint INITIALLY DEFERRED? */
2912  bool transformed; /* true when transformIndexStmt is finished */
2913  bool concurrent; /* should this be a concurrent index build? */
2914  bool if_not_exists; /* just do nothing if index already exists? */
2915  bool reset_default_tblspc; /* reset default_tablespace prior to
2916  * executing */
2917 } IndexStmt;
2918 
2919 /* ----------------------
2920  * Create Statistics Statement
2921  * ----------------------
2922  */
2923 typedef struct CreateStatsStmt
2926  List *defnames; /* qualified name (list of String) */
2927  List *stat_types; /* stat types (list of String) */
2928  List *exprs; /* expressions to build statistics on */
2929  List *relations; /* rels to build stats on (list of RangeVar) */
2930  char *stxcomment; /* comment to apply to stats, or NULL */
2931  bool transformed; /* true when transformStatsStmt is finished */
2932  bool if_not_exists; /* do nothing if stats name already exists */
2933 } CreateStatsStmt;
2934 
2935 /*
2936  * StatsElem - statistics parameters (used in CREATE STATISTICS)
2937  *
2938  * For a plain attribute, 'name' is the name of the referenced table column
2939  * and 'expr' is NULL. For an expression, 'name' is NULL and 'expr' is the
2940  * expression tree.
2941  */
2942 typedef struct StatsElem
2945  char *name; /* name of attribute to index, or NULL */
2946  Node *expr; /* expression to index, or NULL */
2947 } StatsElem;
2948 
2949 
2950 /* ----------------------
2951  * Alter Statistics Statement
2952  * ----------------------
2953  */
2954 typedef struct AlterStatsStmt
2957  List *defnames; /* qualified name (list of String) */
2958  int stxstattarget; /* statistics target */
2959  bool missing_ok; /* skip error if statistics object is missing */
2960 } AlterStatsStmt;
2961 
2962 /* ----------------------
2963  * Create Function Statement
2964  * ----------------------
2965  */
2966 typedef struct CreateFunctionStmt
2969  bool is_procedure; /* it's really CREATE PROCEDURE */
2970  bool replace; /* T => replace if already exists */
2971  List *funcname; /* qualified name of function to create */
2972  List *parameters; /* a list of FunctionParameter */
2973  TypeName *returnType; /* the return type */
2974  List *options; /* a list of DefElem */
2978 typedef enum FunctionParameterMode
2979 {
2980  /* the assigned enum values appear in pg_proc, don't change 'em! */
2981  FUNC_PARAM_IN = 'i', /* input only */
2982  FUNC_PARAM_OUT = 'o', /* output only */
2983  FUNC_PARAM_INOUT = 'b', /* both */
2984  FUNC_PARAM_VARIADIC = 'v', /* variadic (always input) */
2985  FUNC_PARAM_TABLE = 't', /* table function output column */
2986  /* this is not used in pg_proc: */
2987  FUNC_PARAM_DEFAULT = 'd' /* default; effectively same as IN */
2990 typedef struct FunctionParameter
2993  char *name; /* parameter name, or NULL if not given */
2994  TypeName *argType; /* TypeName for parameter type */
2995  FunctionParameterMode mode; /* IN/OUT/etc */
2996  Node *defexpr; /* raw default expr, or NULL if not given */
2999 typedef struct AlterFunctionStmt
3003  ObjectWithArgs *func; /* name and args of function */
3004  List *actions; /* list of DefElem */
3006 
3007 /* ----------------------
3008  * DO Statement
3009  *
3010  * DoStmt is the raw parser output, InlineCodeBlock is the execution-time API
3011  * ----------------------
3012  */
3013 typedef struct DoStmt
3016  List *args; /* List of DefElem nodes */
3017 } DoStmt;
3019 typedef struct InlineCodeBlock
3022  char *source_text; /* source text of anonymous code block */
3023  Oid langOid; /* OID of selected language */
3024  bool langIsTrusted; /* trusted property of the language */
3025  bool atomic; /* atomic execution context */
3026 } InlineCodeBlock;
3027 
3028 /* ----------------------
3029  * CALL statement
3030  *
3031  * OUT-mode arguments are removed from the transformed funcexpr. The outargs
3032  * list contains copies of the expressions for all output arguments, in the
3033  * order of the procedure's declared arguments. (outargs is never evaluated,
3034  * but is useful to the caller as a reference for what to assign to.)
3035  * ----------------------
3036  */
3037 typedef struct CallStmt
3040  FuncCall *funccall; /* from the parser */
3041  FuncExpr *funcexpr; /* transformed call, with only input args */
3042  List *outargs; /* transformed output-argument expressions */
3043 } CallStmt;
3045 typedef struct CallContext
3048  bool atomic;
3049 } CallContext;
3050 
3051 /* ----------------------
3052  * Alter Object Rename Statement
3053  * ----------------------
3054  */
3055 typedef struct RenameStmt
3058  ObjectType renameType; /* OBJECT_TABLE, OBJECT_COLUMN, etc */
3059  ObjectType relationType; /* if column name, associated relation type */
3060  RangeVar *relation; /* in case it's a table */
3061  Node *object; /* in case it's some other object */
3062  char *subname; /* name of contained object (column, rule,
3063  * trigger, etc) */
3064  char *newname; /* the new name */
3065  DropBehavior behavior; /* RESTRICT or CASCADE behavior */
3066  bool missing_ok; /* skip error if missing? */
3067 } RenameStmt;
3068 
3069 /* ----------------------
3070  * ALTER object DEPENDS ON EXTENSION extname
3071  * ----------------------
3072  */
3073 typedef struct AlterObjectDependsStmt
3076  ObjectType objectType; /* OBJECT_FUNCTION, OBJECT_TRIGGER, etc */
3077  RangeVar *relation; /* in case a table is involved */
3078  Node *object; /* name of the object */
3079  String *extname; /* extension name */
3080  bool remove; /* set true to remove dep rather than add */
3082 
3083 /* ----------------------
3084  * ALTER object SET SCHEMA Statement
3085  * ----------------------
3086  */
3087 typedef struct AlterObjectSchemaStmt
3090  ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
3091  RangeVar *relation; /* in case it's a table */
3092  Node *object; /* in case it's some other object */
3093  char *newschema; /* the new schema */
3094  bool missing_ok; /* skip error if missing? */
3096 
3097 /* ----------------------
3098  * Alter Object Owner Statement
3099  * ----------------------
3100  */
3101 typedef struct AlterOwnerStmt
3104  ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
3105  RangeVar *relation; /* in case it's a table */
3106  Node *object; /* in case it's some other object */
3107  RoleSpec *newowner; /* the new owner */
3108 } AlterOwnerStmt;
3109 
3110 /* ----------------------
3111  * Alter Operator Set ( this-n-that )
3112  * ----------------------
3113  */
3114 typedef struct AlterOperatorStmt
3117  ObjectWithArgs *opername; /* operator name and argument types */
3118  List *options; /* List of DefElem nodes */
3120 
3121 /* ------------------------
3122  * Alter Type Set ( this-n-that )
3123  * ------------------------
3124  */
3125 typedef struct AlterTypeStmt
3128  List *typeName; /* type name (possibly qualified) */
3129  List *options; /* List of DefElem nodes */
3130 } AlterTypeStmt;
3131 
3132 /* ----------------------
3133  * Create Rule Statement
3134  * ----------------------
3135  */
3136 typedef struct RuleStmt
3139  RangeVar *relation; /* relation the rule is for */
3140  char *rulename; /* name of the rule */
3141  Node *whereClause; /* qualifications */
3142  CmdType event; /* SELECT, INSERT, etc */
3143  bool instead; /* is a 'do instead'? */
3144  List *actions; /* the action statements */
3145  bool replace; /* OR REPLACE */
3146 } RuleStmt;
3147 
3148 /* ----------------------
3149  * Notify Statement
3150  * ----------------------
3151  */
3152 typedef struct NotifyStmt
3155  char *conditionname; /* condition name to notify */
3156  char *payload; /* the payload string, or NULL if none */
3157 } NotifyStmt;
3158 
3159 /* ----------------------
3160  * Listen Statement
3161  * ----------------------
3162  */
3163 typedef struct ListenStmt
3166  char *conditionname; /* condition name to listen on */
3167 } ListenStmt;
3168 
3169 /* ----------------------
3170  * Unlisten Statement
3171  * ----------------------
3172  */
3173 typedef struct UnlistenStmt
3176  char *conditionname; /* name to unlisten on, or NULL for all */
3177 } UnlistenStmt;
3178 
3179 /* ----------------------
3180  * {Begin|Commit|Rollback} Transaction Statement
3181  * ----------------------
3182  */
3183 typedef enum TransactionStmtKind
3186  TRANS_STMT_START, /* semantically identical to BEGIN */
3197 typedef struct TransactionStmt
3200  TransactionStmtKind kind; /* see above */
3201  List *options; /* for BEGIN/START commands */
3202  char *savepoint_name; /* for savepoint commands */
3203  char *gid; /* for two-phase-commit related commands */
3204  bool chain; /* AND CHAIN option */
3205 } TransactionStmt;
3206 
3207 /* ----------------------
3208  * Create Type Statement, composite types
3209  * ----------------------
3210  */
3211 typedef struct CompositeTypeStmt
3214  RangeVar *typevar; /* the composite type to be created */
3215  List *coldeflist; /* list of ColumnDef nodes */
3217 
3218 /* ----------------------
3219  * Create Type Statement, enum types
3220  * ----------------------
3221  */
3222 typedef struct CreateEnumStmt
3225  List *typeName; /* qualified name (list of String) */
3226  List *vals; /* enum values (list of String) */
3227 } CreateEnumStmt;
3228 
3229 /* ----------------------
3230  * Create Type Statement, range types
3231  * ----------------------
3232  */
3233 typedef struct CreateRangeStmt
3236  List *typeName; /* qualified name (list of String) */
3237  List *params; /* range parameters (list of DefElem) */
3238 } CreateRangeStmt;
3239 
3240 /* ----------------------
3241  * Alter Type Statement, enum types
3242  * ----------------------
3243  */
3244 typedef struct AlterEnumStmt
3247  List *typeName; /* qualified name (list of String) */
3248  char *oldVal; /* old enum value's name, if renaming */
3249  char *newVal; /* new enum value's name */
3250  char *newValNeighbor; /* neighboring enum value, if specified */
3251  bool newValIsAfter; /* place new enum value after neighbor? */
3252  bool skipIfNewValExists; /* no error if new already exists? */
3253 } AlterEnumStmt;
3254 
3255 /* ----------------------
3256  * Create View Statement
3257  * ----------------------
3258  */
3259 typedef enum ViewCheckOption
3264 } ViewCheckOption;
3266 typedef struct ViewStmt
3269  RangeVar *view; /* the view to be created */
3270  List *aliases; /* target column names */
3271  Node *query; /* the SELECT query (as a raw parse tree) */
3272  bool replace; /* replace an existing view? */
3273  List *options; /* options from WITH clause */
3274  ViewCheckOption withCheckOption; /* WITH CHECK OPTION */
3275 } ViewStmt;
3276 
3277 /* ----------------------
3278  * Load Statement
3279  * ----------------------
3280  */
3281 typedef struct LoadStmt
3284  char *filename; /* file to load */
3285 } LoadStmt;
3286 
3287 /* ----------------------
3288  * Createdb Statement
3289  * ----------------------
3290  */
3291 typedef struct CreatedbStmt
3294  char *dbname; /* name of database to create */
3295  List *options; /* List of DefElem nodes */
3296 } CreatedbStmt;
3297 
3298 /* ----------------------
3299  * Alter Database
3300  * ----------------------
3301  */
3302 typedef struct AlterDatabaseStmt
3305  char *dbname; /* name of database to alter */
3306  List *options; /* List of DefElem nodes */
3309 typedef struct AlterDatabaseSetStmt
3312  char *dbname; /* database name */
3313  VariableSetStmt *setstmt; /* SET or RESET subcommand */
3315 
3316 /* ----------------------
3317  * Dropdb Statement
3318  * ----------------------
3319  */
3320 typedef struct DropdbStmt
3323  char *dbname; /* database to drop */
3324  bool missing_ok; /* skip error if db is missing? */
3325  List *options; /* currently only FORCE is supported */
3326 } DropdbStmt;
3327 
3328 /* ----------------------
3329  * Alter System Statement
3330  * ----------------------
3331  */
3332 typedef struct AlterSystemStmt
3335  VariableSetStmt *setstmt; /* SET subcommand */
3336 } AlterSystemStmt;
3337 
3338 /* ----------------------
3339  * Cluster Statement (support pbrown's cluster index implementation)
3340  * ----------------------
3341  */
3342 typedef struct ClusterStmt
3345  RangeVar *relation; /* relation being indexed, or NULL if all */
3346  char *indexname; /* original index defined */
3347  List *params; /* list of DefElem nodes */
3348 } ClusterStmt;
3349 
3350 /* ----------------------
3351  * Vacuum and Analyze Statements
3352  *
3353  * Even though these are nominally two statements, it's convenient to use
3354  * just one node type for both.
3355  * ----------------------
3356  */
3357 typedef struct VacuumStmt
3360  List *options; /* list of DefElem nodes */
3361  List *rels; /* list of VacuumRelation, or NIL for all */
3362  bool is_vacuumcmd; /* true for VACUUM, false for ANALYZE */
3363 } VacuumStmt;
3364 
3365 /*
3366  * Info about a single target table of VACUUM/ANALYZE.
3367  *
3368  * If the OID field is set, it always identifies the table to process.
3369  * Then the relation field can be NULL; if it isn't, it's used only to report
3370  * failure to open/lock the relation.
3371  */
3372 typedef struct VacuumRelation
3375  RangeVar *relation; /* table name to process, or NULL */
3376  Oid oid; /* table's OID; InvalidOid if not looked up */
3377  List *va_cols; /* list of column names, or NIL for all */
3378 } VacuumRelation;
3379 
3380 /* ----------------------
3381  * Explain Statement
3382  *
3383  * The "query" field is initially a raw parse tree, and is converted to a
3384  * Query node during parse analysis. Note that rewriting and planning
3385  * of the query are always postponed until execution.
3386  * ----------------------
3387  */
3388 typedef struct ExplainStmt
3391  Node *query; /* the query (see comments above) */
3392  List *options; /* list of DefElem nodes */
3393 } ExplainStmt;
3394 
3395 /* ----------------------
3396  * CREATE TABLE AS Statement (a/k/a SELECT INTO)
3397  *
3398  * A query written as CREATE TABLE AS will produce this node type natively.
3399  * A query written as SELECT ... INTO will be transformed to this form during
3400  * parse analysis.
3401  * A query written as CREATE MATERIALIZED view will produce this node type,
3402  * during parse analysis, since it needs all the same data.
3403  *
3404  * The "query" field is handled similarly to EXPLAIN, though note that it
3405  * can be a SELECT or an EXECUTE, but not other DML statements.
3406  * ----------------------
3407  */
3408 typedef struct CreateTableAsStmt
3411  Node *query; /* the query (see comments above) */
3412  IntoClause *into; /* destination table */
3413  ObjectType objtype; /* OBJECT_TABLE or OBJECT_MATVIEW */
3414  bool is_select_into; /* it was written as SELECT INTO */
3415  bool if_not_exists; /* just do nothing if it already exists? */
3417 
3418 /* ----------------------
3419  * REFRESH MATERIALIZED VIEW Statement
3420  * ----------------------
3421  */
3422 typedef struct RefreshMatViewStmt
3425  bool concurrent; /* allow concurrent access? */
3426  bool skipData; /* true for WITH NO DATA */
3427  RangeVar *relation; /* relation to insert into */
3429 
3430 /* ----------------------
3431  * Checkpoint Statement
3432  * ----------------------
3433  */
3434 typedef struct CheckPointStmt
3437 } CheckPointStmt;
3438 
3439 /* ----------------------
3440  * Discard Statement
3441  * ----------------------
3442  */
3444 typedef enum DiscardMode
3450 } DiscardMode;
3452 typedef struct DiscardStmt
3456 } DiscardStmt;
3457 
3458 /* ----------------------
3459  * LOCK Statement
3460  * ----------------------
3461  */
3462 typedef struct LockStmt
3465  List *relations; /* relations to lock */
3466  int mode; /* lock mode */
3467  bool nowait; /* no wait mode */
3468 } LockStmt;
3469 
3470 /* ----------------------
3471  * SET CONSTRAINTS Statement
3472  * ----------------------
3473  */
3474 typedef struct ConstraintsSetStmt
3477  List *constraints; /* List of names as RangeVars */
3478  bool deferred;
3480 
3481 /* ----------------------
3482  * REINDEX Statement
3483  * ----------------------
3484  */
3485 typedef enum ReindexObjectType
3488  REINDEX_OBJECT_TABLE, /* table or materialized view */
3490  REINDEX_OBJECT_SYSTEM, /* system catalogs */
3494 typedef struct ReindexStmt
3497  ReindexObjectType kind; /* REINDEX_OBJECT_INDEX, REINDEX_OBJECT_TABLE,
3498  * etc. */
3499  RangeVar *relation; /* Table or index to reindex */
3500  const char *name; /* name of database to reindex */
3501  List *params; /* list of DefElem nodes */
3502 } ReindexStmt;
3503 
3504 /* ----------------------
3505  * CREATE CONVERSION Statement
3506  * ----------------------
3507  */
3508 typedef struct CreateConversionStmt
3511  List *conversion_name; /* Name of the conversion */
3512  char *for_encoding_name; /* source encoding name */
3513  char *to_encoding_name; /* destination encoding name */
3514  List *func_name; /* qualified conversion function name */
3515  bool def; /* is this a default conversion? */
3517 
3518 /* ----------------------
3519  * CREATE CAST Statement
3520  * ----------------------
3521  */
3522 typedef struct CreateCastStmt
3529  bool inout;
3530 } CreateCastStmt;
3531 
3532 /* ----------------------
3533  * CREATE TRANSFORM Statement
3534  * ----------------------
3535  */
3536 typedef struct CreateTransformStmt
3539  bool replace;
3541  char *lang;
3545 
3546 /* ----------------------
3547  * PREPARE Statement
3548  * ----------------------
3549  */
3550 typedef struct PrepareStmt
3553  char *name; /* Name of plan, arbitrary */
3554  List *argtypes; /* Types of parameters (List of TypeName) */
3555  Node *query; /* The query itself (as a raw parsetree) */
3556 } PrepareStmt;
3557 
3558 
3559 /* ----------------------
3560  * EXECUTE Statement
3561  * ----------------------
3562  */
3564 typedef struct ExecuteStmt
3567  char *name; /* The name of the plan to execute */
3568  List *params; /* Values to assign to parameters */
3569 } ExecuteStmt;
3570 
3571 
3572 /* ----------------------
3573  * DEALLOCATE Statement
3574  * ----------------------
3575  */
3576 typedef struct DeallocateStmt
3579  char *name; /* The name of the plan to remove */
3580  /* NULL means DEALLOCATE ALL */
3581 } DeallocateStmt;
3582 
3583 /*
3584  * DROP OWNED statement
3585  */
3586 typedef struct DropOwnedStmt
3591 } DropOwnedStmt;
3592 
3593 /*
3594  * REASSIGN OWNED statement
3595  */
3596 typedef struct ReassignOwnedStmt
3602 
3603 /*
3604  * TS Dictionary stmts: DefineStmt, RenameStmt and DropStmt are default
3605  */
3606 typedef struct AlterTSDictionaryStmt
3609  List *dictname; /* qualified name (list of String) */
3610  List *options; /* List of DefElem nodes */
3612 
3613 /*
3614  * TS Configuration stmts: DefineStmt, RenameStmt and DropStmt are default
3615  */
3616 typedef enum AlterTSConfigType
3625 typedef struct AlterTSConfigurationStmt
3628  AlterTSConfigType kind; /* ALTER_TSCONFIG_ADD_MAPPING, etc */
3629  List *cfgname; /* qualified name (list of String) */
3630 
3631  /*
3632  * dicts will be non-NIL if ADD/ALTER MAPPING was specified. If dicts is
3633  * NIL, but tokentype isn't, DROP MAPPING was specified.
3634  */
3635  List *tokentype; /* list of String */
3636  List *dicts; /* list of list of String */
3637  bool override; /* if true - remove old variant */
3638  bool replace; /* if true - replace dictionary by another */
3639  bool missing_ok; /* for DROP - skip error if missing? */
3642 typedef struct PublicationTable
3645  RangeVar *relation; /* relation to be published */
3647 
3648 /*
3649  * Publication object type
3650  */
3651 typedef enum PublicationObjSpecType
3653  PUBLICATIONOBJ_TABLE, /* A table */
3654  PUBLICATIONOBJ_TABLES_IN_SCHEMA, /* All tables in schema */
3655  PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA, /* All tables in first element of
3656  * search_path */
3657  PUBLICATIONOBJ_CONTINUATION /* Continuation of previous type */
3660 typedef struct PublicationObjSpec
3663  PublicationObjSpecType pubobjtype; /* type of this publication object */
3664  char *name;
3666  int location; /* token location, or -1 if unknown */
3669 typedef struct CreatePublicationStmt
3672  char *pubname; /* Name of the publication */
3673  List *options; /* List of DefElem nodes */
3674  List *pubobjects; /* Optional list of publication objects */
3675  bool for_all_tables; /* Special publication for all tables in db */
3678 typedef enum AlterPublicationAction
3680  AP_AddObjects, /* add objects to publication */
3681  AP_DropObjects, /* remove objects from publication */
3682  AP_SetObjects /* set list of objects */
3685 typedef struct AlterPublicationStmt
3688  char *pubname; /* Name of the publication */
3689 
3690  /* parameters used for ALTER PUBLICATION ... WITH */
3691  List *options; /* List of DefElem nodes */
3692 
3693  /*
3694  * Parameters used for ALTER PUBLICATION ... ADD/DROP/SET publication
3695  * objects.
3696  */
3697  List *pubobjects; /* Optional list of publication objects */
3698  bool for_all_tables; /* Special publication for all tables in db */
3699  AlterPublicationAction action; /* What action to perform with the given
3700  * objects */
3703 typedef struct CreateSubscriptionStmt
3706  char *subname; /* Name of the subscription */
3707  char *conninfo; /* Connection string to publisher */
3708  List *publication; /* One or more publication to subscribe to */
3709  List *options; /* List of DefElem nodes */
3712 typedef enum AlterSubscriptionType
3723 typedef struct AlterSubscriptionStmt
3726  AlterSubscriptionType kind; /* ALTER_SUBSCRIPTION_OPTIONS, etc */
3727  char *subname; /* Name of the subscription */
3728  char *conninfo; /* Connection string to publisher */
3729  List *publication; /* One or more publication to subscribe to */
3730  List *options; /* List of DefElem nodes */
3733 typedef struct DropSubscriptionStmt
3736  char *subname; /* Name of the subscription */
3737  bool missing_ok; /* Skip error if missing? */
3738  DropBehavior behavior; /* RESTRICT or CASCADE behavior */
3740 
3741 #endif /* PARSENODES_H */
unsigned int uint32
Definition: c.h:441
#define PG_INT32_MAX
Definition: c.h:524
signed short int16
Definition: c.h:428
uint32 SubTransactionId
Definition: c.h:591
signed int int32
Definition: c.h:429
uint32 bits32
Definition: c.h:450
unsigned int Index
Definition: c.h:549
LockWaitPolicy
Definition: lockoptions.h:37
LockClauseStrength
Definition: lockoptions.h:22
OnConflictAction
Definition: nodes.h:834
double Cardinality
Definition: nodes.h:674
CmdType
Definition: nodes.h:684
NodeTag
Definition: nodes.h:27
LimitOption
Definition: nodes.h:847
JoinType
Definition: nodes.h:708
struct LoadStmt LoadStmt
RoleSpecType
Definition: parsenodes.h:340
@ ROLESPEC_CURRENT_USER
Definition: parsenodes.h:343
@ ROLESPEC_CSTRING
Definition: parsenodes.h:341
@ ROLESPEC_SESSION_USER
Definition: parsenodes.h:344
@ ROLESPEC_CURRENT_ROLE
Definition: parsenodes.h:342
@ ROLESPEC_PUBLIC
Definition: parsenodes.h:345
struct DropSubscriptionStmt DropSubscriptionStmt
struct CreateEnumStmt CreateEnumStmt
struct RoleSpec RoleSpec
struct CreateFunctionStmt CreateFunctionStmt
struct AlterOwnerStmt AlterOwnerStmt
struct ReturnStmt ReturnStmt
struct CreateAmStmt CreateAmStmt
AlterSubscriptionType
Definition: parsenodes.h:3712
@ ALTER_SUBSCRIPTION_ENABLED
Definition: parsenodes.h:3719
@ ALTER_SUBSCRIPTION_DROP_PUBLICATION
Definition: parsenodes.h:3717
@ ALTER_SUBSCRIPTION_SET_PUBLICATION
Definition: parsenodes.h:3715
@ ALTER_SUBSCRIPTION_REFRESH
Definition: parsenodes.h:3718
@ ALTER_SUBSCRIPTION_OPTIONS
Definition: parsenodes.h:3713
@ ALTER_SUBSCRIPTION_CONNECTION
Definition: parsenodes.h:3714
@ ALTER_SUBSCRIPTION_ADD_PUBLICATION
Definition: parsenodes.h:3716
struct TableLikeClause TableLikeClause
struct AlterSystemStmt AlterSystemStmt
struct CopyStmt CopyStmt
TransactionStmtKind
Definition: parsenodes.h:3183
@ TRANS_STMT_ROLLBACK_TO
Definition: parsenodes.h:3190
@ TRANS_STMT_START
Definition: parsenodes.h:3185
@ TRANS_STMT_SAVEPOINT
Definition: parsenodes.h:3188
@ TRANS_STMT_BEGIN
Definition: parsenodes.h:3184
@ TRANS_STMT_ROLLBACK
Definition: parsenodes.h:3187
@ TRANS_STMT_COMMIT_PREPARED
Definition: parsenodes.h:3192
@ TRANS_STMT_COMMIT
Definition: parsenodes.h:3186
@ TRANS_STMT_ROLLBACK_PREPARED
Definition: parsenodes.h:3193
@ TRANS_STMT_PREPARE
Definition: parsenodes.h:3191
@ TRANS_STMT_RELEASE
Definition: parsenodes.h:3189
struct GrantRoleStmt GrantRoleStmt
struct AlterTSDictionaryStmt AlterTSDictionaryStmt
struct OnConflictClause OnConflictClause
struct AlterOperatorStmt AlterOperatorStmt
WCOKind
Definition: parsenodes.h:1217
@ WCO_RLS_CONFLICT_CHECK
Definition: parsenodes.h:1221
@ WCO_RLS_INSERT_CHECK
Definition: parsenodes.h:1219
@ WCO_VIEW_CHECK
Definition: parsenodes.h:1218
@ WCO_RLS_UPDATE_CHECK
Definition: parsenodes.h:1220
struct RangeTblFunction RangeTblFunction
struct A_Indirection A_Indirection
struct XmlSerialize XmlSerialize
SortByNulls
Definition: parsenodes.h:59
@ SORTBY_NULLS_DEFAULT
Definition: parsenodes.h:60
@ SORTBY_NULLS_LAST
Definition: parsenodes.h:62
@ SORTBY_NULLS_FIRST
Definition: parsenodes.h:61
struct DeallocateStmt DeallocateStmt
struct CreateSeqStmt CreateSeqStmt
struct DropTableSpaceStmt DropTableSpaceStmt
struct CreateExtensionStmt CreateExtensionStmt
struct A_Indices A_Indices
struct CreateTableSpaceStmt CreateTableSpaceStmt
GroupingSetKind
Definition: parsenodes.h:1353
@ GROUPING_SET_CUBE
Definition: parsenodes.h:1357
@ GROUPING_SET_SIMPLE
Definition: parsenodes.h:1355
@ GROUPING_SET_ROLLUP
Definition: parsenodes.h:1356
@ GROUPING_SET_SETS
Definition: parsenodes.h:1358
@ GROUPING_SET_EMPTY
Definition: parsenodes.h:1354
struct ReassignOwnedStmt ReassignOwnedStmt
struct ParamRef ParamRef
struct VacuumStmt VacuumStmt
struct NotifyStmt NotifyStmt
SetOperation
Definition: parsenodes.h:1644
@ SETOP_INTERSECT
Definition: parsenodes.h:1647
@ SETOP_UNION
Definition: parsenodes.h:1646
@ SETOP_EXCEPT
Definition: parsenodes.h:1648
@ SETOP_NONE
Definition: parsenodes.h:1645
struct TriggerTransition TriggerTransition
struct ClusterStmt ClusterStmt
struct SelectStmt SelectStmt
struct DropdbStmt DropdbStmt
struct FunctionParameter FunctionParameter
struct UnlistenStmt UnlistenStmt
struct InsertStmt InsertStmt
struct AlterFunctionStmt AlterFunctionStmt
struct StatsElem StatsElem
struct AlterRoleSetStmt AlterRoleSetStmt
struct CreateOpFamilyStmt CreateOpFamilyStmt
struct CreatePublicationStmt CreatePublicationStmt
struct InlineCodeBlock InlineCodeBlock
struct CreateDomainStmt CreateDomainStmt
struct AlterDomainStmt AlterDomainStmt
struct AlterDefaultPrivilegesStmt AlterDefaultPrivilegesStmt
struct CreateStatsStmt CreateStatsStmt
struct UpdateStmt UpdateStmt
struct AlterObjectDependsStmt AlterObjectDependsStmt
struct IndexElem IndexElem
struct AlterCollationStmt AlterCollationStmt
A_Expr_Kind
Definition: parsenodes.h:264
@ AEXPR_BETWEEN
Definition: parsenodes.h:275
@ AEXPR_NULLIF
Definition: parsenodes.h:270
@ AEXPR_NOT_DISTINCT
Definition: parsenodes.h:269
@ AEXPR_BETWEEN_SYM
Definition: parsenodes.h:277
@ AEXPR_NOT_BETWEEN_SYM
Definition: parsenodes.h:278
@ AEXPR_ILIKE
Definition: parsenodes.h:273
@ AEXPR_IN
Definition: parsenodes.h:271
@ AEXPR_NOT_BETWEEN
Definition: parsenodes.h:276
@ AEXPR_DISTINCT
Definition: parsenodes.h:268
@ AEXPR_SIMILAR
Definition: parsenodes.h:274
@ AEXPR_LIKE
Definition: parsenodes.h:272
@ AEXPR_OP
Definition: parsenodes.h:265
@ AEXPR_OP_ANY
Definition: parsenodes.h:266
@ AEXPR_OP_ALL
Definition: parsenodes.h:267
FunctionParameterMode
Definition: parsenodes.h:2978
@ FUNC_PARAM_IN
Definition: parsenodes.h:2980
@ FUNC_PARAM_DEFAULT
Definition: parsenodes.h:2986
@ FUNC_PARAM_OUT
Definition: parsenodes.h:2981
@ FUNC_PARAM_INOUT
Definition: parsenodes.h:2982
@ FUNC_PARAM_TABLE
Definition: parsenodes.h:2984
@ FUNC_PARAM_VARIADIC
Definition: parsenodes.h:2983
struct CreateForeignTableStmt CreateForeignTableStmt
struct CreateOpClassStmt CreateOpClassStmt
AlterTSConfigType
Definition: parsenodes.h:3616
@ ALTER_TSCONFIG_ALTER_MAPPING_FOR_TOKEN
Definition: parsenodes.h:3618
@ ALTER_TSCONFIG_REPLACE_DICT_FOR_TOKEN
Definition: parsenodes.h:3620
@ ALTER_TSCONFIG_REPLACE_DICT
Definition: parsenodes.h:3619
@ ALTER_TSCONFIG_ADD_MAPPING
Definition: parsenodes.h:3617
@ ALTER_TSCONFIG_DROP_MAPPING
Definition: parsenodes.h:3621
struct AlterForeignServerStmt AlterForeignServerStmt
struct ColumnDef ColumnDef
struct CreatedbStmt CreatedbStmt
struct AlterEventTrigStmt AlterEventTrigStmt
struct IndexStmt IndexStmt
struct PartitionCmd PartitionCmd
PublicationObjSpecType
Definition: parsenodes.h:3651
@ PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA
Definition: parsenodes.h:3654
@ PUBLICATIONOBJ_TABLES_IN_SCHEMA
Definition: parsenodes.h:3653
@ PUBLICATIONOBJ_TABLE
Definition: parsenodes.h:3652
@ PUBLICATIONOBJ_CONTINUATION
Definition: parsenodes.h:3656
ImportForeignSchemaType
Definition: parsenodes.h:2477
@ FDW_IMPORT_SCHEMA_LIMIT_TO
Definition: parsenodes.h:2479
@ FDW_IMPORT_SCHEMA_ALL
Definition: parsenodes.h:2478
@ FDW_IMPORT_SCHEMA_EXCEPT
Definition: parsenodes.h:2480
struct AlterRoleStmt AlterRoleStmt
struct WindowDef WindowDef
struct CommentStmt CommentStmt
AlterPublicationAction
Definition: parsenodes.h:3678
@ AP_DropObjects
Definition: parsenodes.h:3680
@ AP_SetObjects
Definition: parsenodes.h:3681
@ AP_AddObjects
Definition: parsenodes.h:3679
struct Query Query
QuerySource
Definition: parsenodes.h:41
@ QSRC_NON_INSTEAD_RULE
Definition: parsenodes.h:46
@ QSRC_PARSER
Definition: parsenodes.h:43
@ QSRC_QUAL_INSTEAD_RULE
Definition: parsenodes.h:45
@ QSRC_ORIGINAL
Definition: parsenodes.h:42
@ QSRC_INSTEAD_RULE
Definition: parsenodes.h:44
struct WithClause WithClause
struct AlterObjectSchemaStmt AlterObjectSchemaStmt
struct MultiAssignRef MultiAssignRef
struct ImportForeignSchemaStmt ImportForeignSchemaStmt
struct ReindexStmt ReindexStmt
struct CreateSubscriptionStmt CreateSubscriptionStmt
struct A_Const A_Const
struct DeleteStmt DeleteStmt
RTEKind
Definition: parsenodes.h:989
@ RTE_JOIN
Definition: parsenodes.h:992
@ RTE_CTE
Definition: parsenodes.h:996
@ RTE_NAMEDTUPLESTORE
Definition: parsenodes.h:997
@ RTE_VALUES
Definition: parsenodes.h:995
@ RTE_SUBQUERY
Definition: parsenodes.h:991
@ RTE_RESULT
Definition: parsenodes.h:998
@ RTE_FUNCTION
Definition: parsenodes.h:993
@ RTE_TABLEFUNC
Definition: parsenodes.h:994
@ RTE_RELATION
Definition: parsenodes.h:990
struct AlterSubscriptionStmt AlterSubscriptionStmt
struct AlterStatsStmt AlterStatsStmt
struct AlterPublicationStmt AlterPublicationStmt
struct RangeFunction RangeFunction
struct PLAssignStmt PLAssignStmt
DefElemAction
Definition: parsenodes.h:747
@ DEFELEM_UNSPEC
Definition: parsenodes.h:748
@ DEFELEM_DROP
Definition: parsenodes.h:751
@ DEFELEM_SET
Definition: parsenodes.h:749
@ DEFELEM_ADD
Definition: parsenodes.h:750
struct ColumnRef ColumnRef
ConstrType
Definition: parsenodes.h:2231
@ CONSTR_FOREIGN
Definition: parsenodes.h:2242
@ CONSTR_ATTR_DEFERRED
Definition: parsenodes.h:2245
@ CONSTR_IDENTITY
Definition: parsenodes.h:2236
@ CONSTR_UNIQUE
Definition: parsenodes.h:2240
@ CONSTR_ATTR_NOT_DEFERRABLE
Definition: parsenodes.h:2244
@ CONSTR_DEFAULT
Definition: parsenodes.h:2235
@ CONSTR_NOTNULL
Definition: parsenodes.h:2234
@ CONSTR_ATTR_IMMEDIATE
Definition: parsenodes.h:2246
@ CONSTR_CHECK
Definition: parsenodes.h:2238
@ CONSTR_NULL
Definition: parsenodes.h:2232
@ CONSTR_GENERATED
Definition: parsenodes.h:2237
@ CONSTR_EXCLUSION
Definition: parsenodes.h:2241
@ CONSTR_ATTR_DEFERRABLE
Definition: parsenodes.h:2243
@ CONSTR_PRIMARY
Definition: parsenodes.h:2239
PartitionRangeDatumKind
Definition: parsenodes.h:863
@ PARTITION_RANGE_DATUM_MAXVALUE
Definition: parsenodes.h:866
@ PARTITION_RANGE_DATUM_VALUE
Definition: parsenodes.h:865
@ PARTITION_RANGE_DATUM_MINVALUE
Definition: parsenodes.h:864
struct GroupingSet GroupingSet
struct CreatePolicyStmt CreatePolicyStmt
FetchDirection
Definition: parsenodes.h:2856
@ FETCH_RELATIVE
Definition: parsenodes.h:2862
@ FETCH_ABSOLUTE
Definition: parsenodes.h:2861
@ FETCH_FORWARD
Definition: parsenodes.h:2858
@ FETCH_BACKWARD
Definition: parsenodes.h:2859
VariableSetKind
Definition: parsenodes.h:2142
@ VAR_SET_DEFAULT
Definition: parsenodes.h:2144
@ VAR_RESET
Definition: parsenodes.h:2147
@ VAR_SET_MULTI
Definition: parsenodes.h:2146
@ VAR_SET_VALUE
Definition: parsenodes.h:2143
@ VAR_SET_CURRENT
Definition: parsenodes.h:2145
@ VAR_RESET_ALL
Definition: parsenodes.h:2148
DropBehavior
Definition: parsenodes.h:1860
@ DROP_CASCADE
Definition: parsenodes.h:1862
@ DROP_RESTRICT
Definition: parsenodes.h:1861
ObjectType
Definition: parsenodes.h:1788
@ OBJECT_EVENT_TRIGGER
Definition: parsenodes.h:1803
@ OBJECT_FDW
Definition: parsenodes.h:1805
@ OBJECT_TSPARSER
Definition: parsenodes.h:1835
@ OBJECT_COLLATION
Definition: parsenodes.h:1796
@ OBJECT_USER_MAPPING
Definition: parsenodes.h:1838
@ OBJECT_ACCESS_METHOD
Definition: parsenodes.h:1789
@ OBJECT_OPCLASS
Definition: parsenodes.h:1813
@ OBJECT_DEFACL
Definition: parsenodes.h:1800
@ OBJECT_AGGREGATE
Definition: parsenodes.h:1790
@ OBJECT_MATVIEW
Definition: parsenodes.h:1812
@ OBJECT_SCHEMA
Definition: parsenodes.h:1824
@ OBJECT_POLICY
Definition: parsenodes.h:1816
@ OBJECT_OPERATOR
Definition: parsenodes.h:1814
@ OBJECT_FOREIGN_TABLE
Definition: parsenodes.h:1807
@ OBJECT_TSCONFIGURATION
Definition: parsenodes.h:1833
@ OBJECT_OPFAMILY
Definition: parsenodes.h:1815
@ OBJECT_DOMAIN
Definition: parsenodes.h:1801
@ OBJECT_COLUMN
Definition: parsenodes.h:1795
@ OBJECT_TABLESPACE
Definition: parsenodes.h:1830
@ OBJECT_ROLE
Definition: parsenodes.h:1821
@ OBJECT_ROUTINE
Definition: parsenodes.h:1822
@ OBJECT_LARGEOBJECT
Definition: parsenodes.h:1811
@ OBJECT_PUBLICATION_NAMESPACE
Definition: parsenodes.h:1819
@ OBJECT_PROCEDURE
Definition: parsenodes.h:1817
@ OBJECT_EXTENSION
Definition: parsenodes.h:1804
@ OBJECT_INDEX
Definition: parsenodes.h:1809
@ OBJECT_DEFAULT
Definition: parsenodes.h:1799
@ OBJECT_DATABASE
Definition: parsenodes.h:1798
@ OBJECT_SEQUENCE
Definition: parsenodes.h:1825
@ OBJECT_TSTEMPLATE
Definition: parsenodes.h:1836
@ OBJECT_LANGUAGE
Definition: parsenodes.h:1810
@ OBJECT_AMOP
Definition: parsenodes.h:1791
@ OBJECT_PUBLICATION_REL
Definition: parsenodes.h:1820
@ OBJECT_FOREIGN_SERVER
Definition: parsenodes.h:1806
@ OBJECT_TSDICTIONARY
Definition: parsenodes.h:1834
@ OBJECT_ATTRIBUTE
Definition: parsenodes.h:1793
@ OBJECT_PUBLICATION
Definition: parsenodes.h:1818
@ OBJECT_RULE
Definition: parsenodes.h:1823
@ OBJECT_CONVERSION
Definition: parsenodes.h:1797
@ OBJECT_AMPROC
Definition: parsenodes.h:1792
@ OBJECT_TABLE
Definition: parsenodes.h:1829
@ OBJECT_VIEW
Definition: parsenodes.h:1839
@ OBJECT_TYPE
Definition: parsenodes.h:1837
@ OBJECT_FUNCTION
Definition: parsenodes.h:1808
@ OBJECT_TABCONSTRAINT
Definition: parsenodes.h:1828
@ OBJECT_DOMCONSTRAINT
Definition: parsenodes.h:1802
@ OBJECT_SUBSCRIPTION
Definition: parsenodes.h:1826
@ OBJECT_STATISTIC_EXT
Definition: parsenodes.h:1827
@ OBJECT_CAST
Definition: parsenodes.h:1794
@ OBJECT_TRIGGER
Definition: parsenodes.h:1832
@ OBJECT_TRANSFORM
Definition: parsenodes.h:1831
struct ListenStmt ListenStmt
struct A_Star A_Star
struct PublicationObjSpec PublicationObjSpec
struct AlterTableSpaceOptionsStmt AlterTableSpaceOptionsStmt
struct CreateRoleStmt CreateRoleStmt
struct AlterTableCmd AlterTableCmd
struct RangeTableSample RangeTableSample
struct DropUserMappingStmt DropUserMappingStmt
ReindexObjectType
Definition: parsenodes.h:3485
@ REINDEX_OBJECT_DATABASE
Definition: parsenodes.h:3490
@ REINDEX_OBJECT_INDEX
Definition: parsenodes.h:3486
@ REINDEX_OBJECT_SCHEMA
Definition: parsenodes.h:3488
@ REINDEX_OBJECT_SYSTEM
Definition: parsenodes.h:3489
@ REINDEX_OBJECT_TABLE
Definition: parsenodes.h:3487
struct CreateForeignServerStmt CreateForeignServerStmt
struct LockingClause LockingClause
AlterTableType
Definition: parsenodes.h:1879
@ AT_AddIndexConstraint
Definition: parsenodes.h:1905
@ AT_DropOf
Definition: parsenodes.h:1937
@ AT_CheckNotNull
Definition: parsenodes.h:1888
@ AT_SetOptions
Definition: parsenodes.h:1890
@ AT_DropIdentity
Definition: parsenodes.h:1949
@ AT_DisableTrigUser
Definition: parsenodes.h:1929
@ AT_DropNotNull
Definition: parsenodes.h:1885
@ AT_AddOf
Definition: parsenodes.h:1936
@ AT_ResetOptions
Definition: parsenodes.h:1891
@ AT_ReplicaIdentity
Definition: parsenodes.h:1938
@ AT_DropColumnRecurse
Definition: parsenodes.h:1895
@ AT_ReplaceRelOptions
Definition: parsenodes.h:1921
@ AT_EnableRowSecurity
Definition: parsenodes.h:1939
@ AT_AddColumnToView
Definition: parsenodes.h:1882
@ AT_ResetRelOptions
Definition: parsenodes.h:1920
@ AT_AddConstraintRecurse
Definition: parsenodes.h:1899
@ AT_EnableReplicaTrig
Definition: parsenodes.h:1924
@ AT_DropOids
Definition: parsenodes.h:1916
@ AT_SetIdentity
Definition: parsenodes.h:1948
@ AT_ReAddStatistics
Definition: parsenodes.h:1950
@ AT_SetUnLogged
Definition: parsenodes.h:1915
@ AT_DisableTrig
Definition: parsenodes.h:1925
@ AT_SetCompression
Definition: parsenodes.h:1893
@ AT_DropExpression
Definition: parsenodes.h:1887
@ AT_AddIndex
Definition: parsenodes.h:1896
@ AT_EnableReplicaRule
Definition: parsenodes.h:1932
@ AT_ReAddIndex
Definition: parsenodes.h:1897
@ AT_DropConstraint
Definition: parsenodes.h:1906
@ AT_SetNotNull
Definition: parsenodes.h:1886
@ AT_ClusterOn
Definition: parsenodes.h:1912
@ AT_AddIdentity
Definition: parsenodes.h:1947
@ AT_ForceRowSecurity
Definition: parsenodes.h:1941
@ AT_EnableAlwaysRule
Definition: parsenodes.h:1931
@ AT_SetAccessMethod
Definition: parsenodes.h:1917
@ AT_AlterColumnType
Definition: parsenodes.h:1909
@ AT_DetachPartitionFinalize
Definition: parsenodes.h:1946
@ AT_AddInherit
Definition: parsenodes.h:1934
@ AT_ReAddDomainConstraint
Definition: parsenodes.h:1901
@ AT_EnableTrig
Definition: parsenodes.h:1922
@ AT_AddColumnRecurse
Definition: parsenodes.h:1881
@ AT_DropColumn
Definition: parsenodes.h:1894
@ AT_ValidateConstraintRecurse
Definition: parsenodes.h:1904
@ AT_ReAddComment
Definition: parsenodes.h:1908
@ AT_AlterColumnGenericOptions
Definition: parsenodes.h:1910
@ AT_DisableTrigAll
Definition: parsenodes.h:1927
@ AT_EnableRule
Definition: parsenodes.h:1930
@ AT_NoForceRowSecurity
Definition: parsenodes.h:1942
@ AT_DetachPartition
Definition: parsenodes.h:1945
@ AT_SetStatistics
Definition: parsenodes.h:1889
@ AT_AttachPartition
Definition: parsenodes.h:1944
@ AT_AddConstraint
Definition: parsenodes.h:1898
@ AT_DropInherit
Definition: parsenodes.h:1935
@ AT_EnableAlwaysTrig
Definition: parsenodes.h:1923
@ AT_SetLogged
Definition: parsenodes.h:1914
@ AT_SetStorage
Definition: parsenodes.h:1892
@ AT_DisableRule
Definition: parsenodes.h:1933
@ AT_DisableRowSecurity
Definition: parsenodes.h:1940
@ AT_SetRelOptions
Definition: parsenodes.h:1919
@ AT_ChangeOwner
Definition: parsenodes.h:1911
@ AT_EnableTrigUser
Definition: parsenodes.h:1928
@ AT_ReAddConstraint
Definition: parsenodes.h:1900
@ AT_DropConstraintRecurse
Definition: parsenodes.h:1907
@ AT_SetTableSpace
Definition: parsenodes.h:1918
@ AT_GenericOptions
Definition: parsenodes.h:1943
@ AT_ColumnDefault
Definition: parsenodes.h:1883
@ AT_CookedColumnDefault
Definition: parsenodes.h:1884
@ AT_AlterConstraint
Definition: parsenodes.h:1902
@ AT_EnableTrigAll
Definition: parsenodes.h:1926
@ AT_DropCluster
Definition: parsenodes.h:1913
@ AT_ValidateConstraint
Definition: parsenodes.h:1903
@ AT_AddColumn
Definition: parsenodes.h:1880
struct WithCheckOption WithCheckOption
struct LockStmt LockStmt
GrantTargetType
Definition: parsenodes.h:2018
@ ACL_TARGET_DEFAULTS
Definition: parsenodes.h:2021
@ ACL_TARGET_OBJECT
Definition: parsenodes.h:2019
@ ACL_TARGET_ALL_IN_SCHEMA
Definition: parsenodes.h:2020
struct CreateEventTrigStmt CreateEventTrigStmt
struct DropOwnedStmt DropOwnedStmt
struct VariableShowStmt VariableShowStmt
struct CreateTransformStmt CreateTransformStmt
struct AlterUserMappingStmt AlterUserMappingStmt
struct PartitionRangeDatum PartitionRangeDatum
struct A_ArrayExpr A_ArrayExpr
struct RangeTableFunc RangeTableFunc
struct InferClause InferClause
struct RangeSubselect RangeSubselect
struct DropStmt DropStmt
struct CreateOpClassItem CreateOpClassItem
struct PrepareStmt PrepareStmt
struct AlterOpFamilyStmt AlterOpFamilyStmt
struct ConstraintsSetStmt ConstraintsSetStmt
struct GrantStmt GrantStmt
struct A_Expr A_Expr
OverridingKind
Definition: parsenodes.h:33
@ OVERRIDING_NOT_SET
Definition: parsenodes.h:34
@ OVERRIDING_SYSTEM_VALUE
Definition: parsenodes.h:36
@ OVERRIDING_USER_VALUE
Definition: pars