From 9612cc159e45b90f0ded1ab4c749bc8a81d187c4 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 17 Nov 2026 16:16:19 -0800 Subject: [PATCH] Moved getting next IVFFlat index scan tuple to separate function [skip ci] --- src/ivfscan.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/ivfscan.c b/src/ivfscan.c index 2ed48f95..42b885d2 100644 --- a/src/ivfscan.c +++ b/src/ivfscan.c @@ -349,6 +349,21 @@ IvfflatReadStreamNextBlock(ReadStream *stream, void *callback_private_data, void } #endif +/* + * Get next scan item + */ +static inline bool +IvfflatNextScanItem(IvfflatScanOpaque so, ItemPointerData *heaptid) +{ + bool isnull; + + if (!tuplesort_gettupleslot(so->sortstate, true, false, so->mslot, NULL)) + return false; + + *heaptid = *((ItemPointer) DatumGetPointer(slot_getattr(so->mslot, 2, &isnull))); + return true; +} + /* * Prepare for an index scan */ @@ -462,8 +477,6 @@ bool ivfflatgettuple(IndexScanDesc scan, ScanDirection dir) { IvfflatScanOpaque so = (IvfflatScanOpaque) scan->opaque; - ItemPointer heaptid; - bool isnull; /* * Index can be used to scan backward, but Postgres doesn't support @@ -498,7 +511,7 @@ ivfflatgettuple(IndexScanDesc scan, ScanDirection dir) so->value = value; } - while (!tuplesort_gettupleslot(so->sortstate, true, false, so->mslot, NULL)) + while (!IvfflatNextScanItem(so, &scan->xs_heaptid)) { if (so->listsVisited == so->listsCount) return false; @@ -506,9 +519,6 @@ ivfflatgettuple(IndexScanDesc scan, ScanDirection dir) IvfflatBench("GetScanItems", GetScanItems(scan, so->value)); } - heaptid = (ItemPointer) DatumGetPointer(slot_getattr(so->mslot, 2, &isnull)); - - scan->xs_heaptid = *heaptid; scan->xs_recheck = false; scan->xs_recheckorderby = false; return true;