Re: new warnings with clang-21 / how const is Datum - Mailing list pgsql-hackers

From Tom Lane
Subject Re: new warnings with clang-21 / how const is Datum
Date
Msg-id 347781.1756739149@sss.pgh.pa.us
Whole thread Raw
In response to new warnings with clang-21 / how const is Datum  (Peter Eisentraut <peter@eisentraut.org>)
List 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



pgsql-hackers by date:

Previous
From: "Jelte Fennema-Nio"
Date:
Subject: Re: Extension security improvement: Add support for extensions with an owned schema
Next
From: Antonin Houska
Date:
Subject: Re: Adding REPACK [concurrently]