summaryrefslogtreecommitdiff
path: root/src/include/partitioning/partprune.h
blob: e3b3bfb7c113dd47c8411287a7e574254be40565 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*-------------------------------------------------------------------------
 *
 * partprune.h
 *	  prototypes for partprune.c
 *
 *
 * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 * src/include/partitioning/partprune.h
 *
 *-------------------------------------------------------------------------
 */
#ifndef PARTPRUNE_H
#define PARTPRUNE_H

#include "nodes/execnodes.h"
#include "nodes/relation.h"


/*
 * PartitionPruneContext
 *
 * Information about a partitioned table needed to perform partition pruning.
 */
typedef struct PartitionPruneContext
{
	/* Partition key information */
	char		strategy;
	int			partnatts;
	Oid		   *partopfamily;
	Oid		   *partopcintype;
	Oid		   *partcollation;
	FmgrInfo   *partsupfunc;

	/* Number of partitions */
	int			nparts;

	/* Partition boundary info */
	PartitionBoundInfo boundinfo;

	/*
	 * This will be set when the context is used from the executor, to allow
	 * Params to be evaluated.
	 */
	PlanState  *planstate;

	/*
	 * Array of ExprStates, indexed as per PruneCtxStateIdx; one for each
	 * partkey in each pruning step.  Allocated if planstate is non-NULL,
	 * otherwise NULL.
	 */
	ExprState **exprstates;

	/*
	 * Similar array of flags, each true if corresponding 'exprstate'
	 * expression contains any PARAM_EXEC Params.  (Can be NULL if planstate
	 * is NULL.)
	 */
	bool	   *exprhasexecparam;

	/* true if it's safe to evaluate PARAM_EXEC Params */
	bool		evalexecparams;
} PartitionPruneContext;

#define PruneCxtStateIdx(partnatts, step_id, keyno) \
	((partnatts) * (step_id) + (keyno))

extern List *make_partition_pruneinfo(PlannerInfo *root, List *partition_rels,
						 List *subpaths, List *prunequal);
extern Relids prune_append_rel_partitions(RelOptInfo *rel);
extern Bitmapset *get_matching_partitions(PartitionPruneContext *context,
						List *pruning_steps);

#endif							/* PARTPRUNE_H */