Re: PgStat_HashKey padding issue when passed by reference
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Andres Freund <andres@anarazel.de>
Cc: Sami Imseih <samimseih@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-09-09T00:24:03Z
Lists: pgsql-hackers
Attachments
- pgstat-hashkey-padding.patch (text/x-diff) patch
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
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Document and check that PgStat_HashKey has no padding
- 3cd3a039da7f 19 (unreleased) landed