PostgreSQL Source Code  git master
primnodes.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * primnodes.h
4  * Definitions for "primitive" node types, those that are used in more
5  * than one of the parse/plan/execute stages of the query pipeline.
6  * Currently, these are mostly nodes for executable expressions
7  * and join trees.
8  *
9  *
10  * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
11  * Portions Copyright (c) 1994, Regents of the University of California
12  *
13  * src/include/nodes/primnodes.h
14  *
15  *-------------------------------------------------------------------------
16  */
17 #ifndef PRIMNODES_H
18 #define PRIMNODES_H
19 
20 #include "access/attnum.h"
21 #include "nodes/bitmapset.h"
22 #include "nodes/pg_list.h"
23 
24 
25 /* ----------------------------------------------------------------
26  * node definitions
27  * ----------------------------------------------------------------
28  */
29 
30 /*
31  * Alias -
32  * specifies an alias for a range variable; the alias might also
33  * specify renaming of columns within the table.
34  *
35  * Note: colnames is a list of String nodes. In Alias structs
36  * associated with RTEs, there may be entries corresponding to dropped
37  * columns; these are normally empty strings (""). See parsenodes.h for info.
38  */
39 typedef struct Alias
40 {
42  char *aliasname; /* aliased rel name (never qualified) */
43  List *colnames; /* optional list of column aliases */
45 
46 /* What to do at commit time for temporary relations */
47 typedef enum OnCommitAction
48 {
49  ONCOMMIT_NOOP, /* No ON COMMIT clause (do nothing) */
50  ONCOMMIT_PRESERVE_ROWS, /* ON COMMIT PRESERVE ROWS (do nothing) */
51  ONCOMMIT_DELETE_ROWS, /* ON COMMIT DELETE ROWS */
52  ONCOMMIT_DROP /* ON COMMIT DROP */
54 
55 /*
56  * RangeVar - range variable, used in FROM clauses
57  *
58  * Also used to represent table names in utility statements; there, the alias
59  * field is not used, and inh tells whether to apply the operation
60  * recursively to child tables. In some contexts it is also useful to carry
61  * a TEMP table indication here.
62  */
63 typedef struct RangeVar
64 {
66  char *catalogname; /* the catalog (database) name, or NULL */
67  char *schemaname; /* the schema name, or NULL */
68  char *relname; /* the relation/sequence name */
69  bool inh; /* expand rel by inheritance? recursively act
70  * on children? */
71  char relpersistence; /* see RELPERSISTENCE_* in pg_class.h */
72  Alias *alias; /* table alias & optional column aliases */
73  int location; /* token location, or -1 if unknown */
75 
76 typedef enum TableFuncType
77 {
81 
82 /*
83  * TableFunc - node for a table function, such as XMLTABLE or JSON_TABLE.
84  *
85  * Entries in the ns_names list are either String nodes containing
86  * literal namespace names, or NULL pointers to represent DEFAULT.
87  */
88 typedef struct TableFunc
89 {
91  TableFuncType functype; /* XMLTABLE or JSON_TABLE */
92  List *ns_uris; /* list of namespace URI expressions */
93  List *ns_names; /* list of namespace names or NULL */
94  Node *docexpr; /* input document expression */
95  Node *rowexpr; /* row filter expression */
96  List *colnames; /* column names (list of String) */
97  List *coltypes; /* OID list of column type OIDs */
98  List *coltypmods; /* integer list of column typmods */
99  List *colcollations; /* OID list of column collation OIDs */
100  List *colexprs; /* list of column filter expressions */
101  List *coldefexprs; /* list of column default expressions */
102  List *colvalexprs; /* list of column value expressions */
103  Bitmapset *notnulls; /* nullability flag for each output column */
104  Node *plan; /* JSON_TABLE plan */
105  int ordinalitycol; /* counts from 0; -1 if none specified */
106  int location; /* token location, or -1 if unknown */
108 
109 /*
110  * IntoClause - target information for SELECT INTO, CREATE TABLE AS, and
111  * CREATE MATERIALIZED VIEW
112  *
113  * For CREATE MATERIALIZED VIEW, viewQuery is the parsed-but-not-rewritten
114  * SELECT Query for the view; otherwise it's NULL. (Although it's actually
115  * Query*, we declare it as Node* to avoid a forward reference.)
116  */
117 typedef struct IntoClause
118 {
120 
121  RangeVar *rel; /* target relation name */
122  List *colNames; /* column names to assign, or NIL */
123  char *accessMethod; /* table access method */
124  List *options; /* options from WITH clause */
125  OnCommitAction onCommit; /* what do we do at COMMIT? */
126  char *tableSpaceName; /* table space to use, or NULL */
127  Node *viewQuery; /* materialized view's SELECT query */
128  bool skipData; /* true for WITH NO DATA */
130 
131 
132 /* ----------------------------------------------------------------
133  * node types for executable expressions
134  * ----------------------------------------------------------------
135  */
136 
137 /*
138  * Expr - generic superclass for executable-expression nodes
139  *
140  * All node types that are used in executable expression trees should derive
141  * from Expr (that is, have Expr as their first field). Since Expr only
142  * contains NodeTag, this is a formality, but it is an easy form of
143  * documentation. See also the ExprState node types in execnodes.h.
144  */
145 typedef struct Expr
146 {
149 
150 /*
151  * Var - expression node representing a variable (ie, a table column)
152  *
153  * In the parser and planner, varno and varattno identify the semantic
154  * referent, which is a base-relation column unless the reference is to a join
155  * USING column that isn't semantically equivalent to either join input column
156  * (because it is a FULL join or the input column requires a type coercion).
157  * In those cases varno and varattno refer to the JOIN RTE. (Early in the
158  * planner, we replace such join references by the implied expression; but up
159  * till then we want join reference Vars to keep their original identity for
160  * query-printing purposes.)
161  *
162  * At the end of planning, Var nodes appearing in upper-level plan nodes are
163  * reassigned to point to the outputs of their subplans; for example, in a
164  * join node varno becomes INNER_VAR or OUTER_VAR and varattno becomes the
165  * index of the proper element of that subplan's target list. Similarly,
166  * INDEX_VAR is used to identify Vars that reference an index column rather
167  * than a heap column. (In ForeignScan and CustomScan plan nodes, INDEX_VAR
168  * is abused to signify references to columns of a custom scan tuple type.)
169  *
170  * ROWID_VAR is used in the planner to identify nonce variables that carry
171  * row identity information during UPDATE/DELETE. This value should never
172  * be seen outside the planner.
173  *
174  * In the parser, varnosyn and varattnosyn are either identical to
175  * varno/varattno, or they specify the column's position in an aliased JOIN
176  * RTE that hides the semantic referent RTE's refname. This is a syntactic
177  * identifier as opposed to the semantic identifier; it tells ruleutils.c
178  * how to print the Var properly. varnosyn/varattnosyn retain their values
179  * throughout planning and execution, so they are particularly helpful to
180  * identify Vars when debugging. Note, however, that a Var that is generated
181  * in the planner and doesn't correspond to any simple relation column may
182  * have varnosyn = varattnosyn = 0.
183  */
184 #define INNER_VAR (-1) /* reference to inner subplan */
185 #define OUTER_VAR (-2) /* reference to outer subplan */
186 #define INDEX_VAR (-3) /* reference to index column */
187 #define ROWID_VAR (-4) /* row identity column during planning */
188 
189 #define IS_SPECIAL_VARNO(varno) ((int) (varno) < 0)
190 
191 /* Symbols for the indexes of the special RTE entries in rules */
192 #define PRS2_OLD_VARNO 1
193 #define PRS2_NEW_VARNO 2
194 
195 typedef struct Var
196 {
198  int varno; /* index of this var's relation in the range
199  * table, or INNER_VAR/OUTER_VAR/etc */
200  AttrNumber varattno; /* attribute number of this var, or zero for
201  * all attrs ("whole-row Var") */
202  Oid vartype; /* pg_type OID for the type of this var */
203  int32 vartypmod; /* pg_attribute typmod value */
204  Oid varcollid; /* OID of collation, or InvalidOid if none */
205  Index varlevelsup; /* for subquery variables referencing outer
206  * relations; 0 in a normal var, >0 means N
207  * levels up */
208  Index varnosyn; /* syntactic relation index (0 if unknown) */
209  AttrNumber varattnosyn; /* syntactic attribute number */
210  int location; /* token location, or -1 if unknown */
211 } Var;
212 
213 /*
214  * Const
215  *
216  * Note: for varlena data types, we make a rule that a Const node's value
217  * must be in non-extended form (4-byte header, no compression or external
218  * references). This ensures that the Const node is self-contained and makes
219  * it more likely that equal() will see logically identical values as equal.
220  */
221 typedef struct Const
222 {
224  Oid consttype; /* pg_type OID of the constant's datatype */
225  int32 consttypmod; /* typmod value, if any */
226  Oid constcollid; /* OID of collation, or InvalidOid if none */
227  int constlen; /* typlen of the constant's datatype */
228  Datum constvalue; /* the constant's value */
229  bool constisnull; /* whether the constant is null (if true,
230  * constvalue is undefined) */
231  bool constbyval; /* whether this datatype is passed by value.
232  * If true, then all the information is stored
233  * in the Datum. If false, then the Datum
234  * contains a pointer to the information. */
235  int location; /* token location, or -1 if unknown */
237 
238 /*
239  * Param
240  *
241  * paramkind specifies the kind of parameter. The possible values
242  * for this field are:
243  *
244  * PARAM_EXTERN: The parameter value is supplied from outside the plan.
245  * Such parameters are numbered from 1 to n.
246  *
247  * PARAM_EXEC: The parameter is an internal executor parameter, used
248  * for passing values into and out of sub-queries or from
249  * nestloop joins to their inner scans.
250  * For historical reasons, such parameters are numbered from 0.
251  * These numbers are independent of PARAM_EXTERN numbers.
252  *
253  * PARAM_SUBLINK: The parameter represents an output column of a SubLink
254  * node's sub-select. The column number is contained in the
255  * `paramid' field. (This type of Param is converted to
256  * PARAM_EXEC during planning.)
257  *
258  * PARAM_MULTIEXPR: Like PARAM_SUBLINK, the parameter represents an
259  * output column of a SubLink node's sub-select, but here, the
260  * SubLink is always a MULTIEXPR SubLink. The high-order 16 bits
261  * of the `paramid' field contain the SubLink's subLinkId, and
262  * the low-order 16 bits contain the column number. (This type
263  * of Param is also converted to PARAM_EXEC during planning.)
264  */
265 typedef enum ParamKind
266 {
272 
273 typedef struct Param
274 {
276  ParamKind paramkind; /* kind of parameter. See above */
277  int paramid; /* numeric ID for parameter */
278  Oid paramtype; /* pg_type OID of parameter's datatype */
279  int32 paramtypmod; /* typmod value, if known */
280  Oid paramcollid; /* OID of collation, or InvalidOid if none */
281  int location; /* token location, or -1 if unknown */
283 
284 /*
285  * Aggref
286  *
287  * The aggregate's args list is a targetlist, ie, a list of TargetEntry nodes.
288  *
289  * For a normal (non-ordered-set) aggregate, the non-resjunk TargetEntries
290  * represent the aggregate's regular arguments (if any) and resjunk TLEs can
291  * be added at the end to represent ORDER BY expressions that are not also
292  * arguments. As in a top-level Query, the TLEs can be marked with
293  * ressortgroupref indexes to let them be referenced by SortGroupClause
294  * entries in the aggorder and/or aggdistinct lists. This represents ORDER BY
295  * and DISTINCT operations to be applied to the aggregate input rows before
296  * they are passed to the transition function. The grammar only allows a
297  * simple "DISTINCT" specifier for the arguments, but we use the full
298  * query-level representation to allow more code sharing.
299  *
300  * For an ordered-set aggregate, the args list represents the WITHIN GROUP
301  * (aggregated) arguments, all of which will be listed in the aggorder list.
302  * DISTINCT is not supported in this case, so aggdistinct will be NIL.
303  * The direct arguments appear in aggdirectargs (as a list of plain
304  * expressions, not TargetEntry nodes).
305  *
306  * aggtranstype is the data type of the state transition values for this
307  * aggregate (resolved to an actual type, if agg's transtype is polymorphic).
308  * This is determined during planning and is InvalidOid before that.
309  *
310  * aggargtypes is an OID list of the data types of the direct and regular
311  * arguments. Normally it's redundant with the aggdirectargs and args lists,
312  * but in a combining aggregate, it's not because the args list has been
313  * replaced with a single argument representing the partial-aggregate
314  * transition values.
315  *
316  * aggsplit indicates the expected partial-aggregation mode for the Aggref's
317  * parent plan node. It's always set to AGGSPLIT_SIMPLE in the parser, but
318  * the planner might change it to something else. We use this mainly as
319  * a crosscheck that the Aggrefs match the plan; but note that when aggsplit
320  * indicates a non-final mode, aggtype reflects the transition data type
321  * not the SQL-level output type of the aggregate.
322  *
323  * aggno and aggtransno are -1 in the parse stage, and are set in planning.
324  * Aggregates with the same 'aggno' represent the same aggregate expression,
325  * and can share the result. Aggregates with same 'transno' but different
326  * 'aggno' can share the same transition state, only the final function needs
327  * to be called separately.
328  */
329 typedef struct Aggref
330 {
332  Oid aggfnoid; /* pg_proc Oid of the aggregate */
333  Oid aggtype; /* type Oid of result of the aggregate */
334  Oid aggcollid; /* OID of collation of result */
335  Oid inputcollid; /* OID of collation that function should use */
336  Oid aggtranstype; /* type Oid of aggregate's transition value */
337  List *aggargtypes; /* type Oids of direct and aggregated args */
338  List *aggdirectargs; /* direct arguments, if an ordered-set agg */
339  List *args; /* aggregated arguments and sort expressions */
340  List *aggorder; /* ORDER BY (list of SortGroupClause) */
341  List *aggdistinct; /* DISTINCT (list of SortGroupClause) */
342  Expr *aggfilter; /* FILTER expression, if any */
343  bool aggstar; /* true if argument list was really '*' */
344  bool aggvariadic; /* true if variadic arguments have been
345  * combined into an array last argument */
346  char aggkind; /* aggregate kind (see pg_aggregate.h) */
347  Index agglevelsup; /* > 0 if agg belongs to outer query */
348  AggSplit aggsplit; /* expected agg-splitting mode of parent Agg */
349  int aggno; /* unique ID within the Agg node */
350  int aggtransno; /* unique ID of transition state in the Agg */
351  int location; /* token location, or -1 if unknown */
353 
354 /*
355  * GroupingFunc
356  *
357  * A GroupingFunc is a GROUPING(...) expression, which behaves in many ways
358  * like an aggregate function (e.g. it "belongs" to a specific query level,
359  * which might not be the one immediately containing it), but also differs in
360  * an important respect: it never evaluates its arguments, they merely
361  * designate expressions from the GROUP BY clause of the query level to which
362  * it belongs.
363  *
364  * The spec defines the evaluation of GROUPING() purely by syntactic
365  * replacement, but we make it a real expression for optimization purposes so
366  * that one Agg node can handle multiple grouping sets at once. Evaluating the
367  * result only needs the column positions to check against the grouping set
368  * being projected. However, for EXPLAIN to produce meaningful output, we have
369  * to keep the original expressions around, since expression deparse does not
370  * give us any feasible way to get at the GROUP BY clause.
371  *
372  * Also, we treat two GroupingFunc nodes as equal if they have equal arguments
373  * lists and agglevelsup, without comparing the refs and cols annotations.
374  *
375  * In raw parse output we have only the args list; parse analysis fills in the
376  * refs list, and the planner fills in the cols list.
377  */
378 typedef struct GroupingFunc
379 {
381  List *args; /* arguments, not evaluated but kept for
382  * benefit of EXPLAIN etc. */
383  List *refs; /* ressortgrouprefs of arguments */
384  List *cols; /* actual column positions set by planner */
385  Index agglevelsup; /* same as Aggref.agglevelsup */
386  int location; /* token location */
388 
389 /*
390  * WindowFunc
391  */
392 typedef struct WindowFunc
393 {
395  Oid winfnoid; /* pg_proc Oid of the function */
396  Oid wintype; /* type Oid of result of the window function */
397  Oid wincollid; /* OID of collation of result */
398  Oid inputcollid; /* OID of collation that function should use */
399  List *args; /* arguments to the window function */
400  Expr *aggfilter; /* FILTER expression, if any */
401  Index winref; /* index of associated WindowClause */
402  bool winstar; /* true if argument list was really '*' */
403  bool winagg; /* is function a simple aggregate? */
404  int location; /* token location, or -1 if unknown */
406 
407 /*
408  * SubscriptingRef: describes a subscripting operation over a container
409  * (array, etc).
410  *
411  * A SubscriptingRef can describe fetching a single element from a container,
412  * fetching a part of a container (e.g. an array slice), storing a single
413  * element into a container, or storing a slice. The "store" cases work with
414  * an initial container value and a source value that is inserted into the
415  * appropriate part of the container; the result of the operation is an
416  * entire new modified container value.
417  *
418  * If reflowerindexpr = NIL, then we are fetching or storing a single container
419  * element at the subscripts given by refupperindexpr. Otherwise we are
420  * fetching or storing a container slice, that is a rectangular subcontainer
421  * with lower and upper bounds given by the index expressions.
422  * reflowerindexpr must be the same length as refupperindexpr when it
423  * is not NIL.
424  *
425  * In the slice case, individual expressions in the subscript lists can be
426  * NULL, meaning "substitute the array's current lower or upper bound".
427  * (Non-array containers may or may not support this.)
428  *
429  * refcontainertype is the actual container type that determines the
430  * subscripting semantics. (This will generally be either the exposed type of
431  * refexpr, or the base type if that is a domain.) refelemtype is the type of
432  * the container's elements; this is saved for the use of the subscripting
433  * functions, but is not used by the core code. refrestype, reftypmod, and
434  * refcollid describe the type of the SubscriptingRef's result. In a store
435  * expression, refrestype will always match refcontainertype; in a fetch,
436  * it could be refelemtype for an element fetch, or refcontainertype for a
437  * slice fetch, or possibly something else as determined by type-specific
438  * subscripting logic. Likewise, reftypmod and refcollid will match the
439  * container's properties in a store, but could be different in a fetch.
440  *
441  * Note: for the cases where a container is returned, if refexpr yields a R/W
442  * expanded container, then the implementation is allowed to modify that
443  * object in-place and return the same object.
444  */
445 typedef struct SubscriptingRef
446 {
448  Oid refcontainertype; /* type of the container proper */
449  Oid refelemtype; /* the container type's pg_type.typelem */
450  Oid refrestype; /* type of the SubscriptingRef's result */
451  int32 reftypmod; /* typmod of the result */
452  Oid refcollid; /* collation of result, or InvalidOid if none */
453  List *refupperindexpr; /* expressions that evaluate to upper
454  * container indexes */
455  List *reflowerindexpr; /* expressions that evaluate to lower
456  * container indexes, or NIL for single
457  * container element */
458  Expr *refexpr; /* the expression that evaluates to a
459  * container value */
460  Expr *refassgnexpr; /* expression for the source value, or NULL if
461  * fetch */
463 
464 /*
465  * CoercionContext - distinguishes the allowed set of type casts
466  *
467  * NB: ordering of the alternatives is significant; later (larger) values
468  * allow more casts than earlier ones.
469  */
470 typedef enum CoercionContext
471 {
472  COERCION_IMPLICIT, /* coercion in context of expression */
473  COERCION_ASSIGNMENT, /* coercion in context of assignment */
474  COERCION_PLPGSQL, /* if no assignment cast, use CoerceViaIO */
475  COERCION_EXPLICIT /* explicit cast operation */
477 
478 /*
479  * CoercionForm - how to display a FuncExpr or related node
480  *
481  * "Coercion" is a bit of a misnomer, since this value records other
482  * special syntaxes besides casts, but for now we'll keep this naming.
483  *
484  * NB: equal() ignores CoercionForm fields, therefore this *must* not carry
485  * any semantically significant information. We need that behavior so that
486  * the planner will consider equivalent implicit and explicit casts to be
487  * equivalent. In cases where those actually behave differently, the coercion
488  * function's arguments will be different.
489  */
490 typedef enum CoercionForm
491 {
492  COERCE_EXPLICIT_CALL, /* display as a function call */
493  COERCE_EXPLICIT_CAST, /* display as an explicit cast */
494  COERCE_IMPLICIT_CAST, /* implicit cast, so hide it */
495  COERCE_SQL_SYNTAX /* display with SQL-mandated special syntax */
497 
498 /*
499  * FuncExpr - expression node for a function call
500  */
501 typedef struct FuncExpr
502 {
504  Oid funcid; /* PG_PROC OID of the function */
505  Oid funcresulttype; /* PG_TYPE OID of result value */
506  bool funcretset; /* true if function returns set */
507  bool funcvariadic; /* true if variadic arguments have been
508  * combined into an array last argument */
509  CoercionForm funcformat; /* how to display this function call */
510  Oid funccollid; /* OID of collation of result */
511  Oid inputcollid; /* OID of collation that function should use */
512  List *args; /* arguments to the function */
513  int location; /* token location, or -1 if unknown */
515 
516 /*
517  * NamedArgExpr - a named argument of a function
518  *
519  * This node type can only appear in the args list of a FuncCall or FuncExpr
520  * node. We support pure positional call notation (no named arguments),
521  * named notation (all arguments are named), and mixed notation (unnamed
522  * arguments followed by named ones).
523  *
524  * Parse analysis sets argnumber to the positional index of the argument,
525  * but doesn't rearrange the argument list.
526  *
527  * The planner will convert argument lists to pure positional notation
528  * during expression preprocessing, so execution never sees a NamedArgExpr.
529  */
530 typedef struct NamedArgExpr
531 {
533  Expr *arg; /* the argument expression */
534  char *name; /* the name */
535  int argnumber; /* argument's number in positional notation */
536  int location; /* argument name location, or -1 if unknown */
538 
539 /*
540  * OpExpr - expression node for an operator invocation
541  *
542  * Semantically, this is essentially the same as a function call.
543  *
544  * Note that opfuncid is not necessarily filled in immediately on creation
545  * of the node. The planner makes sure it is valid before passing the node
546  * tree to the executor, but during parsing/planning opfuncid can be 0.
547  */
548 typedef struct OpExpr
549 {
551  Oid opno; /* PG_OPERATOR OID of the operator */
552  Oid opfuncid; /* PG_PROC OID of underlying function */
553  Oid opresulttype; /* PG_TYPE OID of result value */
554  bool opretset; /* true if operator returns set */
555  Oid opcollid; /* OID of collation of result */
556  Oid inputcollid; /* OID of collation that operator should use */
557  List *args; /* arguments to the operator (1 or 2) */
558  int location; /* token location, or -1 if unknown */
560 
561 /*
562  * DistinctExpr - expression node for "x IS DISTINCT FROM y"
563  *
564  * Except for the nodetag, this is represented identically to an OpExpr
565  * referencing the "=" operator for x and y.
566  * We use "=", not the more obvious "<>", because more datatypes have "="
567  * than "<>". This means the executor must invert the operator result.
568  * Note that the operator function won't be called at all if either input
569  * is NULL, since then the result can be determined directly.
570  */
572 
573 /*
574  * NullIfExpr - a NULLIF expression
575  *
576  * Like DistinctExpr, this is represented the same as an OpExpr referencing
577  * the "=" operator for x and y.
578  */
580 
581 /*
582  * ScalarArrayOpExpr - expression node for "scalar op ANY/ALL (array)"
583  *
584  * The operator must yield boolean. It is applied to the left operand
585  * and each element of the righthand array, and the results are combined
586  * with OR or AND (for ANY or ALL respectively). The node representation
587  * is almost the same as for the underlying operator, but we need a useOr
588  * flag to remember whether it's ANY or ALL, and we don't have to store
589  * the result type (or the collation) because it must be boolean.
590  *
591  * A ScalarArrayOpExpr with a valid hashfuncid is evaluated during execution
592  * by building a hash table containing the Const values from the RHS arg.
593  * This table is probed during expression evaluation. The planner will set
594  * hashfuncid to the hash function which must be used to build and probe the
595  * hash table. The executor determines if it should use hash-based checks or
596  * the more traditional means based on if the hashfuncid is set or not.
597  *
598  * When performing hashed NOT IN, the negfuncid will also be set to the
599  * equality function which the hash table must use to build and probe the hash
600  * table. opno and opfuncid will remain set to the <> operator and its
601  * corresponding function and won't be used during execution. For
602  * non-hashtable based NOT INs, negfuncid will be set to InvalidOid. See
603  * convert_saop_to_hashed_saop().
604  */
605 typedef struct ScalarArrayOpExpr
606 {
608  Oid opno; /* PG_OPERATOR OID of the operator */
609  Oid opfuncid; /* PG_PROC OID of comparison function */
610  Oid hashfuncid; /* PG_PROC OID of hash func or InvalidOid */
611  Oid negfuncid; /* PG_PROC OID of negator of opfuncid function
612  * or InvalidOid. See above */
613  bool useOr; /* true for ANY, false for ALL */
614  Oid inputcollid; /* OID of collation that operator should use */
615  List *args; /* the scalar and array operands */
616  int location; /* token location, or -1 if unknown */
618 
619 /*
620  * BoolExpr - expression node for the basic Boolean operators AND, OR, NOT
621  *
622  * Notice the arguments are given as a List. For NOT, of course the list
623  * must always have exactly one element. For AND and OR, there can be two
624  * or more arguments.
625  */
626 typedef enum BoolExprType
627 {
630 
631 typedef struct BoolExpr
632 {
635  List *args; /* arguments to this expression */
636  int location; /* token location, or -1 if unknown */
638 
639 /*
640  * SubLink
641  *
642  * A SubLink represents a subselect appearing in an expression, and in some
643  * cases also the combining operator(s) just above it. The subLinkType
644  * indicates the form of the expression represented:
645  * EXISTS_SUBLINK EXISTS(SELECT ...)
646  * ALL_SUBLINK (lefthand) op ALL (SELECT ...)
647  * ANY_SUBLINK (lefthand) op ANY (SELECT ...)
648  * ROWCOMPARE_SUBLINK (lefthand) op (SELECT ...)
649  * EXPR_SUBLINK (SELECT with single targetlist item ...)
650  * MULTIEXPR_SUBLINK (SELECT with multiple targetlist items ...)
651  * ARRAY_SUBLINK ARRAY(SELECT with single targetlist item ...)
652  * CTE_SUBLINK WITH query (never actually part of an expression)
653  * For ALL, ANY, and ROWCOMPARE, the lefthand is a list of expressions of the
654  * same length as the subselect's targetlist. ROWCOMPARE will *always* have
655  * a list with more than one entry; if the subselect has just one target
656  * then the parser will create an EXPR_SUBLINK instead (and any operator
657  * above the subselect will be represented separately).
658  * ROWCOMPARE, EXPR, and MULTIEXPR require the subselect to deliver at most
659  * one row (if it returns no rows, the result is NULL).
660  * ALL, ANY, and ROWCOMPARE require the combining operators to deliver boolean
661  * results. ALL and ANY combine the per-row results using AND and OR
662  * semantics respectively.
663  * ARRAY requires just one target column, and creates an array of the target
664  * column's type using any number of rows resulting from the subselect.
665  *
666  * SubLink is classed as an Expr node, but it is not actually executable;
667  * it must be replaced in the expression tree by a SubPlan node during
668  * planning.
669  *
670  * NOTE: in the raw output of gram.y, testexpr contains just the raw form
671  * of the lefthand expression (if any), and operName is the String name of
672  * the combining operator. Also, subselect is a raw parsetree. During parse
673  * analysis, the parser transforms testexpr into a complete boolean expression
674  * that compares the lefthand value(s) to PARAM_SUBLINK nodes representing the
675  * output columns of the subselect. And subselect is transformed to a Query.
676  * This is the representation seen in saved rules and in the rewriter.
677  *
678  * In EXISTS, EXPR, MULTIEXPR, and ARRAY SubLinks, testexpr and operName
679  * are unused and are always null.
680  *
681  * subLinkId is currently used only for MULTIEXPR SubLinks, and is zero in
682  * other SubLinks. This number identifies different multiple-assignment
683  * subqueries within an UPDATE statement's SET list. It is unique only
684  * within a particular targetlist. The output column(s) of the MULTIEXPR
685  * are referenced by PARAM_MULTIEXPR Params appearing elsewhere in the tlist.
686  *
687  * The CTE_SUBLINK case never occurs in actual SubLink nodes, but it is used
688  * in SubPlans generated for WITH subqueries.
689  */
690 typedef enum SubLinkType
691 {
699  CTE_SUBLINK /* for SubPlans only */
701 
702 
703 typedef struct SubLink
704 {
706  SubLinkType subLinkType; /* see above */
707  int subLinkId; /* ID (1..n); 0 if not MULTIEXPR */
708  Node *testexpr; /* outer-query test for ALL/ANY/ROWCOMPARE */
709  List *operName; /* originally specified operator name */
710  Node *subselect; /* subselect as Query* or raw parsetree */
711  int location; /* token location, or -1 if unknown */
713 
714 /*
715  * SubPlan - executable expression node for a subplan (sub-SELECT)
716  *
717  * The planner replaces SubLink nodes in expression trees with SubPlan
718  * nodes after it has finished planning the subquery. SubPlan references
719  * a sub-plantree stored in the subplans list of the toplevel PlannedStmt.
720  * (We avoid a direct link to make it easier to copy expression trees
721  * without causing multiple processing of the subplan.)
722  *
723  * In an ordinary subplan, testexpr points to an executable expression
724  * (OpExpr, an AND/OR tree of OpExprs, or RowCompareExpr) for the combining
725  * operator(s); the left-hand arguments are the original lefthand expressions,
726  * and the right-hand arguments are PARAM_EXEC Param nodes representing the
727  * outputs of the sub-select. (NOTE: runtime coercion functions may be
728  * inserted as well.) This is just the same expression tree as testexpr in
729  * the original SubLink node, but the PARAM_SUBLINK nodes are replaced by
730  * suitably numbered PARAM_EXEC nodes.
731  *
732  * If the sub-select becomes an initplan rather than a subplan, the executable
733  * expression is part of the outer plan's expression tree (and the SubPlan
734  * node itself is not, but rather is found in the outer plan's initPlan
735  * list). In this case testexpr is NULL to avoid duplication.
736  *
737  * The planner also derives lists of the values that need to be passed into
738  * and out of the subplan. Input values are represented as a list "args" of
739  * expressions to be evaluated in the outer-query context (currently these
740  * args are always just Vars, but in principle they could be any expression).
741  * The values are assigned to the global PARAM_EXEC params indexed by parParam
742  * (the parParam and args lists must have the same ordering). setParam is a
743  * list of the PARAM_EXEC params that are computed by the sub-select, if it
744  * is an initplan; they are listed in order by sub-select output column
745  * position. (parParam and setParam are integer Lists, not Bitmapsets,
746  * because their ordering is significant.)
747  *
748  * Also, the planner computes startup and per-call costs for use of the
749  * SubPlan. Note that these include the cost of the subquery proper,
750  * evaluation of the testexpr if any, and any hashtable management overhead.
751  */
752 typedef struct SubPlan
753 {
755  /* Fields copied from original SubLink: */
756  SubLinkType subLinkType; /* see above */
757  /* The combining operators, transformed to an executable expression: */
758  Node *testexpr; /* OpExpr or RowCompareExpr expression tree */
759  List *paramIds; /* IDs of Params embedded in the above */
760  /* Identification of the Plan tree to use: */
761  int plan_id; /* Index (from 1) in PlannedStmt.subplans */
762  /* Identification of the SubPlan for EXPLAIN and debugging purposes: */
763  char *plan_name; /* A name assigned during planning */
764  /* Extra data useful for determining subplan's output type: */
765  Oid firstColType; /* Type of first column of subplan result */
766  int32 firstColTypmod; /* Typmod of first column of subplan result */
767  Oid firstColCollation; /* Collation of first column of subplan
768  * result */
769  /* Information about execution strategy: */
770  bool useHashTable; /* true to store subselect output in a hash
771  * table (implies we are doing "IN") */
772  bool unknownEqFalse; /* true if it's okay to return FALSE when the
773  * spec result is UNKNOWN; this allows much
774  * simpler handling of null values */
775  bool parallel_safe; /* is the subplan parallel-safe? */
776  /* Note: parallel_safe does not consider contents of testexpr or args */
777  /* Information for passing params into and out of the subselect: */
778  /* setParam and parParam are lists of integers (param IDs) */
779  List *setParam; /* initplan subqueries have to set these
780  * Params for parent plan */
781  List *parParam; /* indices of input Params from parent plan */
782  List *args; /* exprs to pass as parParam values */
783  /* Estimated execution costs: */
784  Cost startup_cost; /* one-time setup cost */
785  Cost per_call_cost; /* cost for each subplan evaluation */
787 
788 /*
789  * AlternativeSubPlan - expression node for a choice among SubPlans
790  *
791  * This is used only transiently during planning: by the time the plan
792  * reaches the executor, all AlternativeSubPlan nodes have been removed.
793  *
794  * The subplans are given as a List so that the node definition need not
795  * change if there's ever more than two alternatives. For the moment,
796  * though, there are always exactly two; and the first one is the fast-start
797  * plan.
798  */
799 typedef struct AlternativeSubPlan
800 {
802  List *subplans; /* SubPlan(s) with equivalent results */
804 
805 /* ----------------
806  * FieldSelect
807  *
808  * FieldSelect represents the operation of extracting one field from a tuple
809  * value. At runtime, the input expression is expected to yield a rowtype
810  * Datum. The specified field number is extracted and returned as a Datum.
811  * ----------------
812  */
813 
814 typedef struct FieldSelect
815 {
817  Expr *arg; /* input expression */
818  AttrNumber fieldnum; /* attribute number of field to extract */
819  Oid resulttype; /* type of the field (result type of this
820  * node) */
821  int32 resulttypmod; /* output typmod (usually -1) */
822  Oid resultcollid; /* OID of collation of the field */
824 
825 /* ----------------
826  * FieldStore
827  *
828  * FieldStore represents the operation of modifying one field in a tuple
829  * value, yielding a new tuple value (the input is not touched!). Like
830  * the assign case of SubscriptingRef, this is used to implement UPDATE of a
831  * portion of a column.
832  *
833  * resulttype is always a named composite type (not a domain). To update
834  * a composite domain value, apply CoerceToDomain to the FieldStore.
835  *
836  * A single FieldStore can actually represent updates of several different
837  * fields. The parser only generates FieldStores with single-element lists,
838  * but the planner will collapse multiple updates of the same base column
839  * into one FieldStore.
840  * ----------------
841  */
842 
843 typedef struct FieldStore
844 {
846  Expr *arg; /* input tuple value */
847  List *newvals; /* new value(s) for field(s) */
848  List *fieldnums; /* integer list of field attnums */
849  Oid resulttype; /* type of result (same as type of arg) */
850  /* Like RowExpr, we deliberately omit a typmod and collation here */
852 
853 /* ----------------
854  * RelabelType
855  *
856  * RelabelType represents a "dummy" type coercion between two binary-
857  * compatible datatypes, such as reinterpreting the result of an OID
858  * expression as an int4. It is a no-op at runtime; we only need it
859  * to provide a place to store the correct type to be attributed to
860  * the expression result during type resolution. (We can't get away
861  * with just overwriting the type field of the input expression node,
862  * so we need a separate node to show the coercion's result type.)
863  * ----------------
864  */
865 
866 typedef struct RelabelType
867 {
869  Expr *arg; /* input expression */
870  Oid resulttype; /* output type of coercion expression */
871  int32 resulttypmod; /* output typmod (usually -1) */
872  Oid resultcollid; /* OID of collation, or InvalidOid if none */
873  CoercionForm relabelformat; /* how to display this node */
874  int location; /* token location, or -1 if unknown */
876 
877 /* ----------------
878  * CoerceViaIO
879  *
880  * CoerceViaIO represents a type coercion between two types whose textual
881  * representations are compatible, implemented by invoking the source type's
882  * typoutput function then the destination type's typinput function.
883  * ----------------
884  */
885 
886 typedef struct CoerceViaIO
887 {
889  Expr *arg; /* input expression */
890  Oid resulttype; /* output type of coercion */
891  /* output typmod is not stored, but is presumed -1 */
892  Oid resultcollid; /* OID of collation, or InvalidOid if none */
893  CoercionForm coerceformat; /* how to display this node */
894  int location; /* token location, or -1 if unknown */
896 
897 /* ----------------
898  * ArrayCoerceExpr
899  *
900  * ArrayCoerceExpr represents a type coercion from one array type to another,
901  * which is implemented by applying the per-element coercion expression
902  * "elemexpr" to each element of the source array. Within elemexpr, the
903  * source element is represented by a CaseTestExpr node. Note that even if
904  * elemexpr is a no-op (that is, just CaseTestExpr + RelabelType), the
905  * coercion still requires some effort: we have to fix the element type OID
906  * stored in the array header.
907  * ----------------
908  */
909 
910 typedef struct ArrayCoerceExpr
911 {
913  Expr *arg; /* input expression (yields an array) */
914  Expr *elemexpr; /* expression representing per-element work */
915  Oid resulttype; /* output type of coercion (an array type) */
916  int32 resulttypmod; /* output typmod (also element typmod) */
917  Oid resultcollid; /* OID of collation, or InvalidOid if none */
918  CoercionForm coerceformat; /* how to display this node */
919  int location; /* token location, or -1 if unknown */
921 
922 /* ----------------
923  * ConvertRowtypeExpr
924  *
925  * ConvertRowtypeExpr represents a type coercion from one composite type
926  * to another, where the source type is guaranteed to contain all the columns
927  * needed for the destination type plus possibly others; the columns need not
928  * be in the same positions, but are matched up by name. This is primarily
929  * used to convert a whole-row value of an inheritance child table into a
930  * valid whole-row value of its parent table's rowtype. Both resulttype
931  * and the exposed type of "arg" must be named composite types (not domains).
932  * ----------------
933  */
934 
935 typedef struct ConvertRowtypeExpr
936 {
938  Expr *arg; /* input expression */
939  Oid resulttype; /* output type (always a composite type) */
940  /* Like RowExpr, we deliberately omit a typmod and collation here */
941  CoercionForm convertformat; /* how to display this node */
942  int location; /* token location, or -1 if unknown */
944 
945 /*----------
946  * CollateExpr - COLLATE
947  *
948  * The planner replaces CollateExpr with RelabelType during expression
949  * preprocessing, so execution never sees a CollateExpr.
950  *----------
951  */
952 typedef struct CollateExpr
953 {
955  Expr *arg; /* input expression */
956  Oid collOid; /* collation's OID */
957  int location; /* token location, or -1 if unknown */
959 
960 /*----------
961  * CaseExpr - a CASE expression
962  *
963  * We support two distinct forms of CASE expression:
964  * CASE WHEN boolexpr THEN expr [ WHEN boolexpr THEN expr ... ]
965  * CASE testexpr WHEN compexpr THEN expr [ WHEN compexpr THEN expr ... ]
966  * These are distinguishable by the "arg" field being NULL in the first case
967  * and the testexpr in the second case.
968  *
969  * In the raw grammar output for the second form, the condition expressions
970  * of the WHEN clauses are just the comparison values. Parse analysis
971  * converts these to valid boolean expressions of the form
972  * CaseTestExpr '=' compexpr
973  * where the CaseTestExpr node is a placeholder that emits the correct
974  * value at runtime. This structure is used so that the testexpr need be
975  * evaluated only once. Note that after parse analysis, the condition
976  * expressions always yield boolean.
977  *
978  * Note: we can test whether a CaseExpr has been through parse analysis
979  * yet by checking whether casetype is InvalidOid or not.
980  *----------
981  */
982 typedef struct CaseExpr
983 {
985  Oid casetype; /* type of expression result */
986  Oid casecollid; /* OID of collation, or InvalidOid if none */
987  Expr *arg; /* implicit equality comparison argument */
988  List *args; /* the arguments (list of WHEN clauses) */
989  Expr *defresult; /* the default result (ELSE clause) */
990  int location; /* token location, or -1 if unknown */
992 
993 /*
994  * CaseWhen - one arm of a CASE expression
995  */
996 typedef struct CaseWhen
997 {
999  Expr *expr; /* condition expression */
1000  Expr *result; /* substitution result */
1001  int location; /* token location, or -1 if unknown */
1003 
1004 /*
1005  * Placeholder node for the test value to be processed by a CASE expression.
1006  * This is effectively like a Param, but can be implemented more simply
1007  * since we need only one replacement value at a time.
1008  *
1009  * We also abuse this node type for some other purposes, including:
1010  * * Placeholder for the current array element value in ArrayCoerceExpr;
1011  * see build_coercion_expression().
1012  * * Nested FieldStore/SubscriptingRef assignment expressions in INSERT/UPDATE;
1013  * see transformAssignmentIndirection().
1014  *
1015  * The uses in CaseExpr and ArrayCoerceExpr are safe only to the extent that
1016  * there is not any other CaseExpr or ArrayCoerceExpr between the value source
1017  * node and its child CaseTestExpr(s). This is true in the parse analysis
1018  * output, but the planner's function-inlining logic has to be careful not to
1019  * break it.
1020  *
1021  * The nested-assignment-expression case is safe because the only node types
1022  * that can be above such CaseTestExprs are FieldStore and SubscriptingRef.
1023  */
1024 typedef struct CaseTestExpr
1025 {
1027  Oid typeId; /* type for substituted value */
1028  int32 typeMod; /* typemod for substituted value */
1029  Oid collation; /* collation for the substituted value */
1031 
1032 /*
1033  * ArrayExpr - an ARRAY[] expression
1034  *
1035  * Note: if multidims is false, the constituent expressions all yield the
1036  * scalar type identified by element_typeid. If multidims is true, the
1037  * constituent expressions all yield arrays of element_typeid (ie, the same
1038  * type as array_typeid); at runtime we must check for compatible subscripts.
1039  */
1040 typedef struct ArrayExpr
1041 {
1043  Oid array_typeid; /* type of expression result */
1044  Oid array_collid; /* OID of collation, or InvalidOid if none */
1045  Oid element_typeid; /* common type of array elements */
1046  List *elements; /* the array elements or sub-arrays */
1047  bool multidims; /* true if elements are sub-arrays */
1048  int location; /* token location, or -1 if unknown */
1050 
1051 /*
1052  * RowExpr - a ROW() expression
1053  *
1054  * Note: the list of fields must have a one-for-one correspondence with
1055  * physical fields of the associated rowtype, although it is okay for it
1056  * to be shorter than the rowtype. That is, the N'th list element must
1057  * match up with the N'th physical field. When the N'th physical field
1058  * is a dropped column (attisdropped) then the N'th list element can just
1059  * be a NULL constant. (This case can only occur for named composite types,
1060  * not RECORD types, since those are built from the RowExpr itself rather
1061  * than vice versa.) It is important not to assume that length(args) is
1062  * the same as the number of columns logically present in the rowtype.
1063  *
1064  * colnames provides field names if the ROW() result is of type RECORD.
1065  * Names *must* be provided if row_typeid is RECORDOID; but if it is a
1066  * named composite type, colnames will be ignored in favor of using the
1067  * type's cataloged field names, so colnames should be NIL. Like the
1068  * args list, colnames is defined to be one-for-one with physical fields
1069  * of the rowtype (although dropped columns shouldn't appear in the
1070  * RECORD case, so this fine point is currently moot).
1071  */
1072 typedef struct RowExpr
1073 {
1075  List *args; /* the fields */
1076  Oid row_typeid; /* RECORDOID or a composite type's ID */
1077 
1078  /*
1079  * row_typeid cannot be a domain over composite, only plain composite. To
1080  * create a composite domain value, apply CoerceToDomain to the RowExpr.
1081  *
1082  * Note: we deliberately do NOT store a typmod. Although a typmod will be
1083  * associated with specific RECORD types at runtime, it will differ for
1084  * different backends, and so cannot safely be stored in stored
1085  * parsetrees. We must assume typmod -1 for a RowExpr node.
1086  *
1087  * We don't need to store a collation either. The result type is
1088  * necessarily composite, and composite types never have a collation.
1089  */
1090  CoercionForm row_format; /* how to display this node */
1091  List *colnames; /* list of String, or NIL */
1092  int location; /* token location, or -1 if unknown */
1094 
1095 /*
1096  * RowCompareExpr - row-wise comparison, such as (a, b) <= (1, 2)
1097  *
1098  * We support row comparison for any operator that can be determined to
1099  * act like =, <>, <, <=, >, or >= (we determine this by looking for the
1100  * operator in btree opfamilies). Note that the same operator name might
1101  * map to a different operator for each pair of row elements, since the
1102  * element datatypes can vary.
1103  *
1104  * A RowCompareExpr node is only generated for the < <= > >= cases;
1105  * the = and <> cases are translated to simple AND or OR combinations
1106  * of the pairwise comparisons. However, we include = and <> in the
1107  * RowCompareType enum for the convenience of parser logic.
1108  */
1109 typedef enum RowCompareType
1110 {
1111  /* Values of this enum are chosen to match btree strategy numbers */
1112  ROWCOMPARE_LT = 1, /* BTLessStrategyNumber */
1113  ROWCOMPARE_LE = 2, /* BTLessEqualStrategyNumber */
1114  ROWCOMPARE_EQ = 3, /* BTEqualStrategyNumber */
1115  ROWCOMPARE_GE = 4, /* BTGreaterEqualStrategyNumber */
1116  ROWCOMPARE_GT = 5, /* BTGreaterStrategyNumber */
1117  ROWCOMPARE_NE = 6 /* no such btree strategy */
1119 
1120 typedef struct RowCompareExpr
1121 {
1123  RowCompareType rctype; /* LT LE GE or GT, never EQ or NE */
1124  List *opnos; /* OID list of pairwise comparison ops */
1125  List *opfamilies; /* OID list of containing operator families */
1126  List *inputcollids; /* OID list of collations for comparisons */
1127  List *largs; /* the left-hand input arguments */
1128  List *rargs; /* the right-hand input arguments */
1130 
1131 /*
1132  * CoalesceExpr - a COALESCE expression
1133  */
1134 typedef struct CoalesceExpr
1135 {
1137  Oid coalescetype; /* type of expression result */
1138  Oid coalescecollid; /* OID of collation, or InvalidOid if none */
1139  List *args; /* the arguments */
1140  int location; /* token location, or -1 if unknown */
1142 
1143 /*
1144  * MinMaxExpr - a GREATEST or LEAST function
1145  */
1146 typedef enum MinMaxOp
1147 {
1149  IS_LEAST
1151 
1152 typedef struct MinMaxExpr
1153 {
1155  Oid minmaxtype; /* common type of arguments and result */
1156  Oid minmaxcollid; /* OID of collation of result */
1157  Oid inputcollid; /* OID of collation that function should use */
1158  MinMaxOp op; /* function to execute */
1159  List *args; /* the arguments */
1160  int location; /* token location, or -1 if unknown */
1162 
1163 /*
1164  * SQLValueFunction - parameterless functions with special grammar productions
1165  *
1166  * The SQL standard categorizes some of these as <datetime value function>
1167  * and others as <general value specification>. We call 'em SQLValueFunctions
1168  * for lack of a better term. We store type and typmod of the result so that
1169  * some code doesn't need to know each function individually, and because
1170  * we would need to store typmod anyway for some of the datetime functions.
1171  * Note that currently, all variants return non-collating datatypes, so we do
1172  * not need a collation field; also, all these functions are stable.
1173  */
1175 {
1192 
1193 typedef struct SQLValueFunction
1194 {
1196  SQLValueFunctionOp op; /* which function this is */
1197  Oid type; /* result type/typmod */
1199  int location; /* token location, or -1 if unknown */
1201 
1202 /*
1203  * XmlExpr - various SQL/XML functions requiring special grammar productions
1204  *
1205  * 'name' carries the "NAME foo" argument (already XML-escaped).
1206  * 'named_args' and 'arg_names' represent an xml_attribute list.
1207  * 'args' carries all other arguments.
1208  *
1209  * Note: result type/typmod/collation are not stored, but can be deduced
1210  * from the XmlExprOp. The type/typmod fields are just used for display
1211  * purposes, and are NOT necessarily the true result type of the node.
1212  */
1213 typedef enum XmlExprOp
1214 {
1215  IS_XMLCONCAT, /* XMLCONCAT(args) */
1216  IS_XMLELEMENT, /* XMLELEMENT(name, xml_attributes, args) */
1217  IS_XMLFOREST, /* XMLFOREST(xml_attributes) */
1218  IS_XMLPARSE, /* XMLPARSE(text, is_doc, preserve_ws) */
1219  IS_XMLPI, /* XMLPI(name [, args]) */
1220  IS_XMLROOT, /* XMLROOT(xml, version, standalone) */
1221  IS_XMLSERIALIZE, /* XMLSERIALIZE(is_document, xmlval) */
1222  IS_DOCUMENT /* xmlval IS DOCUMENT */
1224 
1225 typedef enum XmlOptionType
1226 {
1230 
1231 typedef struct XmlExpr
1232 {
1234  XmlExprOp op; /* xml function ID */
1235  char *name; /* name in xml(NAME foo ...) syntaxes */
1236  List *named_args; /* non-XML expressions for xml_attributes */
1237  List *arg_names; /* parallel list of String values */
1238  List *args; /* list of expressions */
1239  XmlOptionType xmloption; /* DOCUMENT or CONTENT */
1240  Oid type; /* target type/typmod for XMLSERIALIZE */
1242  int location; /* token location, or -1 if unknown */
1244 
1245 /*
1246  * JsonExprOp -
1247  * enumeration of JSON functions using JSON path
1248  */
1249 typedef enum JsonExprOp
1250 {
1251  JSON_VALUE_OP, /* JSON_VALUE() */
1252  JSON_QUERY_OP, /* JSON_QUERY() */
1253  JSON_EXISTS_OP, /* JSON_EXISTS() */
1254  JSON_TABLE_OP /* JSON_TABLE() */
1256 
1257 /*
1258  * JsonEncoding -
1259  * representation of JSON ENCODING clause
1260  */
1261 typedef enum JsonEncoding
1262 {
1263  JS_ENC_DEFAULT, /* unspecified */
1268 
1269 /*
1270  * JsonFormatType -
1271  * enumeration of JSON formats used in JSON FORMAT clause
1272  */
1273 typedef enum JsonFormatType
1274 {
1275  JS_FORMAT_DEFAULT, /* unspecified */
1276  JS_FORMAT_JSON, /* FORMAT JSON [ENCODING ...] */
1277  JS_FORMAT_JSONB /* implicit internal format for RETURNING
1278  * jsonb */
1280 
1281 /*
1282  * JsonBehaviorType -
1283  * enumeration of behavior types used in JSON ON ... BEHAVIOR clause
1284  *
1285  * If enum members are reordered, get_json_behavior() from ruleutils.c
1286  * must be updated accordingly.
1287  */
1288 typedef enum JsonBehaviorType
1289 {
1300 
1301 /*
1302  * JsonWrapper -
1303  * representation of WRAPPER clause for JSON_QUERY()
1304  */
1305 typedef enum JsonWrapper
1306 {
1311 
1312 /*
1313  * JsonFormat -
1314  * representation of JSON FORMAT clause
1315  */
1316 typedef struct JsonFormat
1317 {
1319  JsonFormatType format_type; /* format type */
1320  JsonEncoding encoding; /* JSON encoding */
1321  int location; /* token location, or -1 if unknown */
1323 
1324 /*
1325  * JsonReturning -
1326  * transformed representation of JSON RETURNING clause
1327  */
1328 typedef struct JsonReturning
1329 {
1331  JsonFormat *format; /* output JSON format */
1332  Oid typid; /* target type Oid */
1333  int32 typmod; /* target type modifier */
1335 
1336 /*
1337  * JsonValueExpr -
1338  * representation of JSON value expression (expr [FORMAT json_format])
1339  */
1340 typedef struct JsonValueExpr
1341 {
1343  Expr *raw_expr; /* raw expression */
1344  Expr *formatted_expr; /* formatted expression or NULL */
1345  JsonFormat *format; /* FORMAT clause, if specified */
1347 
1349 {
1356  JSCTOR_JSON_PARSE = 7
1358 
1359 /*
1360  * JsonConstructorExpr -
1361  * wrapper over FuncExpr/Aggref/WindowFunc for SQL/JSON constructors
1362  */
1363 typedef struct JsonConstructorExpr
1364 {
1366  JsonConstructorType type; /* constructor type */
1368  Expr *func; /* underlying json[b]_xxx() function call */
1369  Expr *coercion; /* coercion to RETURNING type */
1370  JsonReturning *returning; /* RETURNING clause */
1371  bool absent_on_null; /* ABSENT ON NULL? */
1372  bool unique; /* WITH UNIQUE KEYS? (JSON_OBJECT[AGG] only) */
1375 
1376 /*
1377  * JsonValueType -
1378  * representation of JSON item type in IS JSON predicate
1379  */
1380 typedef enum JsonValueType
1381 {
1382  JS_TYPE_ANY, /* IS JSON [VALUE] */
1383  JS_TYPE_OBJECT, /* IS JSON OBJECT */
1384  JS_TYPE_ARRAY, /* IS JSON ARRAY */
1385  JS_TYPE_SCALAR /* IS JSON SCALAR */
1387 
1388 /*
1389  * JsonIsPredicate -
1390  * representation of IS JSON predicate
1391  */
1392 typedef struct JsonIsPredicate
1393 {
1395  Node *expr; /* subject expression */
1396  JsonFormat *format; /* FORMAT clause, if specified */
1397  JsonValueType item_type; /* JSON item type */
1398  bool unique_keys; /* check key uniqueness? */
1399  int location; /* token location, or -1 if unknown */
1401 
1402 /*
1403  * JsonBehavior -
1404  * representation of JSON ON ... BEHAVIOR clause
1405  */
1406 typedef struct JsonBehavior
1407 {
1409  JsonBehaviorType btype; /* behavior type */
1410  Node *default_expr; /* default expression, if any */
1412 
1413 /*
1414  * JsonCoercion -
1415  * coercion from SQL/JSON item types to SQL types
1416  */
1417 typedef struct JsonCoercion
1418 {
1420  Node *expr; /* resulting expression coerced to target type */
1421  bool via_populate; /* coerce result using json_populate_type()? */
1422  bool via_io; /* coerce result using type input function? */
1423  Oid collation; /* collation for coercion via I/O or populate */
1425 
1426 /*
1427  * JsonItemCoercions -
1428  * expressions for coercion from SQL/JSON item types directly to the
1429  * output SQL type
1430  */
1431 typedef struct JsonItemCoercions
1432 {
1443  JsonCoercion *composite; /* arrays and objects */
1445 
1446 /*
1447  * JsonExpr -
1448  * transformed representation of JSON_VALUE(), JSON_QUERY(), JSON_EXISTS()
1449  */
1450 typedef struct JsonExpr
1451 {
1453  JsonExprOp op; /* json function ID */
1454  Node *formatted_expr; /* formatted context item expression */
1455  JsonCoercion *result_coercion; /* resulting coercion to RETURNING type */
1456  JsonFormat *format; /* context item format (JSON/JSONB) */
1457  Node *path_spec; /* JSON path specification expression */
1458  List *passing_names; /* PASSING argument names */
1459  List *passing_values; /* PASSING argument values */
1460  JsonReturning *returning; /* RETURNING clause type/format info */
1461  JsonBehavior *on_empty; /* ON EMPTY behavior */
1462  JsonBehavior *on_error; /* ON ERROR behavior */
1463  JsonItemCoercions *coercions; /* coercions for JSON_VALUE */
1464  JsonWrapper wrapper; /* WRAPPER for JSON_QUERY */
1465  bool omit_quotes; /* KEEP/OMIT QUOTES for JSON_QUERY */
1466  int location; /* token location, or -1 if unknown */
1468 
1469 /*
1470  * JsonTableParent -
1471  * transformed representation of parent JSON_TABLE plan node
1472  */
1473 typedef struct JsonTableParent
1474 {
1476  Const *path; /* jsonpath constant */
1477  char *name; /* path name */
1478  Node *child; /* nested columns, if any */
1479  bool outerJoin; /* outer or inner join for nested columns? */
1480  int colMin; /* min column index in the resulting column
1481  * list */
1482  int colMax; /* max column index in the resulting column
1483  * list */
1484  bool errorOnError; /* ERROR/EMPTY ON ERROR behavior */
1486 
1487 /*
1488  * JsonTableSibling -
1489  * transformed representation of joined sibling JSON_TABLE plan node
1490  */
1491 typedef struct JsonTableSibling
1492 {
1494  Node *larg; /* left join node */
1495  Node *rarg; /* right join node */
1496  bool cross; /* cross or union join? */
1498 
1499 /* ----------------
1500  * NullTest
1501  *
1502  * NullTest represents the operation of testing a value for NULLness.
1503  * The appropriate test is performed and returned as a boolean Datum.
1504  *
1505  * When argisrow is false, this simply represents a test for the null value.
1506  *
1507  * When argisrow is true, the input expression must yield a rowtype, and
1508  * the node implements "row IS [NOT] NULL" per the SQL standard. This
1509  * includes checking individual fields for NULLness when the row datum
1510  * itself isn't NULL.
1511  *
1512  * NOTE: the combination of a rowtype input and argisrow==false does NOT
1513  * correspond to the SQL notation "row IS [NOT] NULL"; instead, this case
1514  * represents the SQL notation "row IS [NOT] DISTINCT FROM NULL".
1515  * ----------------
1516  */
1517 
1518 typedef enum NullTestType
1519 {
1522 
1523 typedef struct NullTest
1524 {
1526  Expr *arg; /* input expression */
1527  NullTestType nulltesttype; /* IS NULL, IS NOT NULL */
1528  bool argisrow; /* T to perform field-by-field null checks */
1529  int location; /* token location, or -1 if unknown */
1531 
1532 /*
1533  * BooleanTest
1534  *
1535  * BooleanTest represents the operation of determining whether a boolean
1536  * is TRUE, FALSE, or UNKNOWN (ie, NULL). All six meaningful combinations
1537  * are supported. Note that a NULL input does *not* cause a NULL result.
1538  * The appropriate test is performed and returned as a boolean Datum.
1539  */
1540 
1541 typedef enum BoolTestType
1542 {
1545 
1546 typedef struct BooleanTest
1547 {
1549  Expr *arg; /* input expression */
1550  BoolTestType booltesttype; /* test type */
1551  int location; /* token location, or -1 if unknown */
1553 
1554 /*
1555  * CoerceToDomain
1556  *
1557  * CoerceToDomain represents the operation of coercing a value to a domain
1558  * type. At runtime (and not before) the precise set of constraints to be
1559  * checked will be determined. If the value passes, it is returned as the
1560  * result; if not, an error is raised. Note that this is equivalent to
1561  * RelabelType in the scenario where no constraints are applied.
1562  */
1563 typedef struct CoerceToDomain
1564 {
1566  Expr *arg; /* input expression */
1567  Oid resulttype; /* domain type ID (result type) */
1568  int32 resulttypmod; /* output typmod (currently always -1) */
1569  Oid resultcollid; /* OID of collation, or InvalidOid if none */
1570  CoercionForm coercionformat; /* how to display this node */
1571  int location; /* token location, or -1 if unknown */
1573 
1574 /*
1575  * Placeholder node for the value to be processed by a domain's check
1576  * constraint. This is effectively like a Param, but can be implemented more
1577  * simply since we need only one replacement value at a time.
1578  *
1579  * Note: the typeId/typeMod/collation will be set from the domain's base type,
1580  * not the domain itself. This is because we shouldn't consider the value
1581  * to be a member of the domain if we haven't yet checked its constraints.
1582  */
1583 typedef struct CoerceToDomainValue
1584 {
1586  Oid typeId; /* type for substituted value */
1587  int32 typeMod; /* typemod for substituted value */
1588  Oid collation; /* collation for the substituted value */
1589  int location; /* token location, or -1 if unknown */
1591 
1592 /*
1593  * Placeholder node for a DEFAULT marker in an INSERT or UPDATE command.
1594  *
1595  * This is not an executable expression: it must be replaced by the actual
1596  * column default expression during rewriting. But it is convenient to
1597  * treat it as an expression node during parsing and rewriting.
1598  */
1599 typedef struct SetToDefault
1600 {
1602  Oid typeId; /* type for substituted value */
1603  int32 typeMod; /* typemod for substituted value */
1604  Oid collation; /* collation for the substituted value */
1605  int location; /* token location, or -1 if unknown */
1607 
1608 /*
1609  * Node representing [WHERE] CURRENT OF cursor_name
1610  *
1611  * CURRENT OF is a bit like a Var, in that it carries the rangetable index
1612  * of the target relation being constrained; this aids placing the expression
1613  * correctly during planning. We can assume however that its "levelsup" is
1614  * always zero, due to the syntactic constraints on where it can appear.
1615  * Also, cvarno will always be a true RT index, never INNER_VAR etc.
1616  *
1617  * The referenced cursor can be represented either as a hardwired string
1618  * or as a reference to a run-time parameter of type REFCURSOR. The latter
1619  * case is for the convenience of plpgsql.
1620  */
1621 typedef struct CurrentOfExpr
1622 {
1624  Index cvarno; /* RT index of target relation */
1625  char *cursor_name; /* name of referenced cursor, or NULL */
1626  int cursor_param; /* refcursor parameter number, or 0 */
1628 
1629 /*
1630  * NextValueExpr - get next value from sequence
1631  *
1632  * This has the same effect as calling the nextval() function, but it does not
1633  * check permissions on the sequence. This is used for identity columns,
1634  * where the sequence is an implicit dependency without its own permissions.
1635  */
1636 typedef struct NextValueExpr
1637 {
1642 
1643 /*
1644  * InferenceElem - an element of a unique index inference specification
1645  *
1646  * This mostly matches the structure of IndexElems, but having a dedicated
1647  * primnode allows for a clean separation between the use of index parameters
1648  * by utility commands, and this node.
1649  */
1650 typedef struct InferenceElem
1651 {
1653  Node *expr; /* expression to infer from, or NULL */
1654  Oid infercollid; /* OID of collation, or InvalidOid */
1655  Oid inferopclass; /* OID of att opclass, or InvalidOid */
1657 
1658 /*--------------------
1659  * TargetEntry -
1660  * a target entry (used in query target lists)
1661  *
1662  * Strictly speaking, a TargetEntry isn't an expression node (since it can't
1663  * be evaluated by ExecEvalExpr). But we treat it as one anyway, since in
1664  * very many places it's convenient to process a whole query targetlist as a
1665  * single expression tree.
1666  *
1667  * In a SELECT's targetlist, resno should always be equal to the item's
1668  * ordinal position (counting from 1). However, in an INSERT or UPDATE
1669  * targetlist, resno represents the attribute number of the destination
1670  * column for the item; so there may be missing or out-of-order resnos.
1671  * It is even legal to have duplicated resnos; consider
1672  * UPDATE table SET arraycol[1] = ..., arraycol[2] = ..., ...
1673  * In an INSERT, the rewriter and planner will normalize the tlist by
1674  * reordering it into physical column order and filling in default values
1675  * for any columns not assigned values by the original query. In an UPDATE,
1676  * after the rewriter merges multiple assignments for the same column, the
1677  * planner extracts the target-column numbers into a separate "update_colnos"
1678  * list, and then renumbers the tlist elements serially. Thus, tlist resnos
1679  * match ordinal position in all tlists seen by the executor; but it is wrong
1680  * to assume that before planning has happened.
1681  *
1682  * resname is required to represent the correct column name in non-resjunk
1683  * entries of top-level SELECT targetlists, since it will be used as the
1684  * column title sent to the frontend. In most other contexts it is only
1685  * a debugging aid, and may be wrong or even NULL. (In particular, it may
1686  * be wrong in a tlist from a stored rule, if the referenced column has been
1687  * renamed by ALTER TABLE since the rule was made. Also, the planner tends
1688  * to store NULL rather than look up a valid name for tlist entries in
1689  * non-toplevel plan nodes.) In resjunk entries, resname should be either
1690  * a specific system-generated name (such as "ctid") or NULL; anything else
1691  * risks confusing ExecGetJunkAttribute!
1692  *
1693  * ressortgroupref is used in the representation of ORDER BY, GROUP BY, and
1694  * DISTINCT items. Targetlist entries with ressortgroupref=0 are not
1695  * sort/group items. If ressortgroupref>0, then this item is an ORDER BY,
1696  * GROUP BY, and/or DISTINCT target value. No two entries in a targetlist
1697  * may have the same nonzero ressortgroupref --- but there is no particular
1698  * meaning to the nonzero values, except as tags. (For example, one must
1699  * not assume that lower ressortgroupref means a more significant sort key.)
1700  * The order of the associated SortGroupClause lists determine the semantics.
1701  *
1702  * resorigtbl/resorigcol identify the source of the column, if it is a
1703  * simple reference to a column of a base table (or view). If it is not
1704  * a simple reference, these fields are zeroes.
1705  *
1706  * If resjunk is true then the column is a working column (such as a sort key)
1707  * that should be removed from the final output of the query. Resjunk columns
1708  * must have resnos that cannot duplicate any regular column's resno. Also
1709  * note that there are places that assume resjunk columns come after non-junk
1710  * columns.
1711  *--------------------
1712  */
1713 typedef struct TargetEntry
1714 {
1716  Expr *expr; /* expression to evaluate */
1717  AttrNumber resno; /* attribute number (see notes above) */
1718  char *resname; /* name of the column (could be NULL) */
1719  Index ressortgroupref; /* nonzero if referenced by a sort/group
1720  * clause */
1721  Oid resorigtbl; /* OID of column's source table */
1722  AttrNumber resorigcol; /* column's number in source table */
1723  bool resjunk; /* set to true to eliminate the attribute from
1724  * final target list */
1726 
1727 
1728 /* ----------------------------------------------------------------
1729  * node types for join trees
1730  *
1731  * The leaves of a join tree structure are RangeTblRef nodes. Above
1732  * these, JoinExpr nodes can appear to denote a specific kind of join
1733  * or qualified join. Also, FromExpr nodes can appear to denote an
1734  * ordinary cross-product join ("FROM foo, bar, baz WHERE ...").
1735  * FromExpr is like a JoinExpr of jointype JOIN_INNER, except that it
1736  * may have any number of child nodes, not just two.
1737  *
1738  * NOTE: the top level of a Query's jointree is always a FromExpr.
1739  * Even if the jointree contains no rels, there will be a FromExpr.
1740  *
1741  * NOTE: the qualification expressions present in JoinExpr nodes are
1742  * *in addition to* the query's main WHERE clause, which appears as the
1743  * qual of the top-level FromExpr. The reason for associating quals with
1744  * specific nodes in the jointree is that the position of a qual is critical
1745  * when outer joins are present. (If we enforce a qual too soon or too late,
1746  * that may cause the outer join to produce the wrong set of NULL-extended
1747  * rows.) If all joins are inner joins then all the qual positions are
1748  * semantically interchangeable.
1749  *
1750  * NOTE: in the raw output of gram.y, a join tree contains RangeVar,
1751  * RangeSubselect, and RangeFunction nodes, which are all replaced by
1752  * RangeTblRef nodes during the parse analysis phase. Also, the top-level
1753  * FromExpr is added during parse analysis; the grammar regards FROM and
1754  * WHERE as separate.
1755  * ----------------------------------------------------------------
1756  */
1757 
1758 /*
1759  * RangeTblRef - reference to an entry in the query's rangetable
1760  *
1761  * We could use direct pointers to the RT entries and skip having these
1762  * nodes, but multiple pointers to the same node in a querytree cause
1763  * lots of headaches, so it seems better to store an index into the RT.
1764  */
1765 typedef struct RangeTblRef
1766 {
1768  int rtindex;
1770 
1771 /*----------
1772  * JoinExpr - for SQL JOIN expressions
1773  *
1774  * isNatural, usingClause, and quals are interdependent. The user can write
1775  * only one of NATURAL, USING(), or ON() (this is enforced by the grammar).
1776  * If he writes NATURAL then parse analysis generates the equivalent USING()
1777  * list, and from that fills in "quals" with the right equality comparisons.
1778  * If he writes USING() then "quals" is filled with equality comparisons.
1779  * If he writes ON() then only "quals" is set. Note that NATURAL/USING
1780  * are not equivalent to ON() since they also affect the output column list.
1781  *
1782  * alias is an Alias node representing the AS alias-clause attached to the
1783  * join expression, or NULL if no clause. NB: presence or absence of the
1784  * alias has a critical impact on semantics, because a join with an alias
1785  * restricts visibility of the tables/columns inside it.
1786  *
1787  * join_using_alias is an Alias node representing the join correlation
1788  * name that SQL:2016 and later allow to be attached to JOIN/USING.
1789  * Its column alias list includes only the common column names from USING,
1790  * and it does not restrict visibility of the join's input tables.
1791  *
1792  * During parse analysis, an RTE is created for the Join, and its index
1793  * is filled into rtindex. This RTE is present mainly so that Vars can
1794  * be created that refer to the outputs of the join. The planner sometimes
1795  * generates JoinExprs internally; these can have rtindex = 0 if there are
1796  * no join alias variables referencing such joins.
1797  *----------
1798  */
1799 typedef struct JoinExpr
1800 {
1802  JoinType jointype; /* type of join */
1803  bool isNatural; /* Natural join? Will need to shape table */
1804  Node *larg; /* left subtree */
1805  Node *rarg; /* right subtree */
1806  List *usingClause; /* USING clause, if any (list of String) */
1807  Alias *join_using_alias; /* alias attached to USING clause, if any */
1808  Node *quals; /* qualifiers on join, if any */
1809  Alias *alias; /* user-written alias clause, if any */
1810  int rtindex; /* RT index assigned for join, or 0 */
1812 
1813 /*----------
1814  * FromExpr - represents a FROM ... WHERE ... construct
1815  *
1816  * This is both more flexible than a JoinExpr (it can have any number of
1817  * children, including zero) and less so --- we don't need to deal with
1818  * aliases and so on. The output column set is implicitly just the union
1819  * of the outputs of the children.
1820  *----------
1821  */
1822 typedef struct FromExpr
1823 {
1825  List *fromlist; /* List of join subtrees */
1826  Node *quals; /* qualifiers on join, if any */
1828 
1829 /*----------
1830  * OnConflictExpr - represents an ON CONFLICT DO ... expression
1831  *
1832  * The optimizer requires a list of inference elements, and optionally a WHERE
1833  * clause to infer a unique index. The unique index (or, occasionally,
1834  * indexes) inferred are used to arbitrate whether or not the alternative ON
1835  * CONFLICT path is taken.
1836  *----------
1837  */
1838 typedef struct OnConflictExpr
1839 {
1841  OnConflictAction action; /* DO NOTHING or UPDATE? */
1842 
1843  /* Arbiter */
1844  List *arbiterElems; /* unique index arbiter list (of
1845  * InferenceElem's) */
1846  Node *arbiterWhere; /* unique index arbiter WHERE clause */
1847  Oid constraint; /* pg_constraint OID for arbiter */
1848 
1849  /* ON CONFLICT UPDATE */
1850  List *onConflictSet; /* List of ON CONFLICT SET TargetEntrys */
1851  Node *onConflictWhere; /* qualifiers to restrict UPDATE to */
1852  int exclRelIndex; /* RT index of 'excluded' relation */
1853  List *exclRelTlist; /* tlist of the EXCLUDED pseudo relation */
1855 
1856 #endif /* PRIMNODES_H */
int16 AttrNumber
Definition: attnum.h:21
signed int int32
Definition: c.h:429
unsigned int Index
Definition: c.h:549
double Cost
Definition: nodes.h:707
OnConflictAction
Definition: nodes.h:870
NodeTag
Definition: nodes.h:27
AggSplit
Definition: nodes.h:828
JoinType
Definition: nodes.h:744
uintptr_t Datum
Definition: postgres.h:411
unsigned int Oid
Definition: postgres_ext.h:31
BoolTestType
Definition: primnodes.h:1542
@ IS_NOT_TRUE
Definition: primnodes.h:1543
@ IS_NOT_FALSE
Definition: primnodes.h:1543
@ IS_NOT_UNKNOWN
Definition: primnodes.h:1543
@ IS_TRUE
Definition: primnodes.h:1543
@ IS_UNKNOWN
Definition: primnodes.h:1543
@ IS_FALSE
Definition: primnodes.h:1543
struct ArrayExpr ArrayExpr
struct FieldSelect FieldSelect
struct CoalesceExpr CoalesceExpr
struct Aggref Aggref
SubLinkType
Definition: primnodes.h:691
@ ARRAY_SUBLINK
Definition: primnodes.h:698
@ ANY_SUBLINK
Definition: primnodes.h:694
@ MULTIEXPR_SUBLINK
Definition: primnodes.h:697
@ CTE_SUBLINK
Definition: primnodes.h:699
@ EXPR_SUBLINK
Definition: primnodes.h:696
@ ROWCOMPARE_SUBLINK
Definition: primnodes.h:695
@ ALL_SUBLINK
Definition: primnodes.h:693
@ EXISTS_SUBLINK
Definition: primnodes.h:692
struct AlternativeSubPlan AlternativeSubPlan
JsonFormatType
Definition: primnodes.h:1274
@ JS_FORMAT_JSONB
Definition: primnodes.h:1277
@ JS_FORMAT_DEFAULT
Definition: primnodes.h:1275
@ JS_FORMAT_JSON
Definition: primnodes.h:1276
struct InferenceElem InferenceElem
struct ArrayCoerceExpr ArrayCoerceExpr
struct TargetEntry TargetEntry
MinMaxOp
Definition: primnodes.h:1147
@ IS_LEAST
Definition: primnodes.h:1149
@ IS_GREATEST
Definition: primnodes.h:1148
TableFuncType
Definition: primnodes.h:77
@ TFT_XMLTABLE
Definition: primnodes.h:78
@ TFT_JSON_TABLE
Definition: primnodes.h:79
struct CaseWhen CaseWhen
BoolExprType
Definition: primnodes.h:627
@ AND_EXPR
Definition: primnodes.h:628
@ OR_EXPR
Definition: primnodes.h:628
@ NOT_EXPR
Definition: primnodes.h:628
struct SetToDefault SetToDefault
JsonEncoding
Definition: primnodes.h:1262
@ JS_ENC_DEFAULT
Definition: primnodes.h:1263
@ JS_ENC_UTF32
Definition: primnodes.h:1266
@ JS_ENC_UTF8
Definition: primnodes.h:1264
@ JS_ENC_UTF16
Definition: primnodes.h:1265
struct JsonReturning JsonReturning
struct CaseExpr CaseExpr
struct JsonBehavior JsonBehavior
struct WindowFunc WindowFunc
XmlOptionType
Definition: primnodes.h:1226
@ XMLOPTION_CONTENT
Definition: primnodes.h:1228
@ XMLOPTION_DOCUMENT
Definition: primnodes.h:1227
SQLValueFunctionOp
Definition: primnodes.h:1175
@ SVFOP_CURRENT_CATALOG
Definition: primnodes.h:1189
@ SVFOP_LOCALTIME_N
Definition: primnodes.h:1182
@ SVFOP_CURRENT_TIMESTAMP
Definition: primnodes.h:1179
@ SVFOP_LOCALTIME
Definition: primnodes.h:1181
@ SVFOP_CURRENT_TIMESTAMP_N
Definition: primnodes.h:1180
@ SVFOP_CURRENT_ROLE
Definition: primnodes.h:1185
@ SVFOP_USER
Definition: primnodes.h:1187
@ SVFOP_CURRENT_SCHEMA
Definition: primnodes.h:1190
@ SVFOP_LOCALTIMESTAMP_N
Definition: primnodes.h:1184
@ SVFOP_CURRENT_DATE
Definition: primnodes.h:1176
@ SVFOP_CURRENT_TIME_N
Definition: primnodes.h:1178
@ SVFOP_CURRENT_TIME
Definition: primnodes.h:1177
@ SVFOP_LOCALTIMESTAMP
Definition: primnodes.h:1183
@ SVFOP_CURRENT_USER
Definition: primnodes.h:1186
@ SVFOP_SESSION_USER
Definition: primnodes.h:1188
ParamKind
Definition: primnodes.h:266
@ PARAM_MULTIEXPR
Definition: primnodes.h:270
@ PARAM_EXTERN
Definition: primnodes.h:267
@ PARAM_SUBLINK
Definition: primnodes.h:269
@ PARAM_EXEC
Definition: primnodes.h:268
struct CoerceToDomainValue CoerceToDomainValue
struct Var Var
JsonWrapper
Definition: primnodes.h:1306
@ JSW_UNCONDITIONAL
Definition: primnodes.h:1309
@ JSW_CONDITIONAL
Definition: primnodes.h:1308
@ JSW_NONE
Definition: primnodes.h:1307
struct IntoClause IntoClause
struct MinMaxExpr MinMaxExpr
OpExpr DistinctExpr
Definition: primnodes.h:571
struct NamedArgExpr NamedArgExpr
XmlExprOp
Definition: primnodes.h:1214
@ IS_DOCUMENT
Definition: primnodes.h:1222
@ IS_XMLFOREST
Definition: primnodes.h:1217
@ IS_XMLCONCAT
Definition: primnodes.h:1215
@ IS_XMLPI
Definition: primnodes.h:1219
@ IS_XMLPARSE
Definition: primnodes.h:1218
@ IS_XMLSERIALIZE
Definition: primnodes.h:1221
@ IS_XMLROOT
Definition: primnodes.h:1220
@ IS_XMLELEMENT
Definition: primnodes.h:1216
struct JsonIsPredicate JsonIsPredicate
struct JoinExpr JoinExpr
struct CoerceToDomain CoerceToDomain
struct SubLink SubLink
struct NextValueExpr NextValueExpr
struct JsonExpr JsonExpr
struct BoolExpr BoolExpr
struct OpExpr OpExpr
struct Expr Expr
RowCompareType
Definition: primnodes.h:1110
@ ROWCOMPARE_GT
Definition: primnodes.h:1116
@ ROWCOMPARE_LT
Definition: primnodes.h:1112
@ ROWCOMPARE_NE
Definition: primnodes.h:1117
@ ROWCOMPARE_LE
Definition: primnodes.h:1113
@ ROWCOMPARE_EQ
Definition: primnodes.h:1114
@ ROWCOMPARE_GE
Definition: primnodes.h:1115
JsonBehaviorType
Definition: primnodes.h:1289
@ JSON_BEHAVIOR_ERROR
Definition: primnodes.h:1291
@ JSON_BEHAVIOR_TRUE
Definition: primnodes.h:1293
@ JSON_BEHAVIOR_DEFAULT
Definition: primnodes.h:1298
@ JSON_BEHAVIOR_EMPTY
Definition: primnodes.h:1292
@ JSON_BEHAVIOR_FALSE
Definition: primnodes.h:1294
@ JSON_BEHAVIOR_NULL
Definition: primnodes.h:1290
@ JSON_BEHAVIOR_EMPTY_OBJECT
Definition: primnodes.h:1297
@ JSON_BEHAVIOR_UNKNOWN
Definition: primnodes.h:1295
@ JSON_BEHAVIOR_EMPTY_ARRAY
Definition: primnodes.h:1296
struct OnConflictExpr OnConflictExpr
struct FuncExpr FuncExpr
OnCommitAction
Definition: primnodes.h:48
@ ONCOMMIT_DELETE_ROWS
Definition: primnodes.h:51
@ ONCOMMIT_NOOP
Definition: primnodes.h:49
@ ONCOMMIT_PRESERVE_ROWS
Definition: primnodes.h:50
@ ONCOMMIT_DROP
Definition: primnodes.h:52
struct GroupingFunc GroupingFunc
struct XmlExpr XmlExpr
struct SubPlan SubPlan
struct CollateExpr CollateExpr
struct ConvertRowtypeExpr ConvertRowtypeExpr
struct RowExpr RowExpr
struct RangeTblRef RangeTblRef
JsonExprOp
Definition: primnodes.h:1250
@ JSON_QUERY_OP
Definition: primnodes.h:1252
@ JSON_TABLE_OP
Definition: primnodes.h:1254
@ JSON_EXISTS_OP
Definition: primnodes.h:1253
@ JSON_VALUE_OP
Definition: primnodes.h:1251
struct BooleanTest BooleanTest
CoercionForm
Definition: primnodes.h:491
@ COERCE_SQL_SYNTAX
Definition: primnodes.h:495
@ COERCE_IMPLICIT_CAST
Definition: primnodes.h:494
@ COERCE_EXPLICIT_CAST
Definition: primnodes.h:493
@ COERCE_EXPLICIT_CALL
Definition: primnodes.h:492
struct CaseTestExpr CaseTestExpr
struct SQLValueFunction SQLValueFunction
NullTestType
Definition: primnodes.h:1519
@ IS_NULL
Definition: primnodes.h:1520
@ IS_NOT_NULL
Definition: primnodes.h:1520
struct JsonConstructorExpr JsonConstructorExpr
struct CurrentOfExpr CurrentOfExpr
JsonValueType
Definition: primnodes.h:1381
@ JS_TYPE_ANY
Definition: primnodes.h:1382
@ JS_TYPE_ARRAY
Definition: primnodes.h:1384
@ JS_TYPE_OBJECT
Definition: primnodes.h:1383
@ JS_TYPE_SCALAR
Definition: primnodes.h:1385
struct NullTest NullTest
struct RowCompareExpr RowCompareExpr
struct TableFunc TableFunc
struct ScalarArrayOpExpr ScalarArrayOpExpr
struct JsonTableSibling JsonTableSibling
struct JsonFormat JsonFormat
struct Param Param
struct JsonTableParent JsonTableParent
struct JsonCoercion JsonCoercion
struct Alias Alias
CoercionContext
Definition: primnodes.h:471
@ COERCION_PLPGSQL
Definition: primnodes.h:474
@ COERCION_ASSIGNMENT
Definition: primnodes.h:473
@ COERCION_EXPLICIT
Definition: primnodes.h:475
@ COERCION_IMPLICIT
Definition: primnodes.h:472
struct RelabelType RelabelType
struct CoerceViaIO CoerceViaIO
struct RangeVar RangeVar
JsonConstructorType
Definition: primnodes.h:1349
@ JSCTOR_JSON_SERIALIZE
Definition: primnodes.h:1355
@ JSCTOR_JSON_ARRAYAGG
Definition: primnodes.h:1353
@ JSCTOR_JSON_PARSE
Definition: primnodes.h:1356
@ JSCTOR_JSON_OBJECT
Definition: primnodes.h:1350
@ JSCTOR_JSON_SCALAR
Definition: primnodes.h:1354
@ JSCTOR_JSON_ARRAY
Definition: primnodes.h:1351
@ JSCTOR_JSON_OBJECTAGG
Definition: primnodes.h:1352
OpExpr NullIfExpr
Definition: primnodes.h:579
struct Const Const
struct SubscriptingRef SubscriptingRef
struct JsonValueExpr JsonValueExpr
struct FromExpr FromExpr
struct FieldStore FieldStore
struct JsonItemCoercions JsonItemCoercions
bool aggstar
Definition: primnodes.h:343
Oid aggfnoid
Definition: primnodes.h:332
Expr xpr
Definition: primnodes.h:331
List * aggdistinct
Definition: primnodes.h:341
List * aggdirectargs
Definition: primnodes.h:338
bool aggvariadic
Definition: primnodes.h:344
char aggkind
Definition: primnodes.h:346
Oid aggtranstype
Definition: primnodes.h:336
int aggtransno
Definition: primnodes.h:350
Index agglevelsup
Definition: primnodes.h:347
List * args
Definition: primnodes.h:339
Expr * aggfilter
Definition: primnodes.h:342
Oid inputcollid
Definition: primnodes.h:335
Oid aggtype
Definition: primnodes.h:333
List * aggargtypes
Definition: primnodes.h:337
int location
Definition: primnodes.h:351
List * aggorder
Definition: primnodes.h:340
AggSplit aggsplit
Definition: primnodes.h:348
Oid aggcollid
Definition: primnodes.h:334
int aggno
Definition: primnodes.h:349
char * aliasname
Definition: primnodes.h:42
NodeTag type
Definition: primnodes.h:41
List * colnames
Definition: primnodes.h:43
Expr * elemexpr
Definition: primnodes.h:914
int32 resulttypmod
Definition: primnodes.h:916
CoercionForm coerceformat
Definition: primnodes.h:918
int location
Definition: primnodes.h:1048
bool multidims
Definition: primnodes.h:1047
Oid array_typeid
Definition: primnodes.h:1043
Oid array_collid
Definition: primnodes.h:1044
List * elements
Definition: primnodes.h:1046
Expr xpr
Definition: primnodes.h:1042
Oid element_typeid
Definition: primnodes.h:1045
int location
Definition: primnodes.h:636
BoolExprType boolop
Definition: primnodes.h:634
List * args
Definition: primnodes.h:635
Expr xpr
Definition: primnodes.h:633
BoolTestType booltesttype
Definition: primnodes.h:1550
Expr * arg
Definition: primnodes.h:1549
Expr * arg
Definition: primnodes.h:987
int location
Definition: primnodes.h:990
Oid casecollid
Definition: primnodes.h:986
Expr xpr
Definition: primnodes.h:984
Oid casetype
Definition: primnodes.h:985
Expr * defresult
Definition: primnodes.h:989
List * args
Definition: primnodes.h:988
int32 typeMod
Definition: primnodes.h:1028
Expr * result
Definition: primnodes.h:1000
Expr * expr
Definition: primnodes.h:999
Expr xpr
Definition: primnodes.h:998
int location
Definition: primnodes.h:1001
List * args
Definition: primnodes.h:1139
Oid coalescetype
Definition: primnodes.h:1137
Oid coalescecollid
Definition: primnodes.h:1138
CoercionForm coercionformat
Definition: primnodes.h:1570
int32 resulttypmod
Definition: primnodes.h:1568
Expr * arg
Definition: primnodes.h:889
CoercionForm coerceformat
Definition: primnodes.h:893
Oid resultcollid
Definition: primnodes.h:892
int location
Definition: primnodes.h:894
Oid resulttype
Definition: primnodes.h:890
Expr * arg
Definition: primnodes.h:955
int location
Definition: primnodes.h:957
Oid constcollid
Definition: primnodes.h:226
Oid consttype
Definition: primnodes.h:224
int constlen
Definition: primnodes.h:227
Datum constvalue
Definition: primnodes.h:228
bool constisnull
Definition: primnodes.h:229
bool constbyval
Definition: primnodes.h:231
Expr xpr
Definition: primnodes.h:223
int32 consttypmod
Definition: primnodes.h:225
int location
Definition: primnodes.h:235
CoercionForm convertformat
Definition: primnodes.h:941
char * cursor_name
Definition: primnodes.h:1625
NodeTag type
Definition: primnodes.h:147
AttrNumber fieldnum
Definition: primnodes.h:818
Oid resulttype
Definition: primnodes.h:819
Oid resultcollid
Definition: primnodes.h:822
Expr * arg
Definition: primnodes.h:817
int32 resulttypmod
Definition: primnodes.h:821
List * newvals
Definition: primnodes.h:847
Expr xpr
Definition: primnodes.h:845
Expr * arg
Definition: primnodes.h:846
Oid resulttype
Definition: primnodes.h:849
List * fieldnums
Definition: primnodes.h:848
Node * quals
Definition: primnodes.h:1826
NodeTag type
Definition: primnodes.h:1824
List * fromlist
Definition: primnodes.h:1825
Oid funccollid
Definition: primnodes.h:510
bool funcretset
Definition: primnodes.h:506
Expr xpr
Definition: primnodes.h:503
Oid funcid
Definition: primnodes.h:504
bool funcvariadic
Definition: primnodes.h:507
List * args
Definition: primnodes.h:512
CoercionForm funcformat
Definition: primnodes.h:509
Oid inputcollid
Definition: primnodes.h:511
int location
Definition: primnodes.h:513
Oid funcresulttype
Definition: primnodes.h:505
List * args
Definition: primnodes.h:381
Index agglevelsup
Definition: primnodes.h:385
List * refs
Definition: primnodes.h:383
List * cols
Definition: primnodes.h:384
Node * viewQuery
Definition: primnodes.h:127
List * colNames
Definition: primnodes.h:122
char * tableSpaceName
Definition: primnodes.h:126
bool skipData
Definition: primnodes.h:128
OnCommitAction onCommit
Definition: primnodes.h:125
NodeTag type
Definition: primnodes.h:119
List * options
Definition: primnodes.h:124
char * accessMethod
Definition: primnodes.h:123
RangeVar * rel
Definition: primnodes.h:121
Node * quals
Definition: primnodes.h:1808
JoinType jointype
Definition: primnodes.h:1802
Alias * alias
Definition: primnodes.h:1809
int rtindex
Definition: primnodes.h:1810
List * usingClause
Definition: primnodes.h:1806
Alias * join_using_alias
Definition: primnodes.h:1807
Node * larg
Definition: primnodes.h:1804
bool isNatural
Definition: primnodes.h:1803
NodeTag type
Definition: primnodes.h:1801
Node * rarg
Definition: primnodes.h:1805
JsonBehaviorType btype
Definition: primnodes.h:1409
NodeTag type
Definition: primnodes.h:1408
Node * default_expr
Definition: primnodes.h:1410
Node * expr
Definition: primnodes.h:1420
bool via_populate
Definition: primnodes.h:1421
NodeTag type
Definition: primnodes.h:1419
JsonReturning * returning
Definition: primnodes.h:1370
JsonConstructorType type
Definition: primnodes.h:1366
Node * formatted_expr
Definition: primnodes.h:1454
int location
Definition: primnodes.h:1466
List * passing_values
Definition: primnodes.h:1459
JsonBehavior * on_empty
Definition: primnodes.h:1461
JsonFormat * format
Definition: primnodes.h:1456
JsonItemCoercions * coercions
Definition: primnodes.h:1463
Expr xpr
Definition: primnodes.h:1452
List * passing_names
Definition: primnodes.h:1458
Node * path_spec
Definition: primnodes.h:1457
JsonCoercion * result_coercion
Definition: primnodes.h:1455
JsonReturning * returning
Definition: primnodes.h:1460
JsonWrapper wrapper
Definition: primnodes.h:1464
JsonExprOp op
Definition: primnodes.h:1453
JsonBehavior * on_error
Definition: primnodes.h:1462
bool omit_quotes
Definition: primnodes.h:1465
int location
Definition: primnodes.h:1321
NodeTag type
Definition: primnodes.h:1318
JsonEncoding encoding
Definition: primnodes.h:1320
JsonFormatType format_type
Definition: primnodes.h:1319
JsonFormat * format
Definition: primnodes.h:1396
JsonValueType item_type
Definition: primnodes.h:1397
JsonCoercion * string
Definition: primnodes.h:1435
JsonCoercion * timetz
Definition: primnodes.h:1440
JsonCoercion * numeric
Definition: primnodes.h:1436
JsonCoercion * date
Definition: primnodes.h:1438
JsonCoercion * composite
Definition: primnodes.h:1443
JsonCoercion * time
Definition: primnodes.h:1439
JsonCoercion * timestamptz
Definition: primnodes.h:1442
JsonCoercion * boolean
Definition: primnodes.h:1437
JsonCoercion * timestamp
Definition: primnodes.h:1441
JsonFormat * format
Definition: primnodes.h:1331
NodeTag type
Definition: primnodes.h:1330
Expr * formatted_expr
Definition: primnodes.h:1344
JsonFormat * format
Definition: primnodes.h:1345
NodeTag type
Definition: primnodes.h:1342
Expr * raw_expr
Definition: primnodes.h:1343
Definition: pg_list.h:51
Oid inputcollid
Definition: primnodes.h:1157
List * args
Definition: primnodes.h:1159
int location
Definition: primnodes.h:1160
Oid minmaxcollid
Definition: primnodes.h:1156
MinMaxOp op
Definition: primnodes.h:1158
Oid minmaxtype
Definition: primnodes.h:1155
Expr * arg
Definition: primnodes.h:533
char * name
Definition: primnodes.h:534
Definition: nodes.h:574
NullTestType nulltesttype
Definition: primnodes.h:1527
Expr xpr
Definition: primnodes.h:1525
int location
Definition: primnodes.h:1529
bool argisrow
Definition: primnodes.h:1528
Expr * arg
Definition: primnodes.h:1526
List * arbiterElems
Definition: primnodes.h:1844
OnConflictAction action
Definition: primnodes.h:1841
List * onConflictSet
Definition: primnodes.h:1850
List * exclRelTlist
Definition: primnodes.h:1853
NodeTag type
Definition: primnodes.h:1840
Node * onConflictWhere
Definition: primnodes.h:1851
Node * arbiterWhere
Definition: primnodes.h:1846
bool opretset
Definition: primnodes.h:554
int location
Definition: primnodes.h:558
Oid opno
Definition: primnodes.h:551
Oid opcollid
Definition: primnodes.h:555
List * args
Definition: primnodes.h:557
Oid opfuncid
Definition: primnodes.h:552
Expr xpr
Definition: primnodes.h:550
Oid inputcollid
Definition: primnodes.h:556
Oid opresulttype
Definition: primnodes.h:553
Expr xpr
Definition: primnodes.h:275
int32 paramtypmod
Definition: primnodes.h:279
int paramid
Definition: primnodes.h:277
Oid paramtype
Definition: primnodes.h:278
ParamKind paramkind
Definition: primnodes.h:276
int location
Definition: primnodes.h:281
Oid paramcollid
Definition: primnodes.h:280
NodeTag type
Definition: primnodes.h:1767
int location
Definition: primnodes.h:73
char * relname
Definition: primnodes.h:68
bool inh
Definition: primnodes.h:69
Alias * alias
Definition: primnodes.h:72
char relpersistence
Definition: primnodes.h:71
char * catalogname
Definition: primnodes.h:66
char * schemaname
Definition: primnodes.h:67
NodeTag type
Definition: primnodes.h:65
int location
Definition: primnodes.h:874
Oid resultcollid
Definition: primnodes.h:872
int32 resulttypmod
Definition: primnodes.h:871
CoercionForm relabelformat
Definition: primnodes.h:873
Oid resulttype
Definition: primnodes.h:870
Expr * arg
Definition: primnodes.h:869
RowCompareType rctype
Definition: primnodes.h:1123
List * opfamilies
Definition: primnodes.h:1125
List * inputcollids
Definition: primnodes.h:1126
Expr xpr
Definition: primnodes.h:1074
Oid row_typeid
Definition: primnodes.h:1076
int location
Definition: primnodes.h:1092
List * args
Definition: primnodes.h:1075
CoercionForm row_format
Definition: primnodes.h:1090
List * colnames
Definition: primnodes.h:1091
SQLValueFunctionOp op
Definition: primnodes.h:1196
int32 typeMod
Definition: primnodes.h:1603
int plan_id
Definition: primnodes.h:761
char * plan_name
Definition: primnodes.h:763
List * args
Definition: primnodes.h:782
List * paramIds
Definition: primnodes.h:759
bool useHashTable
Definition: primnodes.h:770
Node * testexpr
Definition: primnodes.h:758
int32 firstColTypmod
Definition: primnodes.h:766
List * parParam
Definition: primnodes.h:781
bool parallel_safe
Definition: primnodes.h:775
List * setParam
Definition: primnodes.h:779
Expr xpr
Definition: primnodes.h:754
bool unknownEqFalse
Definition: primnodes.h:772
Cost startup_cost
Definition: primnodes.h:784
Oid firstColCollation
Definition: primnodes.h:767
Cost per_call_cost
Definition: primnodes.h:785
SubLinkType subLinkType
Definition: primnodes.h:756
Oid firstColType
Definition: primnodes.h:765
Expr * refassgnexpr
Definition: primnodes.h:460
List * refupperindexpr
Definition: primnodes.h:453
Expr * refexpr
Definition: primnodes.h:458
Oid refcontainertype
Definition: primnodes.h:448
List * reflowerindexpr
Definition: primnodes.h:455
Bitmapset * notnulls
Definition: primnodes.h:103
List * coldefexprs
Definition: primnodes.h:101
List * colvalexprs
Definition: primnodes.h:102
Node * docexpr
Definition: primnodes.h:94
NodeTag type
Definition: primnodes.h:90
List * ns_names
Definition: primnodes.h:93
List * coltypmods
Definition: primnodes.h:98
List * ns_uris
Definition: primnodes.h:92
Node * plan
Definition: primnodes.h:104
List * coltypes
Definition: primnodes.h:97
Node * rowexpr
Definition: primnodes.h:95
List * colnames
Definition: primnodes.h:96
int location
Definition: primnodes.h:106
List * colexprs
Definition: primnodes.h:100
List * colcollations
Definition: primnodes.h:99
TableFuncType functype
Definition: primnodes.h:91
int ordinalitycol
Definition: primnodes.h:105
Expr * expr
Definition: primnodes.h:1716
char * resname
Definition: primnodes.h:1718
Oid resorigtbl
Definition: primnodes.h:1721
AttrNumber resno
Definition: primnodes.h:1717
bool resjunk
Definition: primnodes.h:1723
Index ressortgroupref
Definition: primnodes.h:1719
AttrNumber resorigcol
Definition: primnodes.h:1722
Definition: primnodes.h:196
Oid vartype
Definition: primnodes.h:202
AttrNumber varattno
Definition: primnodes.h:200
AttrNumber varattnosyn
Definition: primnodes.h:209
Oid varcollid
Definition: primnodes.h:204
Expr xpr
Definition: primnodes.h:197
int varno
Definition: primnodes.h:198
int32 vartypmod
Definition: primnodes.h:203
Index varlevelsup
Definition: primnodes.h:205
int location
Definition: primnodes.h:210
Index varnosyn
Definition: primnodes.h:208
Expr xpr
Definition: primnodes.h:394
bool winagg
Definition: primnodes.h:403
Oid inputcollid
Definition: primnodes.h:398
List * args
Definition: primnodes.h:399
Index winref
Definition: primnodes.h:401
Expr * aggfilter
Definition: primnodes.h:400
int location
Definition: primnodes.h:404
Oid wincollid
Definition: primnodes.h:397
Oid winfnoid
Definition: primnodes.h:395
bool winstar
Definition: primnodes.h:402
Oid wintype
Definition: primnodes.h:396
List * args
Definition: primnodes.h:1238
Expr xpr
Definition: primnodes.h:1233
char * name
Definition: primnodes.h:1235
List * arg_names
Definition: primnodes.h:1237
int32 typmod
Definition: primnodes.h:1241
int location
Definition: primnodes.h:1242
List * named_args
Definition: primnodes.h:1236
XmlExprOp op
Definition: primnodes.h:1234
Oid type
Definition: primnodes.h:1240
XmlOptionType xmloption
Definition: primnodes.h:1239