Skip to content

Commit 2b46914

Browse files
committed
Compatibility with random access tuplesort interface changes in v15
Also update tuplesort15.c according to vanilla changes.
1 parent 7c4c0f2 commit 2b46914

File tree

2 files changed

+324
-72
lines changed

2 files changed

+324
-72
lines changed

src/rumsort.c

+14-3
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,11 @@ writetup_rum_internal(RumTuplesortstate * state, LT_TYPE LT_ARG, SortTuple *stup
222222
(void *) &writtenlen, sizeof(writtenlen));
223223
LogicalTapeWrite(TAPE(state, LT_ARG),
224224
(void *) item, size);
225-
if (state->randomAccess) /* need trailing length word? */
225+
#if PG_VERSION_NUM >= 150000
226+
if (state->sortopt & TUPLESORT_RANDOMACCESS) /* need trailing length word? */
227+
#else
228+
if (state->randomAccess) /* need trailing length word? */
229+
#endif
226230
LogicalTapeWrite(TAPE(state, LT_ARG),
227231
(void *) &writtenlen, sizeof(writtenlen));
228232
}
@@ -260,11 +264,11 @@ readtup_rum_internal(RumTuplesortstate * state, SortTuple *stup,
260264

261265
if (!is_item)
262266
stup->datum1 = Float8GetDatum(state->nKeys > 0 ? ((RumSortItem *) item)->data[0] : 0);
263-
264-
if (state->randomAccess) /* need trailing length word? */
265267
#if PG_VERSION_NUM >= 150000
268+
if (state->sortopt & TUPLESORT_RANDOMACCESS) /* need trailing length word? */
266269
LogicalTapeReadExact(LT_ARG, &tuplen, sizeof(tuplen));
267270
#else
271+
if (state->randomAccess)
268272
LogicalTapeReadExact(state->tapeset, LT_ARG, &tuplen, sizeof(tuplen));
269273
#endif
270274
}
@@ -291,7 +295,14 @@ RumTuplesortstate *
291295
rum_tuplesort_begin_rum(int workMem, int nKeys, bool randomAccess,
292296
bool compareItemPointer)
293297
{
298+
#if PG_VERSION_NUM >= 150000
299+
RumTuplesortstate *state = tuplesort_begin_common(workMem,
300+
randomAccess ?
301+
TUPLESORT_RANDOMACCESS :
302+
TUPLESORT_NONE);
303+
#else
294304
RumTuplesortstate *state = tuplesort_begin_common(workMem, randomAccess);
305+
#endif
295306
MemoryContext oldcontext;
296307

297308
oldcontext = MemoryContextSwitchTo(state->sortcontext);

0 commit comments

Comments
 (0)