PostgreSQL Source Code git master
Loading...
Searching...
No Matches
plannodes.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * plannodes.h
4 * definitions for query plan nodes
5 *
6 *
7 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * src/include/nodes/plannodes.h
11 *
12 *-------------------------------------------------------------------------
13 */
14#ifndef PLANNODES_H
15#define PLANNODES_H
16
17#include "access/sdir.h"
18#include "access/stratnum.h"
19#include "nodes/bitmapset.h"
20#include "nodes/lockoptions.h"
21#include "nodes/primnodes.h"
22
23
24/* ----------------------------------------------------------------
25 * node definitions
26 * ----------------------------------------------------------------
27 */
28
29/* ----------------
30 * PlannedStmtOrigin
31 *
32 * PlannedStmtOrigin identifies from where a PlannedStmt comes from.
33 * ----------------
34 */
36{
37 PLAN_STMT_UNKNOWN = 0, /* plan origin is not yet known */
38 PLAN_STMT_INTERNAL, /* generated internally by a query */
39 PLAN_STMT_STANDARD, /* standard planned statement */
40 PLAN_STMT_CACHE_GENERIC, /* Generic cached plan */
41 PLAN_STMT_CACHE_CUSTOM, /* Custom cached plan */
43
44/* ----------------
45 * PlannedStmt node
46 *
47 * The output of the planner is a Plan tree headed by a PlannedStmt node.
48 * PlannedStmt holds the "one time" information needed by the executor.
49 *
50 * For simplicity in APIs, we also wrap utility statements in PlannedStmt
51 * nodes; in such cases, commandType == CMD_UTILITY, the statement itself
52 * is in the utilityStmt field, and the rest of the struct is mostly dummy.
53 * (We do use canSetTag, stmt_location, stmt_len, and possibly queryId.)
54 *
55 * PlannedStmt, as well as all varieties of Plan, do not support equal(),
56 * not because it's not sensible but because we currently have no need.
57 * ----------------
58 */
59typedef struct PlannedStmt
60{
62
64
65 /* select|insert|update|delete|merge|utility */
67
68 /* query identifier (copied from Query) */
70
71 /* plan identifier (can be set by plugins) */
73
74 /* origin of plan */
76
77 /* is it insert|update|delete|merge RETURNING? */
79
80 /* has insert|update|delete|merge in WITH? */
82
83 /* do I set the command result tag? */
85
86 /* redo plan when TransactionXmin changes? */
88
89 /* is plan specific to current role? */
91
92 /* parallel mode required to execute? */
94
95 /* which forms of JIT should be performed */
97
98 /* tree of Plan nodes */
99 struct Plan *planTree;
100
101 /*
102 * List of PartitionPruneInfo contained in the plan
103 */
105
106 /* list of RangeTblEntry nodes */
108
109 /*
110 * RT indexes of relations that are not subject to runtime pruning or are
111 * needed to perform runtime pruning
112 */
114
115 /*
116 * list of RTEPermissionInfo nodes for rtable entries needing one
117 */
119
120 /* RT indexes of relations targeted by INSERT/UPDATE/DELETE/MERGE */
122
123 /* list of AppendRelInfo nodes */
125
126 /*
127 * Plan trees for SubPlan expressions; note that some could be NULL
128 */
130
131 /* a list of SubPlanRTInfo objects */
133
134 /* indices of subplans that require REWIND */
136
137 /* a list of PlanRowMark's */
139
140 /* RT indexes of relations with row marks */
142
143 /* OIDs of relations the plan depends on */
145
146 /* other dependencies, as PlanInvalItems */
148
149 /* type OIDs for PARAM_EXEC Params */
151
152 /* non-null if this is utility stmt */
154
155 /* info about nodes elided from the plan during setrefs processing */
157
158 /*
159 * DefElem objects added by extensions, e.g. using planner_shutdown_hook
160 *
161 * Set each DefElem's defname to the name of the plugin or extension, and
162 * the argument to a tree of nodes that all have copy and read/write
163 * support.
164 */
166
167 /* statement location in source string (copied from Query) */
168 /* start location, or -1 if unknown */
170 /* length in bytes; 0 means "rest of string" */
173
174/* macro for fetching the Plan associated with a SubPlan node */
175#define exec_subplan_get_plan(plannedstmt, subplan) \
176 ((Plan *) list_nth((plannedstmt)->subplans, (subplan)->plan_id - 1))
177
178
179/* ----------------
180 * Plan node
181 *
182 * All plan nodes "derive" from the Plan structure by having the
183 * Plan structure as the first field. This ensures that everything works
184 * when nodes are cast to Plan's. (node pointers are frequently cast to Plan*
185 * when passed around generically in the executor)
186 *
187 * We never actually instantiate any Plan nodes; this is just the common
188 * abstract superclass for all Plan-type nodes.
189 * ----------------
190 */
191typedef struct Plan
192{
194
196
197 /*
198 * estimated execution costs for plan (see costsize.c for more info)
199 */
200 /* count of disabled nodes */
202 /* cost expended before fetching any tuples */
204 /* total cost (assuming all tuples fetched) */
206
207 /*
208 * planner's estimate of result size of this plan step
209 */
210 /* number of rows plan is expected to emit */
212 /* average row width in bytes */
214
215 /*
216 * information needed for parallel query
217 */
218 /* engage parallel-aware logic? */
220 /* OK to use as part of parallel plan? */
222
223 /*
224 * information needed for asynchronous execution
225 */
226 /* engage asynchronous-capable logic? */
228
229 /*
230 * Common structural data for all Plan types.
231 */
232 /* unique across entire final plan tree */
234 /* target list to be computed at this node */
236 /* implicitly-ANDed qual conditions */
238 /* input plan tree(s) */
239 struct Plan *lefttree;
241 /* Init Plan nodes (un-correlated expr subselects) */
243
244 /*
245 * Information for management of parameter-change-driven rescanning
246 *
247 * extParam includes the paramIDs of all external PARAM_EXEC params
248 * affecting this plan node or its children. setParam params from the
249 * node's initPlans are not included, but their extParams are.
250 *
251 * allParam includes all the extParam paramIDs, plus the IDs of local
252 * params that affect the node (i.e., the setParams of its initplans).
253 * These are _all_ the PARAM_EXEC params that affect this node.
254 */
258
259/* ----------------
260 * these are defined to avoid confusion problems with "left"
261 * and "right" and "inner" and "outer". The convention is that
262 * the "left" plan is the "outer" plan and the "right" plan is
263 * the inner plan, but these make the code more readable.
264 * ----------------
265 */
266#define innerPlan(node) (((Plan *)(node))->righttree)
267#define outerPlan(node) (((Plan *)(node))->lefttree)
268
269
270/* ----------------
271 * ResultType -
272 * Classification of Result nodes
273 * ----------------
274 */
275typedef enum ResultType
276{
277 RESULT_TYPE_GATING, /* project or one-time-filter outer plan */
278 RESULT_TYPE_SCAN, /* replace empty scan */
279 RESULT_TYPE_JOIN, /* replace empty join */
280 RESULT_TYPE_UPPER, /* replace degenerate upper rel */
281 RESULT_TYPE_MINMAX /* implement minmax aggregate */
283
284/* ----------------
285 * Result node -
286 * If no outer plan, evaluate a variable-free targetlist.
287 * If outer plan, return tuples from outer plan (after a level of
288 * projection as shown by targetlist).
289 *
290 * If resconstantqual isn't NULL, it represents a one-time qualification
291 * test (i.e., one that doesn't depend on any variables from the outer plan,
292 * so needs to be evaluated only once).
293 *
294 * relids identifies the relation for which this Result node is generating the
295 * tuples. When subplan is not NULL, it should be empty: this node is not
296 * generating anything in that case, just acting on tuples generated by the
297 * subplan. Otherwise, it contains the relids of the planner relation that
298 * the Result represents.
299 * ----------------
300 */
308
309/* ----------------
310 * ProjectSet node -
311 * Apply a projection that includes set-returning functions to the
312 * output tuples of the outer plan.
313 * ----------------
314 */
315typedef struct ProjectSet
316{
319
320/* ----------------
321 * ModifyTable node -
322 * Apply rows produced by outer plan to result table(s),
323 * by inserting, updating, or deleting.
324 *
325 * If the originally named target table is a partitioned table or inheritance
326 * tree, both nominalRelation and rootRelation contain the RT index of the
327 * partition root or appendrel RTE, which is not otherwise mentioned in the
328 * plan. Otherwise rootRelation is zero. However, nominalRelation will
329 * always be set, as it's the rel that EXPLAIN should claim is the
330 * INSERT/UPDATE/DELETE/MERGE target.
331 *
332 * Note that rowMarks and epqParam are presumed to be valid for all the
333 * table(s); they can't contain any info that varies across tables.
334 * ----------------
335 */
336typedef struct ModifyTable
337{
339 /* INSERT, UPDATE, DELETE, or MERGE */
341 /* do we set the command tag/es_processed? */
343 /* Parent RT index for use of EXPLAIN */
345 /* Root RT index, if partitioned/inherited */
347 /* integer list of RT indexes */
349 /* per-target-table update_colnos lists */
351 /* per-target-table WCO lists */
353 /* alias for OLD in RETURNING lists */
355 /* alias for NEW in RETURNING lists */
357 /* per-target-table RETURNING tlists */
359 /* per-target-table FDW private data lists */
361 /* indices of FDW DM plans */
363 /* PlanRowMarks (non-locking only) */
365 /* ID of Param for EvalPlanQual re-eval */
367 /* ON CONFLICT action */
369 /* List of ON CONFLICT arbiter index OIDs */
371 /* lock strength for ON CONFLICT DO SELECT */
373 /* INSERT ON CONFLICT DO UPDATE targetlist */
375 /* target column numbers for onConflictSet */
377 /* WHERE for ON CONFLICT DO SELECT/UPDATE */
379 /* FOR PORTION OF clause for UPDATE/DELETE */
381 /* RTI of the EXCLUDED pseudo relation */
383 /* tlist of the EXCLUDED pseudo relation */
385 /* per-target-table lists of actions for MERGE */
387 /* per-target-table join conditions for MERGE */
390
391struct PartitionPruneInfo; /* forward reference to struct below */
392
393/* ----------------
394 * Append node -
395 * Generate the concatenation of the results of sub-plans.
396 * ----------------
397 */
398typedef struct Append
399{
401
402 /* RTIs of appendrel(s) formed by this node */
404
405 /* sets of RTIs of appendrels consolidated into this node */
407
408 /* plans to run */
410
411 /* # of asynchronous plans */
413
414 /*
415 * All 'appendplans' preceding this index are non-partial plans. All
416 * 'appendplans' from this index onwards are partial plans.
417 */
419
420 /*
421 * Index into PlannedStmt.partPruneInfos and parallel lists in EState:
422 * es_part_prune_states and es_part_prune_results. Set to -1 if no
423 * run-time pruning is used.
424 */
427
428/* ----------------
429 * MergeAppend node -
430 * Merge the results of pre-sorted sub-plans to preserve the ordering.
431 * ----------------
432 */
433typedef struct MergeAppend
434{
436
437 /* RTIs of appendrel(s) formed by this node */
439
440 /* sets of RTIs of appendrels consolidated into this node */
442
443 /* plans to run */
445
446 /* these fields are just like the sort-key info in struct Sort: */
447
448 /* number of sort-key columns */
450
451 /* their indexes in the target list */
453
454 /* OIDs of operators to sort them by */
456
457 /* OIDs of collations */
459
460 /* NULLS FIRST/LAST directions */
462
463 /*
464 * Index into PlannedStmt.partPruneInfos and parallel lists in EState:
465 * es_part_prune_states and es_part_prune_results. Set to -1 if no
466 * run-time pruning is used.
467 */
470
471/* ----------------
472 * RecursiveUnion node -
473 * Generate a recursive union of two subplans.
474 *
475 * The "outer" subplan is always the non-recursive term, and the "inner"
476 * subplan is the recursive term.
477 * ----------------
478 */
479typedef struct RecursiveUnion
480{
482
483 /* ID of Param representing work table */
485
486 /* Remaining fields are zero/null in UNION ALL case */
487
488 /* number of columns to check for duplicate-ness */
490
491 /* their indexes in the target list */
493
494 /* equality operators to compare with */
497
498 /* estimated number of groups in input */
501
502/* ----------------
503 * BitmapAnd node -
504 * Generate the intersection of the results of sub-plans.
505 *
506 * The subplans must be of types that yield tuple bitmaps. The targetlist
507 * and qual fields of the plan are unused and are always NIL.
508 * ----------------
509 */
515
516/* ----------------
517 * BitmapOr node -
518 * Generate the union of the results of sub-plans.
519 *
520 * The subplans must be of types that yield tuple bitmaps. The targetlist
521 * and qual fields of the plan are unused and are always NIL.
522 * ----------------
523 */
530
531/*
532 * ==========
533 * Scan nodes
534 *
535 * Scan is an abstract type that all relation scan plan types inherit from.
536 * ==========
537 */
538typedef struct Scan
539{
541
542 Plan plan;
543 /* relid is index into the range table */
546
547/* ----------------
548 * sequential scan node
549 * ----------------
550 */
551typedef struct SeqScan
552{
555
556/* ----------------
557 * table sample scan node
558 * ----------------
559 */
560typedef struct SampleScan
561{
563 /* use struct pointer to avoid including parsenodes.h here */
566
567/* ----------------
568 * index scan node
569 *
570 * indexqualorig is an implicitly-ANDed list of index qual expressions, each
571 * in the same form it appeared in the query WHERE condition. Each should
572 * be of the form (indexkey OP comparisonval) or (comparisonval OP indexkey).
573 * The indexkey is a Var or expression referencing column(s) of the index's
574 * base table. The comparisonval might be any expression, but it won't use
575 * any columns of the base table. The expressions are ordered by index
576 * column position (but items referencing the same index column can appear
577 * in any order). indexqualorig is used at runtime only if we have to recheck
578 * a lossy indexqual.
579 *
580 * indexqual has the same form, but the expressions have been commuted if
581 * necessary to put the indexkeys on the left, and the indexkeys are replaced
582 * by Var nodes identifying the index columns (their varno is INDEX_VAR and
583 * their varattno is the index column number).
584 *
585 * indexorderbyorig is similarly the original form of any ORDER BY expressions
586 * that are being implemented by the index, while indexorderby is modified to
587 * have index column Vars on the left-hand side. Here, multiple expressions
588 * must appear in exactly the ORDER BY order, and this is not necessarily the
589 * index column order. Only the expressions are provided, not the auxiliary
590 * sort-order information from the ORDER BY SortGroupClauses; it's assumed
591 * that the sort ordering is fully determinable from the top-level operators.
592 * indexorderbyorig is used at runtime to recheck the ordering, if the index
593 * cannot calculate an accurate ordering. It is also needed for EXPLAIN.
594 *
595 * indexorderbyops is a list of the OIDs of the operators used to sort the
596 * ORDER BY expressions. This is used together with indexorderbyorig to
597 * recheck ordering at run time. (Note that indexorderby, indexorderbyorig,
598 * and indexorderbyops are used for amcanorderbyop cases, not amcanorder.)
599 *
600 * indexorderdir specifies the scan ordering, for indexscans on amcanorder
601 * indexes (for other indexes it should be "don't care").
602 * ----------------
603 */
604typedef struct IndexScan
605{
607 /* OID of index to scan */
609 /* list of index quals (usually OpExprs) */
611 /* the same in original form */
613 /* list of index ORDER BY exprs */
615 /* the same in original form */
617 /* OIDs of sort ops for ORDER BY exprs */
619 /* forward or backward or don't care */
622
623/* ----------------
624 * index-only scan node
625 *
626 * IndexOnlyScan is very similar to IndexScan, but it specifies an
627 * index-only scan, in which the data comes from the index not the heap.
628 * Because of this, *all* Vars in the plan node's targetlist, qual, and
629 * index expressions reference index columns and have varno = INDEX_VAR.
630 *
631 * We could almost use indexqual directly against the index's output tuple
632 * when rechecking lossy index operators, but that won't work for quals on
633 * index columns that are not retrievable. Hence, recheckqual is needed
634 * for rechecks: it expresses the same condition as indexqual, but using
635 * only index columns that are retrievable. (We will not generate an
636 * index-only scan if this is not possible. An example is that if an
637 * index has table column "x" in a retrievable index column "ind1", plus
638 * an expression f(x) in a non-retrievable column "ind2", an indexable
639 * query on f(x) will use "ind2" in indexqual and f(ind1) in recheckqual.
640 * Without the "ind1" column, an index-only scan would be disallowed.)
641 *
642 * We don't currently need a recheckable equivalent of indexorderby,
643 * because we don't support lossy operators in index ORDER BY.
644 *
645 * To help EXPLAIN interpret the index Vars for display, we provide
646 * indextlist, which represents the contents of the index as a targetlist
647 * with one TLE per index column. Vars appearing in this list reference
648 * the base table, and this is the only field in the plan node that may
649 * contain such Vars. Also, for the convenience of setrefs.c, TLEs in
650 * indextlist are marked as resjunk if they correspond to columns that
651 * the index AM cannot reconstruct.
652 * ----------------
653 */
654typedef struct IndexOnlyScan
655{
657 /* OID of index to scan */
659 /* list of index quals (usually OpExprs) */
661 /* index quals in recheckable form */
663 /* list of index ORDER BY exprs */
665 /* TargetEntry list describing index's cols */
667 /* forward or backward or don't care */
670
671/* ----------------
672 * bitmap index scan node
673 *
674 * BitmapIndexScan delivers a bitmap of potential tuple locations;
675 * it does not access the heap itself. The bitmap is used by an
676 * ancestor BitmapHeapScan node, possibly after passing through
677 * intermediate BitmapAnd and/or BitmapOr nodes to combine it with
678 * the results of other BitmapIndexScans.
679 *
680 * The fields have the same meanings as for IndexScan, except we don't
681 * store a direction flag because direction is uninteresting.
682 *
683 * In a BitmapIndexScan plan node, the targetlist and qual fields are
684 * not used and are always NIL. The indexqualorig field is unused at
685 * run time too, but is saved for the benefit of EXPLAIN.
686 * ----------------
687 */
688typedef struct BitmapIndexScan
689{
691 /* OID of index to scan */
693 /* Create shared bitmap if set */
695 /* list of index quals (OpExprs) */
697 /* the same in original form */
700
701/* ----------------
702 * bitmap sequential scan node
703 *
704 * This needs a copy of the qual conditions being used by the input index
705 * scans because there are various cases where we need to recheck the quals;
706 * for example, when the bitmap is lossy about the specific rows on a page
707 * that meet the index condition.
708 * ----------------
709 */
710typedef struct BitmapHeapScan
711{
713 /* index quals, in standard expr form */
716
717/* ----------------
718 * tid scan node
719 *
720 * tidquals is an implicitly OR'ed list of qual expressions of the form
721 * "CTID = pseudoconstant", or "CTID = ANY(pseudoconstant_array)",
722 * or a CurrentOfExpr for the relation.
723 * ----------------
724 */
725typedef struct TidScan
726{
728 /* qual(s) involving CTID = something */
731
732/* ----------------
733 * tid range scan node
734 *
735 * tidrangequals is an implicitly AND'ed list of qual expressions of the form
736 * "CTID relop pseudoconstant", where relop is one of >,>=,<,<=.
737 * ----------------
738 */
739typedef struct TidRangeScan
740{
742 /* qual(s) involving CTID op something */
745
746/* ----------------
747 * subquery scan node
748 *
749 * SubqueryScan is for scanning the output of a sub-query in the range table.
750 * We often need an extra plan node above the sub-query's plan to perform
751 * expression evaluations (which we can't push into the sub-query without
752 * risking changing its semantics). Although we are not scanning a physical
753 * relation, we make this a descendant of Scan anyway for code-sharing
754 * purposes.
755 *
756 * SubqueryScanStatus caches the trivial_subqueryscan property of the node.
757 * SUBQUERY_SCAN_UNKNOWN means not yet determined. This is only used during
758 * planning.
759 *
760 * Note: we store the sub-plan in the type-specific subplan field, not in
761 * the generic lefttree field as you might expect. This is because we do
762 * not want plan-tree-traversal routines to recurse into the subplan without
763 * knowing that they are changing Query contexts.
764 * ----------------
765 */
772
779
780/* ----------------
781 * FunctionScan node
782 * ----------------
783 */
784typedef struct FunctionScan
785{
787 /* list of RangeTblFunction nodes */
789 /* WITH ORDINALITY */
792
793/* ----------------
794 * ValuesScan node
795 * ----------------
796 */
797typedef struct ValuesScan
798{
800 /* list of expression lists */
803
804/* ----------------
805 * TableFunc scan node
806 * ----------------
807 */
808typedef struct TableFuncScan
809{
811 /* table function node */
814
815/* ----------------
816 * CteScan node
817 * ----------------
818 */
819typedef struct CteScan
820{
822 /* ID of init SubPlan for CTE */
824 /* ID of Param representing CTE output */
827
828/* ----------------
829 * NamedTuplestoreScan node
830 * ----------------
831 */
833{
835 /* Name given to Ephemeral Named Relation */
836 char *enrname;
838
839/* ----------------
840 * WorkTableScan node
841 * ----------------
842 */
843typedef struct WorkTableScan
844{
846 /* ID of Param representing work table */
849
850/* ----------------
851 * ForeignScan node
852 *
853 * fdw_exprs and fdw_private are both under the control of the foreign-data
854 * wrapper, but fdw_exprs is presumed to contain expression trees and will
855 * be post-processed accordingly by the planner; fdw_private won't be.
856 * Note that everything in both lists must be copiable by copyObject().
857 * One way to store an arbitrary blob of bytes is to represent it as a bytea
858 * Const. Usually, though, you'll be better off choosing a representation
859 * that can be dumped usefully by nodeToString().
860 *
861 * fdw_scan_tlist is a targetlist describing the contents of the scan tuple
862 * returned by the FDW; it can be NIL if the scan tuple matches the declared
863 * rowtype of the foreign table, which is the normal case for a simple foreign
864 * table scan. (If the plan node represents a foreign join, fdw_scan_tlist
865 * is required since there is no rowtype available from the system catalogs.)
866 * When fdw_scan_tlist is provided, Vars in the node's tlist and quals must
867 * have varno INDEX_VAR, and their varattnos correspond to resnos in the
868 * fdw_scan_tlist (which are also column numbers in the actual scan tuple).
869 * fdw_scan_tlist is never actually executed; it just holds expression trees
870 * describing what is in the scan tuple's columns.
871 *
872 * fdw_recheck_quals should contain any quals which the core system passed to
873 * the FDW but which were not added to scan.plan.qual; that is, it should
874 * contain the quals being checked remotely. This is needed for correct
875 * behavior during EvalPlanQual rechecks.
876 *
877 * When the plan node represents a foreign join, scan.scanrelid is zero and
878 * fs_relids must be consulted to identify the join relation. (fs_relids
879 * is valid for simple scans as well, but will always match scan.scanrelid.)
880 * fs_relids includes outer joins; fs_base_relids does not.
881 *
882 * If the FDW's PlanDirectModify() callback decides to repurpose a ForeignScan
883 * node to perform the UPDATE or DELETE operation directly in the remote
884 * server, it sets 'operation' and 'resultRelation' to identify the operation
885 * type and target relation. Note that these fields are only set if the
886 * modification is performed *fully* remotely; otherwise, the modification is
887 * driven by a local ModifyTable node and 'operation' is left to CMD_SELECT.
888 * ----------------
889 */
890typedef struct ForeignScan
891{
893 /* SELECT/INSERT/UPDATE/DELETE */
895 /* direct modification target's RT index */
897 /* user to perform the scan as; 0 means to check as current user */
899 /* OID of foreign server */
901 /* expressions that FDW may evaluate */
903 /* private data for FDW */
905 /* optional tlist describing scan tuple */
907 /* original quals not in scan.plan.qual */
909 /* base+OJ RTIs generated by this scan */
911 /* base RTIs generated by this scan */
913 /* true if any "system column" is needed */
916
917/* ----------------
918 * CustomScan node
919 *
920 * The comments for ForeignScan's fdw_exprs, fdw_private, fdw_scan_tlist,
921 * and fs_relids fields apply equally to CustomScan's custom_exprs,
922 * custom_private, custom_scan_tlist, and custom_relids fields. The
923 * convention of setting scan.scanrelid to zero for joins applies as well.
924 *
925 * Note that since Plan trees can be copied, custom scan providers *must*
926 * fit all plan data they need into those fields; embedding CustomScan in
927 * a larger struct will not work.
928 * ----------------
929 */
930struct CustomScanMethods;
931
932typedef struct CustomScan
933{
935 /* mask of CUSTOMPATH_* flags, see nodes/extensible.h */
937 /* list of Plan nodes, if any */
939 /* expressions that custom code may evaluate */
941 /* private data for custom code */
943 /* optional tlist describing scan tuple */
945 /* RTIs generated by this scan */
947
948 /*
949 * NOTE: The method field of CustomScan is required to be a pointer to a
950 * static table of callback functions. So we don't copy the table itself,
951 * just reference the original one.
952 */
955
956/*
957 * ==========
958 * Join nodes
959 * ==========
960 */
961
962/* ----------------
963 * Join node
964 *
965 * jointype: rule for joining tuples from left and right subtrees
966 * inner_unique each outer tuple can match to no more than one inner tuple
967 * joinqual: qual conditions that came from JOIN/ON or JOIN/USING
968 * (plan.qual contains conditions that came from WHERE)
969 * ojrelids: outer joins completed at this level
970 *
971 * When jointype is INNER, joinqual and plan.qual are semantically
972 * interchangeable. For OUTER jointypes, the two are *not* interchangeable;
973 * only joinqual is used to determine whether a match has been found for
974 * the purpose of deciding whether to generate null-extended tuples.
975 * (But plan.qual is still applied before actually returning a tuple.)
976 * For an outer join, only joinquals are allowed to be used as the merge
977 * or hash condition of a merge or hash join.
978 *
979 * inner_unique is set if the joinquals are such that no more than one inner
980 * tuple could match any given outer tuple. This allows the executor to
981 * skip searching for additional matches. (This must be provable from just
982 * the joinquals, ignoring plan.qual, due to where the executor tests it.)
983 * ----------------
984 */
985typedef struct Join
986{
988
989 Plan plan;
992 /* JOIN quals (in addition to plan.qual) */
996
997/* ----------------
998 * nest loop join node
999 *
1000 * The nestParams list identifies any executor Params that must be passed
1001 * into execution of the inner subplan carrying values from the current row
1002 * of the outer subplan. Currently we restrict these values to be simple
1003 * Vars, but perhaps someday that'd be worth relaxing. (Note: during plan
1004 * creation, the paramval can actually be a PlaceHolderVar expression; but it
1005 * must be a Var with varno OUTER_VAR by the time it gets to the executor.)
1006 * ----------------
1007 */
1008typedef struct NestLoop
1009{
1011 /* list of NestLoopParam nodes */
1014
1015typedef struct NestLoopParam
1016{
1018
1019 NodeTag type;
1020 /* number of the PARAM_EXEC Param to set */
1022 /* outer-relation Var to assign to Param */
1025
1026/* ----------------
1027 * merge join node
1028 *
1029 * The expected ordering of each mergeable column is described by a btree
1030 * opfamily OID, a collation OID, a direction (BTLessStrategyNumber or
1031 * BTGreaterStrategyNumber) and a nulls-first flag. Note that the two sides
1032 * of each mergeclause may be of different datatypes, but they are ordered the
1033 * same way according to the common opfamily and collation. The operator in
1034 * each mergeclause must be an equality operator of the indicated opfamily.
1035 * ----------------
1036 */
1037typedef struct MergeJoin
1038{
1040
1041 /* Can we skip mark/restore calls? */
1043
1044 /* mergeclauses as expression trees */
1046
1047 /* these are arrays, but have the same length as the mergeclauses list: */
1048
1049 /* per-clause OIDs of btree opfamilies */
1051
1052 /* per-clause OIDs of collations */
1054
1055 /* per-clause ordering (ASC or DESC) */
1057
1058 /* per-clause nulls ordering */
1061
1062/* ----------------
1063 * hash join node
1064 * ----------------
1065 */
1066typedef struct HashJoin
1067{
1072
1073 /*
1074 * List of expressions to be hashed for tuples from the outer plan, to
1075 * perform lookups in the hashtable over the inner plan.
1076 */
1079
1080/* ----------------
1081 * materialization node
1082 * ----------------
1083 */
1084typedef struct Material
1085{
1088
1089/* ----------------
1090 * memoize node
1091 * ----------------
1092 */
1093typedef struct Memoize
1094{
1096
1097 /* size of the two arrays below */
1099
1100 /* hash operators for each key */
1102
1103 /* collations for each key */
1105
1106 /* cache keys in the form of exprs containing parameters */
1108
1109 /*
1110 * true if the cache entry should be marked as complete after we store the
1111 * first tuple in it.
1112 */
1114
1115 /*
1116 * true when cache key should be compared bit by bit, false when using
1117 * hash equality ops
1118 */
1120
1121 /*
1122 * The maximum number of entries that the planner expects will fit in the
1123 * cache, or 0 if unknown
1124 */
1126
1127 /* paramids from param_exprs */
1129
1130 /* Estimated number of rescans, for EXPLAIN */
1132
1133 /* Estimated number of distinct lookup keys, for EXPLAIN */
1135
1136 /* Estimated cache hit ratio, for EXPLAIN */
1138
1140
1141/* ----------------
1142 * sort node
1143 * ----------------
1144 */
1145typedef struct Sort
1146{
1148
1149 /* number of sort-key columns */
1151
1152 /* their indexes in the target list */
1154
1155 /* OIDs of operators to sort them by */
1157
1158 /* OIDs of collations */
1160
1161 /* NULLS FIRST/LAST directions */
1164
1165/* ----------------
1166 * incremental sort node
1167 * ----------------
1168 */
1169typedef struct IncrementalSort
1170{
1172 /* number of presorted columns */
1175
1176/* ---------------
1177 * group node -
1178 * Used for queries with GROUP BY (but no aggregates) specified.
1179 * The input must be presorted according to the grouping columns.
1180 * ---------------
1181 */
1182typedef struct Group
1183{
1185
1186 /* number of grouping columns */
1188
1189 /* their indexes in the target list */
1191
1192 /* equality operators to compare with */
1196
1197/* ---------------
1198 * aggregate node
1199 *
1200 * An Agg node implements plain or grouped aggregation. For grouped
1201 * aggregation, we can work with presorted input or unsorted input;
1202 * the latter strategy uses an internal hashtable.
1203 *
1204 * Notice the lack of any direct info about the aggregate functions to be
1205 * computed. They are found by scanning the node's tlist and quals during
1206 * executor startup. (It is possible that there are no aggregate functions;
1207 * this could happen if they get optimized away by constant-folding, or if
1208 * we are using the Agg node to implement hash-based grouping.)
1209 * ---------------
1210 */
1211typedef struct Agg
1212{
1214
1215 /* basic strategy, see nodes.h */
1217
1218 /* agg-splitting mode, see nodes.h */
1220
1221 /* number of grouping columns */
1223
1224 /* their indexes in the target list */
1226
1227 /* equality operators to compare with */
1230
1231 /* estimated number of groups in input */
1233
1234 /* for pass-by-ref transition data */
1236
1237 /* IDs of Params used in Aggref inputs */
1239
1240 /* Note: planner provides numGroups & aggParams only in HASHED/MIXED case */
1241
1242 /* grouping sets to use */
1244
1245 /* chained Agg/Sort nodes */
1248
1249/* ----------------
1250 * window aggregate node
1251 * ----------------
1252 */
1253typedef struct WindowAgg
1254{
1256
1257 /* name of WindowClause implemented by this node */
1258 char *winname;
1259
1260 /* ID referenced by window functions */
1262
1263 /* number of columns in partition clause */
1265
1266 /* their indexes in the target list */
1268
1269 /* equality operators for partition columns */
1271
1272 /* collations for partition columns */
1274
1275 /* number of columns in ordering clause */
1277
1278 /* their indexes in the target list */
1280
1281 /* equality operators for ordering columns */
1283
1284 /* collations for ordering columns */
1286
1287 /* frame_clause options, see WindowDef */
1289
1290 /* expression for starting bound, if any */
1292
1293 /* expression for ending bound, if any */
1295
1296 /* qual to help short-circuit execution */
1298
1299 /* runCondition for display in EXPLAIN */
1301
1302 /* these fields are used with RANGE offset PRECEDING/FOLLOWING: */
1303
1304 /* in_range function for startOffset */
1306
1307 /* in_range function for endOffset */
1309
1310 /* collation for in_range tests */
1312
1313 /* use ASC sort order for in_range tests? */
1315
1316 /* nulls sort first for in_range tests? */
1318
1319 /*
1320 * false for all apart from the WindowAgg that's closest to the root of
1321 * the plan
1322 */
1325
1326/* ----------------
1327 * unique node
1328 * ----------------
1329 */
1330typedef struct Unique
1331{
1333
1334 /* number of columns to check for uniqueness */
1336
1337 /* their indexes in the target list */
1339
1340 /* equality operators to compare with */
1342
1343 /* collations for equality comparisons */
1346
1347/* ------------
1348 * gather node
1349 *
1350 * Note: rescan_param is the ID of a PARAM_EXEC parameter slot. That slot
1351 * will never actually contain a value, but the Gather node must flag it as
1352 * having changed whenever it is rescanned. The child parallel-aware scan
1353 * nodes are marked as depending on that parameter, so that the rescan
1354 * machinery is aware that their output is likely to change across rescans.
1355 * In some cases we don't need a rescan Param, so rescan_param is set to -1.
1356 * ------------
1357 */
1358typedef struct Gather
1359{
1361 /* planned number of worker processes */
1363 /* ID of Param that signals a rescan, or -1 */
1365 /* don't execute plan more than once */
1367 /* suppress EXPLAIN display (for testing)? */
1369
1370 /*
1371 * param id's of initplans which are referred at gather or one of its
1372 * child nodes
1373 */
1376
1377/* ------------
1378 * gather merge node
1379 * ------------
1380 */
1381typedef struct GatherMerge
1382{
1384
1385 /* planned number of worker processes */
1387
1388 /* ID of Param that signals a rescan, or -1 */
1390
1391 /* remaining fields are just like the sort-key info in struct Sort */
1392
1393 /* number of sort-key columns */
1395
1396 /* their indexes in the target list */
1398
1399 /* OIDs of operators to sort them by */
1401
1402 /* OIDs of collations */
1404
1405 /* NULLS FIRST/LAST directions */
1407
1408 /*
1409 * param id's of initplans which are referred at gather merge or one of
1410 * its child nodes
1411 */
1414
1415/* ----------------
1416 * hash build node
1417 *
1418 * If the executor is supposed to try to apply skew join optimization, then
1419 * skewTable/skewColumn/skewInherit identify the outer relation's join key
1420 * column, from which the relevant MCV statistics can be fetched.
1421 * ----------------
1422 */
1423typedef struct Hash
1424{
1426
1427 /*
1428 * List of expressions to be hashed for tuples from Hash's outer plan,
1429 * needed to put them into the hashtable.
1430 */
1431 /* hash keys for the hashjoin condition */
1433 /* outer join key's table OID, or InvalidOid */
1435 /* outer join key's column #, or zero */
1437 /* is outer join rel an inheritance tree? */
1439 /* all other info is in the parent HashJoin node */
1440 /* estimate total rows if parallel_aware */
1443
1444/* ----------------
1445 * setop node
1446 * ----------------
1447 */
1448typedef struct SetOp
1449{
1451
1452 /* what to do, see nodes.h */
1454
1455 /* how to do it, see nodes.h */
1457
1458 /* number of columns to compare */
1460
1461 /* their indexes in the target list */
1463
1464 /* comparison operators (either equality operators or sort operators) */
1467
1468 /* nulls-first flags if sorting, otherwise not interesting */
1470
1471 /* estimated number of groups in left input */
1474
1475/* ----------------
1476 * lock-rows node
1477 *
1478 * rowMarks identifies the rels to be locked by this node; it should be
1479 * a subset of the rowMarks listed in the top-level PlannedStmt.
1480 * epqParam is a Param that all scan nodes below this one must depend on.
1481 * It is used to force re-evaluation of the plan during EvalPlanQual.
1482 * ----------------
1483 */
1484typedef struct LockRows
1485{
1487 /* a list of PlanRowMark's */
1489 /* ID of Param for EvalPlanQual re-eval */
1492
1493/* ----------------
1494 * limit node
1495 *
1496 * Note: as of Postgres 8.2, the offset and count expressions are expected
1497 * to yield int8, rather than int4 as before.
1498 * ----------------
1499 */
1500typedef struct Limit
1501{
1503
1504 /* OFFSET parameter, or NULL if none */
1506
1507 /* COUNT parameter, or NULL if none */
1509
1510 /* limit type */
1512
1513 /* number of columns to check for similarity */
1515
1516 /* their indexes in the target list */
1518
1519 /* equality operators to compare with */
1521
1522 /* collations for equality comparisons */
1525
1526
1527/*
1528 * RowMarkType -
1529 * enums for types of row-marking operations
1530 *
1531 * The first four of these values represent different lock strengths that
1532 * we can take on tuples according to SELECT FOR [KEY] UPDATE/SHARE requests.
1533 * We support these on regular tables, as well as on foreign tables whose FDWs
1534 * report support for late locking. For other foreign tables, any locking
1535 * that might be done for such requests must happen during the initial row
1536 * fetch; their FDWs provide no mechanism for going back to lock a row later.
1537 * This means that the semantics will be a bit different than for a local
1538 * table; in particular we are likely to lock more rows than would be locked
1539 * locally, since remote rows will be locked even if they then fail
1540 * locally-checked restriction or join quals. However, the prospect of
1541 * doing a separate remote query to lock each selected row is usually pretty
1542 * unappealing, so early locking remains a credible design choice for FDWs.
1543 *
1544 * When doing UPDATE/DELETE/MERGE/SELECT FOR UPDATE/SHARE, we have to uniquely
1545 * identify all the source rows, not only those from the target relations, so
1546 * that we can perform EvalPlanQual rechecking at need. For plain tables we
1547 * can just fetch the TID, much as for a target relation; this case is
1548 * represented by ROW_MARK_REFERENCE. Otherwise (for example for VALUES or
1549 * FUNCTION scans) we have to copy the whole row value. ROW_MARK_COPY is
1550 * pretty inefficient, since most of the time we'll never need the data; but
1551 * fortunately the overhead is usually not performance-critical in practice.
1552 * By default we use ROW_MARK_COPY for foreign tables, but if the FDW has
1553 * a concept of rowid it can request to use ROW_MARK_REFERENCE instead.
1554 * (Again, this probably doesn't make sense if a physical remote fetch is
1555 * needed, but for FDWs that map to local storage it might be credible.)
1556 */
1557typedef enum RowMarkType
1558{
1559 ROW_MARK_EXCLUSIVE, /* obtain exclusive tuple lock */
1560 ROW_MARK_NOKEYEXCLUSIVE, /* obtain no-key exclusive tuple lock */
1561 ROW_MARK_SHARE, /* obtain shared tuple lock */
1562 ROW_MARK_KEYSHARE, /* obtain keyshare tuple lock */
1563 ROW_MARK_REFERENCE, /* just fetch the TID, don't lock it */
1564 ROW_MARK_COPY, /* physically copy the row value */
1566
1567#define RowMarkRequiresRowShareLock(marktype) ((marktype) <= ROW_MARK_KEYSHARE)
1568
1569/*
1570 * PlanRowMark -
1571 * plan-time representation of FOR [KEY] UPDATE/SHARE clauses
1572 *
1573 * When doing UPDATE/DELETE/MERGE/SELECT FOR UPDATE/SHARE, we create a separate
1574 * PlanRowMark node for each non-target relation in the query. Relations that
1575 * are not specified as FOR UPDATE/SHARE are marked ROW_MARK_REFERENCE (if
1576 * regular tables or supported foreign tables) or ROW_MARK_COPY (if not).
1577 *
1578 * Initially all PlanRowMarks have rti == prti and isParent == false.
1579 * When the planner discovers that a relation is the root of an inheritance
1580 * tree, it sets isParent true, and adds an additional PlanRowMark to the
1581 * list for each child relation (including the target rel itself in its role
1582 * as a child, if it is not a partitioned table). Any non-leaf partitioned
1583 * child relations will also have entries with isParent = true. The child
1584 * entries have rti == child rel's RT index and prti == top parent's RT index,
1585 * and can therefore be recognized as children by the fact that prti != rti.
1586 * The parent's allMarkTypes field gets the OR of (1<<markType) across all
1587 * its children (this definition allows children to use different markTypes).
1588 *
1589 * The planner also adds resjunk output columns to the plan that carry
1590 * information sufficient to identify the locked or fetched rows. When
1591 * markType != ROW_MARK_COPY, these columns are named
1592 * tableoid%u OID of table
1593 * ctid%u TID of row
1594 * The tableoid column is only present for an inheritance hierarchy.
1595 * When markType == ROW_MARK_COPY, there is instead a single column named
1596 * wholerow%u whole-row value of relation
1597 * (An inheritance hierarchy could have all three resjunk output columns,
1598 * if some children use a different markType than others.)
1599 * In all three cases, %u represents the rowmark ID number (rowmarkId).
1600 * This number is unique within a plan tree, except that child relation
1601 * entries copy their parent's rowmarkId. (Assigning unique numbers
1602 * means we needn't renumber rowmarkIds when flattening subqueries, which
1603 * would require finding and renaming the resjunk columns as well.)
1604 * Note this means that all tables in an inheritance hierarchy share the
1605 * same resjunk column names.
1606 */
1607typedef struct PlanRowMark
1608{
1610
1611 NodeTag type;
1612 /* range table index of markable relation */
1614 /* range table index of parent relation */
1616 /* unique identifier for resjunk columns */
1618 /* see enum above */
1620 /* OR of (1<<markType) for all children */
1622 /* LockingClause's strength, or LCS_NONE */
1624 /* NOWAIT and SKIP LOCKED options */
1626 /* true if this is a "dummy" parent entry */
1629
1630
1631/*
1632 * Node types to represent partition pruning information.
1633 */
1634
1635/*
1636 * PartitionPruneInfo - Details required to allow the executor to prune
1637 * partitions.
1638 *
1639 * Here we store mapping details to allow translation of a partitioned table's
1640 * index as returned by the partition pruning code into subplan indexes for
1641 * plan types which support arbitrary numbers of subplans, such as Append.
1642 * We also store various details to tell the executor when it should be
1643 * performing partition pruning.
1644 *
1645 * Each PartitionedRelPruneInfo describes the partitioning rules for a single
1646 * partitioned table (a/k/a level of partitioning). Since a partitioning
1647 * hierarchy could contain multiple levels, we represent it by a List of
1648 * PartitionedRelPruneInfos, where the first entry represents the topmost
1649 * partitioned table and additional entries represent non-leaf child
1650 * partitions, ordered such that parents appear before their children.
1651 * Then, since an Append-type node could have multiple partitioning
1652 * hierarchies among its children, we have an unordered List of those Lists.
1653 *
1654 * relids RelOptInfo.relids of the parent plan node (e.g. Append
1655 * or MergeAppend) to which this PartitionPruneInfo node
1656 * belongs. The pruning logic ensures that this matches
1657 * the parent plan node's apprelids.
1658 * prune_infos List of Lists containing PartitionedRelPruneInfo nodes,
1659 * one sublist per run-time-prunable partition hierarchy
1660 * appearing in the parent plan node's subplans.
1661 * other_subplans Indexes of any subplans that are not accounted for
1662 * by any of the PartitionedRelPruneInfo nodes in
1663 * "prune_infos". These subplans must not be pruned.
1664 */
1674
1675/*
1676 * PartitionedRelPruneInfo - Details required to allow the executor to prune
1677 * partitions for a single partitioned table.
1678 *
1679 * subplan_map[], subpart_map[], and leafpart_rti_map[] are indexed by partition
1680 * index of the partitioned table referenced by 'rtindex', the partition index
1681 * being the order that the partitions are defined in the table's
1682 * PartitionDesc. For a leaf partition p, subplan_map[p] contains the
1683 * zero-based index of the partition's subplan in the parent plan's subplan
1684 * list; it is -1 if the partition is non-leaf or has been pruned. For a
1685 * non-leaf partition p, subpart_map[p] contains the zero-based index of that
1686 * sub-partition's PartitionedRelPruneInfo in the hierarchy's
1687 * PartitionedRelPruneInfo list; it is -1 if the partition is a leaf or has
1688 * been pruned. leafpart_rti_map[p] contains the RT index of a leaf partition
1689 * if its subplan is in the parent plan' subplan list; it is 0 either if the
1690 * partition is non-leaf or it is leaf but has been pruned during planning.
1691 * Note that subplan indexes, as stored in 'subplan_map', are global across the
1692 * parent plan node, but partition indexes are valid only within a particular
1693 * hierarchy. relid_map[p] contains the partition's OID, or 0 if the partition
1694 * was pruned.
1695 */
1697{
1699
1700 NodeTag type;
1701
1702 /* RT index of partition rel for this level */
1704
1705 /* Indexes of all partitions which subplans or subparts are present for */
1707
1708 /* Length of the following arrays: */
1710
1711 /* subplan index by partition index, or -1 */
1712 int *subplan_map pg_node_attr(array_size(nparts));
1713
1714 /* subpart index by partition index, or -1 */
1715 int *subpart_map pg_node_attr(array_size(nparts));
1716
1717 /* RT index by partition index, or 0 */
1718 int *leafpart_rti_map pg_node_attr(array_size(nparts));
1719
1720 /* relation OID by partition index, or 0 */
1722
1723 /*
1724 * initial_pruning_steps shows how to prune during executor startup (i.e.,
1725 * without use of any PARAM_EXEC Params); it is NIL if no startup pruning
1726 * is required. exec_pruning_steps shows how to prune with PARAM_EXEC
1727 * Params; it is NIL if no per-scan pruning is required.
1728 */
1729 /* List of PartitionPruneStep */
1731 /* List of PartitionPruneStep */
1733
1734 /* All PARAM_EXEC Param IDs in exec_pruning_steps */
1737
1738/*
1739 * Abstract Node type for partition pruning steps (there are no concrete
1740 * Nodes of this type).
1741 *
1742 * step_id is the global identifier of the step within its pruning context.
1743 */
1751
1752/*
1753 * PartitionPruneStepOp - Information to prune using a set of mutually ANDed
1754 * OpExpr clauses
1755 *
1756 * This contains information extracted from up to partnatts OpExpr clauses,
1757 * where partnatts is the number of partition key columns. 'opstrategy' is the
1758 * strategy of the operator in the clause matched to the last partition key.
1759 * 'exprs' contains expressions which comprise the lookup key to be passed to
1760 * the partition bound search function. 'cmpfns' contains the OIDs of
1761 * comparison functions used to compare aforementioned expressions with
1762 * partition bounds. Both 'exprs' and 'cmpfns' contain the same number of
1763 * items, up to partnatts items.
1764 *
1765 * Once we find the offset of a partition bound using the lookup key, we
1766 * determine which partitions to include in the result based on the value of
1767 * 'opstrategy'. For example, if it were equality, we'd return just the
1768 * partition that would contain that key or a set of partitions if the key
1769 * didn't consist of all partitioning columns. For non-equality strategies,
1770 * we'd need to include other partitions as appropriate.
1771 *
1772 * 'nullkeys' is the set containing the offset of the partition keys (0 to
1773 * partnatts - 1) that were matched to an IS NULL clause. This is only
1774 * considered for hash partitioning as we need to pass which keys are null
1775 * to the hash partition bound search function. It is never possible to
1776 * have an expression be present in 'exprs' for a given partition key and
1777 * the corresponding bit set in 'nullkeys'.
1778 */
1788
1789/*
1790 * PartitionPruneStepCombine - Information to prune using a BoolExpr clause
1791 *
1792 * For BoolExpr clauses, we combine the set of partitions determined for each
1793 * of the argument clauses.
1794 */
1800
1808
1809
1810/*
1811 * Plan invalidation info
1812 *
1813 * We track the objects on which a PlannedStmt depends in two ways:
1814 * relations are recorded as a simple list of OIDs, and everything else
1815 * is represented as a list of PlanInvalItems. A PlanInvalItem is designed
1816 * to be used with the syscache invalidation mechanism, so it identifies a
1817 * system catalog entry by cache ID and hash value.
1818 */
1819typedef struct PlanInvalItem
1820{
1822
1823 NodeTag type;
1824 /* a syscache ID, see utils/syscache.h */
1826 /* hash value of object's cache lookup key */
1829
1830/*
1831 * MonotonicFunction
1832 *
1833 * Allows the planner to track monotonic properties of functions. A function
1834 * is monotonically increasing if a subsequent call cannot yield a lower value
1835 * than the previous call. A monotonically decreasing function cannot yield a
1836 * higher value on subsequent calls, and a function which is both must return
1837 * the same value on each call.
1838 */
1846
1847/*
1848 * SubPlanRTInfo
1849 *
1850 * Information about which range table entries came from which subquery
1851 * planning cycles.
1852 */
1860
1861/*
1862 * ElidedNode
1863 *
1864 * Information about nodes elided from the final plan tree: trivial subquery
1865 * scans, and single-child Append and MergeAppend nodes.
1866 *
1867 * plan_node_id is that of the surviving plan node, the sole child of the
1868 * one which was elided.
1869 */
1877
1878#endif /* PLANNODES_H */
int16 AttrNumber
Definition attnum.h:21
int64_t int64
Definition c.h:680
uint64_t uint64
Definition c.h:684
uint32_t uint32
Definition c.h:683
unsigned int Index
Definition c.h:757
LockWaitPolicy
Definition lockoptions.h:38
LockClauseStrength
Definition lockoptions.h:22
SetOpCmd
Definition nodes.h:405
SetOpStrategy
Definition nodes.h:413
double Cost
Definition nodes.h:259
OnConflictAction
Definition nodes.h:425
double Cardinality
Definition nodes.h:260
CmdType
Definition nodes.h:271
AggStrategy
Definition nodes.h:361
NodeTag
Definition nodes.h:27
AggSplit
Definition nodes.h:383
LimitOption
Definition nodes.h:439
int ParseLoc
Definition nodes.h:248
JoinType
Definition nodes.h:296
#define plan(x)
Definition pg_regress.c:164
SubqueryScanStatus
Definition plannodes.h:767
@ SUBQUERY_SCAN_NONTRIVIAL
Definition plannodes.h:770
@ SUBQUERY_SCAN_UNKNOWN
Definition plannodes.h:768
@ SUBQUERY_SCAN_TRIVIAL
Definition plannodes.h:769
PartitionPruneCombineOp
Definition plannodes.h:1796
@ PARTPRUNE_COMBINE_INTERSECT
Definition plannodes.h:1798
@ PARTPRUNE_COMBINE_UNION
Definition plannodes.h:1797
PlannedStmtOrigin
Definition plannodes.h:36
@ PLAN_STMT_STANDARD
Definition plannodes.h:39
@ PLAN_STMT_UNKNOWN
Definition plannodes.h:37
@ PLAN_STMT_CACHE_CUSTOM
Definition plannodes.h:41
@ PLAN_STMT_CACHE_GENERIC
Definition plannodes.h:40
@ PLAN_STMT_INTERNAL
Definition plannodes.h:38
ResultType
Definition plannodes.h:276
@ RESULT_TYPE_UPPER
Definition plannodes.h:280
@ RESULT_TYPE_SCAN
Definition plannodes.h:278
@ RESULT_TYPE_GATING
Definition plannodes.h:277
@ RESULT_TYPE_MINMAX
Definition plannodes.h:281
@ RESULT_TYPE_JOIN
Definition plannodes.h:279
RowMarkType
Definition plannodes.h:1558
@ ROW_MARK_COPY
Definition plannodes.h:1564
@ ROW_MARK_REFERENCE
Definition plannodes.h:1563
@ ROW_MARK_SHARE
Definition plannodes.h:1561
@ ROW_MARK_EXCLUSIVE
Definition plannodes.h:1559
@ ROW_MARK_NOKEYEXCLUSIVE
Definition plannodes.h:1560
@ ROW_MARK_KEYSHARE
Definition plannodes.h:1562
MonotonicFunction
Definition plannodes.h:1840
@ MONOTONICFUNC_NONE
Definition plannodes.h:1841
@ MONOTONICFUNC_DECREASING
Definition plannodes.h:1843
@ MONOTONICFUNC_INCREASING
Definition plannodes.h:1842
@ MONOTONICFUNC_BOTH
Definition plannodes.h:1844
unsigned int Oid
static int fb(int x)
ScanDirection
Definition sdir.h:25
uint16 StrategyNumber
Definition stratnum.h:22
AggSplit aggsplit
Definition plannodes.h:1219
List * chain
Definition plannodes.h:1246
Oid *grpCollations pg_node_attr(array_size(numCols))
List * groupingSets
Definition plannodes.h:1243
Bitmapset * aggParams
Definition plannodes.h:1238
Cardinality numGroups
Definition plannodes.h:1232
Plan plan
Definition plannodes.h:1213
int numCols
Definition plannodes.h:1222
Oid *grpOperators pg_node_attr(array_size(numCols))
uint64 transitionSpace
Definition plannodes.h:1235
AttrNumber *grpColIdx pg_node_attr(array_size(numCols))
AggStrategy aggstrategy
Definition plannodes.h:1216
int first_partial_plan
Definition plannodes.h:418
int part_prune_index
Definition plannodes.h:425
int nasyncplans
Definition plannodes.h:412
List * child_append_relid_sets
Definition plannodes.h:406
Bitmapset * apprelids
Definition plannodes.h:403
Plan plan
Definition plannodes.h:400
List * appendplans
Definition plannodes.h:409
Plan plan
Definition plannodes.h:512
List * bitmapplans
Definition plannodes.h:513
List * bitmapqualorig
Definition plannodes.h:714
List * indexqualorig
Definition plannodes.h:698
List * bitmapplans
Definition plannodes.h:528
bool isshared
Definition plannodes.h:527
Plan plan
Definition plannodes.h:526
int ctePlanId
Definition plannodes.h:823
int cteParam
Definition plannodes.h:825
Scan scan
Definition plannodes.h:821
uint32 flags
Definition plannodes.h:936
List * custom_scan_tlist
Definition plannodes.h:944
List * custom_private
Definition plannodes.h:942
Bitmapset * custom_relids
Definition plannodes.h:946
List * custom_exprs
Definition plannodes.h:940
const struct CustomScanMethods * methods
Definition plannodes.h:953
List * custom_plans
Definition plannodes.h:938
NodeTag type
Definition plannodes.h:1872
NodeTag elided_type
Definition plannodes.h:1874
int plan_node_id
Definition plannodes.h:1873
Bitmapset * relids
Definition plannodes.h:1875
Oid checkAsUser
Definition plannodes.h:898
CmdType operation
Definition plannodes.h:894
List * fdw_exprs
Definition plannodes.h:902
bool fsSystemCol
Definition plannodes.h:914
Bitmapset * fs_relids
Definition plannodes.h:910
List * fdw_private
Definition plannodes.h:904
Bitmapset * fs_base_relids
Definition plannodes.h:912
Index resultRelation
Definition plannodes.h:896
List * fdw_recheck_quals
Definition plannodes.h:908
List * fdw_scan_tlist
Definition plannodes.h:906
List * functions
Definition plannodes.h:788
bool funcordinality
Definition plannodes.h:790
Oid *collations pg_node_attr(array_size(numCols))
Oid *sortOperators pg_node_attr(array_size(numCols))
bool *nullsFirst pg_node_attr(array_size(numCols))
Bitmapset * initParam
Definition plannodes.h:1412
AttrNumber *sortColIdx pg_node_attr(array_size(numCols))
int num_workers
Definition plannodes.h:1362
bool invisible
Definition plannodes.h:1368
Bitmapset * initParam
Definition plannodes.h:1374
bool single_copy
Definition plannodes.h:1366
Plan plan
Definition plannodes.h:1360
int rescan_param
Definition plannodes.h:1364
AttrNumber *grpColIdx pg_node_attr(array_size(numCols))
int numCols
Definition plannodes.h:1187
Plan plan
Definition plannodes.h:1184
Oid *grpCollations pg_node_attr(array_size(numCols))
Oid *grpOperators pg_node_attr(array_size(numCols))
List * hashcollations
Definition plannodes.h:1071
List * hashclauses
Definition plannodes.h:1069
List * hashoperators
Definition plannodes.h:1070
Join join
Definition plannodes.h:1068
List * hashkeys
Definition plannodes.h:1077
AttrNumber skewColumn
Definition plannodes.h:1436
List * hashkeys
Definition plannodes.h:1432
Oid skewTable
Definition plannodes.h:1434
bool skewInherit
Definition plannodes.h:1438
Cardinality rows_total
Definition plannodes.h:1441
Plan plan
Definition plannodes.h:1425
List * indexqual
Definition plannodes.h:660
List * recheckqual
Definition plannodes.h:662
List * indextlist
Definition plannodes.h:666
ScanDirection indexorderdir
Definition plannodes.h:668
List * indexorderby
Definition plannodes.h:664
List * indexorderby
Definition plannodes.h:614
List * indexorderbyops
Definition plannodes.h:618
ScanDirection indexorderdir
Definition plannodes.h:620
Scan scan
Definition plannodes.h:606
List * indexqualorig
Definition plannodes.h:612
Oid indexid
Definition plannodes.h:608
List * indexqual
Definition plannodes.h:610
List * indexorderbyorig
Definition plannodes.h:616
pg_node_attr(abstract) Plan plan
List * joinqual
Definition plannodes.h:993
JoinType jointype
Definition plannodes.h:990
Bitmapset * ojrelids
Definition plannodes.h:994
bool inner_unique
Definition plannodes.h:991
LimitOption limitOption
Definition plannodes.h:1511
Oid *uniqOperators pg_node_attr(array_size(uniqNumCols))
Plan plan
Definition plannodes.h:1502
Node * limitCount
Definition plannodes.h:1508
AttrNumber *uniqColIdx pg_node_attr(array_size(uniqNumCols))
int uniqNumCols
Definition plannodes.h:1514
Oid *uniqCollations pg_node_attr(array_size(uniqNumCols))
Node * limitOffset
Definition plannodes.h:1505
Definition pg_list.h:54
int epqParam
Definition plannodes.h:1490
List * rowMarks
Definition plannodes.h:1488
Plan plan
Definition plannodes.h:1486
Plan plan
Definition plannodes.h:1086
Plan plan
Definition plannodes.h:1095
bool singlerow
Definition plannodes.h:1113
Cardinality est_calls
Definition plannodes.h:1131
Bitmapset * keyparamids
Definition plannodes.h:1128
Oid *hashOperators pg_node_attr(array_size(numKeys))
bool binary_mode
Definition plannodes.h:1119
int numKeys
Definition plannodes.h:1098
Cardinality est_unique_keys
Definition plannodes.h:1134
List * param_exprs
Definition plannodes.h:1107
double est_hit_ratio
Definition plannodes.h:1137
uint32 est_entries
Definition plannodes.h:1125
Oid *collations pg_node_attr(array_size(numKeys))
bool *nullsFirst pg_node_attr(array_size(numCols))
AttrNumber *sortColIdx pg_node_attr(array_size(numCols))
int part_prune_index
Definition plannodes.h:468
Oid *sortOperators pg_node_attr(array_size(numCols))
Bitmapset * apprelids
Definition plannodes.h:438
Oid *collations pg_node_attr(array_size(numCols))
List * mergeplans
Definition plannodes.h:444
List * child_append_relid_sets
Definition plannodes.h:441
List * mergeclauses
Definition plannodes.h:1045
Oid *mergeFamilies pg_node_attr(array_size(mergeclauses))
bool skip_mark_restore
Definition plannodes.h:1042
bool *mergeReversals pg_node_attr(array_size(mergeclauses))
bool *mergeNullsFirst pg_node_attr(array_size(mergeclauses))
Oid *mergeCollations pg_node_attr(array_size(mergeclauses))
List * updateColnosLists
Definition plannodes.h:350
Index nominalRelation
Definition plannodes.h:344
List * arbiterIndexes
Definition plannodes.h:370
List * onConflictCols
Definition plannodes.h:376
List * mergeJoinConditions
Definition plannodes.h:388
char * returningOldAlias
Definition plannodes.h:354
char * returningNewAlias
Definition plannodes.h:356
CmdType operation
Definition plannodes.h:340
Node * forPortionOf
Definition plannodes.h:380
List * resultRelations
Definition plannodes.h:348
Bitmapset * fdwDirectModifyPlans
Definition plannodes.h:362
List * onConflictSet
Definition plannodes.h:374
List * exclRelTlist
Definition plannodes.h:384
List * mergeActionLists
Definition plannodes.h:386
bool canSetTag
Definition plannodes.h:342
List * fdwPrivLists
Definition plannodes.h:360
List * returningLists
Definition plannodes.h:358
List * withCheckOptionLists
Definition plannodes.h:352
LockClauseStrength onConflictLockStrength
Definition plannodes.h:372
Index rootRelation
Definition plannodes.h:346
Node * onConflictWhere
Definition plannodes.h:378
List * rowMarks
Definition plannodes.h:364
OnConflictAction onConflictAction
Definition plannodes.h:368
Index exclRelRTI
Definition plannodes.h:382
pg_node_attr(no_equal, no_query_jumble) NodeTag type
List * nestParams
Definition plannodes.h:1012
Join join
Definition plannodes.h:1010
Definition nodes.h:133
Bitmapset * other_subplans
Definition plannodes.h:1672
Bitmapset * relids
Definition plannodes.h:1670
pg_node_attr(no_equal, no_query_jumble) NodeTag type
PartitionPruneCombineOp combineOp
Definition plannodes.h:1805
PartitionPruneStep step
Definition plannodes.h:1803
PartitionPruneStep step
Definition plannodes.h:1781
StrategyNumber opstrategy
Definition plannodes.h:1783
Bitmapset * nullkeys
Definition plannodes.h:1786
pg_node_attr(abstract, no_equal, no_query_jumble) NodeTag type
Oid *relid_map pg_node_attr(array_size(nparts))
pg_node_attr(no_equal, no_query_jumble) NodeTag type
Bitmapset * present_parts
Definition plannodes.h:1706
int *leafpart_rti_map pg_node_attr(array_size(nparts))
int *subplan_map pg_node_attr(array_size(nparts))
int *subpart_map pg_node_attr(array_size(nparts))
uint32 hashValue
Definition plannodes.h:1827
pg_node_attr(no_equal, no_query_jumble) NodeTag type
LockClauseStrength strength
Definition plannodes.h:1623
RowMarkType markType
Definition plannodes.h:1619
LockWaitPolicy waitPolicy
Definition plannodes.h:1625
Index rowmarkId
Definition plannodes.h:1617
pg_node_attr(no_equal, no_query_jumble) NodeTag type
Bitmapset * extParam
Definition plannodes.h:255
struct Plan * lefttree
Definition plannodes.h:239
bool async_capable
Definition plannodes.h:227
Cost total_cost
Definition plannodes.h:205
struct Plan * righttree
Definition plannodes.h:240
bool parallel_aware
Definition plannodes.h:219
Cost startup_cost
Definition plannodes.h:203
List * qual
Definition plannodes.h:237
int plan_width
Definition plannodes.h:213
Bitmapset * allParam
Definition plannodes.h:256
bool parallel_safe
Definition plannodes.h:221
Cardinality plan_rows
Definition plannodes.h:211
int plan_node_id
Definition plannodes.h:233
int disabled_nodes
Definition plannodes.h:201
List * targetlist
Definition plannodes.h:235
pg_node_attr(abstract, no_equal, no_query_jumble) NodeTag type
List * initPlan
Definition plannodes.h:242
struct Plan * planTree
Definition plannodes.h:99
bool hasModifyingCTE
Definition plannodes.h:81
List * appendRelations
Definition plannodes.h:124
List * elidedNodes
Definition plannodes.h:156
List * permInfos
Definition plannodes.h:118
bool canSetTag
Definition plannodes.h:84
List * rowMarks
Definition plannodes.h:138
int64 planId
Definition plannodes.h:72
Bitmapset * rewindPlanIDs
Definition plannodes.h:135
List * extension_state
Definition plannodes.h:165
int64 queryId
Definition plannodes.h:69
ParseLoc stmt_len
Definition plannodes.h:171
PlannedStmtOrigin planOrigin
Definition plannodes.h:75
bool hasReturning
Definition plannodes.h:78
ParseLoc stmt_location
Definition plannodes.h:169
Bitmapset * resultRelationRelids
Definition plannodes.h:121
List * invalItems
Definition plannodes.h:147
bool transientPlan
Definition plannodes.h:87
Bitmapset * rowMarkRelids
Definition plannodes.h:141
List * subplans
Definition plannodes.h:129
List * relationOids
Definition plannodes.h:144
List * subrtinfos
Definition plannodes.h:132
bool dependsOnRole
Definition plannodes.h:90
Bitmapset * unprunableRelids
Definition plannodes.h:113
CmdType commandType
Definition plannodes.h:66
pg_node_attr(no_equal, no_query_jumble) NodeTag type
Node * utilityStmt
Definition plannodes.h:153
List * rtable
Definition plannodes.h:107
List * partPruneInfos
Definition plannodes.h:104
List * paramExecTypes
Definition plannodes.h:150
bool parallelModeNeeded
Definition plannodes.h:93
AttrNumber *dupColIdx pg_node_attr(array_size(numCols))
Cardinality numGroups
Definition plannodes.h:499
Oid *dupOperators pg_node_attr(array_size(numCols))
Oid *dupCollations pg_node_attr(array_size(numCols))
Node * resconstantqual
Definition plannodes.h:305
ResultType result_type
Definition plannodes.h:304
Bitmapset * relids
Definition plannodes.h:306
Plan plan
Definition plannodes.h:303
struct TableSampleClause * tablesample
Definition plannodes.h:564
Index scanrelid
Definition plannodes.h:544
pg_node_attr(abstract) Plan plan
Scan scan
Definition plannodes.h:553
SetOpStrategy strategy
Definition plannodes.h:1456
Oid *cmpOperators pg_node_attr(array_size(numCols))
AttrNumber *cmpColIdx pg_node_attr(array_size(numCols))
SetOpCmd cmd
Definition plannodes.h:1453
Oid *cmpCollations pg_node_attr(array_size(numCols))
int numCols
Definition plannodes.h:1459
Plan plan
Definition plannodes.h:1450
bool *cmpNullsFirst pg_node_attr(array_size(numCols))
Cardinality numGroups
Definition plannodes.h:1472
Oid *collations pg_node_attr(array_size(numCols))
bool *nullsFirst pg_node_attr(array_size(numCols))
Oid *sortOperators pg_node_attr(array_size(numCols))
int numCols
Definition plannodes.h:1150
AttrNumber *sortColIdx pg_node_attr(array_size(numCols))
Plan plan
Definition plannodes.h:1147
char * plan_name
Definition plannodes.h:1856
SubqueryScanStatus scanstatus
Definition plannodes.h:777
Plan * subplan
Definition plannodes.h:776
TableFunc * tablefunc
Definition plannodes.h:812
List * tidrangequals
Definition plannodes.h:743
Scan scan
Definition plannodes.h:727
List * tidquals
Definition plannodes.h:729
AttrNumber *uniqColIdx pg_node_attr(array_size(numCols))
Oid *uniqOperators pg_node_attr(array_size(numCols))
Oid *uniqCollations pg_node_attr(array_size(numCols))
Plan plan
Definition plannodes.h:1332
int numCols
Definition plannodes.h:1335
List * values_lists
Definition plannodes.h:801
AttrNumber *ordColIdx pg_node_attr(array_size(ordNumCols))
char * winname
Definition plannodes.h:1258
int partNumCols
Definition plannodes.h:1264
Oid endInRangeFunc
Definition plannodes.h:1308
Node * endOffset
Definition plannodes.h:1294
Oid *partCollations pg_node_attr(array_size(partNumCols))
bool topWindow
Definition plannodes.h:1323
Oid *ordOperators pg_node_attr(array_size(ordNumCols))
List * runConditionOrig
Definition plannodes.h:1300
Oid inRangeColl
Definition plannodes.h:1311
Node * startOffset
Definition plannodes.h:1291
List * runCondition
Definition plannodes.h:1297
Oid startInRangeFunc
Definition plannodes.h:1305
bool inRangeAsc
Definition plannodes.h:1314
Index winref
Definition plannodes.h:1261
AttrNumber *partColIdx pg_node_attr(array_size(partNumCols))
bool inRangeNullsFirst
Definition plannodes.h:1317
Oid *partOperators pg_node_attr(array_size(partNumCols))
int ordNumCols
Definition plannodes.h:1276
Oid *ordCollations pg_node_attr(array_size(ordNumCols))
int frameOptions
Definition plannodes.h:1288
const char * type