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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: new warnings with clang-21 / how const is Datum
Date: 2025-09-01 15:05:49
Message-ID: 347781.1756739149@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter(at)eisentraut(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Antonin Houska 2025-09-01 15:30:18 Re: Adding REPACK [concurrently]
Previous Message Jelte Fennema-Nio 2025-09-01 14:44:41 Re: Extension security improvement: Add support for extensions with an owned schema