27
27
#include "parser/parsetree.h"
28
28
29
29
30
- /* Check PostgreSQL version */
31
- /*
32
- * TODO: a fix for WaitForBackgroundWorkerShutdown()
33
- * has been accepted, so we have to update this number.
34
- */
35
- #if PG_VERSION_NUM < 90503
36
- #error "Cannot build pg_pathman with PostgreSQL version lower than 9.5.3"
30
+ /* Check PostgreSQL version (9.5.4 contains an important fix for BGW) */
31
+ #if PG_VERSION_NUM < 90504
32
+ #error "Cannot build pg_pathman with PostgreSQL version lower than 9.5.4"
37
33
#endif
38
34
39
- /*Print Datum as CString to server log */
35
+ /*Get CString representation of Datum (simple wrapper) */
40
36
#ifdef USE_ASSERT_CHECKING
41
37
#include "utils.h"
42
38
#define DebugPrintDatum (datum ,typid ) ( datum_to_cstring((datum), (typid)) )
59
55
/* type modifier (typmod) for 'range_interval' */
60
56
#define PATHMAN_CONFIG_interval_typmod -1
61
57
58
+ /*
59
+ * Cache current PATHMAN_CONFIG relid (set during load_config()).
60
+ */
62
61
extern Oid pathman_config_relid ;
63
62
63
+ /*
64
+ * Just to clarify our intentions (returns pathman_config_relid).
65
+ */
64
66
Oid get_pathman_config_relid (void );
65
67
66
68
@@ -72,10 +74,12 @@ typedef struct PathmanState
72
74
LWLock * dsm_init_lock ,
73
75
* load_config_lock ,
74
76
* edit_partitions_lock ;
75
- DsmArray databases ;
76
77
}PathmanState ;
77
78
78
79
80
+ /*
81
+ * Result of search_range_partition_eq().
82
+ */
79
83
typedef enum
80
84
{
81
85
SEARCH_RANGEREL_OUT_OF_RANGE = 0 ,
@@ -115,7 +119,6 @@ extern PathmanState *pmstate;
115
119
} while (0)
116
120
117
121
118
- /* utility functions */
119
122
int append_child_relation (PlannerInfo * root ,RelOptInfo * rel ,Index rti ,
120
123
RangeTblEntry * rte ,int index ,Oid childOID ,List * wrappers );
121
124
@@ -140,25 +143,22 @@ void set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, Index rti,
140
143
141
144
typedef struct
142
145
{
143
- const Node * orig ;
144
- List * args ;
145
- List * rangeset ;
146
- bool found_gap ;
147
- double paramsel ;
146
+ const Node * orig ;/* examined expression */
147
+ List * args ;/* extracted from 'orig' */
148
+ List * rangeset ;/* IndexRanges representing selected parts */
149
+ bool found_gap ;/* were there any gaps? */
150
+ double paramsel ;/* estimated selectivity */
148
151
}WrapperNode ;
149
152
150
153
typedef struct
151
154
{
152
- /* Main partitioning structure */
153
- const PartRelationInfo * prel ;
154
-
155
+ const PartRelationInfo * prel ;/* main partitioning structure */
155
156
ExprContext * econtext ;/* for ExecEvalExpr() */
156
-
157
157
bool for_insert ;/* are we in PartitionFilter now? */
158
158
}WalkerContext ;
159
159
160
160
/*
161
- * Usual initialization procedure for WalkerContext
161
+ * Usual initialization procedure for WalkerContext.
162
162
*/
163
163
#define InitWalkerContext (context ,prel_info ,ecxt ,for_ins ) \
164
164
do { \
@@ -184,6 +184,7 @@ void select_range_partitions(const Datum value,
184
184
const int strategy ,
185
185
WrapperNode * result );
186
186
187
+ /* Examine expression in order to select partitions. */
187
188
WrapperNode * walk_expr_tree (Expr * expr ,WalkerContext * context );
188
189
189
190
#endif /* PATHMAN_H */