From bf7fd6d96cb91754e0293da25a75b1774a4ad21a Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Thu, 30 Jul 2026 06:27:09 +0000 Subject: [PATCH v1 3/3] Make charhashfast() return a consistent value regardless of signedness While the output of charhashfast() is never persisted or compared across processes, it is still a good idea to make it return a consistent value regardless of the platform's implementation-defined char signedness. Signed-off-by: Tristan Partin --- src/backend/utils/cache/catcache.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index 0c8955fc61a..2c3f5f7d8bf 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -196,7 +196,17 @@ chareqfast(Datum a, Datum b) static uint32 charhashfast(Datum datum) { - return murmurhash32((int32) DatumGetChar(datum)); + /* + * Cast through unsigned char, not a bare char, to avoid depending on the + * platform's implementation-defined char signedness. There's no need to + * consult GetDefaultCharSignedness() here since CatCache lives in + * backend-private memory: it's never written to disk or WAL, and every + * backend (including any physical standby) rebuilds its own copy + * independently from the catalog contents, rather than relying on a value + * computed by some other, possibly differently-built, process. Any fixed, + * deterministic choice of signedness is fine here. + */ + return murmurhash32((int32) (unsigned char) DatumGetChar(datum)); } static bool -- Tristan Partin https://tristan.partin.io