Re: PgStat_HashKey padding issue when passed by reference - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: PgStat_HashKey padding issue when passed by reference
Date
Msg-id aL9zo5X0MsSxO2pM@paquier.xyz
Whole thread Raw
In response to Re: PgStat_HashKey padding issue when passed by reference  (Andres Freund <andres@anarazel.de>)
Responses Re: PgStat_HashKey padding issue when passed by reference
List pgsql-hackers
On Mon, Sep 08, 2025 at 12:08:12PM -0400, Andres Freund wrote:
> On 2025-09-08 10:25:13 +0900, Michael Paquier wrote:
>> Another idea would be to make sure that the sizeof() of the structure
>> matches with the sum of the sizeof() for the individual fields in it.
>> That's cumbersome to rely on, still simpler.  Perhaps we could do
>> something among these lines for pgstat_shmem.c, or just document that
>> the structure should never have any padding.
>
> I'd just add a comment mentioning that any padding bytes should be avoided.

Agreed on this part.

I am wondering also about the addition of a static assertion as well,
as it seems that this thread and the opinions on it point to such an
addition having value, and requiring valgrind to detect that is
annoying, especially if people propose more patches in the future that
may affect the way we pass the hash key values in this area of the
code.  An idea is attached.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [PATCH] Proposal to Enable/Disable Index using ALTER INDEX
Next
From: Peter Smith
Date:
Subject: Re: [WIP]Vertical Clustered Index (columnar store extension) - take2