Hello,

This patches changes the HeapKeyTest macro to add handling for SK_SEARCHNULL
and SK_SEARCHNOTNULL. While currently no core codes uses these ScanKey flags
it would be useful for extensions if it was supported so extensions
dont have to implement
handling for those by themself.

-- 
Regards, Sven Klemm
From 7ba786ebc065a27375dac9ced6d1928d0e8e5740 Mon Sep 17 00:00:00 2001
From: Sven Klemm <s...@timescale.com>
Date: Sat, 22 Jun 2024 15:21:53 +0200
Subject: [PATCH] Handle SK_SEARCHNULL and SK_SEARCHNOTNULL in HeapKeyTest

Change HeapKeyTest to not return false on SK_ISNULL but instead
return a result according to SK_SEARCHNULL/SK_SEARCHNOTNULL.
---
 src/include/access/valid.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/include/access/valid.h b/src/include/access/valid.h
index 78c5f023ac..b46cf359df 100644
--- a/src/include/access/valid.h
+++ b/src/include/access/valid.h
@@ -37,7 +37,14 @@ HeapKeyTest(HeapTuple tuple, TupleDesc tupdesc, int nkeys, ScanKey keys)
 		Datum		test;
 
 		if (cur_key->sk_flags & SK_ISNULL)
-			return false;
+		{
+			Assert(cur_key->sk_flags & (SK_SEARCHNULL | SK_SEARCHNOTNULL));
+			isnull = heap_attisnull(tuple, cur_key->sk_attno, tupdesc);
+			if (cur_key->sk_flags & SK_SEARCHNULL)
+				return isnull;
+			else
+				return !isnull;
+		}
 
 		atp = heap_getattr(tuple, cur_key->sk_attno, tupdesc, &isnull);
 
-- 
2.45.2

Reply via email to