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 aMtFBuUNv7O0DYN6@paquier.xyz
Whole thread Raw
In response to Re: PgStat_HashKey padding issue when passed by reference  (Sami Imseih <samimseih@gmail.com>)
Responses Re: PgStat_HashKey padding issue when passed by reference
List pgsql-hackers
On Tue, Sep 16, 2025 at 02:38:20PM -0500, Sami Imseih wrote:
> 7d85d87f4d5c35 added code to clear the padding bytes with memset
> in anticipation that the key could be changed in the future, in a way
> that padding will be introduced.

Yep.  The argument raised on this thread with the requirement of the
key being passed by reference has made me change my mind, because I
did not thing that valgrind would complain with that.  So yes, I'm
backpedalling a bit.  Sorry for the confusion.

> So, if we are changing thoughts on
> this, we should add additional comments next to
> ```
> + * NB: We assume that this struct contains no padding.
> ```
> to enforce that the hash stored in objid should be used to
> support additional fields, rather than adding a field directly
> into the key.

Hmm.  Do you have a specific suggestion for enhancement?  I can
think about something like this wording:
"NB: We assume that this struct contains no padding.  The 8 bytes
allocated for the object ID are good enough to ensure the uniqueness
of the hash key, hence the addition of new fields is not recommended."

More suggestions or a better sentence are of course welcome.

> Will help future patch reviews/designs.

Cool, thanks.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Parallel heap vacuum
Next
From: Peter Smith
Date:
Subject: Re: Add support for specifying tables in pg_createsubscriber.