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