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

From Bertrand Drouvot
Subject Re: Safer hash table initialization macro
Date
Msg-id aXco0XWaces41QFp@ip-10-97-1-34.eu-west-3.compute.internal
Whole thread Raw
In response to Re: Safer hash table initialization macro  ("Jelte Fennema-Nio" <postgres@jeltef.nl>)
Responses Re: Safer hash table initialization macro
List 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



pgsql-hackers by date:

Previous
From: Richard Guo
Date:
Subject: Re: Optimize IS DISTINCT FROM with non-nullable inputs
Next
From: Zsolt Parragi
Date:
Subject: Re: unclear OAuth error message