From 0f8759691ae226837091d409404b8d1eb14d99f0 Mon Sep 17 00:00:00 2001
From: Jeff Davis <jdavis@postgresql.org>
Date: Thu, 1 Dec 2022 11:08:47 -0800
Subject: [PATCH v1] Fix broken hash function hashbpcharextended().

Ignore trailing spaces for non-deterministic collations when
hashing.

Fortunately, the previous behavior did not seem to affect hash indexes
or hash partitions, because the trailing spaces were removed before
hashbpcharextended() was called.
---
 src/backend/utils/adt/varchar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c
index 09c483d6ff..a63c498181 100644
--- a/src/backend/utils/adt/varchar.c
+++ b/src/backend/utils/adt/varchar.c
@@ -1086,7 +1086,7 @@ hashbpcharextended(PG_FUNCTION_ARGS)
 			Size		bsize;
 			uint8_t    *buf;
 
-			ulen = icu_to_uchar(&uchar, VARDATA_ANY(key), VARSIZE_ANY_EXHDR(key));
+			ulen = icu_to_uchar(&uchar, keydata, keylen);
 
 			bsize = ucol_getSortKey(mylocale->info.icu.ucol,
 									uchar, ulen, NULL, 0);
-- 
2.34.1

