From ad18a9ea49f55401c2ef58d3ef8381a42a4a346e Mon Sep 17 00:00:00 2001
From: reshke <reshke@qavm-273b4667.qemu>
Date: Sat, 4 Jul 2026 17:31:39 +0300
Subject: [PATCH v1 1/2] Make GIN scan more cancellable

---
 src/backend/access/gin/ginget.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/backend/access/gin/ginget.c b/src/backend/access/gin/ginget.c
index 6b148e69a8e..f36cc67fab0 100644
--- a/src/backend/access/gin/ginget.c
+++ b/src/backend/access/gin/ginget.c
@@ -1666,6 +1666,13 @@ collectMatchesForHeapRow(IndexScanDesc scan, pendingPosition *pos)
 							StopHigh = pos->lastOffset,
 							StopMiddle;
 
+				if (INTERRUPTS_PENDING_CONDITION()) {
+
+					UnlockReleaseBuffer(pos->pendingBuffer);
+
+					CHECK_FOR_INTERRUPTS();
+				}
+
 				/* If already matched on earlier page, do no extra work */
 				if (key->entryRes[j])
 					continue;
-- 
2.43.0

