Re: Safer hash table initialization macro - Mailing list pgsql-hackers

From Jelte Fennema-Nio
Subject Re: Safer hash table initialization macro
Date
Msg-id DEPJFNNOXN6C.39PM8C3I63DKU@jeltef.nl
Whole thread Raw
In response to Re: Safer hash table initialization macro  (Bertrand Drouvot <bertranddrouvot.pg@gmail.com>)
Responses Re: Safer hash table initialization macro
List pgsql-hackers
On Wed Dec 3, 2025 at 12:17 PM CET, Bertrand Drouvot wrote:
> I suggest we move forward one
> step at a time, first step being the new macros. Does that make sense to you?

Normally I would agree, but in this case I think the new macros you
proposing would become obsolete once we have the better hash table
creation functions I have in mind. And if we're going to update all
places where we create hash tables, I'd rather update them to something
really nice than a small improvement.

I couldn't let it go (nerd-sniped). So here's a patchset that adds some
macros that I think are pretty nice. Including a foreach_hash macro.

I'm a bit on the fence about the C11 _Generic code to determine whether
we should use HASH_BLOBS or HASH_STRINGS based on the type of the key.
It works really nicely in practice, but I'm worried it's a bit too much
magic. Probably we should at least have an override to allow using
HASH_BLOBS anyway for a char array (in case it's not null terminated).

Attachment

pgsql-hackers by date:

Previous
From: David Klika
Date:
Subject: Re: Adding REPACK [concurrently]
Next
From: Maxim Orlov
Date:
Subject: Re: POC: make mxidoff 64 bits