Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7f025c9

Browse files
committed
Issue#48: Renames for PostgreSQL 10 and 11 in rbtree structures and functions
1 parent4ed27db commit7f025c9

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

‎src/rum.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,9 +773,13 @@ extern IndexBulkDeleteResult *rumvacuumcleanup(IndexVacuumInfo *info,
773773
externboolrumvalidate(Oidopclassoid);
774774

775775
/* rumbulk.c */
776+
#ifPG_VERSION_NUM<100000
777+
#defineRBTNode RBNode
778+
#endif
779+
776780
typedefstructRumEntryAccumulator
777781
{
778-
RBNoderbnode;
782+
RBTNoderbnode;
779783
Datumkey;
780784
RumNullCategorycategory;
781785
OffsetNumberattnum;

‎src/rumbulk.c

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,18 @@
2121
#defineDEF_NENTRY2048/* RumEntryAccumulator allocation quantum */
2222
#defineDEF_NPTR5/* ItemPointer initial allocation quantum */
2323

24+
/* PostgreSQL pre 10 has different names for this functions */
25+
#ifPG_VERSION_NUM<100000
26+
#definerbt_create(node_size,comparator,combiner,allocfunc,freefunc,arg) \
27+
(rb_create(node_size, comparator, combiner, allocfunc, freefunc, arg))
28+
#definerbt_insert(rbt,data,isNew) \
29+
(rb_insert(rbt, data, isNew))
30+
#endif
31+
2432

2533
/* Combiner function for rbtree.c */
2634
staticvoid
27-
rumCombineData(RBNode*existing,constRBNode*newdata,void*arg)
35+
rumCombineData(RBTNode*existing,constRBTNode*newdata,void*arg)
2836
{
2937
RumEntryAccumulator*eo= (RumEntryAccumulator*)existing;
3038
constRumEntryAccumulator*en= (constRumEntryAccumulator*)newdata;
@@ -65,7 +73,7 @@ rumCombineData(RBNode *existing, const RBNode *newdata, void *arg)
6573

6674
/* Comparator function for rbtree.c */
6775
staticint
68-
cmpEntryAccumulator(constRBNode*a,constRBNode*b,void*arg)
76+
cmpEntryAccumulator(constRBTNode*a,constRBTNode*b,void*arg)
6977
{
7078
constRumEntryAccumulator*ea= (constRumEntryAccumulator*)a;
7179
constRumEntryAccumulator*eb= (constRumEntryAccumulator*)b;
@@ -77,15 +85,15 @@ cmpEntryAccumulator(const RBNode *a, const RBNode *b, void *arg)
7785
}
7886

7987
/* Allocator function for rbtree.c */
80-
staticRBNode*
88+
staticRBTNode*
8189
rumAllocEntryAccumulator(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 reclaimRBNodes individually, so this costs nothing.
96+
* need to reclaimRBTNodes 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 newRBNode from current chunk */
105+
/* Allocate newRBTNode 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

104112
void
@@ -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
{
@@ -273,7 +281,7 @@ void
273281
rumBeginBAScan(BuildAccumulator*accum)
274282
{
275283
#ifPG_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
#ifPG_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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp