Re: Datum as struct

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: Andres Freund <andres@anarazel.de>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-08-09T13:04:35Z
Lists: pgsql-hackers
Peter Eisentraut <peter@eisentraut.org> writes:
> On 08.08.25 22:30, Andres Freund wrote:
>> One thing that would be an interesting follow-up would be to make the struct
>> not just carry the datum, but also the type of the field, to be filled in by
>> tuple deforming and the *GetDatum() functions. Then we could assert that the
>> correct DatumGet*() functions are used. I think that'd allow us to detect a
>> rather large number of issues that we currently aren't finding

> That would make Datum >=9 bytes?  Is that something we would need to 
> worry about in terms of performance?

It'd have to be a cassert-like option, not something you'd enable in
production.

			regards, tom lane



Commits

  1. Use consistent type for pgaio_io_get_id() result

  2. Mop-up for Datum conversion cleanups.

  3. Add missing Datum conversions

  4. Remove useless/superfluous Datum conversions

  5. Fix incorrect lack of Datum conversion in _int_matchsel()

  6. Improve tests of date_trunc() with infinity and unsupported units

  7. Fix incorrect Datum conversion in timestamptz_trunc_internal()

  8. Fix various hash function uses

  9. Fix mixups of FooGetDatum() vs. DatumGetFoo()