PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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-2025, 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 "access/cmptype.h"
22#include "nodes/bitmapset.h"
23#include "nodes/pg_list.h"
24
25
26typedef enum OverridingKind
27{
32
33
34/* ----------------------------------------------------------------
35 * node definitions
36 * ----------------------------------------------------------------
37 */
38
39/*
40 * Alias -
41 * specifies an alias for a range variable; the alias might also
42 * specify renaming of columns within the table.
43 *
44 * Note: colnames is a list of String nodes. In Alias structs
45 * associated with RTEs, there may be entries corresponding to dropped
46 * columns; these are normally empty strings (""). See parsenodes.h for info.
47 */
48typedef struct Alias
49{
51 char *aliasname; /* aliased rel name (never qualified) */
52 List *colnames; /* optional list of column aliases */
54
55/* What to do at commit time for temporary relations */
56typedef enum OnCommitAction
57{
58 ONCOMMIT_NOOP, /* No ON COMMIT clause (do nothing) */
59 ONCOMMIT_PRESERVE_ROWS, /* ON COMMIT PRESERVE ROWS (do nothing) */
60 ONCOMMIT_DELETE_ROWS, /* ON COMMIT DELETE ROWS */
61 ONCOMMIT_DROP, /* ON COMMIT DROP */
63
64/*
65 * RangeVar - range variable, used in FROM clauses
66 *
67 * Also used to represent table names in utility statements; there, the alias
68 * field is not used, and inh tells whether to apply the operation
69 * recursively to child tables. In some contexts it is also useful to carry
70 * a TEMP table indication here.
71 */
72typedef struct RangeVar
73{
75
76 /* the catalog (database) name, or NULL */
78
79 /* the schema name, or NULL */
81
82 /* the relation/sequence name */
83 char *relname;
84
85 /* expand rel by inheritance? recursively act on children? */
86 bool inh;
87
88 /* see RELPERSISTENCE_* in pg_class.h */
90
91 /* table alias & optional column aliases */
93
94 /* token location, or -1 if unknown */
97
98typedef enum TableFuncType
99{
103
104/*
105 * TableFunc - node for a table function, such as XMLTABLE and JSON_TABLE.
106 *
107 * Entries in the ns_names list are either String nodes containing
108 * literal namespace names, or NULL pointers to represent DEFAULT.
109 */
110typedef struct TableFunc
111{
113 /* XMLTABLE or JSON_TABLE */
115 /* list of namespace URI expressions */
116 List *ns_uris pg_node_attr(query_jumble_ignore);
117 /* list of namespace names or NULL */
118 List *ns_names pg_node_attr(query_jumble_ignore);
119 /* input document expression */
121 /* row filter expression */
123 /* column names (list of String) */
124 List *colnames pg_node_attr(query_jumble_ignore);
125 /* OID list of column type OIDs */
126 List *coltypes pg_node_attr(query_jumble_ignore);
127 /* integer list of column typmods */
128 List *coltypmods pg_node_attr(query_jumble_ignore);
129 /* OID list of column collation OIDs */
130 List *colcollations pg_node_attr(query_jumble_ignore);
131 /* list of column filter expressions */
133 /* list of column default expressions */
134 List *coldefexprs pg_node_attr(query_jumble_ignore);
135 /* JSON_TABLE: list of column value expressions */
136 List *colvalexprs pg_node_attr(query_jumble_ignore);
137 /* JSON_TABLE: list of PASSING argument expressions */
138 List *passingvalexprs pg_node_attr(query_jumble_ignore);
139 /* nullability flag for each output column */
140 Bitmapset *notnulls pg_node_attr(query_jumble_ignore);
141 /* JSON_TABLE plan */
142 Node *plan pg_node_attr(query_jumble_ignore);
143 /* counts from 0; -1 if none specified */
144 int ordinalitycol pg_node_attr(query_jumble_ignore);
145 /* token location, or -1 if unknown */
148
149/*
150 * IntoClause - target information for SELECT INTO, CREATE TABLE AS, and
151 * CREATE MATERIALIZED VIEW
152 *
153 * For CREATE MATERIALIZED VIEW, viewQuery is the parsed-but-not-rewritten
154 * SELECT Query for the view; otherwise it's NULL. This is irrelevant in
155 * the query jumbling as CreateTableAsStmt already includes a reference to
156 * its own Query, so ignore it. (We declare it as struct Query* to avoid a
157 * forward reference.)
158 */
159typedef struct IntoClause
160{
162
163 RangeVar *rel; /* target relation name */
164 List *colNames; /* column names to assign, or NIL */
165 char *accessMethod; /* table access method */
166 List *options; /* options from WITH clause */
167 OnCommitAction onCommit; /* what do we do at COMMIT? */
168 char *tableSpaceName; /* table space to use, or NULL */
169 /* materialized view's SELECT query */
170 struct Query *viewQuery pg_node_attr(query_jumble_ignore);
171 bool skipData; /* true for WITH NO DATA */
173
174
175/* ----------------------------------------------------------------
176 * node types for executable expressions
177 * ----------------------------------------------------------------
178 */
179
180/*
181 * Expr - generic superclass for executable-expression nodes
182 *
183 * All node types that are used in executable expression trees should derive
184 * from Expr (that is, have Expr as their first field). Since Expr only
185 * contains NodeTag, this is a formality, but it is an easy form of
186 * documentation. See also the ExprState node types in execnodes.h.
187 */
188typedef struct Expr
189{
190 pg_node_attr(abstract)
191
194
195/*
196 * Var - expression node representing a variable (ie, a table column)
197 *
198 * In the parser and planner, varno and varattno identify the semantic
199 * referent, which is a base-relation column unless the reference is to a join
200 * USING column that isn't semantically equivalent to either join input column
201 * (because it is a FULL join or the input column requires a type coercion).
202 * In those cases varno and varattno refer to the JOIN RTE. (Early in the
203 * planner, we replace such join references by the implied expression; but up
204 * till then we want join reference Vars to keep their original identity for
205 * query-printing purposes.)
206 *
207 * At the end of planning, Var nodes appearing in upper-level plan nodes are
208 * reassigned to point to the outputs of their subplans; for example, in a
209 * join node varno becomes INNER_VAR or OUTER_VAR and varattno becomes the
210 * index of the proper element of that subplan's target list. Similarly,
211 * INDEX_VAR is used to identify Vars that reference an index column rather
212 * than a heap column. (In ForeignScan and CustomScan plan nodes, INDEX_VAR
213 * is abused to signify references to columns of a custom scan tuple type.)
214 *
215 * ROWID_VAR is used in the planner to identify nonce variables that carry
216 * row identity information during UPDATE/DELETE/MERGE. This value should
217 * never be seen outside the planner.
218 *
219 * varnullingrels is the set of RT indexes of outer joins that can force
220 * the Var's value to null (at the point where it appears in the query).
221 * See optimizer/README for discussion of that.
222 *
223 * varlevelsup is greater than zero in Vars that represent outer references.
224 * Note that it affects the meaning of all of varno, varnullingrels, and
225 * varnosyn, all of which refer to the range table of that query level.
226 *
227 * varreturningtype is used for Vars that refer to the target relation in the
228 * RETURNING list of data-modifying queries. The default behavior is to
229 * return old values for DELETE and new values for INSERT and UPDATE, but it
230 * is also possible to explicitly request old or new values.
231 *
232 * In the parser, varnosyn and varattnosyn are either identical to
233 * varno/varattno, or they specify the column's position in an aliased JOIN
234 * RTE that hides the semantic referent RTE's refname. This is a syntactic
235 * identifier as opposed to the semantic identifier; it tells ruleutils.c
236 * how to print the Var properly. varnosyn/varattnosyn retain their values
237 * throughout planning and execution, so they are particularly helpful to
238 * identify Vars when debugging. Note, however, that a Var that is generated
239 * in the planner and doesn't correspond to any simple relation column may
240 * have varnosyn = varattnosyn = 0.
241 */
242#define INNER_VAR (-1) /* reference to inner subplan */
243#define OUTER_VAR (-2) /* reference to outer subplan */
244#define INDEX_VAR (-3) /* reference to index column */
245#define ROWID_VAR (-4) /* row identity column during planning */
246
247#define IS_SPECIAL_VARNO(varno) ((int) (varno) < 0)
248
249/* Symbols for the indexes of the special RTE entries in rules */
250#define PRS2_OLD_VARNO 1
251#define PRS2_NEW_VARNO 2
252
253/* Returning behavior for Vars in RETURNING list */
255{
256 VAR_RETURNING_DEFAULT, /* return OLD for DELETE, else return NEW */
257 VAR_RETURNING_OLD, /* return OLD for DELETE/UPDATE, else NULL */
258 VAR_RETURNING_NEW, /* return NEW for INSERT/UPDATE, else NULL */
260
261typedef struct Var
262{
264
265 /*
266 * index of this var's relation in the range table, or
267 * INNER_VAR/OUTER_VAR/etc
268 */
269 int varno;
270
271 /*
272 * attribute number of this var, or zero for all attrs ("whole-row Var")
273 */
275
276 /* pg_type OID for the type of this var */
277 Oid vartype pg_node_attr(query_jumble_ignore);
278 /* pg_attribute typmod value */
279 int32 vartypmod pg_node_attr(query_jumble_ignore);
280 /* OID of collation, or InvalidOid if none */
281 Oid varcollid pg_node_attr(query_jumble_ignore);
282
283 /*
284 * RT indexes of outer joins that can replace the Var's value with null.
285 * We can omit varnullingrels in the query jumble, because it's fully
286 * determined by varno/varlevelsup plus the Var's query location.
287 */
288 Bitmapset *varnullingrels pg_node_attr(query_jumble_ignore);
289
290 /*
291 * for subquery variables referencing outer relations; 0 in a normal var,
292 * >0 means N levels up
293 */
295
296 /* returning type of this var (see above) */
298
299 /*
300 * varnosyn/varattnosyn are ignored for equality, because Vars with
301 * different syntactic identifiers are semantically the same as long as
302 * their varno/varattno match.
303 */
304 /* syntactic relation index (0 if unknown) */
305 Index varnosyn pg_node_attr(equal_ignore, query_jumble_ignore);
306 /* syntactic attribute number */
307 AttrNumber varattnosyn pg_node_attr(equal_ignore, query_jumble_ignore);
308
309 /* token location, or -1 if unknown */
312
313/*
314 * Const
315 *
316 * Note: for varlena data types, we make a rule that a Const node's value
317 * must be in non-extended form (4-byte header, no compression or external
318 * references). This ensures that the Const node is self-contained and makes
319 * it more likely that equal() will see logically identical values as equal.
320 *
321 * Only the constant type OID is relevant for the query jumbling.
322 */
323typedef struct Const
324{
325 pg_node_attr(custom_copy_equal, custom_read_write)
326
327 Expr xpr;
328 /* pg_type OID of the constant's datatype */
330 /* typmod value, if any */
331 int32 consttypmod pg_node_attr(query_jumble_ignore);
332 /* OID of collation, or InvalidOid if none */
333 Oid constcollid pg_node_attr(query_jumble_ignore);
334 /* typlen of the constant's datatype */
335 int constlen pg_node_attr(query_jumble_ignore);
336 /* the constant's value */
337 Datum constvalue pg_node_attr(query_jumble_ignore);
338 /* whether the constant is null (if true, constvalue is undefined) */
339 bool constisnull pg_node_attr(query_jumble_ignore);
340
341 /*
342 * Whether this datatype is passed by value. If true, then all the
343 * information is stored in the Datum. If false, then the Datum contains
344 * a pointer to the information.
345 */
346 bool constbyval pg_node_attr(query_jumble_ignore);
347
348 /*
349 * token location, or -1 if unknown. All constants are tracked as
350 * locations in query jumbling, to be marked as parameters.
351 */
352 ParseLoc location pg_node_attr(query_jumble_location);
354
355/*
356 * Param
357 *
358 * paramkind specifies the kind of parameter. The possible values
359 * for this field are:
360 *
361 * PARAM_EXTERN: The parameter value is supplied from outside the plan.
362 * Such parameters are numbered from 1 to n.
363 *
364 * PARAM_EXEC: The parameter is an internal executor parameter, used
365 * for passing values into and out of sub-queries or from
366 * nestloop joins to their inner scans.
367 * For historical reasons, such parameters are numbered from 0.
368 * These numbers are independent of PARAM_EXTERN numbers.
369 *
370 * PARAM_SUBLINK: The parameter represents an output column of a SubLink
371 * node's sub-select. The column number is contained in the
372 * `paramid' field. (This type of Param is converted to
373 * PARAM_EXEC during planning.)
374 *
375 * PARAM_MULTIEXPR: Like PARAM_SUBLINK, the parameter represents an
376 * output column of a SubLink node's sub-select, but here, the
377 * SubLink is always a MULTIEXPR SubLink. The high-order 16 bits
378 * of the `paramid' field contain the SubLink's subLinkId, and
379 * the low-order 16 bits contain the column number. (This type
380 * of Param is also converted to PARAM_EXEC during planning.)
381 */
382typedef enum ParamKind
383{
389
390typedef struct Param
391{
393 ParamKind paramkind; /* kind of parameter. See above */
394 int paramid; /* numeric ID for parameter */
395 Oid paramtype; /* pg_type OID of parameter's datatype */
396 /* typmod value, if known */
397 int32 paramtypmod pg_node_attr(query_jumble_ignore);
398 /* OID of collation, or InvalidOid if none */
399 Oid paramcollid pg_node_attr(query_jumble_ignore);
400 /* token location, or -1 if unknown */
403
404/*
405 * Aggref
406 *
407 * The aggregate's args list is a targetlist, ie, a list of TargetEntry nodes.
408 *
409 * For a normal (non-ordered-set) aggregate, the non-resjunk TargetEntries
410 * represent the aggregate's regular arguments (if any) and resjunk TLEs can
411 * be added at the end to represent ORDER BY expressions that are not also
412 * arguments. As in a top-level Query, the TLEs can be marked with
413 * ressortgroupref indexes to let them be referenced by SortGroupClause
414 * entries in the aggorder and/or aggdistinct lists. This represents ORDER BY
415 * and DISTINCT operations to be applied to the aggregate input rows before
416 * they are passed to the transition function. The grammar only allows a
417 * simple "DISTINCT" specifier for the arguments, but we use the full
418 * query-level representation to allow more code sharing.
419 *
420 * For an ordered-set aggregate, the args list represents the WITHIN GROUP
421 * (aggregated) arguments, all of which will be listed in the aggorder list.
422 * DISTINCT is not supported in this case, so aggdistinct will be NIL.
423 * The direct arguments appear in aggdirectargs (as a list of plain
424 * expressions, not TargetEntry nodes).
425 *
426 * aggtranstype is the data type of the state transition values for this
427 * aggregate (resolved to an actual type, if agg's transtype is polymorphic).
428 * This is determined during planning and is InvalidOid before that.
429 *
430 * aggargtypes is an OID list of the data types of the direct and regular
431 * arguments. Normally it's redundant with the aggdirectargs and args lists,
432 * but in a combining aggregate, it's not because the args list has been
433 * replaced with a single argument representing the partial-aggregate
434 * transition values.
435 *
436 * aggpresorted is set by the query planner for ORDER BY and DISTINCT
437 * aggregates where the chosen plan provides presorted input for this
438 * aggregate during execution.
439 *
440 * aggsplit indicates the expected partial-aggregation mode for the Aggref's
441 * parent plan node. It's always set to AGGSPLIT_SIMPLE in the parser, but
442 * the planner might change it to something else. We use this mainly as
443 * a crosscheck that the Aggrefs match the plan; but note that when aggsplit
444 * indicates a non-final mode, aggtype reflects the transition data type
445 * not the SQL-level output type of the aggregate.
446 *
447 * aggno and aggtransno are -1 in the parse stage, and are set in planning.
448 * Aggregates with the same 'aggno' represent the same aggregate expression,
449 * and can share the result. Aggregates with same 'transno' but different
450 * 'aggno' can share the same transition state, only the final function needs
451 * to be called separately.
452 *
453 * Information related to collations, transition types and internal states
454 * are irrelevant for the query jumbling.
455 */
456typedef struct Aggref
457{
459
460 /* pg_proc Oid of the aggregate */
462
463 /* type Oid of result of the aggregate */
464 Oid aggtype pg_node_attr(query_jumble_ignore);
465
466 /* OID of collation of result */
467 Oid aggcollid pg_node_attr(query_jumble_ignore);
468
469 /* OID of collation that function should use */
470 Oid inputcollid pg_node_attr(query_jumble_ignore);
471
472 /*
473 * type Oid of aggregate's transition value; ignored for equal since it
474 * might not be set yet
475 */
476 Oid aggtranstype pg_node_attr(equal_ignore, query_jumble_ignore);
477
478 /* type Oids of direct and aggregated args */
479 List *aggargtypes pg_node_attr(query_jumble_ignore);
480
481 /* direct arguments, if an ordered-set agg */
483
484 /* aggregated arguments and sort expressions */
486
487 /* ORDER BY (list of SortGroupClause) */
489
490 /* DISTINCT (list of SortGroupClause) */
492
493 /* FILTER expression, if any */
495
496 /* true if argument list was really '*' */
497 bool aggstar pg_node_attr(query_jumble_ignore);
498
499 /*
500 * true if variadic arguments have been combined into an array last
501 * argument
502 */
503 bool aggvariadic pg_node_attr(query_jumble_ignore);
504
505 /* aggregate kind (see pg_aggregate.h) */
506 char aggkind pg_node_attr(query_jumble_ignore);
507
508 /* aggregate input already sorted */
509 bool aggpresorted pg_node_attr(equal_ignore, query_jumble_ignore);
510
511 /* > 0 if agg belongs to outer query */
512 Index agglevelsup pg_node_attr(query_jumble_ignore);
513
514 /* expected agg-splitting mode of parent Agg */
515 AggSplit aggsplit pg_node_attr(query_jumble_ignore);
516
517 /* unique ID within the Agg node */
518 int aggno pg_node_attr(query_jumble_ignore);
519
520 /* unique ID of transition state in the Agg */
521 int aggtransno pg_node_attr(query_jumble_ignore);
522
523 /* token location, or -1 if unknown */
526
527/*
528 * GroupingFunc
529 *
530 * A GroupingFunc is a GROUPING(...) expression, which behaves in many ways
531 * like an aggregate function (e.g. it "belongs" to a specific query level,
532 * which might not be the one immediately containing it), but also differs in
533 * an important respect: it never evaluates its arguments, they merely
534 * designate expressions from the GROUP BY clause of the query level to which
535 * it belongs.
536 *
537 * The spec defines the evaluation of GROUPING() purely by syntactic
538 * replacement, but we make it a real expression for optimization purposes so
539 * that one Agg node can handle multiple grouping sets at once. Evaluating the
540 * result only needs the column positions to check against the grouping set
541 * being projected. However, for EXPLAIN to produce meaningful output, we have
542 * to keep the original expressions around, since expression deparse does not
543 * give us any feasible way to get at the GROUP BY clause.
544 *
545 * Also, we treat two GroupingFunc nodes as equal if they have equal arguments
546 * lists and agglevelsup, without comparing the refs and cols annotations.
547 *
548 * In raw parse output we have only the args list; parse analysis fills in the
549 * refs list, and the planner fills in the cols list.
550 *
551 * All the fields used as information for an internal state are irrelevant
552 * for the query jumbling.
553 */
554typedef struct GroupingFunc
555{
557
558 /* arguments, not evaluated but kept for benefit of EXPLAIN etc. */
559 List *args pg_node_attr(query_jumble_ignore);
560
561 /* ressortgrouprefs of arguments */
562 List *refs pg_node_attr(equal_ignore);
563
564 /* actual column positions set by planner */
565 List *cols pg_node_attr(equal_ignore, query_jumble_ignore);
566
567 /* same as Aggref.agglevelsup */
569
570 /* token location */
573
574/*
575 * WindowFunc
576 *
577 * Collation information is irrelevant for the query jumbling, as is the
578 * internal state information of the node like "winstar" and "winagg".
579 */
580typedef struct WindowFunc
581{
583 /* pg_proc Oid of the function */
585 /* type Oid of result of the window function */
586 Oid wintype pg_node_attr(query_jumble_ignore);
587 /* OID of collation of result */
588 Oid wincollid pg_node_attr(query_jumble_ignore);
589 /* OID of collation that function should use */
590 Oid inputcollid pg_node_attr(query_jumble_ignore);
591 /* arguments to the window function */
593 /* FILTER expression, if any */
595 /* List of WindowFuncRunConditions to help short-circuit execution */
596 List *runCondition pg_node_attr(query_jumble_ignore);
597 /* index of associated WindowClause */
599 /* true if argument list was really '*' */
600 bool winstar pg_node_attr(query_jumble_ignore);
601 /* is function a simple aggregate? */
602 bool winagg pg_node_attr(query_jumble_ignore);
603 /* token location, or -1 if unknown */
606
607/*
608 * WindowFuncRunCondition
609 *
610 * Represents intermediate OpExprs which will be used by WindowAgg to
611 * short-circuit execution.
612 */
614{
616
617 /* PG_OPERATOR OID of the operator */
619 /* OID of collation that operator should use */
620 Oid inputcollid pg_node_attr(query_jumble_ignore);
621
622 /*
623 * true of WindowFunc belongs on the left of the resulting OpExpr or false
624 * if the WindowFunc is on the right.
625 */
627
628 /*
629 * The Expr being compared to the WindowFunc to use in the OpExpr in the
630 * WindowAgg's runCondition
631 */
634
635/*
636 * MergeSupportFunc
637 *
638 * A MergeSupportFunc is a merge support function expression that can only
639 * appear in the RETURNING list of a MERGE command. It returns information
640 * about the currently executing merge action.
641 *
642 * Currently, the only supported function is MERGE_ACTION(), which returns the
643 * command executed ("INSERT", "UPDATE", or "DELETE").
644 */
645typedef struct MergeSupportFunc
646{
648 /* type Oid of result */
650 /* OID of collation, or InvalidOid if none */
652 /* token location, or -1 if unknown */
655
656/*
657 * SubscriptingRef: describes a subscripting operation over a container
658 * (array, etc).
659 *
660 * A SubscriptingRef can describe fetching a single element from a container,
661 * fetching a part of a container (e.g. an array slice), storing a single
662 * element into a container, or storing a slice. The "store" cases work with
663 * an initial container value and a source value that is inserted into the
664 * appropriate part of the container; the result of the operation is an
665 * entire new modified container value.
666 *
667 * If reflowerindexpr = NIL, then we are fetching or storing a single container
668 * element at the subscripts given by refupperindexpr. Otherwise we are
669 * fetching or storing a container slice, that is a rectangular subcontainer
670 * with lower and upper bounds given by the index expressions.
671 * reflowerindexpr must be the same length as refupperindexpr when it
672 * is not NIL.
673 *
674 * In the slice case, individual expressions in the subscript lists can be
675 * NULL, meaning "substitute the array's current lower or upper bound".
676 * (Non-array containers may or may not support this.)
677 *
678 * refcontainertype is the actual container type that determines the
679 * subscripting semantics. (This will generally be either the exposed type of
680 * refexpr, or the base type if that is a domain.) refelemtype is the type of
681 * the container's elements; this is saved for the use of the subscripting
682 * functions, but is not used by the core code. refrestype, reftypmod, and
683 * refcollid describe the type of the SubscriptingRef's result. In a store
684 * expression, refrestype will always match refcontainertype; in a fetch,
685 * it could be refelemtype for an element fetch, or refcontainertype for a
686 * slice fetch, or possibly something else as determined by type-specific
687 * subscripting logic. Likewise, reftypmod and refcollid will match the
688 * container's properties in a store, but could be different in a fetch.
689 *
690 * Any internal state data is ignored for the query jumbling.
691 *
692 * Note: for the cases where a container is returned, if refexpr yields a R/W
693 * expanded container, then the implementation is allowed to modify that
694 * object in-place and return the same object.
695 */
696typedef struct SubscriptingRef
697{
699 /* type of the container proper */
700 Oid refcontainertype pg_node_attr(query_jumble_ignore);
701 /* the container type's pg_type.typelem */
702 Oid refelemtype pg_node_attr(query_jumble_ignore);
703 /* type of the SubscriptingRef's result */
704 Oid refrestype pg_node_attr(query_jumble_ignore);
705 /* typmod of the result */
706 int32 reftypmod pg_node_attr(query_jumble_ignore);
707 /* collation of result, or InvalidOid if none */
708 Oid refcollid pg_node_attr(query_jumble_ignore);
709 /* expressions that evaluate to upper container indexes */
711
712 /*
713 * expressions that evaluate to lower container indexes, or NIL for single
714 * container element.
715 */
717 /* the expression that evaluates to a container value */
719 /* expression for the source value, or NULL if fetch */
722
723/*
724 * CoercionContext - distinguishes the allowed set of type casts
725 *
726 * NB: ordering of the alternatives is significant; later (larger) values
727 * allow more casts than earlier ones.
728 */
729typedef enum CoercionContext
730{
731 COERCION_IMPLICIT, /* coercion in context of expression */
732 COERCION_ASSIGNMENT, /* coercion in context of assignment */
733 COERCION_PLPGSQL, /* if no assignment cast, use CoerceViaIO */
734 COERCION_EXPLICIT, /* explicit cast operation */
736
737/*
738 * CoercionForm - how to display a FuncExpr or related node
739 *
740 * "Coercion" is a bit of a misnomer, since this value records other
741 * special syntaxes besides casts, but for now we'll keep this naming.
742 *
743 * NB: equal() ignores CoercionForm fields, therefore this *must* not carry
744 * any semantically significant information. We need that behavior so that
745 * the planner will consider equivalent implicit and explicit casts to be
746 * equivalent. In cases where those actually behave differently, the coercion
747 * function's arguments will be different.
748 */
749typedef enum CoercionForm
750{
751 COERCE_EXPLICIT_CALL, /* display as a function call */
752 COERCE_EXPLICIT_CAST, /* display as an explicit cast */
753 COERCE_IMPLICIT_CAST, /* implicit cast, so hide it */
754 COERCE_SQL_SYNTAX, /* display with SQL-mandated special syntax */
756
757/*
758 * FuncExpr - expression node for a function call
759 *
760 * Collation information is irrelevant for the query jumbling, only the
761 * arguments and the function OID matter.
762 */
763typedef struct FuncExpr
764{
766 /* PG_PROC OID of the function */
768 /* PG_TYPE OID of result value */
769 Oid funcresulttype pg_node_attr(query_jumble_ignore);
770 /* true if function returns set */
771 bool funcretset pg_node_attr(query_jumble_ignore);
772
773 /*
774 * true if variadic arguments have been combined into an array last
775 * argument
776 */
777 bool funcvariadic pg_node_attr(query_jumble_ignore);
778 /* how to display this function call */
779 CoercionForm funcformat pg_node_attr(query_jumble_ignore);
780 /* OID of collation of result */
781 Oid funccollid pg_node_attr(query_jumble_ignore);
782 /* OID of collation that function should use */
783 Oid inputcollid pg_node_attr(query_jumble_ignore);
784 /* arguments to the function */
786 /* token location, or -1 if unknown */
789
790/*
791 * NamedArgExpr - a named argument of a function
792 *
793 * This node type can only appear in the args list of a FuncCall or FuncExpr
794 * node. We support pure positional call notation (no named arguments),
795 * named notation (all arguments are named), and mixed notation (unnamed
796 * arguments followed by named ones).
797 *
798 * Parse analysis sets argnumber to the positional index of the argument,
799 * but doesn't rearrange the argument list.
800 *
801 * The planner will convert argument lists to pure positional notation
802 * during expression preprocessing, so execution never sees a NamedArgExpr.
803 */
804typedef struct NamedArgExpr
805{
807 /* the argument expression */
809 /* the name */
810 char *name pg_node_attr(query_jumble_ignore);
811 /* argument's number in positional notation */
813 /* argument name location, or -1 if unknown */
816
817/*
818 * OpExpr - expression node for an operator invocation
819 *
820 * Semantically, this is essentially the same as a function call.
821 *
822 * Note that opfuncid is not necessarily filled in immediately on creation
823 * of the node. The planner makes sure it is valid before passing the node
824 * tree to the executor, but during parsing/planning opfuncid can be 0.
825 * Therefore, equal() will accept a zero value as being equal to other values.
826 *
827 * Internal state information and collation data is irrelevant for the query
828 * jumbling.
829 */
830typedef struct OpExpr
831{
833
834 /* PG_OPERATOR OID of the operator */
836
837 /* PG_PROC OID of underlying function */
838 Oid opfuncid pg_node_attr(equal_ignore_if_zero, query_jumble_ignore);
839
840 /* PG_TYPE OID of result value */
841 Oid opresulttype pg_node_attr(query_jumble_ignore);
842
843 /* true if operator returns set */
844 bool opretset pg_node_attr(query_jumble_ignore);
845
846 /* OID of collation of result */
847 Oid opcollid pg_node_attr(query_jumble_ignore);
848
849 /* OID of collation that operator should use */
850 Oid inputcollid pg_node_attr(query_jumble_ignore);
851
852 /* arguments to the operator (1 or 2) */
854
855 /* token location, or -1 if unknown */
858
859/*
860 * DistinctExpr - expression node for "x IS DISTINCT FROM y"
861 *
862 * Except for the nodetag, this is represented identically to an OpExpr
863 * referencing the "=" operator for x and y.
864 * We use "=", not the more obvious "<>", because more datatypes have "="
865 * than "<>". This means the executor must invert the operator result.
866 * Note that the operator function won't be called at all if either input
867 * is NULL, since then the result can be determined directly.
868 */
870
871/*
872 * NullIfExpr - a NULLIF expression
873 *
874 * Like DistinctExpr, this is represented the same as an OpExpr referencing
875 * the "=" operator for x and y.
876 */
878
879/*
880 * ScalarArrayOpExpr - expression node for "scalar op ANY/ALL (array)"
881 *
882 * The operator must yield boolean. It is applied to the left operand
883 * and each element of the righthand array, and the results are combined
884 * with OR or AND (for ANY or ALL respectively). The node representation
885 * is almost the same as for the underlying operator, but we need a useOr
886 * flag to remember whether it's ANY or ALL, and we don't have to store
887 * the result type (or the collation) because it must be boolean.
888 *
889 * A ScalarArrayOpExpr with a valid hashfuncid is evaluated during execution
890 * by building a hash table containing the Const values from the RHS arg.
891 * This table is probed during expression evaluation. The planner will set
892 * hashfuncid to the hash function which must be used to build and probe the
893 * hash table. The executor determines if it should use hash-based checks or
894 * the more traditional means based on if the hashfuncid is set or not.
895 *
896 * When performing hashed NOT IN, the negfuncid will also be set to the
897 * equality function which the hash table must use to build and probe the hash
898 * table. opno and opfuncid will remain set to the <> operator and its
899 * corresponding function and won't be used during execution. For
900 * non-hashtable based NOT INs, negfuncid will be set to InvalidOid. See
901 * convert_saop_to_hashed_saop().
902 *
903 * Similar to OpExpr, opfuncid, hashfuncid, and negfuncid are not necessarily
904 * filled in right away, so will be ignored for equality if they are not set
905 * yet.
906 *
907 * OID entries of the internal function types are irrelevant for the query
908 * jumbling, but the operator OID and the arguments are.
909 */
910typedef struct ScalarArrayOpExpr
911{
913
914 /* PG_OPERATOR OID of the operator */
916
917 /* PG_PROC OID of comparison function */
918 Oid opfuncid pg_node_attr(equal_ignore_if_zero, query_jumble_ignore);
919
920 /* PG_PROC OID of hash func or InvalidOid */
921 Oid hashfuncid pg_node_attr(equal_ignore_if_zero, query_jumble_ignore);
922
923 /* PG_PROC OID of negator of opfuncid function or InvalidOid. See above */
924 Oid negfuncid pg_node_attr(equal_ignore_if_zero, query_jumble_ignore);
925
926 /* true for ANY, false for ALL */
927 bool useOr;
928
929 /* OID of collation that operator should use */
930 Oid inputcollid pg_node_attr(query_jumble_ignore);
931
932 /* the scalar and array operands */
934
935 /* token location, or -1 if unknown */
938
939/*
940 * BoolExpr - expression node for the basic Boolean operators AND, OR, NOT
941 *
942 * Notice the arguments are given as a List. For NOT, of course the list
943 * must always have exactly one element. For AND and OR, there can be two
944 * or more arguments.
945 */
946typedef enum BoolExprType
947{
950
951typedef struct BoolExpr
952{
953 pg_node_attr(custom_read_write)
954
955 Expr xpr;
957 List *args; /* arguments to this expression */
958 ParseLoc location; /* token location, or -1 if unknown */
960
961/*
962 * SubLink
963 *
964 * A SubLink represents a subselect appearing in an expression, and in some
965 * cases also the combining operator(s) just above it. The subLinkType
966 * indicates the form of the expression represented:
967 * EXISTS_SUBLINK EXISTS(SELECT ...)
968 * ALL_SUBLINK (lefthand) op ALL (SELECT ...)
969 * ANY_SUBLINK (lefthand) op ANY (SELECT ...)
970 * ROWCOMPARE_SUBLINK (lefthand) op (SELECT ...)
971 * EXPR_SUBLINK (SELECT with single targetlist item ...)
972 * MULTIEXPR_SUBLINK (SELECT with multiple targetlist items ...)
973 * ARRAY_SUBLINK ARRAY(SELECT with single targetlist item ...)
974 * CTE_SUBLINK WITH query (never actually part of an expression)
975 * For ALL, ANY, and ROWCOMPARE, the lefthand is a list of expressions of the
976 * same length as the subselect's targetlist. ROWCOMPARE will *always* have
977 * a list with more than one entry; if the subselect has just one target
978 * then the parser will create an EXPR_SUBLINK instead (and any operator
979 * above the subselect will be represented separately).
980 * ROWCOMPARE, EXPR, and MULTIEXPR require the subselect to deliver at most
981 * one row (if it returns no rows, the result is NULL).
982 * ALL, ANY, and ROWCOMPARE require the combining operators to deliver boolean
983 * results. ALL and ANY combine the per-row results using AND and OR
984 * semantics respectively.
985 * ARRAY requires just one target column, and creates an array of the target
986 * column's type using any number of rows resulting from the subselect.
987 *
988 * SubLink is classed as an Expr node, but it is not actually executable;
989 * it must be replaced in the expression tree by a SubPlan node during
990 * planning.
991 *
992 * NOTE: in the raw output of gram.y, testexpr contains just the raw form
993 * of the lefthand expression (if any), and operName is the String name of
994 * the combining operator. Also, subselect is a raw parsetree. During parse
995 * analysis, the parser transforms testexpr into a complete boolean expression
996 * that compares the lefthand value(s) to PARAM_SUBLINK nodes representing the
997 * output columns of the subselect. And subselect is transformed to a Query.
998 * This is the representation seen in saved rules and in the rewriter.
999 *
1000 * In EXISTS, EXPR, MULTIEXPR, and ARRAY SubLinks, testexpr and operName
1001 * are unused and are always null.
1002 *
1003 * subLinkId is currently used only for MULTIEXPR SubLinks, and is zero in
1004 * other SubLinks. This number identifies different multiple-assignment
1005 * subqueries within an UPDATE statement's SET list. It is unique only
1006 * within a particular targetlist. The output column(s) of the MULTIEXPR
1007 * are referenced by PARAM_MULTIEXPR Params appearing elsewhere in the tlist.
1008 *
1009 * The CTE_SUBLINK case never occurs in actual SubLink nodes, but it is used
1010 * in SubPlans generated for WITH subqueries.
1011 */
1012typedef enum SubLinkType
1013{
1021 CTE_SUBLINK, /* for SubPlans only */
1023
1024
1025typedef struct SubLink
1026{
1028 SubLinkType subLinkType; /* see above */
1029 int subLinkId; /* ID (1..n); 0 if not MULTIEXPR */
1030 Node *testexpr; /* outer-query test for ALL/ANY/ROWCOMPARE */
1031 /* originally specified operator name */
1032 List *operName pg_node_attr(query_jumble_ignore);
1033 /* subselect as Query* or raw parsetree */
1035 ParseLoc location; /* token location, or -1 if unknown */
1037
1038/*
1039 * SubPlan - executable expression node for a subplan (sub-SELECT)
1040 *
1041 * The planner replaces SubLink nodes in expression trees with SubPlan
1042 * nodes after it has finished planning the subquery. SubPlan references
1043 * a sub-plantree stored in the subplans list of the toplevel PlannedStmt.
1044 * (We avoid a direct link to make it easier to copy expression trees
1045 * without causing multiple processing of the subplan.)
1046 *
1047 * In an ordinary subplan, testexpr points to an executable expression
1048 * (OpExpr, an AND/OR tree of OpExprs, or RowCompareExpr) for the combining
1049 * operator(s); the left-hand arguments are the original lefthand expressions,
1050 * and the right-hand arguments are PARAM_EXEC Param nodes representing the
1051 * outputs of the sub-select. (NOTE: runtime coercion functions may be
1052 * inserted as well.) This is just the same expression tree as testexpr in
1053 * the original SubLink node, but the PARAM_SUBLINK nodes are replaced by
1054 * suitably numbered PARAM_EXEC nodes.
1055 *
1056 * If the sub-select becomes an initplan rather than a subplan, the executable
1057 * expression is part of the outer plan's expression tree (and the SubPlan
1058 * node itself is not, but rather is found in the outer plan's initPlan
1059 * list). In this case testexpr is NULL to avoid duplication.
1060 *
1061 * The planner also derives lists of the values that need to be passed into
1062 * and out of the subplan. Input values are represented as a list "args" of
1063 * expressions to be evaluated in the outer-query context (currently these
1064 * args are always just Vars, but in principle they could be any expression).
1065 * The values are assigned to the global PARAM_EXEC params indexed by parParam
1066 * (the parParam and args lists must have the same ordering). setParam is a
1067 * list of the PARAM_EXEC params that are computed by the sub-select, if it
1068 * is an initplan or MULTIEXPR plan; they are listed in order by sub-select
1069 * output column position. (parParam and setParam are integer Lists, not
1070 * Bitmapsets, because their ordering is significant.)
1071 *
1072 * Also, the planner computes startup and per-call costs for use of the
1073 * SubPlan. Note that these include the cost of the subquery proper,
1074 * evaluation of the testexpr if any, and any hashtable management overhead.
1075 */
1076typedef struct SubPlan
1077{
1078 pg_node_attr(no_query_jumble)
1079
1080 Expr xpr;
1081 /* Fields copied from original SubLink: */
1082 SubLinkType subLinkType; /* see above */
1083 /* The combining operators, transformed to an executable expression: */
1084 Node *testexpr; /* OpExpr or RowCompareExpr expression tree */
1085 List *paramIds; /* IDs of Params embedded in the above */
1086 /* Identification of the Plan tree to use: */
1087 int plan_id; /* Index (from 1) in PlannedStmt.subplans */
1088 /* Identification of the SubPlan for EXPLAIN and debugging purposes: */
1089 char *plan_name; /* A name assigned during planning */
1090 /* Extra data useful for determining subplan's output type: */
1091 Oid firstColType; /* Type of first column of subplan result */
1092 int32 firstColTypmod; /* Typmod of first column of subplan result */
1093 Oid firstColCollation; /* Collation of first column of subplan
1094 * result */
1095 /* Information about execution strategy: */
1096 bool useHashTable; /* true to store subselect output in a hash
1097 * table (implies we are doing "IN") */
1098 bool unknownEqFalse; /* true if it's okay to return FALSE when the
1099 * spec result is UNKNOWN; this allows much
1100 * simpler handling of null values */
1101 bool parallel_safe; /* is the subplan parallel-safe? */
1102 /* Note: parallel_safe does not consider contents of testexpr or args */
1103 /* Information for passing params into and out of the subselect: */
1104 /* setParam and parParam are lists of integers (param IDs) */
1105 List *setParam; /* initplan and MULTIEXPR subqueries have to
1106 * set these Params for parent plan */
1107 List *parParam; /* indices of input Params from parent plan */
1108 List *args; /* exprs to pass as parParam values */
1109 /* Estimated execution costs: */
1110 Cost startup_cost; /* one-time setup cost */
1111 Cost per_call_cost; /* cost for each subplan evaluation */
1113
1114/*
1115 * AlternativeSubPlan - expression node for a choice among SubPlans
1116 *
1117 * This is used only transiently during planning: by the time the plan
1118 * reaches the executor, all AlternativeSubPlan nodes have been removed.
1119 *
1120 * The subplans are given as a List so that the node definition need not
1121 * change if there's ever more than two alternatives. For the moment,
1122 * though, there are always exactly two; and the first one is the fast-start
1123 * plan.
1124 */
1126{
1127 pg_node_attr(no_query_jumble)
1128
1129 Expr xpr;
1130 List *subplans; /* SubPlan(s) with equivalent results */
1132
1133/* ----------------
1134 * FieldSelect
1135 *
1136 * FieldSelect represents the operation of extracting one field from a tuple
1137 * value. At runtime, the input expression is expected to yield a rowtype
1138 * Datum. The specified field number is extracted and returned as a Datum.
1139 * ----------------
1140 */
1141
1142typedef struct FieldSelect
1143{
1145 Expr *arg; /* input expression */
1146 AttrNumber fieldnum; /* attribute number of field to extract */
1147 /* type of the field (result type of this node) */
1148 Oid resulttype pg_node_attr(query_jumble_ignore);
1149 /* output typmod (usually -1) */
1150 int32 resulttypmod pg_node_attr(query_jumble_ignore);
1151 /* OID of collation of the field */
1152 Oid resultcollid pg_node_attr(query_jumble_ignore);
1154
1155/* ----------------
1156 * FieldStore
1157 *
1158 * FieldStore represents the operation of modifying one field in a tuple
1159 * value, yielding a new tuple value (the input is not touched!). Like
1160 * the assign case of SubscriptingRef, this is used to implement UPDATE of a
1161 * portion of a column.
1162 *
1163 * resulttype is always a named composite type (not a domain). To update
1164 * a composite domain value, apply CoerceToDomain to the FieldStore.
1165 *
1166 * A single FieldStore can actually represent updates of several different
1167 * fields. The parser only generates FieldStores with single-element lists,
1168 * but the planner will collapse multiple updates of the same base column
1169 * into one FieldStore.
1170 * ----------------
1171 */
1172
1173typedef struct FieldStore
1174{
1176 Expr *arg; /* input tuple value */
1177 List *newvals; /* new value(s) for field(s) */
1178 /* integer list of field attnums */
1179 List *fieldnums pg_node_attr(query_jumble_ignore);
1180 /* type of result (same as type of arg) */
1181 Oid resulttype pg_node_attr(query_jumble_ignore);
1182 /* Like RowExpr, we deliberately omit a typmod and collation here */
1184
1185/* ----------------
1186 * RelabelType
1187 *
1188 * RelabelType represents a "dummy" type coercion between two binary-
1189 * compatible datatypes, such as reinterpreting the result of an OID
1190 * expression as an int4. It is a no-op at runtime; we only need it
1191 * to provide a place to store the correct type to be attributed to
1192 * the expression result during type resolution. (We can't get away
1193 * with just overwriting the type field of the input expression node,
1194 * so we need a separate node to show the coercion's result type.)
1195 * ----------------
1196 */
1197
1198typedef struct RelabelType
1199{
1201 Expr *arg; /* input expression */
1202 Oid resulttype; /* output type of coercion expression */
1203 /* output typmod (usually -1) */
1204 int32 resulttypmod pg_node_attr(query_jumble_ignore);
1205 /* OID of collation, or InvalidOid if none */
1206 Oid resultcollid pg_node_attr(query_jumble_ignore);
1207 /* how to display this node */
1208 CoercionForm relabelformat pg_node_attr(query_jumble_ignore);
1209 ParseLoc location; /* token location, or -1 if unknown */
1211
1212/* ----------------
1213 * CoerceViaIO
1214 *
1215 * CoerceViaIO represents a type coercion between two types whose textual
1216 * representations are compatible, implemented by invoking the source type's
1217 * typoutput function then the destination type's typinput function.
1218 * ----------------
1219 */
1220
1221typedef struct CoerceViaIO
1222{
1224 Expr *arg; /* input expression */
1225 Oid resulttype; /* output type of coercion */
1226 /* output typmod is not stored, but is presumed -1 */
1227 /* OID of collation, or InvalidOid if none */
1228 Oid resultcollid pg_node_attr(query_jumble_ignore);
1229 /* how to display this node */
1230 CoercionForm coerceformat pg_node_attr(query_jumble_ignore);
1231 ParseLoc location; /* token location, or -1 if unknown */
1233
1234/* ----------------
1235 * ArrayCoerceExpr
1236 *
1237 * ArrayCoerceExpr represents a type coercion from one array type to another,
1238 * which is implemented by applying the per-element coercion expression
1239 * "elemexpr" to each element of the source array. Within elemexpr, the
1240 * source element is represented by a CaseTestExpr node. Note that even if
1241 * elemexpr is a no-op (that is, just CaseTestExpr + RelabelType), the
1242 * coercion still requires some effort: we have to fix the element type OID
1243 * stored in the array header.
1244 * ----------------
1245 */
1246
1247typedef struct ArrayCoerceExpr
1248{
1250 Expr *arg; /* input expression (yields an array) */
1251 Expr *elemexpr; /* expression representing per-element work */
1252 Oid resulttype; /* output type of coercion (an array type) */
1253 /* output typmod (also element typmod) */
1254 int32 resulttypmod pg_node_attr(query_jumble_ignore);
1255 /* OID of collation, or InvalidOid if none */
1256 Oid resultcollid pg_node_attr(query_jumble_ignore);
1257 /* how to display this node */
1258 CoercionForm coerceformat pg_node_attr(query_jumble_ignore);
1259 ParseLoc location; /* token location, or -1 if unknown */
1261
1262/* ----------------
1263 * ConvertRowtypeExpr
1264 *
1265 * ConvertRowtypeExpr represents a type coercion from one composite type
1266 * to another, where the source type is guaranteed to contain all the columns
1267 * needed for the destination type plus possibly others; the columns need not
1268 * be in the same positions, but are matched up by name. This is primarily
1269 * used to convert a whole-row value of an inheritance child table into a
1270 * valid whole-row value of its parent table's rowtype. Both resulttype
1271 * and the exposed type of "arg" must be named composite types (not domains).
1272 * ----------------
1273 */
1274
1276{
1278 Expr *arg; /* input expression */
1279 Oid resulttype; /* output type (always a composite type) */
1280 /* Like RowExpr, we deliberately omit a typmod and collation here */
1281 /* how to display this node */
1282 CoercionForm convertformat pg_node_attr(query_jumble_ignore);
1283 ParseLoc location; /* token location, or -1 if unknown */
1285
1286/*----------
1287 * CollateExpr - COLLATE
1288 *
1289 * The planner replaces CollateExpr with RelabelType during expression
1290 * preprocessing, so execution never sees a CollateExpr.
1291 *----------
1292 */
1293typedef struct CollateExpr
1294{
1296 Expr *arg; /* input expression */
1297 Oid collOid; /* collation's OID */
1298 ParseLoc location; /* token location, or -1 if unknown */
1300
1301/*----------
1302 * CaseExpr - a CASE expression
1303 *
1304 * We support two distinct forms of CASE expression:
1305 * CASE WHEN boolexpr THEN expr [ WHEN boolexpr THEN expr ... ]
1306 * CASE testexpr WHEN compexpr THEN expr [ WHEN compexpr THEN expr ... ]
1307 * These are distinguishable by the "arg" field being NULL in the first case
1308 * and the testexpr in the second case.
1309 *
1310 * In the raw grammar output for the second form, the condition expressions
1311 * of the WHEN clauses are just the comparison values. Parse analysis
1312 * converts these to valid boolean expressions of the form
1313 * CaseTestExpr '=' compexpr
1314 * where the CaseTestExpr node is a placeholder that emits the correct
1315 * value at runtime. This structure is used so that the testexpr need be
1316 * evaluated only once. Note that after parse analysis, the condition
1317 * expressions always yield boolean.
1318 *
1319 * Note: we can test whether a CaseExpr has been through parse analysis
1320 * yet by checking whether casetype is InvalidOid or not.
1321 *----------
1322 */
1323typedef struct CaseExpr
1324{
1326 /* type of expression result */
1327 Oid casetype pg_node_attr(query_jumble_ignore);
1328 /* OID of collation, or InvalidOid if none */
1329 Oid casecollid pg_node_attr(query_jumble_ignore);
1330 Expr *arg; /* implicit equality comparison argument */
1331 List *args; /* the arguments (list of WHEN clauses) */
1332 Expr *defresult; /* the default result (ELSE clause) */
1333 ParseLoc location; /* token location, or -1 if unknown */
1335
1336/*
1337 * CaseWhen - one arm of a CASE expression
1338 */
1339typedef struct CaseWhen
1340{
1342 Expr *expr; /* condition expression */
1343 Expr *result; /* substitution result */
1344 ParseLoc location; /* token location, or -1 if unknown */
1346
1347/*
1348 * Placeholder node for the test value to be processed by a CASE expression.
1349 * This is effectively like a Param, but can be implemented more simply
1350 * since we need only one replacement value at a time.
1351 *
1352 * We also abuse this node type for some other purposes, including:
1353 * * Placeholder for the current array element value in ArrayCoerceExpr;
1354 * see build_coercion_expression().
1355 * * Nested FieldStore/SubscriptingRef assignment expressions in INSERT/UPDATE;
1356 * see transformAssignmentIndirection().
1357 * * Placeholder for intermediate results in some SQL/JSON expression nodes,
1358 * such as JsonConstructorExpr.
1359 *
1360 * The uses in CaseExpr and ArrayCoerceExpr are safe only to the extent that
1361 * there is not any other CaseExpr or ArrayCoerceExpr between the value source
1362 * node and its child CaseTestExpr(s). This is true in the parse analysis
1363 * output, but the planner's function-inlining logic has to be careful not to
1364 * break it.
1365 *
1366 * The nested-assignment-expression case is safe because the only node types
1367 * that can be above such CaseTestExprs are FieldStore and SubscriptingRef.
1368 */
1369typedef struct CaseTestExpr
1370{
1372 Oid typeId; /* type for substituted value */
1373 /* typemod for substituted value */
1374 int32 typeMod pg_node_attr(query_jumble_ignore);
1375 /* collation for the substituted value */
1376 Oid collation pg_node_attr(query_jumble_ignore);
1378
1379/*
1380 * ArrayExpr - an ARRAY[] expression
1381 *
1382 * Note: if multidims is false, the constituent expressions all yield the
1383 * scalar type identified by element_typeid. If multidims is true, the
1384 * constituent expressions all yield arrays of element_typeid (ie, the same
1385 * type as array_typeid); at runtime we must check for compatible subscripts.
1386 */
1387typedef struct ArrayExpr
1388{
1390 /* type of expression result */
1391 Oid array_typeid pg_node_attr(query_jumble_ignore);
1392 /* OID of collation, or InvalidOid if none */
1393 Oid array_collid pg_node_attr(query_jumble_ignore);
1394 /* common type of array elements */
1395 Oid element_typeid pg_node_attr(query_jumble_ignore);
1396 /* the array elements or sub-arrays */
1397 List *elements pg_node_attr(query_jumble_squash);
1398 /* true if elements are sub-arrays */
1399 bool multidims pg_node_attr(query_jumble_ignore);
1400 /* token location, or -1 if unknown */
1403
1404/*
1405 * RowExpr - a ROW() expression
1406 *
1407 * Note: the list of fields must have a one-for-one correspondence with
1408 * physical fields of the associated rowtype, although it is okay for it
1409 * to be shorter than the rowtype. That is, the N'th list element must
1410 * match up with the N'th physical field. When the N'th physical field
1411 * is a dropped column (attisdropped) then the N'th list element can just
1412 * be a NULL constant. (This case can only occur for named composite types,
1413 * not RECORD types, since those are built from the RowExpr itself rather
1414 * than vice versa.) It is important not to assume that length(args) is
1415 * the same as the number of columns logically present in the rowtype.
1416 *
1417 * colnames provides field names if the ROW() result is of type RECORD.
1418 * Names *must* be provided if row_typeid is RECORDOID; but if it is a
1419 * named composite type, colnames will be ignored in favor of using the
1420 * type's cataloged field names, so colnames should be NIL. Like the
1421 * args list, colnames is defined to be one-for-one with physical fields
1422 * of the rowtype (although dropped columns shouldn't appear in the
1423 * RECORD case, so this fine point is currently moot).
1424 */
1425typedef struct RowExpr
1426{
1428 List *args; /* the fields */
1429
1430 /* RECORDOID or a composite type's ID */
1431 Oid row_typeid pg_node_attr(query_jumble_ignore);
1432
1433 /*
1434 * row_typeid cannot be a domain over composite, only plain composite. To
1435 * create a composite domain value, apply CoerceToDomain to the RowExpr.
1436 *
1437 * Note: we deliberately do NOT store a typmod. Although a typmod will be
1438 * associated with specific RECORD types at runtime, it will differ for
1439 * different backends, and so cannot safely be stored in stored
1440 * parsetrees. We must assume typmod -1 for a RowExpr node.
1441 *
1442 * We don't need to store a collation either. The result type is
1443 * necessarily composite, and composite types never have a collation.
1444 */
1445
1446 /* how to display this node */
1447 CoercionForm row_format pg_node_attr(query_jumble_ignore);
1448
1449 /* list of String, or NIL */
1450 List *colnames pg_node_attr(query_jumble_ignore);
1451
1452 ParseLoc location; /* token location, or -1 if unknown */
1454
1455/*
1456 * RowCompareExpr - row-wise comparison, such as (a, b) <= (1, 2)
1457 *
1458 * We support row comparison for any operator that can be determined to
1459 * act like =, <>, <, <=, >, or >= (we determine this by looking for the
1460 * operator in btree opfamilies). Note that the same operator name might
1461 * map to a different operator for each pair of row elements, since the
1462 * element datatypes can vary.
1463 *
1464 * A RowCompareExpr node is only generated for the < <= > >= cases;
1465 * the = and <> cases are translated to simple AND or OR combinations
1466 * of the pairwise comparisons.
1467 */
1468typedef struct RowCompareExpr
1469{
1471
1472 /* LT LE GE or GT, never EQ or NE */
1474 /* OID list of pairwise comparison ops */
1475 List *opnos pg_node_attr(query_jumble_ignore);
1476 /* OID list of containing operator families */
1477 List *opfamilies pg_node_attr(query_jumble_ignore);
1478 /* OID list of collations for comparisons */
1479 List *inputcollids pg_node_attr(query_jumble_ignore);
1480 /* the left-hand input arguments */
1482 /* the right-hand input arguments */
1485
1486/*
1487 * CoalesceExpr - a COALESCE expression
1488 */
1489typedef struct CoalesceExpr
1490{
1492 /* type of expression result */
1493 Oid coalescetype pg_node_attr(query_jumble_ignore);
1494 /* OID of collation, or InvalidOid if none */
1495 Oid coalescecollid pg_node_attr(query_jumble_ignore);
1496 /* the arguments */
1498 /* token location, or -1 if unknown */
1501
1502/*
1503 * MinMaxExpr - a GREATEST or LEAST function
1504 */
1505typedef enum MinMaxOp
1506{
1508 IS_LEAST
1510
1511typedef struct MinMaxExpr
1512{
1514 /* common type of arguments and result */
1515 Oid minmaxtype pg_node_attr(query_jumble_ignore);
1516 /* OID of collation of result */
1517 Oid minmaxcollid pg_node_attr(query_jumble_ignore);
1518 /* OID of collation that function should use */
1519 Oid inputcollid pg_node_attr(query_jumble_ignore);
1520 /* function to execute */
1522 /* the arguments */
1524 /* token location, or -1 if unknown */
1527
1528/*
1529 * SQLValueFunction - parameterless functions with special grammar productions
1530 *
1531 * The SQL standard categorizes some of these as <datetime value function>
1532 * and others as <general value specification>. We call 'em SQLValueFunctions
1533 * for lack of a better term. We store type and typmod of the result so that
1534 * some code doesn't need to know each function individually, and because
1535 * we would need to store typmod anyway for some of the datetime functions.
1536 * Note that currently, all variants return non-collating datatypes, so we do
1537 * not need a collation field; also, all these functions are stable.
1538 */
1540{
1557
1558typedef struct SQLValueFunction
1559{
1561 SQLValueFunctionOp op; /* which function this is */
1562
1563 /*
1564 * Result type/typmod. Type is fully determined by "op", so no need to
1565 * include this Oid in the query jumbling.
1566 */
1567 Oid type pg_node_attr(query_jumble_ignore);
1569 ParseLoc location; /* token location, or -1 if unknown */
1571
1572/*
1573 * XmlExpr - various SQL/XML functions requiring special grammar productions
1574 *
1575 * 'name' carries the "NAME foo" argument (already XML-escaped).
1576 * 'named_args' and 'arg_names' represent an xml_attribute list.
1577 * 'args' carries all other arguments.
1578 *
1579 * Note: result type/typmod/collation are not stored, but can be deduced
1580 * from the XmlExprOp. The type/typmod fields are just used for display
1581 * purposes, and are NOT necessarily the true result type of the node.
1582 */
1583typedef enum XmlExprOp
1584{
1585 IS_XMLCONCAT, /* XMLCONCAT(args) */
1586 IS_XMLELEMENT, /* XMLELEMENT(name, xml_attributes, args) */
1587 IS_XMLFOREST, /* XMLFOREST(xml_attributes) */
1588 IS_XMLPARSE, /* XMLPARSE(text, is_doc, preserve_ws) */
1589 IS_XMLPI, /* XMLPI(name [, args]) */
1590 IS_XMLROOT, /* XMLROOT(xml, version, standalone) */
1591 IS_XMLSERIALIZE, /* XMLSERIALIZE(is_document, xmlval, indent) */
1592 IS_DOCUMENT, /* xmlval IS DOCUMENT */
1594
1595typedef enum XmlOptionType
1596{
1600
1601typedef struct XmlExpr
1602{
1604 /* xml function ID */
1606 /* name in xml(NAME foo ...) syntaxes */
1607 char *name pg_node_attr(query_jumble_ignore);
1608 /* non-XML expressions for xml_attributes */
1610 /* parallel list of String values */
1611 List *arg_names pg_node_attr(query_jumble_ignore);
1612 /* list of expressions */
1614 /* DOCUMENT or CONTENT */
1616 /* INDENT option for XMLSERIALIZE */
1618 /* target type/typmod for XMLSERIALIZE */
1619 Oid type pg_node_attr(query_jumble_ignore);
1620 int32 typmod pg_node_attr(query_jumble_ignore);
1621 /* token location, or -1 if unknown */
1624
1625/*
1626 * JsonEncoding -
1627 * representation of JSON ENCODING clause
1628 */
1629typedef enum JsonEncoding
1630{
1631 JS_ENC_DEFAULT, /* unspecified */
1636
1637/*
1638 * JsonFormatType -
1639 * enumeration of JSON formats used in JSON FORMAT clause
1640 */
1641typedef enum JsonFormatType
1642{
1643 JS_FORMAT_DEFAULT, /* unspecified */
1644 JS_FORMAT_JSON, /* FORMAT JSON [ENCODING ...] */
1645 JS_FORMAT_JSONB, /* implicit internal format for RETURNING
1646 * jsonb */
1648
1649/*
1650 * JsonFormat -
1651 * representation of JSON FORMAT clause
1652 */
1653typedef struct JsonFormat
1654{
1656 JsonFormatType format_type; /* format type */
1657 JsonEncoding encoding; /* JSON encoding */
1658 ParseLoc location; /* token location, or -1 if unknown */
1660
1661/*
1662 * JsonReturning -
1663 * transformed representation of JSON RETURNING clause
1664 */
1665typedef struct JsonReturning
1666{
1668 JsonFormat *format; /* output JSON format */
1669 Oid typid; /* target type Oid */
1670 int32 typmod; /* target type modifier */
1672
1673/*
1674 * JsonValueExpr -
1675 * representation of JSON value expression (expr [FORMAT JsonFormat])
1676 *
1677 * raw_expr is the user-specified value, while formatted_expr is the value
1678 * obtained by coercing raw_expr to the type required by either the FORMAT
1679 * clause or an enclosing node's RETURNING clause.
1680 *
1681 * When deparsing a JsonValueExpr, get_rule_expr() prints raw_expr. However,
1682 * during the evaluation of a JsonValueExpr, the value of formatted_expr
1683 * takes precedence over that of raw_expr.
1684 */
1685typedef struct JsonValueExpr
1686{
1688 Expr *raw_expr; /* user-specified expression */
1689 Expr *formatted_expr; /* coerced formatted expression */
1690 JsonFormat *format; /* FORMAT clause, if specified */
1692
1694{
1703
1704/*
1705 * JsonConstructorExpr -
1706 * wrapper over FuncExpr/Aggref/WindowFunc for SQL/JSON constructors
1707 */
1709{
1711 JsonConstructorType type; /* constructor type */
1713 Expr *func; /* underlying json[b]_xxx() function call */
1714 Expr *coercion; /* coercion to RETURNING type */
1715 JsonReturning *returning; /* RETURNING clause */
1716 bool absent_on_null; /* ABSENT ON NULL? */
1717 bool unique; /* WITH UNIQUE KEYS? (JSON_OBJECT[AGG] only) */
1720
1721/*
1722 * JsonValueType -
1723 * representation of JSON item type in IS JSON predicate
1724 */
1725typedef enum JsonValueType
1726{
1727 JS_TYPE_ANY, /* IS JSON [VALUE] */
1728 JS_TYPE_OBJECT, /* IS JSON OBJECT */
1729 JS_TYPE_ARRAY, /* IS JSON ARRAY */
1730 JS_TYPE_SCALAR, /* IS JSON SCALAR */
1732
1733/*
1734 * JsonIsPredicate -
1735 * representation of IS JSON predicate
1736 */
1737typedef struct JsonIsPredicate
1738{
1740 Node *expr; /* subject expression */
1741 JsonFormat *format; /* FORMAT clause, if specified */
1742 JsonValueType item_type; /* JSON item type */
1743 bool unique_keys; /* check key uniqueness? */
1744 ParseLoc location; /* token location, or -1 if unknown */
1746
1747/* Nodes used in SQL/JSON query functions */
1748
1749/*
1750 * JsonWrapper -
1751 * representation of WRAPPER clause for JSON_QUERY()
1752 */
1753typedef enum JsonWrapper
1754{
1760
1761/*
1762 * JsonBehaviorType -
1763 * enumeration of behavior types used in SQL/JSON ON ERROR/EMPTY clauses
1764 *
1765 * If enum members are reordered, get_json_behavior() from ruleutils.c
1766 * must be updated accordingly.
1767 */
1769{
1780
1781/*
1782 * JsonBehavior
1783 * Specifications for ON ERROR / ON EMPTY behaviors of SQL/JSON
1784 * query functions specified by a JsonExpr
1785 *
1786 * 'expr' is the expression to emit when a given behavior (EMPTY or ERROR)
1787 * occurs on evaluating the SQL/JSON query function. 'coerce' is set to true
1788 * if 'expr' isn't already of the expected target type given by
1789 * JsonExpr.returning.
1790 */
1791typedef struct JsonBehavior
1792{
1794
1798 ParseLoc location; /* token location, or -1 if unknown */
1800
1801/*
1802 * JsonExprOp -
1803 * enumeration of SQL/JSON query function types
1804 */
1805typedef enum JsonExprOp
1806{
1807 JSON_EXISTS_OP, /* JSON_EXISTS() */
1808 JSON_QUERY_OP, /* JSON_QUERY() */
1809 JSON_VALUE_OP, /* JSON_VALUE() */
1810 JSON_TABLE_OP, /* JSON_TABLE() */
1812
1813/*
1814 * JsonExpr -
1815 * Transformed representation of JSON_VALUE(), JSON_QUERY(), and
1816 * JSON_EXISTS()
1817 */
1818typedef struct JsonExpr
1819{
1821
1823
1824 char *column_name; /* JSON_TABLE() column name or NULL if this is
1825 * not for a JSON_TABLE() */
1826
1827 /* jsonb-valued expression to query */
1829
1830 /* Format of the above expression needed by ruleutils.c */
1832
1833 /* jsonpath-valued expression containing the query pattern */
1835
1836 /* Expected type/format of the output. */
1838
1839 /* Information about the PASSING argument expressions */
1842
1843 /* User-specified or default ON EMPTY and ON ERROR behaviors */
1846
1847 /*
1848 * Information about converting the result of jsonpath functions
1849 * JsonPathQuery() and JsonPathValue() to the RETURNING type.
1850 */
1853
1854 /* WRAPPER specification for JSON_QUERY */
1856
1857 /* KEEP or OMIT QUOTES for singleton scalars returned by JSON_QUERY() */
1859
1860 /* JsonExpr's collation. */
1862
1863 /* Original JsonFuncExpr's location */
1866
1867/*
1868 * JsonTablePath
1869 * A JSON path expression to be computed as part of evaluating
1870 * a JSON_TABLE plan node
1871 */
1872typedef struct JsonTablePath
1873{
1875
1877 char *name;
1879
1880/*
1881 * JsonTablePlan -
1882 * Abstract class to represent different types of JSON_TABLE "plans".
1883 * A plan is used to generate a "row pattern" value by evaluating a JSON
1884 * path expression against an input JSON document, which is then used for
1885 * populating JSON_TABLE() columns
1886 */
1887typedef struct JsonTablePlan
1888{
1890
1891 NodeTag type;
1893
1894/*
1895 * JSON_TABLE plan to evaluate a JSON path expression and NESTED paths, if
1896 * any.
1897 */
1898typedef struct JsonTablePathScan
1899{
1901
1902 /* JSON path to evaluate */
1904
1905 /*
1906 * ERROR/EMPTY ON ERROR behavior; only significant in the plan for the
1907 * top-level path.
1908 */
1910
1911 /* Plan(s) for nested columns, if any. */
1913
1914 /*
1915 * 0-based index in TableFunc.colvalexprs of the 1st and the last column
1916 * covered by this plan. Both are -1 if all columns are nested and thus
1917 * computed by the child plan(s).
1918 */
1922
1923/*
1924 * JsonTableSiblingJoin -
1925 * Plan to join rows of sibling NESTED COLUMNS clauses in the same parent
1926 * COLUMNS clause
1927 */
1929{
1931
1935
1936/* ----------------
1937 * NullTest
1938 *
1939 * NullTest represents the operation of testing a value for NULLness.
1940 * The appropriate test is performed and returned as a boolean Datum.
1941 *
1942 * When argisrow is false, this simply represents a test for the null value.
1943 *
1944 * When argisrow is true, the input expression must yield a rowtype, and
1945 * the node implements "row IS [NOT] NULL" per the SQL standard. This
1946 * includes checking individual fields for NULLness when the row datum
1947 * itself isn't NULL.
1948 *
1949 * NOTE: the combination of a rowtype input and argisrow==false does NOT
1950 * correspond to the SQL notation "row IS [NOT] NULL"; instead, this case
1951 * represents the SQL notation "row IS [NOT] DISTINCT FROM NULL".
1952 * ----------------
1953 */
1954
1955typedef enum NullTestType
1956{
1959
1960typedef struct NullTest
1961{
1963 Expr *arg; /* input expression */
1964 NullTestType nulltesttype; /* IS NULL, IS NOT NULL */
1965 /* T to perform field-by-field null checks */
1966 bool argisrow pg_node_attr(query_jumble_ignore);
1967 ParseLoc location; /* token location, or -1 if unknown */
1969
1970/*
1971 * BooleanTest
1972 *
1973 * BooleanTest represents the operation of determining whether a boolean
1974 * is TRUE, FALSE, or UNKNOWN (ie, NULL). All six meaningful combinations
1975 * are supported. Note that a NULL input does *not* cause a NULL result.
1976 * The appropriate test is performed and returned as a boolean Datum.
1977 */
1978
1979typedef enum BoolTestType
1980{
1983
1984typedef struct BooleanTest
1985{
1987 Expr *arg; /* input expression */
1989 ParseLoc location; /* token location, or -1 if unknown */
1991
1992
1993/*
1994 * MergeAction
1995 *
1996 * Transformed representation of a WHEN clause in a MERGE statement
1997 */
1998
1999typedef enum MergeMatchKind
2000{
2005
2006#define NUM_MERGE_MATCH_KINDS (MERGE_WHEN_NOT_MATCHED_BY_TARGET + 1)
2007
2008typedef struct MergeAction
2009{
2011 MergeMatchKind matchKind; /* MATCHED/NOT MATCHED BY SOURCE/TARGET */
2012 CmdType commandType; /* INSERT/UPDATE/DELETE/DO NOTHING */
2013 /* OVERRIDING clause */
2014 OverridingKind override pg_node_attr(query_jumble_ignore);
2015 Node *qual; /* transformed WHEN conditions */
2016 List *targetList; /* the target list (of TargetEntry) */
2017 /* target attribute numbers of an UPDATE */
2018 List *updateColnos pg_node_attr(query_jumble_ignore);
2020
2021/*
2022 * CoerceToDomain
2023 *
2024 * CoerceToDomain represents the operation of coercing a value to a domain
2025 * type. At runtime (and not before) the precise set of constraints to be
2026 * checked will be determined. If the value passes, it is returned as the
2027 * result; if not, an error is raised. Note that this is equivalent to
2028 * RelabelType in the scenario where no constraints are applied.
2029 */
2030typedef struct CoerceToDomain
2031{
2033 Expr *arg; /* input expression */
2034 Oid resulttype; /* domain type ID (result type) */
2035 /* output typmod (currently always -1) */
2036 int32 resulttypmod pg_node_attr(query_jumble_ignore);
2037 /* OID of collation, or InvalidOid if none */
2038 Oid resultcollid pg_node_attr(query_jumble_ignore);
2039 /* how to display this node */
2040 CoercionForm coercionformat pg_node_attr(query_jumble_ignore);
2041 ParseLoc location; /* token location, or -1 if unknown */
2043
2044/*
2045 * Placeholder node for the value to be processed by a domain's check
2046 * constraint. This is effectively like a Param, but can be implemented more
2047 * simply since we need only one replacement value at a time.
2048 *
2049 * Note: the typeId/typeMod/collation will be set from the domain's base type,
2050 * not the domain itself. This is because we shouldn't consider the value
2051 * to be a member of the domain if we haven't yet checked its constraints.
2052 */
2054{
2056 /* type for substituted value */
2058 /* typemod for substituted value */
2059 int32 typeMod pg_node_attr(query_jumble_ignore);
2060 /* collation for the substituted value */
2061 Oid collation pg_node_attr(query_jumble_ignore);
2062 /* token location, or -1 if unknown */
2065
2066/*
2067 * Placeholder node for a DEFAULT marker in an INSERT or UPDATE command.
2068 *
2069 * This is not an executable expression: it must be replaced by the actual
2070 * column default expression during rewriting. But it is convenient to
2071 * treat it as an expression node during parsing and rewriting.
2072 */
2073typedef struct SetToDefault
2074{
2076 /* type for substituted value */
2078 /* typemod for substituted value */
2079 int32 typeMod pg_node_attr(query_jumble_ignore);
2080 /* collation for the substituted value */
2081 Oid collation pg_node_attr(query_jumble_ignore);
2082 /* token location, or -1 if unknown */
2085
2086/*
2087 * Node representing [WHERE] CURRENT OF cursor_name
2088 *
2089 * CURRENT OF is a bit like a Var, in that it carries the rangetable index
2090 * of the target relation being constrained; this aids placing the expression
2091 * correctly during planning. We can assume however that its "levelsup" is
2092 * always zero, due to the syntactic constraints on where it can appear.
2093 * Also, cvarno will always be a true RT index, never INNER_VAR etc.
2094 *
2095 * The referenced cursor can be represented either as a hardwired string
2096 * or as a reference to a run-time parameter of type REFCURSOR. The latter
2097 * case is for the convenience of plpgsql.
2098 */
2099typedef struct CurrentOfExpr
2100{
2102 Index cvarno; /* RT index of target relation */
2103 char *cursor_name; /* name of referenced cursor, or NULL */
2104 int cursor_param; /* refcursor parameter number, or 0 */
2106
2107/*
2108 * NextValueExpr - get next value from sequence
2109 *
2110 * This has the same effect as calling the nextval() function, but it does not
2111 * check permissions on the sequence. This is used for identity columns,
2112 * where the sequence is an implicit dependency without its own permissions.
2113 */
2114typedef struct NextValueExpr
2115{
2120
2121/*
2122 * InferenceElem - an element of a unique index inference specification
2123 *
2124 * This mostly matches the structure of IndexElems, but having a dedicated
2125 * primnode allows for a clean separation between the use of index parameters
2126 * by utility commands, and this node.
2127 */
2128typedef struct InferenceElem
2129{
2131 Node *expr; /* expression to infer from, or NULL */
2132 Oid infercollid; /* OID of collation, or InvalidOid */
2133 Oid inferopclass; /* OID of att opclass, or InvalidOid */
2135
2136/*
2137 * ReturningExpr - return OLD/NEW.(expression) in RETURNING list
2138 *
2139 * This is used when updating an auto-updatable view and returning a view
2140 * column that is not simply a Var referring to the base relation. In such
2141 * cases, OLD/NEW.viewcol can expand to an arbitrary expression, but the
2142 * result is required to be NULL if the OLD/NEW row doesn't exist. To handle
2143 * this, the rewriter wraps the expanded expression in a ReturningExpr, which
2144 * is equivalent to "CASE WHEN (OLD/NEW row exists) THEN (expr) ELSE NULL".
2145 *
2146 * A similar situation can arise when rewriting the RETURNING clause of a
2147 * rule, which may also contain arbitrary expressions.
2148 *
2149 * ReturningExpr nodes never appear in a parsed Query --- they are only ever
2150 * inserted by the rewriter and the planner.
2151 */
2152typedef struct ReturningExpr
2153{
2155 int retlevelsup; /* > 0 if it belongs to outer query */
2156 bool retold; /* true for OLD, false for NEW */
2157 Expr *retexpr; /* expression to be returned */
2159
2160/*--------------------
2161 * TargetEntry -
2162 * a target entry (used in query target lists)
2163 *
2164 * Strictly speaking, a TargetEntry isn't an expression node (since it can't
2165 * be evaluated by ExecEvalExpr). But we treat it as one anyway, since in
2166 * very many places it's convenient to process a whole query targetlist as a
2167 * single expression tree.
2168 *
2169 * In a SELECT's targetlist, resno should always be equal to the item's
2170 * ordinal position (counting from 1). However, in an INSERT or UPDATE
2171 * targetlist, resno represents the attribute number of the destination
2172 * column for the item; so there may be missing or out-of-order resnos.
2173 * It is even legal to have duplicated resnos; consider
2174 * UPDATE table SET arraycol[1] = ..., arraycol[2] = ..., ...
2175 * In an INSERT, the rewriter and planner will normalize the tlist by
2176 * reordering it into physical column order and filling in default values
2177 * for any columns not assigned values by the original query. In an UPDATE,
2178 * after the rewriter merges multiple assignments for the same column, the
2179 * planner extracts the target-column numbers into a separate "update_colnos"
2180 * list, and then renumbers the tlist elements serially. Thus, tlist resnos
2181 * match ordinal position in all tlists seen by the executor; but it is wrong
2182 * to assume that before planning has happened.
2183 *
2184 * resname is required to represent the correct column name in non-resjunk
2185 * entries of top-level SELECT targetlists, since it will be used as the
2186 * column title sent to the frontend. In most other contexts it is only
2187 * a debugging aid, and may be wrong or even NULL. (In particular, it may
2188 * be wrong in a tlist from a stored rule, if the referenced column has been
2189 * renamed by ALTER TABLE since the rule was made. Also, the planner tends
2190 * to store NULL rather than look up a valid name for tlist entries in
2191 * non-toplevel plan nodes.) In resjunk entries, resname should be either
2192 * a specific system-generated name (such as "ctid") or NULL; anything else
2193 * risks confusing ExecGetJunkAttribute!
2194 *
2195 * ressortgroupref is used in the representation of ORDER BY, GROUP BY, and
2196 * DISTINCT items. Targetlist entries with ressortgroupref=0 are not
2197 * sort/group items. If ressortgroupref>0, then this item is an ORDER BY,
2198 * GROUP BY, and/or DISTINCT target value. No two entries in a targetlist
2199 * may have the same nonzero ressortgroupref --- but there is no particular
2200 * meaning to the nonzero values, except as tags. (For example, one must
2201 * not assume that lower ressortgroupref means a more significant sort key.)
2202 * The order of the associated SortGroupClause lists determine the semantics.
2203 *
2204 * resorigtbl/resorigcol identify the source of the column, if it is a
2205 * simple reference to a column of a base table (or view). If it is not
2206 * a simple reference, these fields are zeroes.
2207 *
2208 * If resjunk is true then the column is a working column (such as a sort key)
2209 * that should be removed from the final output of the query. Resjunk columns
2210 * must have resnos that cannot duplicate any regular column's resno. Also
2211 * note that there are places that assume resjunk columns come after non-junk
2212 * columns.
2213 *--------------------
2214 */
2215typedef struct TargetEntry
2216{
2218 /* expression to evaluate */
2220 /* attribute number (see notes above) */
2222 /* name of the column (could be NULL) */
2223 char *resname pg_node_attr(query_jumble_ignore);
2224 /* nonzero if referenced by a sort/group clause */
2226 /* OID of column's source table */
2227 Oid resorigtbl pg_node_attr(query_jumble_ignore);
2228 /* column's number in source table */
2229 AttrNumber resorigcol pg_node_attr(query_jumble_ignore);
2230 /* set to true to eliminate the attribute from final target list */
2231 bool resjunk pg_node_attr(query_jumble_ignore);
2233
2234
2235/* ----------------------------------------------------------------
2236 * node types for join trees
2237 *
2238 * The leaves of a join tree structure are RangeTblRef nodes. Above
2239 * these, JoinExpr nodes can appear to denote a specific kind of join
2240 * or qualified join. Also, FromExpr nodes can appear to denote an
2241 * ordinary cross-product join ("FROM foo, bar, baz WHERE ...").
2242 * FromExpr is like a JoinExpr of jointype JOIN_INNER, except that it
2243 * may have any number of child nodes, not just two.
2244 *
2245 * NOTE: the top level of a Query's jointree is always a FromExpr.
2246 * Even if the jointree contains no rels, there will be a FromExpr.
2247 *
2248 * NOTE: the qualification expressions present in JoinExpr nodes are
2249 * *in addition to* the query's main WHERE clause, which appears as the
2250 * qual of the top-level FromExpr. The reason for associating quals with
2251 * specific nodes in the jointree is that the position of a qual is critical
2252 * when outer joins are present. (If we enforce a qual too soon or too late,
2253 * that may cause the outer join to produce the wrong set of NULL-extended
2254 * rows.) If all joins are inner joins then all the qual positions are
2255 * semantically interchangeable.
2256 *
2257 * NOTE: in the raw output of gram.y, a join tree contains RangeVar,
2258 * RangeSubselect, and RangeFunction nodes, which are all replaced by
2259 * RangeTblRef nodes during the parse analysis phase. Also, the top-level
2260 * FromExpr is added during parse analysis; the grammar regards FROM and
2261 * WHERE as separate.
2262 * ----------------------------------------------------------------
2263 */
2264
2265/*
2266 * RangeTblRef - reference to an entry in the query's rangetable
2267 *
2268 * We could use direct pointers to the RT entries and skip having these
2269 * nodes, but multiple pointers to the same node in a querytree cause
2270 * lots of headaches, so it seems better to store an index into the RT.
2271 */
2272typedef struct RangeTblRef
2273{
2277
2278/*----------
2279 * JoinExpr - for SQL JOIN expressions
2280 *
2281 * isNatural, usingClause, and quals are interdependent. The user can write
2282 * only one of NATURAL, USING(), or ON() (this is enforced by the grammar).
2283 * If he writes NATURAL then parse analysis generates the equivalent USING()
2284 * list, and from that fills in "quals" with the right equality comparisons.
2285 * If he writes USING() then "quals" is filled with equality comparisons.
2286 * If he writes ON() then only "quals" is set. Note that NATURAL/USING
2287 * are not equivalent to ON() since they also affect the output column list.
2288 *
2289 * alias is an Alias node representing the AS alias-clause attached to the
2290 * join expression, or NULL if no clause. NB: presence or absence of the
2291 * alias has a critical impact on semantics, because a join with an alias
2292 * restricts visibility of the tables/columns inside it.
2293 *
2294 * join_using_alias is an Alias node representing the join correlation
2295 * name that SQL:2016 and later allow to be attached to JOIN/USING.
2296 * Its column alias list includes only the common column names from USING,
2297 * and it does not restrict visibility of the join's input tables.
2298 *
2299 * During parse analysis, an RTE is created for the Join, and its index
2300 * is filled into rtindex. This RTE is present mainly so that Vars can
2301 * be created that refer to the outputs of the join. The planner sometimes
2302 * generates JoinExprs internally; these can have rtindex = 0 if there are
2303 * no join alias variables referencing such joins.
2304 *----------
2305 */
2306typedef struct JoinExpr
2307{
2309 JoinType jointype; /* type of join */
2310 bool isNatural; /* Natural join? Will need to shape table */
2311 Node *larg; /* left subtree */
2312 Node *rarg; /* right subtree */
2313 /* USING clause, if any (list of String) */
2314 List *usingClause pg_node_attr(query_jumble_ignore);
2315 /* alias attached to USING clause, if any */
2316 Alias *join_using_alias pg_node_attr(query_jumble_ignore);
2317 /* qualifiers on join, if any */
2319 /* user-written alias clause, if any */
2320 Alias *alias pg_node_attr(query_jumble_ignore);
2321 /* RT index assigned for join, or 0 */
2324
2325/*----------
2326 * FromExpr - represents a FROM ... WHERE ... construct
2327 *
2328 * This is both more flexible than a JoinExpr (it can have any number of
2329 * children, including zero) and less so --- we don't need to deal with
2330 * aliases and so on. The output column set is implicitly just the union
2331 * of the outputs of the children.
2332 *----------
2333 */
2334typedef struct FromExpr
2335{
2337 List *fromlist; /* List of join subtrees */
2338 Node *quals; /* qualifiers on join, if any */
2340
2341/*----------
2342 * OnConflictExpr - represents an ON CONFLICT DO ... expression
2343 *
2344 * The optimizer requires a list of inference elements, and optionally a WHERE
2345 * clause to infer a unique index. The unique index (or, occasionally,
2346 * indexes) inferred are used to arbitrate whether or not the alternative ON
2347 * CONFLICT path is taken.
2348 *----------
2349 */
2350typedef struct OnConflictExpr
2351{
2353 OnConflictAction action; /* DO NOTHING or UPDATE? */
2354
2355 /* Arbiter */
2356 List *arbiterElems; /* unique index arbiter list (of
2357 * InferenceElem's) */
2358 Node *arbiterWhere; /* unique index arbiter WHERE clause */
2359 Oid constraint; /* pg_constraint OID for arbiter */
2360
2361 /* ON CONFLICT UPDATE */
2362 List *onConflictSet; /* List of ON CONFLICT SET TargetEntrys */
2363 Node *onConflictWhere; /* qualifiers to restrict UPDATE to */
2364 int exclRelIndex; /* RT index of 'excluded' relation */
2365 List *exclRelTlist; /* tlist of the EXCLUDED pseudo relation */
2367
2368#endif /* PRIMNODES_H */
int16 AttrNumber
Definition: attnum.h:21
int32_t int32
Definition: c.h:498
unsigned int Index
Definition: c.h:585
CompareType
Definition: cmptype.h:32
double Cost
Definition: nodes.h:257
OnConflictAction
Definition: nodes.h:423
CmdType
Definition: nodes.h:269
NodeTag
Definition: nodes.h:27
AggSplit
Definition: nodes.h:381
int ParseLoc
Definition: nodes.h:246
JoinType
Definition: nodes.h:294
#define plan(x)
Definition: pg_regress.c:161
uintptr_t Datum
Definition: postgres.h:69
unsigned int Oid
Definition: postgres_ext.h:30
BoolTestType
Definition: primnodes.h:1980
@ IS_NOT_TRUE
Definition: primnodes.h:1981
@ IS_NOT_FALSE
Definition: primnodes.h:1981
@ IS_NOT_UNKNOWN
Definition: primnodes.h:1981
@ IS_TRUE
Definition: primnodes.h:1981
@ IS_UNKNOWN
Definition: primnodes.h:1981
@ IS_FALSE
Definition: primnodes.h:1981
struct ArrayExpr ArrayExpr
struct FieldSelect FieldSelect
struct CoalesceExpr CoalesceExpr
struct Aggref Aggref
SubLinkType
Definition: primnodes.h:1013
@ ARRAY_SUBLINK
Definition: primnodes.h:1020
@ ANY_SUBLINK
Definition: primnodes.h:1016
@ MULTIEXPR_SUBLINK
Definition: primnodes.h:1019
@ CTE_SUBLINK
Definition: primnodes.h:1021
@ EXPR_SUBLINK
Definition: primnodes.h:1018
@ ROWCOMPARE_SUBLINK
Definition: primnodes.h:1017
@ ALL_SUBLINK
Definition: primnodes.h:1015
@ EXISTS_SUBLINK
Definition: primnodes.h:1014
struct AlternativeSubPlan AlternativeSubPlan
JsonFormatType
Definition: primnodes.h:1642
@ JS_FORMAT_JSONB
Definition: primnodes.h:1645
@ JS_FORMAT_DEFAULT
Definition: primnodes.h:1643
@ JS_FORMAT_JSON
Definition: primnodes.h:1644
struct WindowFuncRunCondition WindowFuncRunCondition
struct InferenceElem InferenceElem
struct ArrayCoerceExpr ArrayCoerceExpr
struct TargetEntry TargetEntry
MinMaxOp
Definition: primnodes.h:1506
@ IS_LEAST
Definition: primnodes.h:1508
@ IS_GREATEST
Definition: primnodes.h:1507
TableFuncType
Definition: primnodes.h:99
@ TFT_XMLTABLE
Definition: primnodes.h:100
@ TFT_JSON_TABLE
Definition: primnodes.h:101
struct CaseWhen CaseWhen
BoolExprType
Definition: primnodes.h:947
@ AND_EXPR
Definition: primnodes.h:948
@ OR_EXPR
Definition: primnodes.h:948
@ NOT_EXPR
Definition: primnodes.h:948
struct SetToDefault SetToDefault
JsonEncoding
Definition: primnodes.h:1630
@ JS_ENC_DEFAULT
Definition: primnodes.h:1631
@ JS_ENC_UTF32
Definition: primnodes.h:1634
@ JS_ENC_UTF8
Definition: primnodes.h:1632
@ JS_ENC_UTF16
Definition: primnodes.h:1633
struct JsonReturning JsonReturning
struct CaseExpr CaseExpr
struct JsonBehavior JsonBehavior
struct WindowFunc WindowFunc
XmlOptionType
Definition: primnodes.h:1596
@ XMLOPTION_CONTENT
Definition: primnodes.h:1598
@ XMLOPTION_DOCUMENT
Definition: primnodes.h:1597
SQLValueFunctionOp
Definition: primnodes.h:1540
@ SVFOP_CURRENT_CATALOG
Definition: primnodes.h:1554
@ SVFOP_LOCALTIME_N
Definition: primnodes.h:1547
@ SVFOP_CURRENT_TIMESTAMP
Definition: primnodes.h:1544
@ SVFOP_LOCALTIME
Definition: primnodes.h:1546
@ SVFOP_CURRENT_TIMESTAMP_N
Definition: primnodes.h:1545
@ SVFOP_CURRENT_ROLE
Definition: primnodes.h:1550
@ SVFOP_USER
Definition: primnodes.h:1552
@ SVFOP_CURRENT_SCHEMA
Definition: primnodes.h:1555
@ SVFOP_LOCALTIMESTAMP_N
Definition: primnodes.h:1549
@ SVFOP_CURRENT_DATE
Definition: primnodes.h:1541
@ SVFOP_CURRENT_TIME_N
Definition: primnodes.h:1543
@ SVFOP_CURRENT_TIME
Definition: primnodes.h:1542
@ SVFOP_LOCALTIMESTAMP
Definition: primnodes.h:1548
@ SVFOP_CURRENT_USER
Definition: primnodes.h:1551
@ SVFOP_SESSION_USER
Definition: primnodes.h:1553
ParamKind
Definition: primnodes.h:383
@ PARAM_MULTIEXPR
Definition: primnodes.h:387
@ PARAM_EXTERN
Definition: primnodes.h:384
@ PARAM_SUBLINK
Definition: primnodes.h:386
@ PARAM_EXEC
Definition: primnodes.h:385
struct CoerceToDomainValue CoerceToDomainValue
struct Var Var
JsonWrapper
Definition: primnodes.h:1754
@ JSW_UNCONDITIONAL
Definition: primnodes.h:1758
@ JSW_CONDITIONAL
Definition: primnodes.h:1757
@ JSW_UNSPEC
Definition: primnodes.h:1755
@ JSW_NONE
Definition: primnodes.h:1756
struct IntoClause IntoClause
struct MinMaxExpr MinMaxExpr
OpExpr DistinctExpr
Definition: primnodes.h:869
struct NamedArgExpr NamedArgExpr
XmlExprOp
Definition: primnodes.h:1584
@ IS_DOCUMENT
Definition: primnodes.h:1592
@ IS_XMLFOREST
Definition: primnodes.h:1587
@ IS_XMLCONCAT
Definition: primnodes.h:1585
@ IS_XMLPI
Definition: primnodes.h:1589
@ IS_XMLPARSE
Definition: primnodes.h:1588
@ IS_XMLSERIALIZE
Definition: primnodes.h:1591
@ IS_XMLROOT
Definition: primnodes.h:1590
@ IS_XMLELEMENT
Definition: primnodes.h:1586
struct JsonIsPredicate JsonIsPredicate
struct JoinExpr JoinExpr
struct CoerceToDomain CoerceToDomain
struct SubLink SubLink
struct NextValueExpr NextValueExpr
VarReturningType
Definition: primnodes.h:255
@ VAR_RETURNING_OLD
Definition: primnodes.h:257
@ VAR_RETURNING_NEW
Definition: primnodes.h:258
@ VAR_RETURNING_DEFAULT
Definition: primnodes.h:256
struct JsonExpr JsonExpr
struct BoolExpr BoolExpr
struct OpExpr OpExpr
struct Expr Expr
JsonBehaviorType
Definition: primnodes.h:1769
@ JSON_BEHAVIOR_ERROR
Definition: primnodes.h:1771
@ JSON_BEHAVIOR_TRUE
Definition: primnodes.h:1773
@ JSON_BEHAVIOR_DEFAULT
Definition: primnodes.h:1778
@ JSON_BEHAVIOR_EMPTY
Definition: primnodes.h:1772
@ JSON_BEHAVIOR_FALSE
Definition: primnodes.h:1774
@ JSON_BEHAVIOR_NULL
Definition: primnodes.h:1770
@ JSON_BEHAVIOR_EMPTY_OBJECT
Definition: primnodes.h:1777
@ JSON_BEHAVIOR_UNKNOWN
Definition: primnodes.h:1775
@ JSON_BEHAVIOR_EMPTY_ARRAY
Definition: primnodes.h:1776
struct OnConflictExpr OnConflictExpr
struct FuncExpr FuncExpr
OnCommitAction
Definition: primnodes.h:57
@ ONCOMMIT_DELETE_ROWS
Definition: primnodes.h:60
@ ONCOMMIT_NOOP
Definition: primnodes.h:58
@ ONCOMMIT_PRESERVE_ROWS
Definition: primnodes.h:59
@ ONCOMMIT_DROP
Definition: primnodes.h:61
struct GroupingFunc GroupingFunc
struct XmlExpr XmlExpr
struct JsonTablePlan JsonTablePlan
struct SubPlan SubPlan
struct CollateExpr CollateExpr
struct ConvertRowtypeExpr ConvertRowtypeExpr
struct MergeAction MergeAction
struct RowExpr RowExpr
struct RangeTblRef RangeTblRef
JsonExprOp
Definition: primnodes.h:1806
@ JSON_QUERY_OP
Definition: primnodes.h:1808
@ JSON_TABLE_OP
Definition: primnodes.h:1810
@ JSON_EXISTS_OP
Definition: primnodes.h:1807
@ JSON_VALUE_OP
Definition: primnodes.h:1809
struct BooleanTest BooleanTest
CoercionForm
Definition: primnodes.h:750
@ COERCE_SQL_SYNTAX
Definition: primnodes.h:754
@ COERCE_IMPLICIT_CAST
Definition: primnodes.h:753
@ COERCE_EXPLICIT_CAST
Definition: primnodes.h:752
@ COERCE_EXPLICIT_CALL
Definition: primnodes.h:751
struct CaseTestExpr CaseTestExpr
OverridingKind
Definition: primnodes.h:27
@ OVERRIDING_NOT_SET
Definition: primnodes.h:28
@ OVERRIDING_SYSTEM_VALUE
Definition: primnodes.h:30
@ OVERRIDING_USER_VALUE
Definition: primnodes.h:29
struct SQLValueFunction SQLValueFunction
NullTestType
Definition: primnodes.h:1956
@ IS_NULL
Definition: primnodes.h:1957
@ IS_NOT_NULL
Definition: primnodes.h:1957
struct JsonConstructorExpr JsonConstructorExpr
struct CurrentOfExpr CurrentOfExpr
JsonValueType
Definition: primnodes.h:1726
@ JS_TYPE_ANY
Definition: primnodes.h:1727
@ JS_TYPE_ARRAY
Definition: primnodes.h:1729
@ JS_TYPE_OBJECT
Definition: primnodes.h:1728
@ JS_TYPE_SCALAR
Definition: primnodes.h:1730
struct NullTest NullTest
MergeMatchKind
Definition: primnodes.h:2000
@ MERGE_WHEN_NOT_MATCHED_BY_TARGET
Definition: primnodes.h:2003
@ MERGE_WHEN_NOT_MATCHED_BY_SOURCE
Definition: primnodes.h:2002
@ MERGE_WHEN_MATCHED
Definition: primnodes.h:2001
struct RowCompareExpr RowCompareExpr
struct JsonTablePath JsonTablePath
struct TableFunc TableFunc
struct JsonTablePathScan JsonTablePathScan
struct JsonTableSiblingJoin JsonTableSiblingJoin
struct ScalarArrayOpExpr ScalarArrayOpExpr
struct ReturningExpr ReturningExpr
struct JsonFormat JsonFormat
struct Param Param
struct Alias Alias
CoercionContext
Definition: primnodes.h:730
@ COERCION_PLPGSQL
Definition: primnodes.h:733
@ COERCION_ASSIGNMENT
Definition: primnodes.h:732
@ COERCION_EXPLICIT
Definition: primnodes.h:734
@ COERCION_IMPLICIT
Definition: primnodes.h:731
struct RelabelType RelabelType
struct CoerceViaIO CoerceViaIO
struct RangeVar RangeVar
JsonConstructorType
Definition: primnodes.h:1694
@ JSCTOR_JSON_SERIALIZE
Definition: primnodes.h:1701
@ JSCTOR_JSON_ARRAYAGG
Definition: primnodes.h:1698
@ JSCTOR_JSON_PARSE
Definition: primnodes.h:1699
@ JSCTOR_JSON_OBJECT
Definition: primnodes.h:1695
@ JSCTOR_JSON_SCALAR
Definition: primnodes.h:1700
@ JSCTOR_JSON_ARRAY
Definition: primnodes.h:1696
@ JSCTOR_JSON_OBJECTAGG
Definition: primnodes.h:1697
OpExpr NullIfExpr
Definition: primnodes.h:877
struct Const Const
struct SubscriptingRef SubscriptingRef
struct JsonValueExpr JsonValueExpr
struct MergeSupportFunc MergeSupportFunc
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:461
Expr xpr
Definition: primnodes.h:458
List * aggdistinct
Definition: primnodes.h:491
AggSplit aggsplit pg_node_attr(query_jumble_ignore)
List * aggdirectargs
Definition: primnodes.h:482
List *aggargtypes pg_node_attr(query_jumble_ignore)
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:485
Expr * aggfilter
Definition: primnodes.h:494
int aggno pg_node_attr(query_jumble_ignore)
Oid aggtype pg_node_attr(query_jumble_ignore)
bool aggvariadic pg_node_attr(query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:524
List * aggorder
Definition: primnodes.h:488
bool aggpresorted pg_node_attr(equal_ignore, query_jumble_ignore)
char * aliasname
Definition: primnodes.h:51
NodeTag type
Definition: primnodes.h:50
List * colnames
Definition: primnodes.h:52
pg_node_attr(no_query_jumble) Expr xpr
Oid resultcollid pg_node_attr(query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:1259
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)
ParseLoc location
Definition: primnodes.h:1401
Oid array_collid pg_node_attr(query_jumble_ignore)
List *elements pg_node_attr(query_jumble_squash)
Expr xpr
Definition: primnodes.h:1389
bool multidims pg_node_attr(query_jumble_ignore)
Oid array_typeid pg_node_attr(query_jumble_ignore)
pg_node_attr(custom_read_write) Expr xpr
BoolExprType boolop
Definition: primnodes.h:956
List * args
Definition: primnodes.h:957
ParseLoc location
Definition: primnodes.h:958
ParseLoc location
Definition: primnodes.h:1989
BoolTestType booltesttype
Definition: primnodes.h:1988
Expr * arg
Definition: primnodes.h:1987
Expr * arg
Definition: primnodes.h:1330
Oid casecollid pg_node_attr(query_jumble_ignore)
Expr xpr
Definition: primnodes.h:1325
ParseLoc location
Definition: primnodes.h:1333
Oid casetype pg_node_attr(query_jumble_ignore)
Expr * defresult
Definition: primnodes.h:1332
List * args
Definition: primnodes.h:1331
int32 typeMod pg_node_attr(query_jumble_ignore)
Oid collation pg_node_attr(query_jumble_ignore)
Expr * result
Definition: primnodes.h:1343
Expr * expr
Definition: primnodes.h:1342
Expr xpr
Definition: primnodes.h:1341
ParseLoc location
Definition: primnodes.h:1344
Oid coalescetype pg_node_attr(query_jumble_ignore)
List * args
Definition: primnodes.h:1497
Oid coalescecollid pg_node_attr(query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:1499
Oid collation pg_node_attr(query_jumble_ignore)
int32 typeMod pg_node_attr(query_jumble_ignore)
int32 resulttypmod pg_node_attr(query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:2041
CoercionForm coercionformat pg_node_attr(query_jumble_ignore)
Oid resultcollid pg_node_attr(query_jumble_ignore)
Expr * arg
Definition: primnodes.h:1224
CoercionForm coerceformat pg_node_attr(query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:1231
Oid resulttype
Definition: primnodes.h:1225
Oid resultcollid pg_node_attr(query_jumble_ignore)
Expr * arg
Definition: primnodes.h:1296
ParseLoc location
Definition: primnodes.h:1298
ParseLoc location pg_node_attr(query_jumble_location)
Oid consttype
Definition: primnodes.h:329
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 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:2103
pg_node_attr(abstract) NodeTag type
int32 resulttypmod pg_node_attr(query_jumble_ignore)
AttrNumber fieldnum
Definition: primnodes.h:1146
Oid resulttype pg_node_attr(query_jumble_ignore)
Expr * arg
Definition: primnodes.h:1145
Oid resultcollid pg_node_attr(query_jumble_ignore)
List *fieldnums pg_node_attr(query_jumble_ignore)
Oid resulttype pg_node_attr(query_jumble_ignore)
List * newvals
Definition: primnodes.h:1177
Expr * arg
Definition: primnodes.h:1176
Node * quals
Definition: primnodes.h:2338
NodeTag type
Definition: primnodes.h:2336
List * fromlist
Definition: primnodes.h:2337
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:765
bool funcretset pg_node_attr(query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:787
Oid funcid
Definition: primnodes.h:767
List * args
Definition: primnodes.h:785
CoercionForm funcformat pg_node_attr(query_jumble_ignore)
Oid funcresulttype pg_node_attr(query_jumble_ignore)
List *cols pg_node_attr(equal_ignore, query_jumble_ignore)
List *args pg_node_attr(query_jumble_ignore)
Index agglevelsup
Definition: primnodes.h:568
List *refs pg_node_attr(equal_ignore)
ParseLoc location
Definition: primnodes.h:571
struct Query *viewQuery pg_node_attr(query_jumble_ignore)
List * colNames
Definition: primnodes.h:164
char * tableSpaceName
Definition: primnodes.h:168
bool skipData
Definition: primnodes.h:171
OnCommitAction onCommit
Definition: primnodes.h:167
NodeTag type
Definition: primnodes.h:161
List * options
Definition: primnodes.h:166
char * accessMethod
Definition: primnodes.h:165
RangeVar * rel
Definition: primnodes.h:163
Node * quals
Definition: primnodes.h:2318
JoinType jointype
Definition: primnodes.h:2309
Alias *join_using_alias pg_node_attr(query_jumble_ignore)
int rtindex
Definition: primnodes.h:2322
Alias *alias pg_node_attr(query_jumble_ignore)
Node * larg
Definition: primnodes.h:2311
bool isNatural
Definition: primnodes.h:2310
NodeTag type
Definition: primnodes.h:2308
Node * rarg
Definition: primnodes.h:2312
List *usingClause pg_node_attr(query_jumble_ignore)
Node * expr
Definition: primnodes.h:1796
ParseLoc location
Definition: primnodes.h:1798
JsonBehaviorType btype
Definition: primnodes.h:1795
NodeTag type
Definition: primnodes.h:1793
JsonReturning * returning
Definition: primnodes.h:1715
JsonConstructorType type
Definition: primnodes.h:1711
char * column_name
Definition: primnodes.h:1824
Node * formatted_expr
Definition: primnodes.h:1828
ParseLoc location
Definition: primnodes.h:1864
List * passing_values
Definition: primnodes.h:1841
JsonBehavior * on_empty
Definition: primnodes.h:1844
JsonFormat * format
Definition: primnodes.h:1831
Expr xpr
Definition: primnodes.h:1820
List * passing_names
Definition: primnodes.h:1840
Node * path_spec
Definition: primnodes.h:1834
bool use_io_coercion
Definition: primnodes.h:1851
Oid collation
Definition: primnodes.h:1861
JsonReturning * returning
Definition: primnodes.h:1837
bool use_json_coercion
Definition: primnodes.h:1852
JsonWrapper wrapper
Definition: primnodes.h:1855
JsonExprOp op
Definition: primnodes.h:1822
JsonBehavior * on_error
Definition: primnodes.h:1845
bool omit_quotes
Definition: primnodes.h:1858
ParseLoc location
Definition: primnodes.h:1658
NodeTag type
Definition: primnodes.h:1655
JsonEncoding encoding
Definition: primnodes.h:1657
JsonFormatType format_type
Definition: primnodes.h:1656
JsonFormat * format
Definition: primnodes.h:1741
JsonValueType item_type
Definition: primnodes.h:1742
ParseLoc location
Definition: primnodes.h:1744
JsonFormat * format
Definition: primnodes.h:1668
NodeTag type
Definition: primnodes.h:1667
JsonTablePath * path
Definition: primnodes.h:1903
JsonTablePlan * child
Definition: primnodes.h:1912
JsonTablePlan plan
Definition: primnodes.h:1900
NodeTag type
Definition: primnodes.h:1874
Const * value
Definition: primnodes.h:1876
pg_node_attr(abstract) NodeTag type
JsonTablePlan * rplan
Definition: primnodes.h:1933
JsonTablePlan * lplan
Definition: primnodes.h:1932
JsonTablePlan plan
Definition: primnodes.h:1930
Expr * formatted_expr
Definition: primnodes.h:1689
JsonFormat * format
Definition: primnodes.h:1690
NodeTag type
Definition: primnodes.h:1687
Expr * raw_expr
Definition: primnodes.h:1688
Definition: pg_list.h:54
List *updateColnos pg_node_attr(query_jumble_ignore)
OverridingKind override pg_node_attr(query_jumble_ignore)
NodeTag type
Definition: primnodes.h:2010
Node * qual
Definition: primnodes.h:2015
CmdType commandType
Definition: primnodes.h:2012
List * targetList
Definition: primnodes.h:2016
MergeMatchKind matchKind
Definition: primnodes.h:2011
ParseLoc location
Definition: primnodes.h:653
List * args
Definition: primnodes.h:1523
Oid minmaxcollid pg_node_attr(query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:1525
Oid inputcollid pg_node_attr(query_jumble_ignore)
Oid minmaxtype pg_node_attr(query_jumble_ignore)
MinMaxOp op
Definition: primnodes.h:1521
char *name pg_node_attr(query_jumble_ignore)
Expr * arg
Definition: primnodes.h:808
ParseLoc location
Definition: primnodes.h:814
Definition: nodes.h:135
NullTestType nulltesttype
Definition: primnodes.h:1964
Expr xpr
Definition: primnodes.h:1962
bool argisrow pg_node_attr(query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:1967
Expr * arg
Definition: primnodes.h:1963
List * arbiterElems
Definition: primnodes.h:2356
OnConflictAction action
Definition: primnodes.h:2353
List * onConflictSet
Definition: primnodes.h:2362
List * exclRelTlist
Definition: primnodes.h:2365
NodeTag type
Definition: primnodes.h:2352
Node * onConflictWhere
Definition: primnodes.h:2363
Node * arbiterWhere
Definition: primnodes.h:2358
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)
bool opretset pg_node_attr(query_jumble_ignore)
Oid opno
Definition: primnodes.h:835
List * args
Definition: primnodes.h:853
ParseLoc location
Definition: primnodes.h:856
Expr xpr
Definition: primnodes.h:832
ParseLoc location
Definition: primnodes.h:401
Expr xpr
Definition: primnodes.h:392
int paramid
Definition: primnodes.h:394
Oid paramtype
Definition: primnodes.h:395
ParamKind paramkind
Definition: primnodes.h:393
int32 paramtypmod pg_node_attr(query_jumble_ignore)
Oid paramcollid pg_node_attr(query_jumble_ignore)
NodeTag type
Definition: primnodes.h:2274
char * relname
Definition: primnodes.h:83
bool inh
Definition: primnodes.h:86
Alias * alias
Definition: primnodes.h:92
char relpersistence
Definition: primnodes.h:89
char * catalogname
Definition: primnodes.h:77
ParseLoc location
Definition: primnodes.h:95
char * schemaname
Definition: primnodes.h:80
NodeTag type
Definition: primnodes.h:74
int32 resulttypmod pg_node_attr(query_jumble_ignore)
Oid resulttype
Definition: primnodes.h:1202
Oid resultcollid pg_node_attr(query_jumble_ignore)
CoercionForm relabelformat pg_node_attr(query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:1209
Expr * arg
Definition: primnodes.h:1201
Expr * retexpr
Definition: primnodes.h:2157
List *opnos pg_node_attr(query_jumble_ignore)
CompareType cmptype
Definition: primnodes.h:1473
List *inputcollids pg_node_attr(query_jumble_ignore)
List *opfamilies pg_node_attr(query_jumble_ignore)
Expr xpr
Definition: primnodes.h:1427
CoercionForm row_format pg_node_attr(query_jumble_ignore)
List * args
Definition: primnodes.h:1428
ParseLoc location
Definition: primnodes.h:1452
List *colnames pg_node_attr(query_jumble_ignore)
Oid row_typeid pg_node_attr(query_jumble_ignore)
Oid type pg_node_attr(query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:1569
SQLValueFunctionOp op
Definition: primnodes.h:1561
Oid hashfuncid pg_node_attr(equal_ignore_if_zero, query_jumble_ignore)
Oid negfuncid pg_node_attr(equal_ignore_if_zero, query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:936
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)
ParseLoc location
Definition: primnodes.h:2083
int plan_id
Definition: primnodes.h:1087
char * plan_name
Definition: primnodes.h:1089
List * args
Definition: primnodes.h:1108
List * paramIds
Definition: primnodes.h:1085
bool useHashTable
Definition: primnodes.h:1096
Node * testexpr
Definition: primnodes.h:1084
int32 firstColTypmod
Definition: primnodes.h:1092
pg_node_attr(no_query_jumble) Expr xpr
List * parParam
Definition: primnodes.h:1107
bool parallel_safe
Definition: primnodes.h:1101
List * setParam
Definition: primnodes.h:1105
bool unknownEqFalse
Definition: primnodes.h:1098
Cost startup_cost
Definition: primnodes.h:1110
Oid firstColCollation
Definition: primnodes.h:1093
Cost per_call_cost
Definition: primnodes.h:1111
SubLinkType subLinkType
Definition: primnodes.h:1082
Oid firstColType
Definition: primnodes.h:1091
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:720
List * refupperindexpr
Definition: primnodes.h:710
Expr * refexpr
Definition: primnodes.h:718
List * reflowerindexpr
Definition: primnodes.h:716
List *passingvalexprs pg_node_attr(query_jumble_ignore)
List *colnames pg_node_attr(query_jumble_ignore)
List *ns_names pg_node_attr(query_jumble_ignore)
Node *plan pg_node_attr(query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:146
Bitmapset *notnulls pg_node_attr(query_jumble_ignore)
Node * docexpr
Definition: primnodes.h:120
int ordinalitycol pg_node_attr(query_jumble_ignore)
List *coldefexprs pg_node_attr(query_jumble_ignore)
NodeTag type
Definition: primnodes.h:112
List *colvalexprs pg_node_attr(query_jumble_ignore)
List *colcollations pg_node_attr(query_jumble_ignore)
List *coltypes pg_node_attr(query_jumble_ignore)
Node * rowexpr
Definition: primnodes.h:122
List *ns_uris pg_node_attr(query_jumble_ignore)
List * colexprs
Definition: primnodes.h:132
TableFuncType functype
Definition: primnodes.h:114
List *coltypmods pg_node_attr(query_jumble_ignore)
Expr * expr
Definition: primnodes.h:2219
char *resname pg_node_attr(query_jumble_ignore)
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:2221
Index ressortgroupref
Definition: primnodes.h:2225
Definition: primnodes.h:262
ParseLoc location
Definition: primnodes.h:310
AttrNumber varattno
Definition: primnodes.h:274
int32 vartypmod pg_node_attr(query_jumble_ignore)
Oid varcollid pg_node_attr(query_jumble_ignore)
Expr xpr
Definition: primnodes.h:263
int varno
Definition: primnodes.h:269
VarReturningType varreturningtype
Definition: primnodes.h:297
AttrNumber varattnosyn pg_node_attr(equal_ignore, query_jumble_ignore)
Bitmapset *varnullingrels pg_node_attr(query_jumble_ignore)
Index varlevelsup
Definition: primnodes.h:294
Oid vartype pg_node_attr(query_jumble_ignore)
Index varnosyn pg_node_attr(equal_ignore, query_jumble_ignore)
Oid inputcollid pg_node_attr(query_jumble_ignore)
Expr xpr
Definition: primnodes.h:582
List * args
Definition: primnodes.h:592
Index winref
Definition: primnodes.h:598
bool winagg pg_node_attr(query_jumble_ignore)
Oid inputcollid pg_node_attr(query_jumble_ignore)
Expr * aggfilter
Definition: primnodes.h:594
ParseLoc location
Definition: primnodes.h:604
Oid wincollid pg_node_attr(query_jumble_ignore)
Oid wintype pg_node_attr(query_jumble_ignore)
List *runCondition pg_node_attr(query_jumble_ignore)
bool winstar pg_node_attr(query_jumble_ignore)
Oid winfnoid
Definition: primnodes.h:584
int32 typmod pg_node_attr(query_jumble_ignore)
List * args
Definition: primnodes.h:1613
Expr xpr
Definition: primnodes.h:1603
ParseLoc location
Definition: primnodes.h:1622
bool indent
Definition: primnodes.h:1617
char *name pg_node_attr(query_jumble_ignore)
XmlOptionType xmloption pg_node_attr(query_jumble_ignore)
List * named_args
Definition: primnodes.h:1609
XmlExprOp op
Definition: primnodes.h:1605
Oid type pg_node_attr(query_jumble_ignore)
List *arg_names pg_node_attr(query_jumble_ignore)
const char * type
const char * name
int xmloption
Definition: xml.c:110