Re: new warnings with clang-21 / how const is Datum

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

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-09-01T15:05:49Z
Lists: pgsql-hackers
Peter Eisentraut <peter@eisentraut.org> writes:
> Overall, the question to what extent fmgr functions are allowed to 
> modify objects pointed to by their input arguments doesn't seem to be 
> addressed anywhere.

I think it's generally understood that an fmgr function must not
modify pass-by-reference inputs, because they could easily be
pointing directly into a heap tuple in a shared buffer.  The
exception is functions that participate in custom APIs where the
presence of output argument(s) is explicitly documented.

One question that statement leaves unanswered is whether datatype
input functions qualify as a "custom API".  I'd vote not (ie they
shouldn't modify their input strings) unless we find exceptions.

So that suggests that the use of non-const pointer Datums should be
the outlier.

			regards, tom lane



Commits

  1. Some stylistic improvements in toast_save_datum()

  2. Silence compiler warnings on clang 21

  3. Convert *GetDatum() and DatumGet*() macros to inline functions