Re: PgStat_HashKey padding issue when passed by reference
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Sami Imseih <samimseih@gmail.com>
Cc: Andres Freund <andres@anarazel.de>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-09-09T02:29:04Z
Lists: pgsql-hackers
On Mon, Sep 08, 2025 at 09:20:14PM -0500, Sami Imseih wrote:
> The following will fail the assert since padding is needed for the
> new Oid member.
>
> @@ -53,6 +53,7 @@ typedef struct PgStat_HashKey
> {
> PgStat_Kind kind; /* statistics entry kind */
> Oid dboid; /* database
> ID. InvalidOid for shared objects. */
> + Oid field1;
> uint64 objid; /* object ID (table,
> function, etc.), or
>
> This will not fail the assert, since no padding is needed for the new member.
>
> @@ -53,6 +53,7 @@ typedef struct PgStat_HashKey
> {
> PgStat_Kind kind; /* statistics entry kind */
> Oid dboid; /* database
> ID. InvalidOid for shared objects. */
> + uint64 field1;
> uint64 objid; /* object ID (table,
> function, etc.), or
Exactly. Hence my proposal of static assertion is doing exactly the
job I want it to do :)
--
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