Re: Decoupling our alignment assumptions about int64 and double

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Decoupling our alignment assumptions about int64 and double
Date: 2026-02-06 22:05:06
Message-ID: 2135701.1770415506@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> Thomas Munro <thomas(dot)munro(at)gmail(dot)com> writes:
>> I see that pg_upgrade is the real problem, but if that's somehow OK
>> ("v19 is a new port, dump and restore needed!") then I wonder if
>> -malign=natural (which seems to be the GCC equivalent of what the
>> native compiler called -qalign=natural) might be an option.

> Of course the $64 question is whether we can get away with requiring a
> dump and reload (and how we'd make pg_upgrade enforce that if we did,
> considering that existing installations' pg_control will only surface
> the value of MAXALIGN not DOUBLEALIGN).

Your thought of maybe applying some compiler ju-jitsu led me to a
different research direction: if we can get the compiler to lay out
the catalog structs as if DOUBLEALIGN and LONGALIGN were 4, then
problem solved without need for any user-table compatibility break.
And we can: it looks like inserting

#pragma pack(4)

before each catalog struct definition (and then "#pragma pack()"
afterwards to restore the normal rules) would do the trick.
This is probably quite gcc-specific, but if we're tossing xlc
overboard that doesn't matter.

Ideally we'd find a way to embed that in the CATALOG macros rather
than needing explicit AIX-droppings all over include/catalog/*.h.
But I'm not sure that it's possible to put a #pragma in a macro.
Even if we can't be neat about it, this is seeming like an attractive
line of inquiry.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2026-02-06 22:07:00 Re: [PING] fallocate() causes btrfs to never compress postgresql files
Previous Message Nathan Bossart 2026-02-06 21:29:13 Re: Speed up COPY FROM text/CSV parsing using SIMD