From aa78bcca138b7df04ee518f0c94862d0bc9d2d8b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20K=C5=82eczek?= <michal@kleczek.org>
Date: Tue, 19 Mar 2024 08:44:08 +0100
Subject: [PATCH] Pass key->sk_attno to consistent function in
 gistindex_keytest.

Right now consistent function is unaware of the key attribute that it is called for.
This in turn makes it impossible to perform any additional processing based on catalog information,
for example partition bounds.

Passing index key attribute number allows the consistent function to lookup
(and possibly cache) catalog information using Relation provided in GISTENTRY.
---
 src/backend/access/gist/gistget.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c
index b35b8a9757..9bae153305 100644
--- a/src/backend/access/gist/gistget.c
+++ b/src/backend/access/gist/gistget.c
@@ -218,13 +218,14 @@ gistindex_keytest(IndexScanDesc scan,
 			 */
 			recheck = true;
 
-			test = FunctionCall5Coll(&key->sk_func,
+			test = FunctionCall6Coll(&key->sk_func,
 									 key->sk_collation,
 									 PointerGetDatum(&de),
 									 key->sk_argument,
 									 Int16GetDatum(key->sk_strategy),
 									 ObjectIdGetDatum(key->sk_subtype),
-									 PointerGetDatum(&recheck));
+									 PointerGetDatum(&recheck),
+									 Int16GetDatum(key->sk_attno));
 
 			if (!DatumGetBool(test))
 				return false;
-- 
2.39.3 (Apple Git-146)

