v20250501-0004-fix-update-moreRight-moreLeft-in-btgetbatc.patch

text/x-patch

Filename: v20250501-0004-fix-update-moreRight-moreLeft-in-btgetbatc.patch
Type: text/x-patch
Part: 3
Message: Re: index prefetching

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v20250501-0004
Subject: fix: update moreRight/moreLeft in btgetbatch
File+
src/backend/access/nbtree/nbtree.c 11 0
From c5f52325414d57022f66500c29fe091e4a39c77b Mon Sep 17 00:00:00 2001
From: Tomas Vondra <tomas@vondra.me>
Date: Wed, 23 Apr 2025 22:21:51 +0200
Subject: [PATCH v20250501 4/7] fix: update moreRight/moreLeft in btgetbatch

---
 src/backend/access/nbtree/nbtree.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c
index 405c601d3ff..6ea1dfcc52c 100644
--- a/src/backend/access/nbtree/nbtree.c
+++ b/src/backend/access/nbtree/nbtree.c
@@ -308,6 +308,11 @@ btgetbatch(IndexScanDesc scan, ScanDirection dir)
 	{
 		IndexScanBatch batch = INDEX_SCAN_BATCH(scan, scan->xs_batches->nextBatch-1);
 		pos = (BTBatchScanPos) batch->opaque;
+
+		if (ScanDirectionIsForward(scan->xs_batches->direction))
+			pos->moreRight = true;
+		else
+			pos->moreLeft = true;
 	}
 
 	/* Each loop iteration performs another primitive index scan */
@@ -322,6 +327,12 @@ btgetbatch(IndexScanDesc scan, ScanDirection dir)
 			res = _bt_first_batch(scan, dir);
 		else
 		{
+			if (so->numArrayKeys)
+			{
+				_bt_start_array_keys(scan, so->currPos.dir);
+				so->needPrimScan = false;
+			}
+
 			/*
 			 * Now continue the scan.
 			 */
-- 
2.49.0