Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vOSdB-008OOz-16 for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Nov 2025 03:25:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vOSd9-0034B0-2v for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Nov 2025 03:25:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vOSd9-0034Aq-1x for pgsql-hackers@lists.postgresql.org; Thu, 27 Nov 2025 03:25:15 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vOSd7-001fyp-1j for pgsql-hackers@postgresql.org; Thu, 27 Nov 2025 03:25:15 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 5AR3PC7X032296; Wed, 26 Nov 2025 22:25:12 -0500 From: Tom Lane To: Thomas Munro cc: David Geier , pgsql-hackers Subject: Re: Consistently use palloc_object() and palloc_array() In-reply-to: References: Comments: In-reply-to Thomas Munro message dated "Thu, 27 Nov 2025 15:53:20 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <32294.1764213912.1@sss.pgh.pa.us> Date: Wed, 26 Nov 2025 22:25:12 -0500 Message-ID: <32295.1764213912@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thomas Munro 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