Re: PgStat_HashKey padding issue when passed by reference

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Sami Imseih <samimseih(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PgStat_HashKey padding issue when passed by reference
Date: 2025-09-17 23:32:22
Message-ID: aMtFBuUNv7O0DYN6@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2025-09-17 23:53:22 Re: Add support for specifying tables in pg_createsubscriber.
Previous Message Andres Freund 2025-09-17 23:24:15 Re: Parallel heap vacuum