Re: Making type Datum be 8 bytes everywhere

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: Tom Lane <tgl@sss.pgh.pa.us>, Joe Conway <mail@joeconway.com>
Cc: Michael Paquier <michael@paquier.xyz>, Andres Freund <andres@anarazel.de>, pgsql-hackers@lists.postgresql.org, Robert Haas <robertmhaas@gmail.com>
Date: 2025-08-12T06:30:43Z
Lists: pgsql-hackers
On 09.08.25 18:44, Tom Lane wrote:
> I've now fleshed out the patch series with some cleanup of code that's
> been rendered dead.

These patches look mechanically correct to me.

For patch 0002:

The various additional uses of *GetDatum and DatumGet* could be applied 
as a separate patch.  That would make the remaining patch clearer as 
mostly just removing dead code.

In tupmacs.h, I think the two sites with

     case sizeof(Datum):

should be rewritten using

     case sizeof(int64):

to match the other cases.  Otherwise, this code ends up looking 
mysteriously asymmetric.  (And the related code in pg_type.c as well.)

The remaining mentions of "SIZEOF_DATUM" in gistproc.c and network.c 
could be replaced by "sizeof(Datum)".  Then we could eventually remove 
SIZEOF_DATUM altogether.  (Maybe DatumBigEndianToNative() would better 
live in a different header file at that point, not sure.)

For patch 0003:

I would also remove most of the remaining uses of FLOAT8PASSBYVAL, 
especially where it is used in relation with INT8OID, which is just 
endlessly confusing.

We should also get rid of these things in the control file and the ABI 
magic structs, but that could be done as separate patches.  It would 
probably require a separate round of thinking about compatibility, 
upgrading, etc.


I'm also thinking, as a follow-on project, we could get rid of typbyval 
and require that typbyval == (typlen > 0 && typlen <= 8).  Something to 
think about.




Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Avoid faulty alignment of Datums in build_sorted_items().

  2. Grab the low-hanging fruit from forcing USE_FLOAT8_BYVAL to true.

  3. Grab the low-hanging fruit from forcing sizeof(Datum) to 8.

  4. Make type Datum be 8 bytes wide everywhere.

  5. Mop-up for Datum conversion cleanups.