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