PostgreSQL Source Code  git master
partprune.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * partprune.h
4  * prototypes for partprune.c
5  *
6  *
7  * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/partitioning/partprune.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef PARTPRUNE_H
15 #define PARTPRUNE_H
16 
17 #include "nodes/execnodes.h"
18 #include "partitioning/partdefs.h"
19 
20 struct PlannerInfo; /* avoid including pathnodes.h here */
21 struct RelOptInfo;
22 
23 
24 /*
25  * PartitionPruneContext
26  * Stores information needed at runtime for pruning computations
27  * related to a single partitioned table.
28  *
29  * strategy Partition strategy, e.g. LIST, RANGE, HASH.
30  * partnatts Number of columns in the partition key.
31  * nparts Number of partitions in this partitioned table.
32  * boundinfo Partition boundary info for the partitioned table.
33  * partcollation Array of partnatts elements, storing the collations of the
34  * partition key columns.
35  * partsupfunc Array of FmgrInfos for the comparison or hashing functions
36  * associated with the partition keys (partnatts elements).
37  * (This points into the partrel's partition key, typically.)
38  * stepcmpfuncs Array of FmgrInfos for the comparison or hashing function
39  * for each pruning step and partition key.
40  * ppccontext Memory context holding this PartitionPruneContext's
41  * subsidiary data, such as the FmgrInfos.
42  * planstate Points to the parent plan node's PlanState when called
43  * during execution; NULL when called from the planner.
44  * exprcontext ExprContext to use when evaluating pruning expressions
45  * exprstates Array of ExprStates, indexed as per PruneCxtStateIdx; one
46  * for each partition key in each pruning step. Allocated if
47  * planstate is non-NULL, otherwise NULL.
48  */
49 typedef struct PartitionPruneContext
50 {
51  char strategy;
52  int partnatts;
53  int nparts;
63 
64 /*
65  * PruneCxtStateIdx() computes the correct index into the stepcmpfuncs[]
66  * and exprstates[] arrays for step step_id and partition key column keyno.
67  * (Note: there is code that assumes the entries for a given step are
68  * sequential, so this is not chosen freely.)
69  */
70 #define PruneCxtStateIdx(partnatts, step_id, keyno) \
71  ((partnatts) * (step_id) + (keyno))
72 
74  struct RelOptInfo *parentrel,
75  List *subpaths,
76  List *prunequal);
79  List *pruning_steps);
80 
81 #endif /* PARTPRUNE_H */
Bitmapset * get_matching_partitions(PartitionPruneContext *context, List *pruning_steps)
Definition: partprune.c:819
struct PartitionPruneContext PartitionPruneContext
Bitmapset * prune_append_rel_partitions(struct RelOptInfo *rel)
Definition: partprune.c:752
PartitionPruneInfo * make_partition_pruneinfo(struct PlannerInfo *root, struct RelOptInfo *parentrel, List *subpaths, List *prunequal)
Definition: partprune.c:222
unsigned int Oid
Definition: postgres_ext.h:31
Definition: fmgr.h:57
Definition: pg_list.h:51
FmgrInfo * partsupfunc
Definition: partprune.h:56
ExprContext * exprcontext
Definition: partprune.h:60
MemoryContext ppccontext
Definition: partprune.h:58
PartitionBoundInfo boundinfo
Definition: partprune.h:54
PlanState * planstate
Definition: partprune.h:59
FmgrInfo * stepcmpfuncs
Definition: partprune.h:57
ExprState ** exprstates
Definition: partprune.h:61