Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 002356c

Browse files
author
Alexander Korotkov
committed
Fix building RUM after commit 9fa6f00b.
1 parent 42fd827 commit 002356c

File tree

4 files changed

+28
-31
lines changed

4 files changed

+28
-31
lines changed

src/rum.h

+16
Original file line numberDiff line numberDiff line change
@@ -1057,4 +1057,20 @@ extern Datum FunctionCall10Coll(FmgrInfo *flinfo, Oid collation,
10571057
Datum arg6, Datum arg7, Datum arg8,
10581058
Datum arg9, Datum arg10);
10591059

1060+
/* PostgreSQL version-agnostic creation of memory context */
1061+
#if PG_VERSION_NUM >= 110000
1062+
#define RumContextCreate(parent, name) \
1063+
AllocSetContextCreateExtended(parent, name, \
1064+
MEMCONTEXT_COPY_NAME, \
1065+
ALLOCSET_DEFAULT_MINSIZE, \
1066+
ALLOCSET_DEFAULT_INITSIZE, \
1067+
ALLOCSET_DEFAULT_MAXSIZE)
1068+
#else
1069+
#define RumContextCreate(parent, name) \
1070+
AllocSetContextCreate(parent, name, \
1071+
ALLOCSET_DEFAULT_MINSIZE, \
1072+
ALLOCSET_DEFAULT_INITSIZE, \
1073+
ALLOCSET_DEFAULT_MAXSIZE)
1074+
#endif
1075+
10601076
#endif /* __RUM_H__ */

src/ruminsert.c

+7-16
Original file line numberDiff line numberDiff line change
@@ -633,17 +633,11 @@ rumbuild(Relation heap, Relation index, struct IndexInfo *indexInfo)
633633
* create a temporary memory context that is reset once for each tuple
634634
* inserted into the index
635635
*/
636-
buildstate.tmpCtx = AllocSetContextCreate(CurrentMemoryContext,
637-
"Rum build temporary context",
638-
ALLOCSET_DEFAULT_MINSIZE,
639-
ALLOCSET_DEFAULT_INITSIZE,
640-
ALLOCSET_DEFAULT_MAXSIZE);
641-
642-
buildstate.funcCtx = AllocSetContextCreate(CurrentMemoryContext,
643-
"Rum build temporary context for user-defined function",
644-
ALLOCSET_DEFAULT_MINSIZE,
645-
ALLOCSET_DEFAULT_INITSIZE,
646-
ALLOCSET_DEFAULT_MAXSIZE);
636+
buildstate.tmpCtx = RumContextCreate(CurrentMemoryContext,
637+
"Rum build temporary context");
638+
639+
buildstate.funcCtx = RumContextCreate(CurrentMemoryContext,
640+
"Rum build temporary context for user-defined function");
647641

648642
buildstate.accum.rumstate = &buildstate.rumstate;
649643
rumInitBA(&buildstate.accum);
@@ -813,11 +807,8 @@ ruminsert(Relation index, Datum *values, bool *isnull,
813807
Datum outerAddInfo = (Datum) 0;
814808
bool outerAddInfoIsNull = true;
815809

816-
insertCtx = AllocSetContextCreate(CurrentMemoryContext,
817-
"Rum insert temporary context",
818-
ALLOCSET_DEFAULT_MINSIZE,
819-
ALLOCSET_DEFAULT_INITSIZE,
820-
ALLOCSET_DEFAULT_MAXSIZE);
810+
insertCtx = RumContextCreate(CurrentMemoryContext,
811+
"Rum insert temporary context");
821812

822813
oldCtx = MemoryContextSwitchTo(insertCtx);
823814

src/rumscan.c

+4-10
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,10 @@ rumbeginscan(Relation rel, int nkeys, int norderbys)
3535
so->firstCall = true;
3636
so->totalentries = 0;
3737
so->sortedEntries = NULL;
38-
so->tempCtx = AllocSetContextCreate(CurrentMemoryContext,
39-
"Rum scan temporary context",
40-
ALLOCSET_DEFAULT_MINSIZE,
41-
ALLOCSET_DEFAULT_INITSIZE,
42-
ALLOCSET_DEFAULT_MAXSIZE);
43-
so->keyCtx = AllocSetContextCreate(CurrentMemoryContext,
44-
"Rum scan key context",
45-
ALLOCSET_DEFAULT_MINSIZE,
46-
ALLOCSET_DEFAULT_INITSIZE,
47-
ALLOCSET_DEFAULT_MAXSIZE);
38+
so->tempCtx = RumContextCreate(CurrentMemoryContext,
39+
"Rum scan temporary context");
40+
so->keyCtx = RumContextCreate(CurrentMemoryContext,
41+
"Rum scan key context");
4842

4943
initRumState(&so->rumstate, scan->indexRelation);
5044

src/rumsort.c

+1-5
Original file line numberDiff line numberDiff line change
@@ -877,11 +877,7 @@ rum_tuplesort_begin_common(int workMem, bool randomAccess)
877877
* Create a working memory context for this sort operation. All data
878878
* needed by the sort will live inside this context.
879879
*/
880-
sortcontext = AllocSetContextCreate(CurrentMemoryContext,
881-
"TupleSort",
882-
ALLOCSET_DEFAULT_MINSIZE,
883-
ALLOCSET_DEFAULT_INITSIZE,
884-
ALLOCSET_DEFAULT_MAXSIZE);
880+
sortcontext = RumContextCreate(CurrentMemoryContext, "TupleSort");
885881

886882
/*
887883
* Make the Tuplesortstate within the per-sort context. This way, we

0 commit comments

Comments
 (0)