Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 003c68a

Browse files
committed
Rename rbtree.c functions to use "rbt" prefix not "rb" prefix.
The "rb" prefix is used by Ruby, so that our existing code results in name collisions that break plruby. We discussed ways to prevent that by adjusting dynamic linker options, but it seems that at best we'd move the pain to other cases. Renaming to avoid the collision is the only portable fix anyway. Fortunately, our rbtree code is not (yet?) widely used --- in core, there's only a single usage in GIN --- so it seems likely that we can get away with a rename. I chose to do this basically as s/rb/rbt/g, except for places where there already was a "t" after "rb". The patch could have been made smaller by only touching linker-visible symbols, but it would have resulted in oddly inconsistent-looking code. Better to make it look like "rbt" was the plan all along. Back-patch to v10. The rbtree.c code exists back to 9.5, but rb_iterate() which is the actual immediate source of pain was added in v10, so it seems like changing the names before that would have more risk than benefit. Per report from Pavel Raiskup. Discussion: https://postgr.es/m/4738198.8KVIIDhgEB@nb.usersys.redhat.com
1 parent 8f623be commit 003c68a

File tree

5 files changed

+267
-264
lines changed

5 files changed

+267
-264
lines changed

src/backend/access/gin/ginbulk.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
/* Combiner function for rbtree.c */
2929
static void
30-
ginCombineData(RBNode *existing, const RBNode *newdata, void *arg)
30+
ginCombineData(RBTNode *existing, const RBTNode *newdata, void *arg)
3131
{
3232
GinEntryAccumulator *eo = (GinEntryAccumulator *) existing;
3333
const GinEntryAccumulator *en = (const GinEntryAccumulator *) newdata;
@@ -69,7 +69,7 @@ ginCombineData(RBNode *existing, const RBNode *newdata, void *arg)
6969

7070
/* Comparator function for rbtree.c */
7171
static int
72-
cmpEntryAccumulator(const RBNode *a, const RBNode *b, void *arg)
72+
cmpEntryAccumulator(const RBTNode *a, const RBTNode *b, void *arg)
7373
{
7474
const GinEntryAccumulator *ea = (const GinEntryAccumulator *) a;
7575
const GinEntryAccumulator *eb = (const GinEntryAccumulator *) b;
@@ -81,15 +81,15 @@ cmpEntryAccumulator(const RBNode *a, const RBNode *b, void *arg)
8181
}
8282

8383
/* Allocator function for rbtree.c */
84-
static RBNode *
84+
static RBTNode *
8585
ginAllocEntryAccumulator(void *arg)
8686
{
8787
BuildAccumulator *accum = (BuildAccumulator *) arg;
8888
GinEntryAccumulator *ea;
8989

9090
/*
9191
* Allocate memory by rather big chunks to decrease overhead. We have no
92-
* need to reclaim RBNodes individually, so this costs nothing.
92+
* need to reclaim RBTNodes individually, so this costs nothing.
9393
*/
9494
if (accum->entryallocator == NULL || accum->eas_used >= DEF_NENTRY)
9595
{
@@ -98,11 +98,11 @@ ginAllocEntryAccumulator(void *arg)
9898
accum->eas_used = 0;
9999
}
100100

101-
/* Allocate new RBNode from current chunk */
101+
/* Allocate new RBTNode from current chunk */
102102
ea = accum->entryallocator + accum->eas_used;
103103
accum->eas_used++;
104104

105-
return (RBNode *) ea;
105+
return (RBTNode *) ea;
106106
}
107107

108108
void
@@ -112,12 +112,12 @@ ginInitBA(BuildAccumulator *accum)
112112
accum->allocatedMemory = 0;
113113
accum->entryallocator = NULL;
114114
accum->eas_used = 0;
115-
accum->tree = rb_create(sizeof(GinEntryAccumulator),
116-
cmpEntryAccumulator,
117-
ginCombineData,
118-
ginAllocEntryAccumulator,
119-
NULL, /* no freefunc needed */
120-
(void *) accum);
115+
accum->tree = rbt_create(sizeof(GinEntryAccumulator),
116+
cmpEntryAccumulator,
117+
ginCombineData,
118+
ginAllocEntryAccumulator,
119+
NULL, /* no freefunc needed */
120+
(void *) accum);
121121
}
122122

123123
/*
@@ -163,8 +163,8 @@ ginInsertBAEntry(BuildAccumulator *accum,
163163
/* temporarily set up single-entry itempointer list */
164164
eatmp.list = heapptr;
165165

166-
ea = (GinEntryAccumulator *) rb_insert(accum->tree, (RBNode *) &eatmp,
167-
&isNew);
166+
ea = (GinEntryAccumulator *) rbt_insert(accum->tree, (RBTNode *) &eatmp,
167+
&isNew);
168168

169169
if (isNew)
170170
{
@@ -256,7 +256,7 @@ qsortCompareItemPointers(const void *a, const void *b)
256256
void
257257
ginBeginBAScan(BuildAccumulator *accum)
258258
{
259-
rb_begin_iterate(accum->tree, LeftRightWalk, &accum->tree_walk);
259+
rbt_begin_iterate(accum->tree, LeftRightWalk, &accum->tree_walk);
260260
}
261261

262262
/*
@@ -272,7 +272,7 @@ ginGetBAEntry(BuildAccumulator *accum,
272272
GinEntryAccumulator *entry;
273273
ItemPointerData *list;
274274

275-
entry = (GinEntryAccumulator *) rb_iterate(&accum->tree_walk);
275+
entry = (GinEntryAccumulator *) rbt_iterate(&accum->tree_walk);
276276

277277
if (entry == NULL)
278278
return NULL; /* no more entries */

0 commit comments

Comments
 (0)