PostgreSQL Source Code git master
primnodes.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * primnodes.h
4 * Definitions for "primitive" node types, those that are used in more
5 * than one of the parse/plan/execute stages of the query pipeline.
6 * Currently, these are mostly nodes for executable expressions
7 * and join trees.
8 *
9 *
10 * Portions Copyright (c) 1996-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{
392 pg_node_attr(custom_query_jumble)
393
394 Expr xpr;
395 ParamKind paramkind; /* kind of parameter. See above */
396 int paramid; /* numeric ID for parameter */
397 Oid paramtype; /* pg_type OID of parameter's datatype */
398 /* typmod value, if known */
400 /* OID of collation, or InvalidOid if none */
402 /* token location, or -1 if unknown */
405
406/*
407 * Aggref
408 *
409 * The aggregate's args list is a targetlist, ie, a list of TargetEntry nodes.
410 *
411 * For a normal (non-ordered-set) aggregate, the non-resjunk TargetEntries
412 * represent the aggregate's regular arguments (if any) and resjunk TLEs can
413 * be added at the end to represent ORDER BY expressions that are not also
414 * arguments. As in a top-level Query, the TLEs can be marked with
415 * ressortgroupref indexes to let them be referenced by SortGroupClause
416 * entries in the aggorder and/or aggdistinct lists. This represents ORDER BY
417 * and DISTINCT operations to be applied to the aggregate input rows before
418 * they are passed to the transition function. The grammar only allows a
419 * simple "DISTINCT" specifier for the arguments, but we use the full
420 * query-level representation to allow more code sharing.
421 *
422 * For an ordered-set aggregate, the args list represents the WITHIN GROUP
423 * (aggregated) arguments, all of which will be listed in the aggorder list.
424 * DISTINCT is not supported in this case, so aggdistinct will be NIL.
425 * The direct arguments appear in aggdirectargs (as a list of plain
426 * expressions, not TargetEntry nodes).
427 *
428 * aggtranstype is the data type of the state transition values for this
429 * aggregate (resolved to an actual type, if agg's transtype is polymorphic).
430 * This is determined during planning and is InvalidOid before that.
431 *
432 * aggargtypes is an OID list of the data types of the direct and regular
433 * arguments. Normally it's redundant with the aggdirectargs and args lists,
434 * but in a combining aggregate, it's not because the args list has been
435 * replaced with a single argument representing the partial-aggregate
436 * transition values.
437 *
438 * aggpresorted is set by the query planner for ORDER BY and DISTINCT
439 * aggregates where the chosen plan provides presorted input for this
440 * aggregate during execution.
441 *
442 * aggsplit indicates the expected partial-aggregation mode for the Aggref's
443 * parent plan node. It's always set to AGGSPLIT_SIMPLE in the parser, but
444 * the planner might change it to something else. We use this mainly as
445 * a crosscheck that the Aggrefs match the plan; but note that when aggsplit
446 * indicates a non-final mode, aggtype reflects the transition data type
447 * not the SQL-level output type of the aggregate.
448 *
449 * aggno and aggtransno are -1 in the parse stage, and are set in planning.
450 * Aggregates with the same 'aggno' represent the same aggregate expression,
451 * and can share the result. Aggregates with same 'transno' but different
452 * 'aggno' can share the same transition state, only the final function needs
453 * to be called separately.
454 *
455 * Information related to collations, transition types and internal states
456 * are irrelevant for the query jumbling.
457 */
458typedef struct Aggref
459{
461
462 /* pg_proc Oid of the aggregate */
464
465 /* type Oid of result of the aggregate */
466 Oid aggtype pg_node_attr(query_jumble_ignore);
467
468 /* OID of collation of result */
469 Oid aggcollid pg_node_attr(query_jumble_ignore);
470
471 /* OID of collation that function should use */
472 Oid inputcollid pg_node_attr(query_jumble_ignore);
473
474 /*
475 * type Oid of aggregate's transition value; ignored for equal since it
476 * might not be set yet
477 */
478 Oid aggtranstype pg_node_attr(equal_ignore, query_jumble_ignore);
479
480 /* type Oids of direct and aggregated args */
481 List *aggargtypes pg_node_attr(query_jumble_ignore);
482
483 /* direct arguments, if an ordered-set agg */
485
486 /* aggregated arguments and sort expressions */
488
489 /* ORDER BY (list of SortGroupClause) */
491
492 /* DISTINCT (list of SortGroupClause) */
494
495 /* FILTER expression, if any */
497
498 /* true if argument list was really '*' */
499 bool aggstar pg_node_attr(query_jumble_ignore);
500
501 /*
502 * true if variadic arguments have been combined into an array last
503 * argument
504 */
505 bool aggvariadic pg_node_attr(query_jumble_ignore);
506
507 /* aggregate kind (see pg_aggregate.h) */
508 char aggkind pg_node_attr(query_jumble_ignore);
509
510 /* aggregate input already sorted */
511 bool aggpresorted pg_node_attr(equal_ignore, query_jumble_ignore);
512
513 /* > 0 if agg belongs to outer query */
514 Index agglevelsup pg_node_attr(query_jumble_ignore);
515
516 /* expected agg-splitting mode of parent Agg */
517 AggSplit aggsplit pg_node_attr(query_jumble_ignore);
518
519 /* unique ID within the Agg node */
520 int aggno pg_node_attr(query_jumble_ignore);
521
522 /* unique ID of transition state in the Agg */
523 int aggtransno pg_node_attr(query_jumble_ignore);
524
525 /* token location, or -1 if unknown */
528
529/*
530 * GroupingFunc
531 *
532 * A GroupingFunc is a GROUPING(...) expression, which behaves in many ways
533 * like an aggregate function (e.g. it "belongs" to a specific query level,
534 * which might not be the one immediately containing it), but also differs in
535 * an important respect: it never evaluates its arguments, they merely
536 * designate expressions from the GROUP BY clause of the query level to which
537 * it belongs.
538 *
539 * The spec defines the evaluation of GROUPING() purely by syntactic
540 * replacement, but we make it a real expression for optimization purposes so
541 * that one Agg node can handle multiple grouping sets at once. Evaluating the
542 * result only needs the column positions to check against the grouping set
543 * being projected. However, for EXPLAIN to produce meaningful output, we have
544 * to keep the original expressions around, since expression deparse does not
545 * give us any feasible way to get at the GROUP BY clause.
546 *
547 * Also, we treat two GroupingFunc nodes as equal if they have equal arguments
548 * lists and agglevelsup, without comparing the refs and cols annotations.
549 *
550 * In raw parse output we have only the args list; parse analysis fills in the
551 * refs list, and the planner fills in the cols list.
552 *
553 * All the fields used as information for an internal state are irrelevant
554 * for the query jumbling.
555 */
556typedef struct GroupingFunc
557{
559
560 /* arguments, not evaluated but kept for benefit of EXPLAIN etc. */
561 List *args pg_node_attr(query_jumble_ignore);
562
563 /* ressortgrouprefs of arguments */
564 List *refs pg_node_attr(equal_ignore);
565
566 /* actual column positions set by planner */
567 List *cols pg_node_attr(equal_ignore, query_jumble_ignore);
568
569 /* same as Aggref.agglevelsup */
571
572 /* token location */
575
576/*
577 * WindowFunc
578 *
579 * Collation information is irrelevant for the query jumbling, as is the
580 * internal state information of the node like "winstar" and "winagg".
581 */
582
583/*
584 * Null Treatment options. If specified, initially set to PARSER_IGNORE_NULLS
585 * which is then converted to IGNORE_NULLS if the window function allows the
586 * null treatment clause.
587 */
588#define NO_NULLTREATMENT 0
589#define PARSER_IGNORE_NULLS 1
590#define PARSER_RESPECT_NULLS 2
591#define IGNORE_NULLS 3
592
593typedef struct WindowFunc
594{
596 /* pg_proc Oid of the function */
598 /* type Oid of result of the window function */
599 Oid wintype pg_node_attr(query_jumble_ignore);
600 /* OID of collation of result */
601 Oid wincollid pg_node_attr(query_jumble_ignore);
602 /* OID of collation that function should use */
603 Oid inputcollid pg_node_attr(query_jumble_ignore);
604 /* arguments to the window function */
606 /* FILTER expression, if any */
608 /* List of WindowFuncRunConditions to help short-circuit execution */
609 List *runCondition pg_node_attr(query_jumble_ignore);
610 /* index of associated WindowClause */
612 /* true if argument list was really '*' */
613 bool winstar pg_node_attr(query_jumble_ignore);
614 /* is function a simple aggregate? */
615 bool winagg pg_node_attr(query_jumble_ignore);
616 /* ignore nulls. One of the Null Treatment options */
618 /* token location, or -1 if unknown */
621
622/*
623 * WindowFuncRunCondition
624 *
625 * Represents intermediate OpExprs which will be used by WindowAgg to
626 * short-circuit execution.
627 */
629{
631
632 /* PG_OPERATOR OID of the operator */
634 /* OID of collation that operator should use */
635 Oid inputcollid pg_node_attr(query_jumble_ignore);
636
637 /*
638 * true of WindowFunc belongs on the left of the resulting OpExpr or false
639 * if the WindowFunc is on the right.
640 */
642
643 /*
644 * The Expr being compared to the WindowFunc to use in the OpExpr in the
645 * WindowAgg's runCondition
646 */
649
650/*
651 * MergeSupportFunc
652 *
653 * A MergeSupportFunc is a merge support function expression that can only
654 * appear in the RETURNING list of a MERGE command. It returns information
655 * about the currently executing merge action.
656 *
657 * Currently, the only supported function is MERGE_ACTION(), which returns the
658 * command executed ("INSERT", "UPDATE", or "DELETE").
659 */
660typedef struct MergeSupportFunc
661{
663 /* type Oid of result */
665 /* OID of collation, or InvalidOid if none */
667 /* token location, or -1 if unknown */
670
671/*
672 * SubscriptingRef: describes a subscripting operation over a container
673 * (array, etc).
674 *
675 * A SubscriptingRef can describe fetching a single element from a container,
676 * fetching a part of a container (e.g. an array slice), storing a single
677 * element into a container, or storing a slice. The "store" cases work with
678 * an initial container value and a source value that is inserted into the
679 * appropriate part of the container; the result of the operation is an
680 * entire new modified container value.
681 *
682 * If reflowerindexpr = NIL, then we are fetching or storing a single container
683 * element at the subscripts given by refupperindexpr. Otherwise we are
684 * fetching or storing a container slice, that is a rectangular subcontainer
685 * with lower and upper bounds given by the index expressions.
686 * reflowerindexpr must be the same length as refupperindexpr when it
687 * is not NIL.
688 *
689 * In the slice case, individual expressions in the subscript lists can be
690 * NULL, meaning "substitute the array's current lower or upper bound".
691 * (Non-array containers may or may not support this.)
692 *
693 * refcontainertype is the actual container type that determines the
694 * subscripting semantics. (This will generally be either the exposed type of
695 * refexpr, or the base type if that is a domain.) refelemtype is the type of
696 * the container's elements; this is saved for the use of the subscripting
697 * functions, but is not used by the core code. refrestype, reftypmod, and
698 * refcollid describe the type of the SubscriptingRef's result. In a store
699 * expression, refrestype will always match refcontainertype; in a fetch,
700 * it could be refelemtype for an element fetch, or refcontainertype for a
701 * slice fetch, or possibly something else as determined by type-specific
702 * subscripting logic. Likewise, reftypmod and refcollid will match the
703 * container's properties in a store, but could be different in a fetch.
704 *
705 * Any internal state data is ignored for the query jumbling.
706 *
707 * Note: for the cases where a container is returned, if refexpr yields a R/W
708 * expanded container, then the implementation is allowed to modify that
709 * object in-place and return the same object.
710 */
711typedef struct SubscriptingRef
712{
714 /* type of the container proper */
715 Oid refcontainertype pg_node_attr(query_jumble_ignore);
716 /* the container type's pg_type.typelem */
717 Oid refelemtype pg_node_attr(query_jumble_ignore);
718 /* type of the SubscriptingRef's result */
719 Oid refrestype pg_node_attr(query_jumble_ignore);
720 /* typmod of the result */
721 int32 reftypmod pg_node_attr(query_jumble_ignore);
722 /* collation of result, or InvalidOid if none */
723 Oid refcollid pg_node_attr(query_jumble_ignore);
724 /* expressions that evaluate to upper container indexes */
726
727 /*
728 * expressions that evaluate to lower container indexes, or NIL for single
729 * container element.
730 */
732 /* the expression that evaluates to a container value */
734 /* expression for the source value, or NULL if fetch */
737
738/*
739 * CoercionContext - distinguishes the allowed set of type casts
740 *
741 * NB: ordering of the alternatives is significant; later (larger) values
742 * allow more casts than earlier ones.
743 */
744typedef enum CoercionContext
745{
746 COERCION_IMPLICIT, /* coercion in context of expression */
747 COERCION_ASSIGNMENT, /* coercion in context of assignment */
748 COERCION_PLPGSQL, /* if no assignment cast, use CoerceViaIO */
749 COERCION_EXPLICIT, /* explicit cast operation */
751
752/*
753 * CoercionForm - how to display a FuncExpr or related node
754 *
755 * "Coercion" is a bit of a misnomer, since this value records other
756 * special syntaxes besides casts, but for now we'll keep this naming.
757 *
758 * NB: equal() ignores CoercionForm fields, therefore this *must* not carry
759 * any semantically significant information. We need that behavior so that
760 * the planner will consider equivalent implicit and explicit casts to be
761 * equivalent. In cases where those actually behave differently, the coercion
762 * function's arguments will be different.
763 */
764typedef enum CoercionForm
765{
766 COERCE_EXPLICIT_CALL, /* display as a function call */
767 COERCE_EXPLICIT_CAST, /* display as an explicit cast */
768 COERCE_IMPLICIT_CAST, /* implicit cast, so hide it */
769 COERCE_SQL_SYNTAX, /* display with SQL-mandated special syntax */
771
772/*
773 * FuncExpr - expression node for a function call
774 *
775 * Collation information is irrelevant for the query jumbling, only the
776 * arguments and the function OID matter.
777 */
778typedef struct FuncExpr
779{
781 /* PG_PROC OID of the function */
783 /* PG_TYPE OID of result value */
784 Oid funcresulttype pg_node_attr(query_jumble_ignore);
785 /* true if function returns set */
786 bool funcretset pg_node_attr(query_jumble_ignore);
787
788 /*
789 * true if variadic arguments have been combined into an array last
790 * argument
791 */
792 bool funcvariadic pg_node_attr(query_jumble_ignore);
793 /* how to display this function call */
794 CoercionForm funcformat pg_node_attr(query_jumble_ignore);
795 /* OID of collation of result */
796 Oid funccollid pg_node_attr(query_jumble_ignore);
797 /* OID of collation that function should use */
798 Oid inputcollid pg_node_attr(query_jumble_ignore);
799 /* arguments to the function */
801 /* token location, or -1 if unknown */
804
805/*
806 * NamedArgExpr - a named argument of a function
807 *
808 * This node type can only appear in the args list of a FuncCall or FuncExpr
809 * node. We support pure positional call notation (no named arguments),
810 * named notation (all arguments are named), and mixed notation (unnamed
811 * arguments followed by named ones).
812 *
813 * Parse analysis sets argnumber to the positional index of the argument,
814 * but doesn't rearrange the argument list.
815 *
816 * The planner will convert argument lists to pure positional notation
817 * during expression preprocessing, so execution never sees a NamedArgExpr.
818 */
819typedef struct NamedArgExpr
820{
822 /* the argument expression */
824 /* the name */
825 char *name pg_node_attr(query_jumble_ignore);
826 /* argument's number in positional notation */
828 /* argument name location, or -1 if unknown */
831
832/*
833 * OpExpr - expression node for an operator invocation
834 *
835 * Semantically, this is essentially the same as a function call.
836 *
837 * Note that opfuncid is not necessarily filled in immediately on creation
838 * of the node. The planner makes sure it is valid before passing the node
839 * tree to the executor, but during parsing/planning opfuncid can be 0.
840 * Therefore, equal() will accept a zero value as being equal to other values.
841 *
842 * Internal state information and collation data is irrelevant for the query
843 * jumbling.
844 */
845typedef struct OpExpr
846{
848
849 /* PG_OPERATOR OID of the operator */
851
852 /* PG_PROC OID of underlying function */
853 Oid opfuncid pg_node_attr(equal_ignore_if_zero, query_jumble_ignore);
854
855 /* PG_TYPE OID of result value */
856 Oid opresulttype pg_node_attr(query_jumble_ignore);
857
858 /* true if operator returns set */
859 bool opretset pg_node_attr(query_jumble_ignore);
860
861 /* OID of collation of result */
862 Oid opcollid pg_node_attr(query_jumble_ignore);
863
864 /* OID of collation that operator should use */
865 Oid inputcollid pg_node_attr(query_jumble_ignore);
866
867 /* arguments to the operator (1 or 2) */
869
870 /* token location, or -1 if unknown */
873
874/*
875 * DistinctExpr - expression node for "x IS DISTINCT FROM y"
876 *
877 * Except for the nodetag, this is represented identically to an OpExpr
878 * referencing the "=" operator for x and y.
879 * We use "=", not the more obvious "<>", because more datatypes have "="
880 * than "<>". This means the executor must invert the operator result.
881 * Note that the operator function won't be called at all if either input
882 * is NULL, since then the result can be determined directly.
883 */
885
886/*
887 * NullIfExpr - a NULLIF expression
888 *
889 * Like DistinctExpr, this is represented the same as an OpExpr referencing
890 * the "=" operator for x and y.
891 */
893
894/*
895 * ScalarArrayOpExpr - expression node for "scalar op ANY/ALL (array)"
896 *
897 * The operator must yield boolean. It is applied to the left operand
898 * and each element of the righthand array, and the results are combined
899 * with OR or AND (for ANY or ALL respectively). The node representation
900 * is almost the same as for the underlying operator, but we need a useOr
901 * flag to remember whether it's ANY or ALL, and we don't have to store
902 * the result type (or the collation) because it must be boolean.
903 *
904 * A ScalarArrayOpExpr with a valid hashfuncid is evaluated during execution
905 * by building a hash table containing the Const values from the RHS arg.
906 * This table is probed during expression evaluation. The planner will set
907 * hashfuncid to the hash function which must be used to build and probe the
908 * hash table. The executor determines if it should use hash-based checks or
909 * the more traditional means based on if the hashfuncid is set or not.
910 *
911 * When performing hashed NOT IN, the negfuncid will also be set to the
912 * equality function which the hash table must use to build and probe the hash
913 * table. opno and opfuncid will remain set to the <> operator and its
914 * corresponding function and won't be used during execution. For
915 * non-hashtable based NOT INs, negfuncid will be set to InvalidOid. See
916 * convert_saop_to_hashed_saop().
917 *
918 * Similar to OpExpr, opfuncid, hashfuncid, and negfuncid are not necessarily
919 * filled in right away, so will be ignored for equality if they are not set
920 * yet.
921 *
922 * OID entries of the internal function types are irrelevant for the query
923 * jumbling, but the operator OID and the arguments are.
924 */
925typedef struct ScalarArrayOpExpr
926{
928
929 /* PG_OPERATOR OID of the operator */
931
932 /* PG_PROC OID of comparison function */
933 Oid opfuncid pg_node_attr(equal_ignore_if_zero, query_jumble_ignore);
934
935 /* PG_PROC OID of hash func or InvalidOid */
936 Oid hashfuncid pg_node_attr(equal_ignore_if_zero, query_jumble_ignore);
937
938 /* PG_PROC OID of negator of opfuncid function or InvalidOid. See above */
939 Oid negfuncid pg_node_attr(equal_ignore_if_zero, query_jumble_ignore);
940
941 /* true for ANY, false for ALL */
942 bool useOr;
943
944 /* OID of collation that operator should use */
945 Oid inputcollid pg_node_attr(query_jumble_ignore);
946
947 /* the scalar and array operands */
949
950 /* token location, or -1 if unknown */
953
954/*
955 * BoolExpr - expression node for the basic Boolean operators AND, OR, NOT
956 *
957 * Notice the arguments are given as a List. For NOT, of course the list
958 * must always have exactly one element. For AND and OR, there can be two
959 * or more arguments.
960 */
961typedef enum BoolExprType
962{
965
966typedef struct BoolExpr
967{
968 pg_node_attr(custom_read_write)
969
970 Expr xpr;
972 List *args; /* arguments to this expression */
973 ParseLoc location; /* token location, or -1 if unknown */
975
976/*
977 * SubLink
978 *
979 * A SubLink represents a subselect appearing in an expression, and in some
980 * cases also the combining operator(s) just above it. The subLinkType
981 * indicates the form of the expression represented:
982 * EXISTS_SUBLINK EXISTS(SELECT ...)
983 * ALL_SUBLINK (lefthand) op ALL (SELECT ...)
984 * ANY_SUBLINK (lefthand) op ANY (SELECT ...)
985 * ROWCOMPARE_SUBLINK (lefthand) op (SELECT ...)
986 * EXPR_SUBLINK (SELECT with single targetlist item ...)
987 * MULTIEXPR_SUBLINK (SELECT with multiple targetlist items ...)
988 * ARRAY_SUBLINK ARRAY(SELECT with single targetlist item ...)
989 * CTE_SUBLINK WITH query (never actually part of an expression)
990 * For ALL, ANY, and ROWCOMPARE, the lefthand is a list of expressions of the
991 * same length as the subselect's targetlist. ROWCOMPARE will *always* have
992 * a list with more than one entry; if the subselect has just one target
993 * then the parser will create an EXPR_SUBLINK instead (and any operator
994 * above the subselect will be represented separately).
995 * ROWCOMPARE, EXPR, and MULTIEXPR require the subselect to deliver at most
996 * one row (if it returns no rows, the result is NULL).
997 * ALL, ANY, and ROWCOMPARE require the combining operators to deliver boolean
998 * results. ALL and ANY combine the per-row results using AND and OR
999 * semantics respectively.
1000 * ARRAY requires just one target column, and creates an array of the target
1001 * column's type using any number of rows resulting from the subselect.
1002 *
1003 * SubLink is classed as an Expr node, but it is not actually executable;
1004 * it must be replaced in the expression tree by a SubPlan node during
1005 * planning.
1006 *
1007 * NOTE: in the raw output of gram.y, testexpr contains just the raw form
1008 * of the lefthand expression (if any), and operName is the String name of
1009 * the combining operator. Also, subselect is a raw parsetree. During parse
1010 * analysis, the parser transforms testexpr into a complete boolean expression
1011 * that compares the lefthand value(s) to PARAM_SUBLINK nodes representing the
1012 * output columns of the subselect. And subselect is transformed to a Query.
1013 * This is the representation seen in saved rules and in the rewriter.
1014 *
1015 * In EXISTS, EXPR, MULTIEXPR, and ARRAY SubLinks, testexpr and operName
1016 * are unused and are always null.
1017 *
1018 * subLinkId is currently used only for MULTIEXPR SubLinks, and is zero in
1019 * other SubLinks. This number identifies different multiple-assignment
1020 * subqueries within an UPDATE statement's SET list. It is unique only
1021 * within a particular targetlist. The output column(s) of the MULTIEXPR
1022 * are referenced by PARAM_MULTIEXPR Params appearing elsewhere in the tlist.
1023 *
1024 * The CTE_SUBLINK case never occurs in actual SubLink nodes, but it is used
1025 * in SubPlans generated for WITH subqueries.
1026 */
1027typedef enum SubLinkType
1028{
1036 CTE_SUBLINK, /* for SubPlans only */
1038
1039
1040typedef struct SubLink
1041{
1043 SubLinkType subLinkType; /* see above */
1044 int subLinkId; /* ID (1..n); 0 if not MULTIEXPR */
1045 Node *testexpr; /* outer-query test for ALL/ANY/ROWCOMPARE */
1046 /* originally specified operator name */
1047 List *operName pg_node_attr(query_jumble_ignore);
1048 /* subselect as Query* or raw parsetree */
1050 ParseLoc location; /* token location, or -1 if unknown */
1052
1053/*
1054 * SubPlan - executable expression node for a subplan (sub-SELECT)
1055 *
1056 * The planner replaces SubLink nodes in expression trees with SubPlan
1057 * nodes after it has finished planning the subquery. SubPlan references
1058 * a sub-plantree stored in the subplans list of the toplevel PlannedStmt.
1059 * (We avoid a direct link to make it easier to copy expression trees
1060 * without causing multiple processing of the subplan.)
1061 *
1062 * In an ordinary subplan, testexpr points to an executable expression
1063 * (OpExpr, an AND/OR tree of OpExprs, or RowCompareExpr) for the combining
1064 * operator(s); the left-hand arguments are the original lefthand expressions,
1065 * and the right-hand arguments are PARAM_EXEC Param nodes representing the
1066 * outputs of the sub-select. (NOTE: runtime coercion functions may be
1067 * inserted as well.) This is just the same expression tree as testexpr in
1068 * the original SubLink node, but the PARAM_SUBLINK nodes are replaced by
1069 * suitably numbered PARAM_EXEC nodes.
1070 *
1071 * If the sub-select becomes an initplan rather than a subplan, the executable
1072 * expression is part of the outer plan's expression tree (and the SubPlan
1073 * node itself is not, but rather is found in the outer plan's initPlan
1074 * list). In this case testexpr is NULL to avoid duplication.
1075 *
1076 * The planner also derives lists of the values that need to be passed into
1077 * and out of the subplan. Input values are represented as a list "args" of
1078 * expressions to be evaluated in the outer-query context (currently these
1079 * args are always just Vars, but in principle they could be any expression).
1080 * The values are assigned to the global PARAM_EXEC params indexed by parParam
1081 * (the parParam and args lists must have the same ordering). setParam is a
1082 * list of the PARAM_EXEC params that are computed by the sub-select, if it
1083 * is an initplan or MULTIEXPR plan; they are listed in order by sub-select
1084 * output column position. (parParam and setParam are integer Lists, not
1085 * Bitmapsets, because their ordering is significant.)
1086 *
1087 * Also, the planner computes startup and per-call costs for use of the
1088 * SubPlan. Note that these include the cost of the subquery proper,
1089 * evaluation of the testexpr if any, and any hashtable management overhead.
1090 */
1091typedef struct SubPlan
1092{
1093 pg_node_attr(no_query_jumble)
1094
1095 Expr xpr;
1096 /* Fields copied from original SubLink: */
1097 SubLinkType subLinkType; /* see above */
1098 /* The combining operators, transformed to an executable expression: */
1099 Node *testexpr; /* OpExpr or RowCompareExpr expression tree */
1100 List *paramIds; /* IDs of Params embedded in the above */
1101 /* Identification of the Plan tree to use: */
1102 int plan_id; /* Index (from 1) in PlannedStmt.subplans */
1103 /* Identification of the SubPlan for EXPLAIN and debugging purposes: */
1104 char *plan_name; /* A name assigned during planning */
1105 /* Extra data useful for determining subplan's output type: */
1106 Oid firstColType; /* Type of first column of subplan result */
1107 int32 firstColTypmod; /* Typmod of first column of subplan result */
1108 Oid firstColCollation; /* Collation of first column of subplan
1109 * result */
1110 /* Information about execution strategy: */
1111 bool isInitPlan; /* true if it's an InitPlan */
1112 bool useHashTable; /* true to store subselect output in a hash
1113 * table (implies we are doing "IN") */
1114 bool unknownEqFalse; /* true if it's okay to return FALSE when the
1115 * spec result is UNKNOWN; this allows much
1116 * simpler handling of null values */
1117 bool parallel_safe; /* is the subplan parallel-safe? */
1118 /* Note: parallel_safe does not consider contents of testexpr or args */
1119 /* Information for passing params into and out of the subselect: */
1120 /* setParam and parParam are lists of integers (param IDs) */
1121 List *setParam; /* initplan and MULTIEXPR subqueries have to
1122 * set these Params for parent plan */
1123 List *parParam; /* indices of input Params from parent plan */
1124 List *args; /* exprs to pass as parParam values */
1125 /* Estimated execution costs: */
1126 Cost startup_cost; /* one-time setup cost */
1127 Cost per_call_cost; /* cost for each subplan evaluation */
1129
1130/*
1131 * AlternativeSubPlan - expression node for a choice among SubPlans
1132 *
1133 * This is used only transiently during planning: by the time the plan
1134 * reaches the executor, all AlternativeSubPlan nodes have been removed.
1135 *
1136 * The subplans are given as a List so that the node definition need not
1137 * change if there's ever more than two alternatives. For the moment,
1138 * though, there are always exactly two; and the first one is the fast-start
1139 * plan.
1140 */
1142{
1143 pg_node_attr(no_query_jumble)
1144
1145 Expr xpr;
1146 List *subplans; /* SubPlan(s) with equivalent results */
1148
1149/* ----------------
1150 * FieldSelect
1151 *
1152 * FieldSelect represents the operation of extracting one field from a tuple
1153 * value. At runtime, the input expression is expected to yield a rowtype
1154 * Datum. The specified field number is extracted and returned as a Datum.
1155 * ----------------
1156 */
1157
1158typedef struct FieldSelect
1159{
1161 Expr *arg; /* input expression */
1162 AttrNumber fieldnum; /* attribute number of field to extract */
1163 /* type of the field (result type of this node) */
1164 Oid resulttype pg_node_attr(query_jumble_ignore);
1165 /* output typmod (usually -1) */
1166 int32 resulttypmod pg_node_attr(query_jumble_ignore);
1167 /* OID of collation of the field */
1168 Oid resultcollid pg_node_attr(query_jumble_ignore);
1170
1171/* ----------------
1172 * FieldStore
1173 *
1174 * FieldStore represents the operation of modifying one field in a tuple
1175 * value, yielding a new tuple value (the input is not touched!). Like
1176 * the assign case of SubscriptingRef, this is used to implement UPDATE of a
1177 * portion of a column.
1178 *
1179 * resulttype is always a named composite type (not a domain). To update
1180 * a composite domain value, apply CoerceToDomain to the FieldStore.
1181 *
1182 * A single FieldStore can actually represent updates of several different
1183 * fields. The parser only generates FieldStores with single-element lists,
1184 * but the planner will collapse multiple updates of the same base column
1185 * into one FieldStore.
1186 * ----------------
1187 */
1188
1189typedef struct FieldStore
1190{
1192 Expr *arg; /* input tuple value */
1193 List *newvals; /* new value(s) for field(s) */
1194 /* integer list of field attnums */
1195 List *fieldnums pg_node_attr(query_jumble_ignore);
1196 /* type of result (same as type of arg) */
1197 Oid resulttype pg_node_attr(query_jumble_ignore);
1198 /* Like RowExpr, we deliberately omit a typmod and collation here */
1200
1201/* ----------------
1202 * RelabelType
1203 *
1204 * RelabelType represents a "dummy" type coercion between two binary-
1205 * compatible datatypes, such as reinterpreting the result of an OID
1206 * expression as an int4. It is a no-op at runtime; we only need it
1207 * to provide a place to store the correct type to be attributed to
1208 * the expression result during type resolution. (We can't get away
1209 * with just overwriting the type field of the input expression node,
1210 * so we need a separate node to show the coercion's result type.)
1211 * ----------------
1212 */
1213
1214typedef struct RelabelType
1215{
1217 Expr *arg; /* input expression */
1218 Oid resulttype; /* output type of coercion expression */
1219 /* output typmod (usually -1) */
1220 int32 resulttypmod pg_node_attr(query_jumble_ignore);
1221 /* OID of collation, or InvalidOid if none */
1222 Oid resultcollid pg_node_attr(query_jumble_ignore);
1223 /* how to display this node */
1224 CoercionForm relabelformat pg_node_attr(query_jumble_ignore);
1225 ParseLoc location; /* token location, or -1 if unknown */
1227
1228/* ----------------
1229 * CoerceViaIO
1230 *
1231 * CoerceViaIO represents a type coercion between two types whose textual
1232 * representations are compatible, implemented by invoking the source type's
1233 * typoutput function then the destination type's typinput function.
1234 * ----------------
1235 */
1236
1237typedef struct CoerceViaIO
1238{
1240 Expr *arg; /* input expression */
1241 Oid resulttype; /* output type of coercion */
1242 /* output typmod is not stored, but is presumed -1 */
1243 /* OID of collation, or InvalidOid if none */
1244 Oid resultcollid pg_node_attr(query_jumble_ignore);
1245 /* how to display this node */
1246 CoercionForm coerceformat pg_node_attr(query_jumble_ignore);
1247 ParseLoc location; /* token location, or -1 if unknown */
1249
1250/* ----------------
1251 * ArrayCoerceExpr
1252 *
1253 * ArrayCoerceExpr represents a type coercion from one array type to another,
1254 * which is implemented by applying the per-element coercion expression
1255 * "elemexpr" to each element of the source array. Within elemexpr, the
1256 * source element is represented by a CaseTestExpr node. Note that even if
1257 * elemexpr is a no-op (that is, just CaseTestExpr + RelabelType), the
1258 * coercion still requires some effort: we have to fix the element type OID
1259 * stored in the array header.
1260 * ----------------
1261 */
1262
1263typedef struct ArrayCoerceExpr
1264{
1266 Expr *arg; /* input expression (yields an array) */
1267 Expr *elemexpr; /* expression representing per-element work */
1268 Oid resulttype; /* output type of coercion (an array type) */
1269 /* output typmod (also element typmod) */
1270 int32 resulttypmod pg_node_attr(query_jumble_ignore);
1271 /* OID of collation, or InvalidOid if none */
1272 Oid resultcollid pg_node_attr(query_jumble_ignore);
1273 /* how to display this node */
1274 CoercionForm coerceformat pg_node_attr(query_jumble_ignore);
1275 ParseLoc location; /* token location, or -1 if unknown */
1277
1278/* ----------------
1279 * ConvertRowtypeExpr
1280 *
1281 * ConvertRowtypeExpr represents a type coercion from one composite type
1282 * to another, where the source type is guaranteed to contain all the columns
1283 * needed for the destination type plus possibly others; the columns need not
1284 * be in the same positions, but are matched up by name. This is primarily
1285 * used to convert a whole-row value of an inheritance child table into a
1286 * valid whole-row value of its parent table's rowtype. Both resulttype
1287 * and the exposed type of "arg" must be named composite types (not domains).
1288 * ----------------
1289 */
1290
1292{
1294 Expr *arg; /* input expression */
1295 Oid resulttype; /* output type (always a composite type) */
1296 /* Like RowExpr, we deliberately omit a typmod and collation here */
1297 /* how to display this node */
1298 CoercionForm convertformat pg_node_attr(query_jumble_ignore);
1299 ParseLoc location; /* token location, or -1 if unknown */
1301
1302/*----------
1303 * CollateExpr - COLLATE
1304 *
1305 * The planner replaces CollateExpr with RelabelType during expression
1306 * preprocessing, so execution never sees a CollateExpr.
1307 *----------
1308 */
1309typedef struct CollateExpr
1310{
1312 Expr *arg; /* input expression */
1313 Oid collOid; /* collation's OID */
1314 ParseLoc location; /* token location, or -1 if unknown */
1316
1317/*----------
1318 * CaseExpr - a CASE expression
1319 *
1320 * We support two distinct forms of CASE expression:
1321 * CASE WHEN boolexpr THEN expr [ WHEN boolexpr THEN expr ... ]
1322 * CASE testexpr WHEN compexpr THEN expr [ WHEN compexpr THEN expr ... ]
1323 * These are distinguishable by the "arg" field being NULL in the first case
1324 * and the testexpr in the second case.
1325 *
1326 * In the raw grammar output for the second form, the condition expressions
1327 * of the WHEN clauses are just the comparison values. Parse analysis
1328 * converts these to valid boolean expressions of the form
1329 * CaseTestExpr '=' compexpr
1330 * where the CaseTestExpr node is a placeholder that emits the correct
1331 * value at runtime. This structure is used so that the testexpr need be
1332 * evaluated only once. Note that after parse analysis, the condition
1333 * expressions always yield boolean.
1334 *
1335 * Note: we can test whether a CaseExpr has been through parse analysis
1336 * yet by checking whether casetype is InvalidOid or not.
1337 *----------
1338 */
1339typedef struct CaseExpr
1340{
1342 /* type of expression result */
1343 Oid casetype pg_node_attr(query_jumble_ignore);
1344 /* OID of collation, or InvalidOid if none */
1345 Oid casecollid pg_node_attr(query_jumble_ignore);
1346 Expr *arg; /* implicit equality comparison argument */
1347 List *args; /* the arguments (list of WHEN clauses) */
1348 Expr *defresult; /* the default result (ELSE clause) */
1349 ParseLoc location; /* token location, or -1 if unknown */
1351
1352/*
1353 * CaseWhen - one arm of a CASE expression
1354 */
1355typedef struct CaseWhen
1356{
1358 Expr *expr; /* condition expression */
1359 Expr *result; /* substitution result */
1360 ParseLoc location; /* token location, or -1 if unknown */
1362
1363/*
1364 * Placeholder node for the test value to be processed by a CASE expression.
1365 * This is effectively like a Param, but can be implemented more simply
1366 * since we need only one replacement value at a time.
1367 *
1368 * We also abuse this node type for some other purposes, including:
1369 * * Placeholder for the current array element value in ArrayCoerceExpr;
1370 * see build_coercion_expression().
1371 * * Nested FieldStore/SubscriptingRef assignment expressions in INSERT/UPDATE;
1372 * see transformAssignmentIndirection().
1373 * * Placeholder for intermediate results in some SQL/JSON expression nodes,
1374 * such as JsonConstructorExpr.
1375 *
1376 * The uses in CaseExpr and ArrayCoerceExpr are safe only to the extent that
1377 * there is not any other CaseExpr or ArrayCoerceExpr between the value source
1378 * node and its child CaseTestExpr(s). This is true in the parse analysis
1379 * output, but the planner's function-inlining logic has to be careful not to
1380 * break it.
1381 *
1382 * The nested-assignment-expression case is safe because the only node types
1383 * that can be above such CaseTestExprs are FieldStore and SubscriptingRef.
1384 */
1385typedef struct CaseTestExpr
1386{
1388 Oid typeId; /* type for substituted value */
1389 /* typemod for substituted value */
1390 int32 typeMod pg_node_attr(query_jumble_ignore);
1391 /* collation for the substituted value */
1392 Oid collation pg_node_attr(query_jumble_ignore);
1394
1395/*
1396 * ArrayExpr - an ARRAY[] expression
1397 *
1398 * Note: if multidims is false, the constituent expressions all yield the
1399 * scalar type identified by element_typeid. If multidims is true, the
1400 * constituent expressions all yield arrays of element_typeid (ie, the same
1401 * type as array_typeid); at runtime we must check for compatible subscripts.
1402 */
1403typedef struct ArrayExpr
1404{
1406 /* type of expression result */
1407 Oid array_typeid pg_node_attr(query_jumble_ignore);
1408 /* OID of collation, or InvalidOid if none */
1409 Oid array_collid pg_node_attr(query_jumble_ignore);
1410 /* common type of array elements */
1411 Oid element_typeid pg_node_attr(query_jumble_ignore);
1412 /* the array elements or sub-arrays */
1413 List *elements pg_node_attr(query_jumble_squash);
1414 /* true if elements are sub-arrays */
1415 bool multidims pg_node_attr(query_jumble_ignore);
1416 /* location of the start of the elements list */
1418 /* location of the end of the elements list */
1420 /* token location, or -1 if unknown */
1423
1424/*
1425 * RowExpr - a ROW() expression
1426 *
1427 * Note: the list of fields must have a one-for-one correspondence with
1428 * physical fields of the associated rowtype, although it is okay for it
1429 * to be shorter than the rowtype. That is, the N'th list element must
1430 * match up with the N'th physical field. When the N'th physical field
1431 * is a dropped column (attisdropped) then the N'th list element can just
1432 * be a NULL constant. (This case can only occur for named composite types,
1433 * not RECORD types, since those are built from the RowExpr itself rather
1434 * than vice versa.) It is important not to assume that length(args) is
1435 * the same as the number of columns logically present in the rowtype.
1436 *
1437 * colnames provides field names if the ROW() result is of type RECORD.
1438 * Names *must* be provided if row_typeid is RECORDOID; but if it is a
1439 * named composite type, colnames will be ignored in favor of using the
1440 * type's cataloged field names, so colnames should be NIL. Like the
1441 * args list, colnames is defined to be one-for-one with physical fields
1442 * of the rowtype (although dropped columns shouldn't appear in the
1443 * RECORD case, so this fine point is currently moot).
1444 */
1445typedef struct RowExpr
1446{
1448 List *args; /* the fields */
1449
1450 /* RECORDOID or a composite type's ID */
1451 Oid row_typeid pg_node_attr(query_jumble_ignore);
1452
1453 /*
1454 * row_typeid cannot be a domain over composite, only plain composite. To
1455 * create a composite domain value, apply CoerceToDomain to the RowExpr.
1456 *
1457 * Note: we deliberately do NOT store a typmod. Although a typmod will be
1458 * associated with specific RECORD types at runtime, it will differ for
1459 * different backends, and so cannot safely be stored in stored
1460 * parsetrees. We must assume typmod -1 for a RowExpr node.
1461 *
1462 * We don't need to store a collation either. The result type is
1463 * necessarily composite, and composite types never have a collation.
1464 */
1465
1466 /* how to display this node */
1467 CoercionForm row_format pg_node_attr(query_jumble_ignore);
1468
1469 /* list of String, or NIL */
1470 List *colnames pg_node_attr(query_jumble_ignore);
1471
1472 ParseLoc location; /* token location, or -1 if unknown */
1474
1475/*
1476 * RowCompareExpr - row-wise comparison, such as (a, b) <= (1, 2)
1477 *
1478 * We support row comparison for any operator that can be determined to
1479 * act like =, <>, <, <=, >, or >= (we determine this by looking for the
1480 * operator in btree opfamilies). Note that the same operator name might
1481 * map to a different operator for each pair of row elements, since the
1482 * element datatypes can vary.
1483 *
1484 * A RowCompareExpr node is only generated for the < <= > >= cases;
1485 * the = and <> cases are translated to simple AND or OR combinations
1486 * of the pairwise comparisons.
1487 */
1488typedef struct RowCompareExpr
1489{
1491
1492 /* LT LE GE or GT, never EQ or NE */
1494 /* OID list of pairwise comparison ops */
1495 List *opnos pg_node_attr(query_jumble_ignore);
1496 /* OID list of containing operator families */
1497 List *opfamilies pg_node_attr(query_jumble_ignore);
1498 /* OID list of collations for comparisons */
1499 List *inputcollids pg_node_attr(query_jumble_ignore);
1500 /* the left-hand input arguments */
1502 /* the right-hand input arguments */
1505
1506/*
1507 * CoalesceExpr - a COALESCE expression
1508 */
1509typedef struct CoalesceExpr
1510{
1512 /* type of expression result */
1513 Oid coalescetype pg_node_attr(query_jumble_ignore);
1514 /* OID of collation, or InvalidOid if none */
1515 Oid coalescecollid pg_node_attr(query_jumble_ignore);
1516 /* the arguments */
1518 /* token location, or -1 if unknown */
1521
1522/*
1523 * MinMaxExpr - a GREATEST or LEAST function
1524 */
1525typedef enum MinMaxOp
1526{
1528 IS_LEAST
1530
1531typedef struct MinMaxExpr
1532{
1534 /* common type of arguments and result */
1535 Oid minmaxtype pg_node_attr(query_jumble_ignore);
1536 /* OID of collation of result */
1537 Oid minmaxcollid pg_node_attr(query_jumble_ignore);
1538 /* OID of collation that function should use */
1539 Oid inputcollid pg_node_attr(query_jumble_ignore);
1540 /* function to execute */
1542 /* the arguments */
1544 /* token location, or -1 if unknown */
1547
1548/*
1549 * SQLValueFunction - parameterless functions with special grammar productions
1550 *
1551 * The SQL standard categorizes some of these as <datetime value function>
1552 * and others as <general value specification>. We call 'em SQLValueFunctions
1553 * for lack of a better term. We store type and typmod of the result so that
1554 * some code doesn't need to know each function individually, and because
1555 * we would need to store typmod anyway for some of the datetime functions.
1556 * Note that currently, all variants return non-collating datatypes, so we do
1557 * not need a collation field; also, all these functions are stable.
1558 */
1560{
1577
1578typedef struct SQLValueFunction
1579{
1581 SQLValueFunctionOp op; /* which function this is */
1582
1583 /*
1584 * Result type/typmod. Type is fully determined by "op", so no need to
1585 * include this Oid in the query jumbling.
1586 */
1587 Oid type pg_node_attr(query_jumble_ignore);
1589 ParseLoc location; /* token location, or -1 if unknown */
1591
1592/*
1593 * XmlExpr - various SQL/XML functions requiring special grammar productions
1594 *
1595 * 'name' carries the "NAME foo" argument (already XML-escaped).
1596 * 'named_args' and 'arg_names' represent an xml_attribute list.
1597 * 'args' carries all other arguments.
1598 *
1599 * Note: result type/typmod/collation are not stored, but can be deduced
1600 * from the XmlExprOp. The type/typmod fields are just used for display
1601 * purposes, and are NOT necessarily the true result type of the node.
1602 */
1603typedef enum XmlExprOp
1604{
1605 IS_XMLCONCAT, /* XMLCONCAT(args) */
1606 IS_XMLELEMENT, /* XMLELEMENT(name, xml_attributes, args) */
1607 IS_XMLFOREST, /* XMLFOREST(xml_attributes) */
1608 IS_XMLPARSE, /* XMLPARSE(text, is_doc, preserve_ws) */
1609 IS_XMLPI, /* XMLPI(name [, args]) */
1610 IS_XMLROOT, /* XMLROOT(xml, version, standalone) */
1611 IS_XMLSERIALIZE, /* XMLSERIALIZE(is_document, xmlval, indent) */
1612 IS_DOCUMENT, /* xmlval IS DOCUMENT */
1614
1615typedef enum XmlOptionType
1616{
1620
1621typedef struct XmlExpr
1622{
1624 /* xml function ID */
1626 /* name in xml(NAME foo ...) syntaxes */
1627 char *name pg_node_attr(query_jumble_ignore);
1628 /* non-XML expressions for xml_attributes */
1630 /* parallel list of String values */
1631 List *arg_names pg_node_attr(query_jumble_ignore);
1632 /* list of expressions */
1634 /* DOCUMENT or CONTENT */
1636 /* INDENT option for XMLSERIALIZE */
1638 /* target type/typmod for XMLSERIALIZE */
1639 Oid type pg_node_attr(query_jumble_ignore);
1640 int32 typmod pg_node_attr(query_jumble_ignore);
1641 /* token location, or -1 if unknown */
1644
1645/*
1646 * JsonEncoding -
1647 * representation of JSON ENCODING clause
1648 */
1649typedef enum JsonEncoding
1650{
1651 JS_ENC_DEFAULT, /* unspecified */
1656
1657/*
1658 * JsonFormatType -
1659 * enumeration of JSON formats used in JSON FORMAT clause
1660 */
1661typedef enum JsonFormatType
1662{
1663 JS_FORMAT_DEFAULT, /* unspecified */
1664 JS_FORMAT_JSON, /* FORMAT JSON [ENCODING ...] */
1665 JS_FORMAT_JSONB, /* implicit internal format for RETURNING
1666 * jsonb */
1668
1669/*
1670 * JsonFormat -
1671 * representation of JSON FORMAT clause
1672 */
1673typedef struct JsonFormat
1674{
1676 JsonFormatType format_type; /* format type */
1677 JsonEncoding encoding; /* JSON encoding */
1678 ParseLoc location; /* token location, or -1 if unknown */
1680
1681/*
1682 * JsonReturning -
1683 * transformed representation of JSON RETURNING clause
1684 */
1685typedef struct JsonReturning
1686{
1688 JsonFormat *format; /* output JSON format */
1689 Oid typid; /* target type Oid */
1690 int32 typmod; /* target type modifier */
1692
1693/*
1694 * JsonValueExpr -
1695 * representation of JSON value expression (expr [FORMAT JsonFormat])
1696 *
1697 * raw_expr is the user-specified value, while formatted_expr is the value
1698 * obtained by coercing raw_expr to the type required by either the FORMAT
1699 * clause or an enclosing node's RETURNING clause.
1700 *
1701 * When deparsing a JsonValueExpr, get_rule_expr() prints raw_expr. However,
1702 * during the evaluation of a JsonValueExpr, the value of formatted_expr
1703 * takes precedence over that of raw_expr.
1704 */
1705typedef struct JsonValueExpr
1706{
1708 Expr *raw_expr; /* user-specified expression */
1709 Expr *formatted_expr; /* coerced formatted expression */
1710 JsonFormat *format; /* FORMAT clause, if specified */
1712
1714{
1723
1724/*
1725 * JsonConstructorExpr -
1726 * wrapper over FuncExpr/Aggref/WindowFunc for SQL/JSON constructors
1727 */
1729{
1731 JsonConstructorType type; /* constructor type */
1733 Expr *func; /* underlying json[b]_xxx() function call */
1734 Expr *coercion; /* coercion to RETURNING type */
1735 JsonReturning *returning; /* RETURNING clause */
1736 bool absent_on_null; /* ABSENT ON NULL? */
1737 bool unique; /* WITH UNIQUE KEYS? (JSON_OBJECT[AGG] only) */
1740
1741/*
1742 * JsonValueType -
1743 * representation of JSON item type in IS JSON predicate
1744 */
1745typedef enum JsonValueType
1746{
1747 JS_TYPE_ANY, /* IS JSON [VALUE] */
1748 JS_TYPE_OBJECT, /* IS JSON OBJECT */
1749 JS_TYPE_ARRAY, /* IS JSON ARRAY */
1750 JS_TYPE_SCALAR, /* IS JSON SCALAR */
1752
1753/*
1754 * JsonIsPredicate -
1755 * representation of IS JSON predicate
1756 */
1757typedef struct JsonIsPredicate
1758{
1760 Node *expr; /* subject expression */
1761 JsonFormat *format; /* FORMAT clause, if specified */
1762 JsonValueType item_type; /* JSON item type */
1763 bool unique_keys; /* check key uniqueness? */
1764 ParseLoc location; /* token location, or -1 if unknown */
1766
1767/* Nodes used in SQL/JSON query functions */
1768
1769/*
1770 * JsonWrapper -
1771 * representation of WRAPPER clause for JSON_QUERY()
1772 */
1773typedef enum JsonWrapper
1774{
1780
1781/*
1782 * JsonBehaviorType -
1783 * enumeration of behavior types used in SQL/JSON ON ERROR/EMPTY clauses
1784 *
1785 * If enum members are reordered, get_json_behavior() from ruleutils.c
1786 * must be updated accordingly.
1787 */
1789{
1800
1801/*
1802 * JsonBehavior
1803 * Specifications for ON ERROR / ON EMPTY behaviors of SQL/JSON
1804 * query functions specified by a JsonExpr
1805 *
1806 * 'expr' is the expression to emit when a given behavior (EMPTY or ERROR)
1807 * occurs on evaluating the SQL/JSON query function. 'coerce' is set to true
1808 * if 'expr' isn't already of the expected target type given by
1809 * JsonExpr.returning.
1810 */
1811typedef struct JsonBehavior
1812{
1814
1818 ParseLoc location; /* token location, or -1 if unknown */
1820
1821/*
1822 * JsonExprOp -
1823 * enumeration of SQL/JSON query function types
1824 */
1825typedef enum JsonExprOp
1826{
1827 JSON_EXISTS_OP, /* JSON_EXISTS() */
1828 JSON_QUERY_OP, /* JSON_QUERY() */
1829 JSON_VALUE_OP, /* JSON_VALUE() */
1830 JSON_TABLE_OP, /* JSON_TABLE() */
1832
1833/*
1834 * JsonExpr -
1835 * Transformed representation of JSON_VALUE(), JSON_QUERY(), and
1836 * JSON_EXISTS()
1837 */
1838typedef struct JsonExpr
1839{
1841
1843
1844 char *column_name; /* JSON_TABLE() column name or NULL if this is
1845 * not for a JSON_TABLE() */
1846
1847 /* jsonb-valued expression to query */
1849
1850 /* Format of the above expression needed by ruleutils.c */
1852
1853 /* jsonpath-valued expression containing the query pattern */
1855
1856 /* Expected type/format of the output. */
1858
1859 /* Information about the PASSING argument expressions */
1862
1863 /* User-specified or default ON EMPTY and ON ERROR behaviors */
1866
1867 /*
1868 * Information about converting the result of jsonpath functions
1869 * JsonPathQuery() and JsonPathValue() to the RETURNING type.
1870 */
1873
1874 /* WRAPPER specification for JSON_QUERY */
1876
1877 /* KEEP or OMIT QUOTES for singleton scalars returned by JSON_QUERY() */
1879
1880 /* JsonExpr's collation. */
1882
1883 /* Original JsonFuncExpr's location */
1886
1887/*
1888 * JsonTablePath
1889 * A JSON path expression to be computed as part of evaluating
1890 * a JSON_TABLE plan node
1891 */
1892typedef struct JsonTablePath
1893{
1895
1897 char *name;
1899
1900/*
1901 * JsonTablePlan -
1902 * Abstract class to represent different types of JSON_TABLE "plans".
1903 * A plan is used to generate a "row pattern" value by evaluating a JSON
1904 * path expression against an input JSON document, which is then used for
1905 * populating JSON_TABLE() columns
1906 */
1907typedef struct JsonTablePlan
1908{
1910
1911 NodeTag type;
1913
1914/*
1915 * JSON_TABLE plan to evaluate a JSON path expression and NESTED paths, if
1916 * any.
1917 */
1918typedef struct JsonTablePathScan
1919{
1921
1922 /* JSON path to evaluate */
1924
1925 /*
1926 * ERROR/EMPTY ON ERROR behavior; only significant in the plan for the
1927 * top-level path.
1928 */
1930
1931 /* Plan(s) for nested columns, if any. */
1933
1934 /*
1935 * 0-based index in TableFunc.colvalexprs of the 1st and the last column
1936 * covered by this plan. Both are -1 if all columns are nested and thus
1937 * computed by the child plan(s).
1938 */
1942
1943/*
1944 * JsonTableSiblingJoin -
1945 * Plan to join rows of sibling NESTED COLUMNS clauses in the same parent
1946 * COLUMNS clause
1947 */
1949{
1951
1955
1956/* ----------------
1957 * NullTest
1958 *
1959 * NullTest represents the operation of testing a value for NULLness.
1960 * The appropriate test is performed and returned as a boolean Datum.
1961 *
1962 * When argisrow is false, this simply represents a test for the null value.
1963 *
1964 * When argisrow is true, the input expression must yield a rowtype, and
1965 * the node implements "row IS [NOT] NULL" per the SQL standard. This
1966 * includes checking individual fields for NULLness when the row datum
1967 * itself isn't NULL.
1968 *
1969 * NOTE: the combination of a rowtype input and argisrow==false does NOT
1970 * correspond to the SQL notation "row IS [NOT] NULL"; instead, this case
1971 * represents the SQL notation "row IS [NOT] DISTINCT FROM NULL".
1972 * ----------------
1973 */
1974
1975typedef enum NullTestType
1976{
1979
1980typedef struct NullTest
1981{
1983 Expr *arg; /* input expression */
1984 NullTestType nulltesttype; /* IS NULL, IS NOT NULL */
1985 /* T to perform field-by-field null checks */
1986 bool argisrow pg_node_attr(query_jumble_ignore);
1987 ParseLoc location; /* token location, or -1 if unknown */
1989
1990/*
1991 * BooleanTest
1992 *
1993 * BooleanTest represents the operation of determining whether a boolean
1994 * is TRUE, FALSE, or UNKNOWN (ie, NULL). All six meaningful combinations
1995 * are supported. Note that a NULL input does *not* cause a NULL result.
1996 * The appropriate test is performed and returned as a boolean Datum.
1997 */
1998
1999typedef enum BoolTestType
2000{
2003
2004typedef struct BooleanTest
2005{
2007 Expr *arg; /* input expression */
2009 ParseLoc location; /* token location, or -1 if unknown */
2011
2012
2013/*
2014 * MergeAction
2015 *
2016 * Transformed representation of a WHEN clause in a MERGE statement
2017 */
2018
2019typedef enum MergeMatchKind
2020{
2025
2026#define NUM_MERGE_MATCH_KINDS (MERGE_WHEN_NOT_MATCHED_BY_TARGET + 1)
2027
2028typedef struct MergeAction
2029{
2031 MergeMatchKind matchKind; /* MATCHED/NOT MATCHED BY SOURCE/TARGET */
2032 CmdType commandType; /* INSERT/UPDATE/DELETE/DO NOTHING */
2033 /* OVERRIDING clause */
2034 OverridingKind override pg_node_attr(query_jumble_ignore);
2035 Node *qual; /* transformed WHEN conditions */
2036 List *targetList; /* the target list (of TargetEntry) */
2037 /* target attribute numbers of an UPDATE */
2038 List *updateColnos pg_node_attr(query_jumble_ignore);
2040
2041/*
2042 * CoerceToDomain
2043 *
2044 * CoerceToDomain represents the operation of coercing a value to a domain
2045 * type. At runtime (and not before) the precise set of constraints to be
2046 * checked will be determined. If the value passes, it is returned as the
2047 * result; if not, an error is raised. Note that this is equivalent to
2048 * RelabelType in the scenario where no constraints are applied.
2049 */
2050typedef struct CoerceToDomain
2051{
2053 Expr *arg; /* input expression */
2054 Oid resulttype; /* domain type ID (result type) */
2055 /* output typmod (currently always -1) */
2056 int32 resulttypmod pg_node_attr(query_jumble_ignore);
2057 /* OID of collation, or InvalidOid if none */
2058 Oid resultcollid pg_node_attr(query_jumble_ignore);
2059 /* how to display this node */
2060 CoercionForm coercionformat pg_node_attr(query_jumble_ignore);
2061 ParseLoc location; /* token location, or -1 if unknown */
2063
2064/*
2065 * Placeholder node for the value to be processed by a domain's check
2066 * constraint. This is effectively like a Param, but can be implemented more
2067 * simply since we need only one replacement value at a time.
2068 *
2069 * Note: the typeId/typeMod/collation will be set from the domain's base type,
2070 * not the domain itself. This is because we shouldn't consider the value
2071 * to be a member of the domain if we haven't yet checked its constraints.
2072 */
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 * Placeholder node for a DEFAULT marker in an INSERT or UPDATE command.
2088 *
2089 * This is not an executable expression: it must be replaced by the actual
2090 * column default expression during rewriting. But it is convenient to
2091 * treat it as an expression node during parsing and rewriting.
2092 */
2093typedef struct SetToDefault
2094{
2096 /* type for substituted value */
2098 /* typemod for substituted value */
2099 int32 typeMod pg_node_attr(query_jumble_ignore);
2100 /* collation for the substituted value */
2101 Oid collation pg_node_attr(query_jumble_ignore);
2102 /* token location, or -1 if unknown */
2105
2106/*
2107 * Node representing [WHERE] CURRENT OF cursor_name
2108 *
2109 * CURRENT OF is a bit like a Var, in that it carries the rangetable index
2110 * of the target relation being constrained; this aids placing the expression
2111 * correctly during planning. We can assume however that its "levelsup" is
2112 * always zero, due to the syntactic constraints on where it can appear.
2113 * Also, cvarno will always be a true RT index, never INNER_VAR etc.
2114 *
2115 * The referenced cursor can be represented either as a hardwired string
2116 * or as a reference to a run-time parameter of type REFCURSOR. The latter
2117 * case is for the convenience of plpgsql.
2118 */
2119typedef struct CurrentOfExpr
2120{
2122 Index cvarno; /* RT index of target relation */
2123 char *cursor_name; /* name of referenced cursor, or NULL */
2124 int cursor_param; /* refcursor parameter number, or 0 */
2126
2127/*
2128 * NextValueExpr - get next value from sequence
2129 *
2130 * This has the same effect as calling the nextval() function, but it does not
2131 * check permissions on the sequence. This is used for identity columns,
2132 * where the sequence is an implicit dependency without its own permissions.
2133 */
2134typedef struct NextValueExpr
2135{
2140
2141/*
2142 * InferenceElem - an element of a unique index inference specification
2143 *
2144 * This mostly matches the structure of IndexElems, but having a dedicated
2145 * primnode allows for a clean separation between the use of index parameters
2146 * by utility commands, and this node.
2147 */
2148typedef struct InferenceElem
2149{
2151 Node *expr; /* expression to infer from, or NULL */
2152 Oid infercollid; /* OID of collation, or InvalidOid */
2153 Oid inferopclass; /* OID of att opclass, or InvalidOid */
2155
2156/*
2157 * ReturningExpr - return OLD/NEW.(expression) in RETURNING list
2158 *
2159 * This is used when updating an auto-updatable view and returning a view
2160 * column that is not simply a Var referring to the base relation. In such
2161 * cases, OLD/NEW.viewcol can expand to an arbitrary expression, but the
2162 * result is required to be NULL if the OLD/NEW row doesn't exist. To handle
2163 * this, the rewriter wraps the expanded expression in a ReturningExpr, which
2164 * is equivalent to "CASE WHEN (OLD/NEW row exists) THEN (expr) ELSE NULL".
2165 *
2166 * A similar situation can arise when rewriting the RETURNING clause of a
2167 * rule, which may also contain arbitrary expressions.
2168 *
2169 * ReturningExpr nodes never appear in a parsed Query --- they are only ever
2170 * inserted by the rewriter and the planner.
2171 */
2172typedef struct ReturningExpr
2173{
2175 int retlevelsup; /* > 0 if it belongs to outer query */
2176 bool retold; /* true for OLD, false for NEW */
2177 Expr *retexpr; /* expression to be returned */
2179
2180/*--------------------
2181 * TargetEntry -
2182 * a target entry (used in query target lists)
2183 *
2184 * Strictly speaking, a TargetEntry isn't an expression node (since it can't
2185 * be evaluated by ExecEvalExpr). But we treat it as one anyway, since in
2186 * very many places it's convenient to process a whole query targetlist as a
2187 * single expression tree.
2188 *
2189 * In a SELECT's targetlist, resno should always be equal to the item's
2190 * ordinal position (counting from 1). However, in an INSERT or UPDATE
2191 * targetlist, resno represents the attribute number of the destination
2192 * column for the item; so there may be missing or out-of-order resnos.
2193 * It is even legal to have duplicated resnos; consider
2194 * UPDATE table SET arraycol[1] = ..., arraycol[2] = ..., ...
2195 * In an INSERT, the rewriter and planner will normalize the tlist by
2196 * reordering it into physical column order and filling in default values
2197 * for any columns not assigned values by the original query. In an UPDATE,
2198 * after the rewriter merges multiple assignments for the same column, the
2199 * planner extracts the target-column numbers into a separate "update_colnos"
2200 * list, and then renumbers the tlist elements serially. Thus, tlist resnos
2201 * match ordinal position in all tlists seen by the executor; but it is wrong
2202 * to assume that before planning has happened.
2203 *
2204 * resname is required to represent the correct column name in non-resjunk
2205 * entries of top-level SELECT targetlists, since it will be used as the
2206 * column title sent to the frontend. In most other contexts it is only
2207 * a debugging aid, and may be wrong or even NULL. (In particular, it may
2208 * be wrong in a tlist from a stored rule, if the referenced column has been
2209 * renamed by ALTER TABLE since the rule was made. Also, the planner tends
2210 * to store NULL rather than look up a valid name for tlist entries in
2211 * non-toplevel plan nodes.) In resjunk entries, resname should be either
2212 * a specific system-generated name (such as "ctid") or NULL; anything else
2213 * risks confusing ExecGetJunkAttribute!
2214 *
2215 * ressortgroupref is used in the representation of ORDER BY, GROUP BY, and
2216 * DISTINCT items. Targetlist entries with ressortgroupref=0 are not
2217 * sort/group items. If ressortgroupref>0, then this item is an ORDER BY,
2218 * GROUP BY, and/or DISTINCT target value. No two entries in a targetlist
2219 * may have the same nonzero ressortgroupref --- but there is no particular
2220 * meaning to the nonzero values, except as tags. (For example, one must
2221 * not assume that lower ressortgroupref means a more significant sort key.)
2222 * The order of the associated SortGroupClause lists determine the semantics.
2223 *
2224 * resorigtbl/resorigcol identify the source of the column, if it is a
2225 * simple reference to a column of a base table (or view). If it is not
2226 * a simple reference, these fields are zeroes.
2227 *
2228 * If resjunk is true then the column is a working column (such as a sort key)
2229 * that should be removed from the final output of the query. Resjunk columns
2230 * must have resnos that cannot duplicate any regular column's resno. Also
2231 * note that there are places that assume resjunk columns come after non-junk
2232 * columns.
2233 *--------------------
2234 */
2235typedef struct TargetEntry
2236{
2238 /* expression to evaluate */
2240 /* attribute number (see notes above) */
2242 /* name of the column (could be NULL) */
2243 char *resname pg_node_attr(query_jumble_ignore);
2244 /* nonzero if referenced by a sort/group clause */
2246 /* OID of column's source table */
2247 Oid resorigtbl pg_node_attr(query_jumble_ignore);
2248 /* column's number in source table */
2249 AttrNumber resorigcol pg_node_attr(query_jumble_ignore);
2250 /* set to true to eliminate the attribute from final target list */
2251 bool resjunk pg_node_attr(query_jumble_ignore);
2253
2254
2255/* ----------------------------------------------------------------
2256 * node types for join trees
2257 *
2258 * The leaves of a join tree structure are RangeTblRef nodes. Above
2259 * these, JoinExpr nodes can appear to denote a specific kind of join
2260 * or qualified join. Also, FromExpr nodes can appear to denote an
2261 * ordinary cross-product join ("FROM foo, bar, baz WHERE ...").
2262 * FromExpr is like a JoinExpr of jointype JOIN_INNER, except that it
2263 * may have any number of child nodes, not just two.
2264 *
2265 * NOTE: the top level of a Query's jointree is always a FromExpr.
2266 * Even if the jointree contains no rels, there will be a FromExpr.
2267 *
2268 * NOTE: the qualification expressions present in JoinExpr nodes are
2269 * *in addition to* the query's main WHERE clause, which appears as the
2270 * qual of the top-level FromExpr. The reason for associating quals with
2271 * specific nodes in the jointree is that the position of a qual is critical
2272 * when outer joins are present. (If we enforce a qual too soon or too late,
2273 * that may cause the outer join to produce the wrong set of NULL-extended
2274 * rows.) If all joins are inner joins then all the qual positions are
2275 * semantically interchangeable.
2276 *
2277 * NOTE: in the raw output of gram.y, a join tree contains RangeVar,
2278 * RangeSubselect, and RangeFunction nodes, which are all replaced by
2279 * RangeTblRef nodes during the parse analysis phase. Also, the top-level
2280 * FromExpr is added during parse analysis; the grammar regards FROM and
2281 * WHERE as separate.
2282 * ----------------------------------------------------------------
2283 */
2284
2285/*
2286 * RangeTblRef - reference to an entry in the query's rangetable
2287 *
2288 * We could use direct pointers to the RT entries and skip having these
2289 * nodes, but multiple pointers to the same node in a querytree cause
2290 * lots of headaches, so it seems better to store an index into the RT.
2291 */
2292typedef struct RangeTblRef
2293{
2297
2298/*----------
2299 * JoinExpr - for SQL JOIN expressions
2300 *
2301 * isNatural, usingClause, and quals are interdependent. The user can write
2302 * only one of NATURAL, USING(), or ON() (this is enforced by the grammar).
2303 * If he writes NATURAL then parse analysis generates the equivalent USING()
2304 * list, and from that fills in "quals" with the right equality comparisons.
2305 * If he writes USING() then "quals" is filled with equality comparisons.
2306 * If he writes ON() then only "quals" is set. Note that NATURAL/USING
2307 * are not equivalent to ON() since they also affect the output column list.
2308 *
2309 * alias is an Alias node representing the AS alias-clause attached to the
2310 * join expression, or NULL if no clause. NB: presence or absence of the
2311 * alias has a critical impact on semantics, because a join with an alias
2312 * restricts visibility of the tables/columns inside it.
2313 *
2314 * join_using_alias is an Alias node representing the join correlation
2315 * name that SQL:2016 and later allow to be attached to JOIN/USING.
2316 * Its column alias list includes only the common column names from USING,
2317 * and it does not restrict visibility of the join's input tables.
2318 *
2319 * During parse analysis, an RTE is created for the Join, and its index
2320 * is filled into rtindex. This RTE is present mainly so that Vars can
2321 * be created that refer to the outputs of the join. The planner sometimes
2322 * generates JoinExprs internally; these can have rtindex = 0 if there are
2323 * no join alias variables referencing such joins.
2324 *----------
2325 */
2326typedef struct JoinExpr
2327{
2329 JoinType jointype; /* type of join */
2330 bool isNatural; /* Natural join? Will need to shape table */
2331 Node *larg; /* left subtree */
2332 Node *rarg; /* right subtree */
2333 /* USING clause, if any (list of String) */
2334 List *usingClause pg_node_attr(query_jumble_ignore);
2335 /* alias attached to USING clause, if any */
2336 Alias *join_using_alias pg_node_attr(query_jumble_ignore);
2337 /* qualifiers on join, if any */
2339 /* user-written alias clause, if any */
2340 Alias *alias pg_node_attr(query_jumble_ignore);
2341 /* RT index assigned for join, or 0 */
2344
2345/*----------
2346 * FromExpr - represents a FROM ... WHERE ... construct
2347 *
2348 * This is both more flexible than a JoinExpr (it can have any number of
2349 * children, including zero) and less so --- we don't need to deal with
2350 * aliases and so on. The output column set is implicitly just the union
2351 * of the outputs of the children.
2352 *----------
2353 */
2354typedef struct FromExpr
2355{
2357 List *fromlist; /* List of join subtrees */
2358 Node *quals; /* qualifiers on join, if any */
2360
2361/*----------
2362 * OnConflictExpr - represents an ON CONFLICT DO ... expression
2363 *
2364 * The optimizer requires a list of inference elements, and optionally a WHERE
2365 * clause to infer a unique index. The unique index (or, occasionally,
2366 * indexes) inferred are used to arbitrate whether or not the alternative ON
2367 * CONFLICT path is taken.
2368 *----------
2369 */
2370typedef struct OnConflictExpr
2371{
2373 OnConflictAction action; /* DO NOTHING or UPDATE? */
2374
2375 /* Arbiter */
2376 List *arbiterElems; /* unique index arbiter list (of
2377 * InferenceElem's) */
2378 Node *arbiterWhere; /* unique index arbiter WHERE clause */
2379 Oid constraint; /* pg_constraint OID for arbiter */
2380
2381 /* ON CONFLICT UPDATE */
2382 List *onConflictSet; /* List of ON CONFLICT SET TargetEntrys */
2383 Node *onConflictWhere; /* qualifiers to restrict UPDATE to */
2384 int exclRelIndex; /* RT index of 'excluded' relation */
2385 List *exclRelTlist; /* tlist of the EXCLUDED pseudo relation */
2387
2388#endif /* PRIMNODES_H */
int16 AttrNumber
Definition: attnum.h:21
int32_t int32
Definition: c.h:534
unsigned int Index
Definition: c.h:619
CompareType
Definition: cmptype.h:32
double Cost
Definition: nodes.h:261
OnConflictAction
Definition: nodes.h:427
CmdType
Definition: nodes.h:273
NodeTag
Definition: nodes.h:27
AggSplit
Definition: nodes.h:385
int ParseLoc
Definition: nodes.h:250
JoinType
Definition: nodes.h:298
#define plan(x)
Definition: pg_regress.c:161
uint64_t Datum
Definition: postgres.h:70
unsigned int Oid
Definition: postgres_ext.h:32
BoolTestType
Definition: primnodes.h:2000
@ IS_NOT_TRUE
Definition: primnodes.h:2001
@ IS_NOT_FALSE
Definition: primnodes.h:2001
@ IS_NOT_UNKNOWN
Definition: primnodes.h:2001
@ IS_TRUE
Definition: primnodes.h:2001
@ IS_UNKNOWN
Definition: primnodes.h:2001
@ IS_FALSE
Definition: primnodes.h:2001
struct ArrayExpr ArrayExpr
struct FieldSelect FieldSelect
struct CoalesceExpr CoalesceExpr
struct Aggref Aggref
SubLinkType
Definition: primnodes.h:1028
@ ARRAY_SUBLINK
Definition: primnodes.h:1035
@ ANY_SUBLINK
Definition: primnodes.h:1031
@ MULTIEXPR_SUBLINK
Definition: primnodes.h:1034
@ CTE_SUBLINK
Definition: primnodes.h:1036
@ EXPR_SUBLINK
Definition: primnodes.h:1033
@ ROWCOMPARE_SUBLINK
Definition: primnodes.h:1032
@ ALL_SUBLINK
Definition: primnodes.h:1030
@ EXISTS_SUBLINK
Definition: primnodes.h:1029
struct AlternativeSubPlan AlternativeSubPlan
JsonFormatType
Definition: primnodes.h:1662
@ JS_FORMAT_JSONB
Definition: primnodes.h:1665
@ JS_FORMAT_DEFAULT
Definition: primnodes.h:1663
@ JS_FORMAT_JSON
Definition: primnodes.h:1664
struct WindowFuncRunCondition WindowFuncRunCondition
struct InferenceElem InferenceElem
struct ArrayCoerceExpr ArrayCoerceExpr
struct TargetEntry TargetEntry
MinMaxOp
Definition: primnodes.h:1526
@ IS_LEAST
Definition: primnodes.h:1528
@ IS_GREATEST
Definition: primnodes.h:1527
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:962
@ AND_EXPR
Definition: primnodes.h:963
@ OR_EXPR
Definition: primnodes.h:963
@ NOT_EXPR
Definition: primnodes.h:963
struct SetToDefault SetToDefault
JsonEncoding
Definition: primnodes.h:1650
@ JS_ENC_DEFAULT
Definition: primnodes.h:1651
@ JS_ENC_UTF32
Definition: primnodes.h:1654
@ JS_ENC_UTF8
Definition: primnodes.h:1652
@ JS_ENC_UTF16
Definition: primnodes.h:1653
struct JsonReturning JsonReturning
struct CaseExpr CaseExpr
struct JsonBehavior JsonBehavior
struct WindowFunc WindowFunc
XmlOptionType
Definition: primnodes.h:1616
@ XMLOPTION_CONTENT
Definition: primnodes.h:1618
@ XMLOPTION_DOCUMENT
Definition: primnodes.h:1617
SQLValueFunctionOp
Definition: primnodes.h:1560
@ SVFOP_CURRENT_CATALOG
Definition: primnodes.h:1574
@ SVFOP_LOCALTIME_N
Definition: primnodes.h:1567
@ SVFOP_CURRENT_TIMESTAMP
Definition: primnodes.h:1564
@ SVFOP_LOCALTIME
Definition: primnodes.h:1566
@ SVFOP_CURRENT_TIMESTAMP_N
Definition: primnodes.h:1565
@ SVFOP_CURRENT_ROLE
Definition: primnodes.h:1570
@ SVFOP_USER
Definition: primnodes.h:1572
@ SVFOP_CURRENT_SCHEMA
Definition: primnodes.h:1575
@ SVFOP_LOCALTIMESTAMP_N
Definition: primnodes.h:1569
@ SVFOP_CURRENT_DATE
Definition: primnodes.h:1561
@ SVFOP_CURRENT_TIME_N
Definition: primnodes.h:1563
@ SVFOP_CURRENT_TIME
Definition: primnodes.h:1562
@ SVFOP_LOCALTIMESTAMP
Definition: primnodes.h:1568
@ SVFOP_CURRENT_USER
Definition: primnodes.h:1571
@ SVFOP_SESSION_USER
Definition: primnodes.h:1573
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:1774
@ JSW_UNCONDITIONAL
Definition: primnodes.h:1778
@ JSW_CONDITIONAL
Definition: primnodes.h:1777
@ JSW_UNSPEC
Definition: primnodes.h:1775
@ JSW_NONE
Definition: primnodes.h:1776
struct IntoClause IntoClause
struct MinMaxExpr MinMaxExpr
OpExpr DistinctExpr
Definition: primnodes.h:884
struct NamedArgExpr NamedArgExpr
XmlExprOp
Definition: primnodes.h:1604
@ IS_DOCUMENT
Definition: primnodes.h:1612
@ IS_XMLFOREST
Definition: primnodes.h:1607
@ IS_XMLCONCAT
Definition: primnodes.h:1605
@ IS_XMLPI
Definition: primnodes.h:1609
@ IS_XMLPARSE
Definition: primnodes.h:1608
@ IS_XMLSERIALIZE
Definition: primnodes.h:1611
@ IS_XMLROOT
Definition: primnodes.h:1610
@ IS_XMLELEMENT
Definition: primnodes.h:1606
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:1789
@ JSON_BEHAVIOR_ERROR
Definition: primnodes.h:1791
@ JSON_BEHAVIOR_TRUE
Definition: primnodes.h:1793
@ JSON_BEHAVIOR_DEFAULT
Definition: primnodes.h:1798
@ JSON_BEHAVIOR_EMPTY
Definition: primnodes.h:1792
@ JSON_BEHAVIOR_FALSE
Definition: primnodes.h:1794
@ JSON_BEHAVIOR_NULL
Definition: primnodes.h:1790
@ JSON_BEHAVIOR_EMPTY_OBJECT
Definition: primnodes.h:1797
@ JSON_BEHAVIOR_UNKNOWN
Definition: primnodes.h:1795
@ JSON_BEHAVIOR_EMPTY_ARRAY
Definition: primnodes.h:1796
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:1826
@ JSON_QUERY_OP
Definition: primnodes.h:1828
@ JSON_TABLE_OP
Definition: primnodes.h:1830
@ JSON_EXISTS_OP
Definition: primnodes.h:1827
@ JSON_VALUE_OP
Definition: primnodes.h:1829
struct BooleanTest BooleanTest
CoercionForm
Definition: primnodes.h:765
@ COERCE_SQL_SYNTAX
Definition: primnodes.h:769
@ COERCE_IMPLICIT_CAST
Definition: primnodes.h:768
@ COERCE_EXPLICIT_CAST
Definition: primnodes.h:767
@ COERCE_EXPLICIT_CALL
Definition: primnodes.h:766
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:1976
@ IS_NULL
Definition: primnodes.h:1977
@ IS_NOT_NULL
Definition: primnodes.h:1977
struct JsonConstructorExpr JsonConstructorExpr
struct CurrentOfExpr CurrentOfExpr
JsonValueType
Definition: primnodes.h:1746
@ JS_TYPE_ANY
Definition: primnodes.h:1747
@ JS_TYPE_ARRAY
Definition: primnodes.h:1749
@ JS_TYPE_OBJECT
Definition: primnodes.h:1748
@ JS_TYPE_SCALAR
Definition: primnodes.h:1750
struct NullTest NullTest
MergeMatchKind
Definition: primnodes.h:2020
@ MERGE_WHEN_NOT_MATCHED_BY_TARGET
Definition: primnodes.h:2023
@ MERGE_WHEN_NOT_MATCHED_BY_SOURCE
Definition: primnodes.h:2022
@ MERGE_WHEN_MATCHED
Definition: primnodes.h:2021
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:745
@ COERCION_PLPGSQL
Definition: primnodes.h:748
@ COERCION_ASSIGNMENT
Definition: primnodes.h:747
@ COERCION_EXPLICIT
Definition: primnodes.h:749
@ COERCION_IMPLICIT
Definition: primnodes.h:746
struct RelabelType RelabelType
struct CoerceViaIO CoerceViaIO
struct RangeVar RangeVar
JsonConstructorType
Definition: primnodes.h:1714
@ JSCTOR_JSON_SERIALIZE
Definition: primnodes.h:1721
@ JSCTOR_JSON_ARRAYAGG
Definition: primnodes.h:1718
@ JSCTOR_JSON_PARSE
Definition: primnodes.h:1719
@ JSCTOR_JSON_OBJECT
Definition: primnodes.h:1715
@ JSCTOR_JSON_SCALAR
Definition: primnodes.h:1720
@ JSCTOR_JSON_ARRAY
Definition: primnodes.h:1716
@ JSCTOR_JSON_OBJECTAGG
Definition: primnodes.h:1717
OpExpr NullIfExpr
Definition: primnodes.h:892
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:463
Expr xpr
Definition: primnodes.h:460
List * aggdistinct
Definition: primnodes.h:493
AggSplit aggsplit pg_node_attr(query_jumble_ignore)
List * aggdirectargs
Definition: primnodes.h:484
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:487
Expr * aggfilter
Definition: primnodes.h:496
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:526
List * aggorder
Definition: primnodes.h:490
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:1275
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:1421
ParseLoc list_start
Definition: primnodes.h:1417
Oid array_collid pg_node_attr(query_jumble_ignore)
List *elements pg_node_attr(query_jumble_squash)
ParseLoc list_end
Definition: primnodes.h:1419
Expr xpr
Definition: primnodes.h:1405
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:971
List * args
Definition: primnodes.h:972
ParseLoc location
Definition: primnodes.h:973
ParseLoc location
Definition: primnodes.h:2009
BoolTestType booltesttype
Definition: primnodes.h:2008
Expr * arg
Definition: primnodes.h:2007
Expr * arg
Definition: primnodes.h:1346
Oid casecollid pg_node_attr(query_jumble_ignore)
Expr xpr
Definition: primnodes.h:1341
ParseLoc location
Definition: primnodes.h:1349
Oid casetype pg_node_attr(query_jumble_ignore)
Expr * defresult
Definition: primnodes.h:1348
List * args
Definition: primnodes.h:1347
int32 typeMod pg_node_attr(query_jumble_ignore)
Oid collation pg_node_attr(query_jumble_ignore)
Expr * result
Definition: primnodes.h:1359
Expr * expr
Definition: primnodes.h:1358
Expr xpr
Definition: primnodes.h:1357
ParseLoc location
Definition: primnodes.h:1360
Oid coalescetype pg_node_attr(query_jumble_ignore)
List * args
Definition: primnodes.h:1517
Oid coalescecollid pg_node_attr(query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:1519
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:2061
CoercionForm coercionformat pg_node_attr(query_jumble_ignore)
Oid resultcollid pg_node_attr(query_jumble_ignore)
Expr * arg
Definition: primnodes.h:1240
CoercionForm coerceformat pg_node_attr(query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:1247
Oid resulttype
Definition: primnodes.h:1241
Oid resultcollid pg_node_attr(query_jumble_ignore)
Expr * arg
Definition: primnodes.h:1312
ParseLoc location
Definition: primnodes.h:1314
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:2123
pg_node_attr(abstract) NodeTag type
int32 resulttypmod pg_node_attr(query_jumble_ignore)
AttrNumber fieldnum
Definition: primnodes.h:1162
Oid resulttype pg_node_attr(query_jumble_ignore)
Expr * arg
Definition: primnodes.h:1161
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:1193
Expr * arg
Definition: primnodes.h:1192
Node * quals
Definition: primnodes.h:2358
NodeTag type
Definition: primnodes.h:2356
List * fromlist
Definition: primnodes.h:2357
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:780
bool funcretset pg_node_attr(query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:802
Oid funcid
Definition: primnodes.h:782
List * args
Definition: primnodes.h:800
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:570
List *refs pg_node_attr(equal_ignore)
ParseLoc location
Definition: primnodes.h:573
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:2338
JoinType jointype
Definition: primnodes.h:2329
Alias *join_using_alias pg_node_attr(query_jumble_ignore)
int rtindex
Definition: primnodes.h:2342
Alias *alias pg_node_attr(query_jumble_ignore)
Node * larg
Definition: primnodes.h:2331
bool isNatural
Definition: primnodes.h:2330
NodeTag type
Definition: primnodes.h:2328
Node * rarg
Definition: primnodes.h:2332
List *usingClause pg_node_attr(query_jumble_ignore)
Node * expr
Definition: primnodes.h:1816
ParseLoc location
Definition: primnodes.h:1818
JsonBehaviorType btype
Definition: primnodes.h:1815
NodeTag type
Definition: primnodes.h:1813
JsonReturning * returning
Definition: primnodes.h:1735
JsonConstructorType type
Definition: primnodes.h:1731
char * column_name
Definition: primnodes.h:1844
Node * formatted_expr
Definition: primnodes.h:1848
ParseLoc location
Definition: primnodes.h:1884
List * passing_values
Definition: primnodes.h:1861
JsonBehavior * on_empty
Definition: primnodes.h:1864
JsonFormat * format
Definition: primnodes.h:1851
Expr xpr
Definition: primnodes.h:1840
List * passing_names
Definition: primnodes.h:1860
Node * path_spec
Definition: primnodes.h:1854
bool use_io_coercion
Definition: primnodes.h:1871
Oid collation
Definition: primnodes.h:1881
JsonReturning * returning
Definition: primnodes.h:1857
bool use_json_coercion
Definition: primnodes.h:1872
JsonWrapper wrapper
Definition: primnodes.h:1875
JsonExprOp op
Definition: primnodes.h:1842
JsonBehavior * on_error
Definition: primnodes.h:1865
bool omit_quotes
Definition: primnodes.h:1878
ParseLoc location
Definition: primnodes.h:1678
NodeTag type
Definition: primnodes.h:1675
JsonEncoding encoding
Definition: primnodes.h:1677
JsonFormatType format_type
Definition: primnodes.h:1676
JsonFormat * format
Definition: primnodes.h:1761
JsonValueType item_type
Definition: primnodes.h:1762
ParseLoc location
Definition: primnodes.h:1764
JsonFormat * format
Definition: primnodes.h:1688
NodeTag type
Definition: primnodes.h:1687
JsonTablePath * path
Definition: primnodes.h:1923
JsonTablePlan * child
Definition: primnodes.h:1932
JsonTablePlan plan
Definition: primnodes.h:1920
NodeTag type
Definition: primnodes.h:1894
Const * value
Definition: primnodes.h:1896
pg_node_attr(abstract) NodeTag type
JsonTablePlan * rplan
Definition: primnodes.h:1953
JsonTablePlan * lplan
Definition: primnodes.h:1952
JsonTablePlan plan
Definition: primnodes.h:1950
Expr * formatted_expr
Definition: primnodes.h:1709
JsonFormat * format
Definition: primnodes.h:1710
NodeTag type
Definition: primnodes.h:1707
Expr * raw_expr
Definition: primnodes.h:1708
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:2030
Node * qual
Definition: primnodes.h:2035
CmdType commandType
Definition: primnodes.h:2032
List * targetList
Definition: primnodes.h:2036
MergeMatchKind matchKind
Definition: primnodes.h:2031
ParseLoc location
Definition: primnodes.h:668
List * args
Definition: primnodes.h:1543
Oid minmaxcollid pg_node_attr(query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:1545
Oid inputcollid pg_node_attr(query_jumble_ignore)
Oid minmaxtype pg_node_attr(query_jumble_ignore)
MinMaxOp op
Definition: primnodes.h:1541
char *name pg_node_attr(query_jumble_ignore)
Expr * arg
Definition: primnodes.h:823
ParseLoc location
Definition: primnodes.h:829
Definition: nodes.h:135
NullTestType nulltesttype
Definition: primnodes.h:1984
Expr xpr
Definition: primnodes.h:1982
bool argisrow pg_node_attr(query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:1987
Expr * arg
Definition: primnodes.h:1983
List * arbiterElems
Definition: primnodes.h:2376
OnConflictAction action
Definition: primnodes.h:2373
List * onConflictSet
Definition: primnodes.h:2382
List * exclRelTlist
Definition: primnodes.h:2385
NodeTag type
Definition: primnodes.h:2372
Node * onConflictWhere
Definition: primnodes.h:2383
Node * arbiterWhere
Definition: primnodes.h:2378
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:850
List * args
Definition: primnodes.h:868
ParseLoc location
Definition: primnodes.h:871
Expr xpr
Definition: primnodes.h:847
ParseLoc location
Definition: primnodes.h:403
int32 paramtypmod
Definition: primnodes.h:399
int paramid
Definition: primnodes.h:396
Oid paramtype
Definition: primnodes.h:397
ParamKind paramkind
Definition: primnodes.h:395
pg_node_attr(custom_query_jumble) Expr xpr
Oid paramcollid
Definition: primnodes.h:401
NodeTag type
Definition: primnodes.h:2294
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:1218
Oid resultcollid pg_node_attr(query_jumble_ignore)
CoercionForm relabelformat pg_node_attr(query_jumble_ignore)
ParseLoc location
Definition: primnodes.h:1225
Expr * arg
Definition: primnodes.h:1217
Expr * retexpr
Definition: primnodes.h:2177
List *opnos pg_node_attr(query_jumble_ignore)
CompareType cmptype
Definition: primnodes.h:1493
List *inputcollids pg_node_attr(query_jumble_ignore)
List *opfamilies pg_node_attr(query_jumble_ignore)
Expr xpr
Definition: primnodes.h:1447
CoercionForm row_format pg_node_attr(query_jumble_ignore)
List * args
Definition: primnodes.h:1448
ParseLoc location
Definition: primnodes.h:1472
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:1589
SQLValueFunctionOp op
Definition: primnodes.h:1581
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:951
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:2103
int plan_id
Definition: primnodes.h:1102
char * plan_name
Definition: primnodes.h:1104
List * args
Definition: primnodes.h:1124
List * paramIds
Definition: primnodes.h:1100
bool isInitPlan
Definition: primnodes.h:1111
bool useHashTable
Definition: primnodes.h:1112
Node * testexpr
Definition: primnodes.h:1099
int32 firstColTypmod
Definition: primnodes.h:1107
pg_node_attr(no_query_jumble) Expr xpr
List * parParam
Definition: primnodes.h:1123
bool parallel_safe
Definition: primnodes.h:1117
List * setParam
Definition: primnodes.h:1121
bool unknownEqFalse
Definition: primnodes.h:1114
Cost startup_cost
Definition: primnodes.h:1126
Oid firstColCollation
Definition: primnodes.h:1108
Cost per_call_cost
Definition: primnodes.h:1127
SubLinkType subLinkType
Definition: primnodes.h:1097
Oid firstColType
Definition: primnodes.h:1106
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:735
List * refupperindexpr
Definition: primnodes.h:725
Expr * refexpr
Definition: primnodes.h:733
List * reflowerindexpr
Definition: primnodes.h:731
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:2239
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:2241
Index ressortgroupref
Definition: primnodes.h:2245
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:595
List * args
Definition: primnodes.h:605
Index winref
Definition: primnodes.h:611
bool winagg pg_node_attr(query_jumble_ignore)
Oid inputcollid pg_node_attr(query_jumble_ignore)
Expr * aggfilter
Definition: primnodes.h:607
ParseLoc location
Definition: primnodes.h:619
Oid wincollid pg_node_attr(query_jumble_ignore)
Oid wintype pg_node_attr(query_jumble_ignore)
List *runCondition pg_node_attr(query_jumble_ignore)
int ignore_nulls
Definition: primnodes.h:617
bool winstar pg_node_attr(query_jumble_ignore)
Oid winfnoid
Definition: primnodes.h:597
int32 typmod pg_node_attr(query_jumble_ignore)
List * args
Definition: primnodes.h:1633
Expr xpr
Definition: primnodes.h:1623
ParseLoc location
Definition: primnodes.h:1642
bool indent
Definition: primnodes.h:1637
char *name pg_node_attr(query_jumble_ignore)
XmlOptionType xmloption pg_node_attr(query_jumble_ignore)
List * named_args
Definition: primnodes.h:1629
XmlExprOp op
Definition: primnodes.h:1625
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:109