pgsql: Clean up usage of hash_any() and hash_any_extended()

From: John Naylor <john(dot)naylor(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Clean up usage of hash_any() and hash_any_extended()
Date: 2026-09-23 10:36:02
Message-ID: E1x9KKY-00000000tsj-2Ggb@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Clean up usage of hash_any() and hash_any_extended()

Back in the days before a91e2fa94, hash_any() was the primary hash
function and it returned a Datum. That commit changed hash_any() to a
wrapper over hash_bytes(). Some places actually wanted the underlying
uint32 from hash_bytes(), but that now presents as useless round-trip
casting, so update the call sites where we don't immediately need a
Datum.

hash_numeric() didn't have round-trip casting, but it was internally
inconsistent: Paths returning a constant used PG_RETURN_UINT32(), but
the path using the result of hash_any() used PG_RETURN_DATUM. Change
it to use uint32 throughout.

Author: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>
Suggested-by: John Naylor <johncnaylorls(at)gmail(dot)com>
Reviewed-by: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Discussion: https://postgr.es/m/CAJ7c6TMPhDRQMmkUHPv8oOK97B1mR8NRS61DgjpdaZUPAwaeZQ%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a1c37421a8707b365f5dd27d328648c7fe0503a0

Modified Files
--------------
contrib/ltree/ltree_op.c | 4 ++--
src/backend/access/tablesample/bernoulli.c | 4 ++--
src/backend/access/tablesample/system.c | 4 ++--
src/backend/commands/async.c | 8 ++++----
src/backend/lib/bloomfilter.c | 2 +-
src/backend/lib/hyperloglog.c | 2 +-
src/backend/nodes/bitmapset.c | 4 ++--
src/backend/nodes/queryjumblefuncs.c | 10 +++++-----
src/backend/tsearch/ts_typanalyze.c | 3 +--
src/backend/utils/adt/bytea.c | 4 ++--
src/backend/utils/adt/jsonb_gin.c | 2 +-
src/backend/utils/adt/jsonb_util.c | 10 +++++-----
src/backend/utils/adt/numeric.c | 27 ++++++++++++++-------------
src/backend/utils/adt/varlena.c | 4 ++--
src/backend/utils/cache/funccache.c | 8 ++++----
15 files changed, 48 insertions(+), 48 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2026-09-23 10:57:44 pgsql: doc: Mention oid8 TOAST values in the limits appendix
Previous Message Dean Rasheed 2026-09-23 08:41:40 pgsql: Fix concurrent delete handling in MERGE ... WHEN NOT MATCHED BY