Re: Safer hash table initialization macro

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Cc: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Safer hash table initialization macro
Date: 2026-01-26 08:41:53
Message-ID: aXco0XWaces41QFp@ip-10-97-1-34.eu-west-3.compute.internal
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Mon, Jan 26, 2026 at 12:38:15AM +0100, Jelte Fennema-Nio wrote:
> On Wed Jan 14, 2026 at 9:46 AM CET, Jelte Fennema-Nio wrote:
> > Changed wording and changed to NOTE.
>
> Attached is v7 which is rebased and changed the hash_create calls
> introduced by 282b1cde9de.

Thanks!

The changes make sense to me.

Just a pgindent nit, in 0003:

$ git diff
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 73f93512f9b..0a1e7c709c9 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -3162,8 +3162,8 @@ AddEventToPendingNotifies(Notification *n)
Assert(pendingNotifies->uniqueChannelHash == NULL);
pendingNotifies->uniqueChannelHash =
hash_make_cxt(ChannelName, channel, "Pending Notify Channel Names",
- 64L,
- CurTransactionContext);
+ 64L,
+ CurTransactionContext);

Also, I can see (I think it's coming from 0004):

In file included from ../../../../src/include/access/hash.h:28,
from typcache.c:46:
typcache.c: In function ‘TypeCacheRelCallback’:
typcache.c:2472:46: warning: declaration of ‘typentry’ shadows a previous local [-Wshadow=compatible-local]
2472 | foreach_hash(TypeCacheEntry, typentry, TypeCacheHash)
| ^~~~~~~~
../../../../src/include/utils/hsearch.h:314:20: note: in definition of macro ‘foreach_hash’
314 | for (type *var = NULL, *var##__outerloop = (type *) 1; \
| ^~~
typcache.c:2412:25: note: shadowed declaration is here
2412 | TypeCacheEntry *typentry;
| ^~~~~~~~

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zsolt Parragi 2026-01-26 08:53:00 Re: unclear OAuth error message
Previous Message Richard Guo 2026-01-26 08:00:08 Re: Optimize IS DISTINCT FROM with non-nullable inputs