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