21
21
#define DEF_NENTRY 2048 /* RumEntryAccumulator allocation quantum */
22
22
#define DEF_NPTR 5 /* ItemPointer initial allocation quantum */
23
23
24
+ /* PostgreSQL pre 10 has different names for this functions */
25
+ #if PG_VERSION_NUM < 100000
26
+ #define rbt_create (node_size , comparator , combiner , allocfunc , freefunc , arg ) \
27
+ (rb_create(node_size, comparator, combiner, allocfunc, freefunc, arg))
28
+ #define rbt_insert (rbt , data , isNew ) \
29
+ (rb_insert(rbt, data, isNew))
30
+ #endif
31
+
24
32
25
33
/* Combiner function for rbtree.c */
26
34
static void
27
- rumCombineData (RBNode * existing , const RBNode * newdata , void * arg )
35
+ rumCombineData (RBTNode * existing , const RBTNode * newdata , void * arg )
28
36
{
29
37
RumEntryAccumulator * eo = (RumEntryAccumulator * ) existing ;
30
38
const RumEntryAccumulator * en = (const RumEntryAccumulator * ) newdata ;
@@ -65,7 +73,7 @@ rumCombineData(RBNode *existing, const RBNode *newdata, void *arg)
65
73
66
74
/* Comparator function for rbtree.c */
67
75
static int
68
- cmpEntryAccumulator (const RBNode * a , const RBNode * b , void * arg )
76
+ cmpEntryAccumulator (const RBTNode * a , const RBTNode * b , void * arg )
69
77
{
70
78
const RumEntryAccumulator * ea = (const RumEntryAccumulator * ) a ;
71
79
const RumEntryAccumulator * eb = (const RumEntryAccumulator * ) b ;
@@ -77,15 +85,15 @@ cmpEntryAccumulator(const RBNode *a, const RBNode *b, void *arg)
77
85
}
78
86
79
87
/* Allocator function for rbtree.c */
80
- static RBNode *
88
+ static RBTNode *
81
89
rumAllocEntryAccumulator (void * arg )
82
90
{
83
91
BuildAccumulator * accum = (BuildAccumulator * ) arg ;
84
92
RumEntryAccumulator * ea ;
85
93
86
94
/*
87
95
* Allocate memory by rather big chunks to decrease overhead. We have no
88
- * need to reclaim RBNodes individually, so this costs nothing.
96
+ * need to reclaim RBTNodes individually, so this costs nothing.
89
97
*/
90
98
if (accum -> entryallocator == NULL || accum -> eas_used >= DEF_NENTRY )
91
99
{
@@ -94,11 +102,11 @@ rumAllocEntryAccumulator(void *arg)
94
102
accum -> eas_used = 0 ;
95
103
}
96
104
97
- /* Allocate new RBNode from current chunk */
105
+ /* Allocate new RBTNode from current chunk */
98
106
ea = accum -> entryallocator + accum -> eas_used ;
99
107
accum -> eas_used ++ ;
100
108
101
- return (RBNode * ) ea ;
109
+ return (RBTNode * ) ea ;
102
110
}
103
111
104
112
void
@@ -108,12 +116,12 @@ rumInitBA(BuildAccumulator *accum)
108
116
accum -> allocatedMemory = 0 ;
109
117
accum -> entryallocator = NULL ;
110
118
accum -> eas_used = 0 ;
111
- accum -> tree = rb_create (sizeof (RumEntryAccumulator ),
112
- cmpEntryAccumulator ,
113
- rumCombineData ,
114
- rumAllocEntryAccumulator ,
115
- NULL , /* no freefunc needed */
116
- (void * ) accum );
119
+ accum -> tree = rbt_create (sizeof (RumEntryAccumulator ),
120
+ cmpEntryAccumulator ,
121
+ rumCombineData ,
122
+ rumAllocEntryAccumulator ,
123
+ NULL , /* no freefunc needed */
124
+ (void * ) accum );
117
125
}
118
126
119
127
/*
@@ -163,8 +171,8 @@ rumInsertBAEntry(BuildAccumulator *accum,
163
171
item .addInfo = addInfo ;
164
172
item .addInfoIsNull = addInfoIsNull ;
165
173
166
- ea = (RumEntryAccumulator * ) rb_insert (accum -> tree , (RBNode * ) & eatmp ,
167
- & isNew );
174
+ ea = (RumEntryAccumulator * ) rbt_insert (accum -> tree , (RBTNode * ) & eatmp ,
175
+ & isNew );
168
176
169
177
if (isNew )
170
178
{
273
281
rumBeginBAScan (BuildAccumulator * accum )
274
282
{
275
283
#if PG_VERSION_NUM >= 100000
276
- rb_begin_iterate (accum -> tree , LeftRightWalk , & accum -> tree_walk );
284
+ rbt_begin_iterate (accum -> tree , LeftRightWalk , & accum -> tree_walk );
277
285
#else
278
286
rb_begin_iterate (accum -> tree , LeftRightWalk );
279
287
#endif
@@ -293,7 +301,7 @@ rumGetBAEntry(BuildAccumulator *accum,
293
301
RumItem * list ;
294
302
295
303
#if PG_VERSION_NUM >= 100000
296
- entry = (RumEntryAccumulator * ) rb_iterate (& accum -> tree_walk );
304
+ entry = (RumEntryAccumulator * ) rbt_iterate (& accum -> tree_walk );
297
305
#else
298
306
entry = (RumEntryAccumulator * ) rb_iterate (accum -> tree );
299
307
#endif
0 commit comments