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>, Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@lists.postgresql.org, Robert Haas <robertmhaas@gmail.com>
Date: 2025-07-31T14:17:06Z
Lists: pgsql-hackers
On 30.07.25 18:06, Tom Lane wrote:
> Right, we have for a long time not worried about whether VARDATA and
> the allied macros are being fed a pointer or a Datum.  I recall that
> somebody tried to make those macros into static inlines awhile back,
> and failed because of the lack of clarity about how to declare their
> arguments.

I don't know if that was me, but I have posted a patch about this now: 
https://www.postgresql.org/message-id/928ea48f-77c6-417b-897c-621ef16685a6%40eisentraut.org

> I think the way forward here is to tackle that head-on
> and split the top-level macros into two static inlines, along the
> lines of
> 	VARDATA(Pointer ptr)
> and
> 	VARDATA_D(Datum dat)
> where the _D versions are simply DatumGetPointer and then call the
> non-D versions.
> 
> I'm giving the traditional names to the Pointer variants because it
> turns out that way more places would have to change if we do it the
> other way: in a rough count, about 50 versus about 1700.  (This is
> counting only the core backend.)  Beyond that, though, bikeshedding
> on the naming is welcome.

In my patch, I just added the missing DatumGetPointer() calls, which 
seemed easy enough.

There is precedent for having two different functions, though, like 
att_addlength_pointer() and att_addlength_datum().




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.