pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: David Geier <geidav.pg@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Consistently use palloc_object() and palloc_array()
Date: Wed, 26 Nov 2025 22:25:12 -0500
Message-ID: <32295.1764213912@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+hUKGK4=dD3qS3Db9d9pWg1me4eoZr1hWSxE_8_NRyKS2gqeA@mail.gmail.com>
References: <ad0748d4-3080-436e-b0bc-ac8f86a3466a@gmail.com>
	<CA+hUKGK4=dD3qS3Db9d9pWg1me4eoZr1hWSxE_8_NRyKS2gqeA@mail.gmail.com>

Thomas Munro <thomas.munro@gmail.com> writes:
> This isn't a fully-baked thought, just a thought that occurred to me
> while looking into that:  If palloc_object(Int128AggState) were smart
> enough to detect that alignof(T) > MAXALIGN and redirect to
> palloc_aligned(sizeof(T), alignof(T), ...) at compile time, then
> Int128AggState would naturally propagate the layout requirements of
> its __int128 member, and we wouldn't need to do that weird stuff, and
> it wouldn't be error-prone if usage of __int128 spreads to more
> structs.  That really only makes sense if we generalise
> palloc_object() as a programming style and consider direct use of
> palloc() to be a rarer low-level interface that triggers human
> reviewers to think about alignment, I guess.

Hmm ... I had the same doubts as Michael about whether this change
could possibly be worth the ensuing back-patching pain.  But if
it leads to an improvement in type-safety, that'd be a reason to
take on the work.

			regards, tom lane





view thread (29+ messages)  latest in thread

Message-ID: <32295.1764213912@sss.pgh.pa.us>
Permalink:  ../32295.1764213912@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/32295.1764213912@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, thomas.munro@gmail.com, geidav.pg@gmail.com
  Subject: Re: Consistently use palloc_object() and palloc_array()
  In-Reply-To: <32295.1764213912@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox