pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Grab the low-hanging fruit from forcing sizeof(Datum) to 8.
Date: Wed, 13 Aug 2025 21:18:38 +0000
Message-ID: <E1umIrm-000Pi6-2c@gemulon.postgresql.org> (raw)

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

Remove conditionally-compiled code for smaller Datum widths,
and simplify comments that describe cases no longer of interest.

I also fixed up a few more places that were not using
DatumGetIntXX where they should, and made some cosmetic
adjustments such as using sizeof(int64) not sizeof(Datum)
in places where that fit better with the surrounding code.

One thing I remembered while preparing this part is that SP-GiST
stores pass-by-value prefix keys as Datums, so that the on-disk
representation depends on sizeof(Datum).  That's even more
unfortunate than the existing commentary makes it out to be,
because now there is a hazard that the change of sizeof(Datum)
will break SP-GiST indexes on 32-bit machines.  It appears that
there are no existing SP-GiST opclasses that are actually
affected; and if there are some that I didn't find, the number
of installations that are using them on 32-bit machines is
doubtless tiny.  So I'm proceeding on the assumption that we
can get away with this, but it's something to worry about.

(gininsert.c looks like it has a similar problem, but it's okay
because the "tuples" it's constructing are just transient data
within the tuplesort step.  That's pretty poorly documented
though, so I added some comments.)

Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/1749799.1752797397@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6aebedc38497ecebda22caf61bcadf78a8331b52

Modified Files
--------------
doc/src/sgml/xfunc.sgml                |   3 +-
src/backend/access/gin/gininsert.c     |   5 +-
src/backend/access/gist/gistproc.c     |  10 +--
src/backend/access/nbtree/nbtcompare.c |  20 ------
src/backend/catalog/pg_type.c          |   4 +-
src/backend/utils/adt/mac.c            |  27 +++-----
src/backend/utils/adt/network.c        |  54 ++++-----------
src/backend/utils/adt/numeric.c        | 117 ++++-----------------------------
src/backend/utils/adt/timestamp.c      |  21 ------
src/backend/utils/adt/uuid.c           |   6 +-
src/backend/utils/adt/varlena.c        |  27 +++-----
src/backend/utils/sort/tuplesort.c     |   8 ---
src/include/access/gin_tuple.h         |   4 +-
src/include/access/spgist_private.h    |  14 ++--
src/include/access/tupmacs.h           |  15 ++---
src/include/port/pg_bswap.h            |  17 +----
src/include/utils/sortsupport.h        |   4 --
17 files changed, 72 insertions(+), 284 deletions(-)



view thread (2+ messages)

Message-ID: <E1umIrm-000Pi6-2c@gemulon.postgresql.org>
Permalink:  ../E1umIrm-000Pi6-2c@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1umIrm-000Pi6-2c@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Grab the low-hanging fruit from forcing sizeof(Datum) to 8.
  In-Reply-To: <E1umIrm-000Pi6-2c@gemulon.postgresql.org>

* 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