2121#define DEF_NENTRY 2048 /* RumEntryAccumulator allocation quantum */
2222#define DEF_NPTR 5 /* ItemPointer initial allocation quantum */
2323
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+
2432
2533/* Combiner function for rbtree.c */
2634static void
27- rumCombineData (RBNode * existing , const RBNode * newdata , void * arg )
35+ rumCombineData (RBTNode * existing , const RBTNode * newdata , void * arg )
2836{
2937 RumEntryAccumulator * eo = (RumEntryAccumulator * ) existing ;
3038 const RumEntryAccumulator * en = (const RumEntryAccumulator * ) newdata ;
@@ -65,7 +73,7 @@ rumCombineData(RBNode *existing, const RBNode *newdata, void *arg)
6573
6674/* Comparator function for rbtree.c */
6775static int
68- cmpEntryAccumulator (const RBNode * a , const RBNode * b , void * arg )
76+ cmpEntryAccumulator (const RBTNode * a , const RBTNode * b , void * arg )
6977{
7078 const RumEntryAccumulator * ea = (const RumEntryAccumulator * ) a ;
7179 const RumEntryAccumulator * eb = (const RumEntryAccumulator * ) b ;
@@ -77,15 +85,15 @@ cmpEntryAccumulator(const RBNode *a, const RBNode *b, void *arg)
7785}
7886
7987/* Allocator function for rbtree.c */
80- static RBNode *
88+ static RBTNode *
8189rumAllocEntryAccumulator (void * arg )
8290{
8391 BuildAccumulator * accum = (BuildAccumulator * ) arg ;
8492 RumEntryAccumulator * ea ;
8593
8694 /*
8795 * 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.
8997 */
9098 if (accum -> entryallocator == NULL || accum -> eas_used >= DEF_NENTRY )
9199 {
@@ -94,11 +102,11 @@ rumAllocEntryAccumulator(void *arg)
94102 accum -> eas_used = 0 ;
95103 }
96104
97- /* Allocate new RBNode from current chunk */
105+ /* Allocate new RBTNode from current chunk */
98106 ea = accum -> entryallocator + accum -> eas_used ;
99107 accum -> eas_used ++ ;
100108
101- return (RBNode * ) ea ;
109+ return (RBTNode * ) ea ;
102110}
103111
104112void
@@ -108,12 +116,12 @@ rumInitBA(BuildAccumulator *accum)
108116 accum -> allocatedMemory = 0 ;
109117 accum -> entryallocator = NULL ;
110118 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 );
117125}
118126
119127/*
@@ -163,8 +171,8 @@ rumInsertBAEntry(BuildAccumulator *accum,
163171 item .addInfo = addInfo ;
164172 item .addInfoIsNull = addInfoIsNull ;
165173
166- ea = (RumEntryAccumulator * ) rb_insert (accum -> tree , (RBNode * ) & eatmp ,
167- & isNew );
174+ ea = (RumEntryAccumulator * ) rbt_insert (accum -> tree , (RBTNode * ) & eatmp ,
175+ & isNew );
168176
169177 if (isNew )
170178 {
273281rumBeginBAScan (BuildAccumulator * accum )
274282{
275283#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 );
277285#else
278286 rb_begin_iterate (accum -> tree , LeftRightWalk );
279287#endif
@@ -293,7 +301,7 @@ rumGetBAEntry(BuildAccumulator *accum,
293301 RumItem * list ;
294302
295303#if PG_VERSION_NUM >= 100000
296- entry = (RumEntryAccumulator * ) rb_iterate (& accum -> tree_walk );
304+ entry = (RumEntryAccumulator * ) rbt_iterate (& accum -> tree_walk );
297305#else
298306 entry = (RumEntryAccumulator * ) rb_iterate (accum -> tree );
299307#endif
0 commit comments