Re: Mark function arguments of type "Datum *" as "const Datum *" where possible - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Mark function arguments of type "Datum *" as "const Datum *" where possible
Date
Msg-id 641abcbf-8044-4c65-895e-683e17b170a1@eisentraut.org
Whole thread Raw
In response to Re: Mark function arguments of type "Datum *" as "const Datum *" where possible  (Chao Li <li.evan.chao@gmail.com>)
List pgsql-hackers
On 28.09.25 05:02, Chao Li wrote:
> 
> On Fri, Sep 26, 2025 at 11:00 PM Tom Lane <tgl@sss.pgh.pa.us 
> <mailto:tgl@sss.pgh.pa.us>> wrote:
> 
>     Yeah.  In particular, probably 99% of such Datum arrays also have an
>     associated array of bool isnull flags.  IMO it makes exactly zero
>     sense to const-ify the Datums without similar protection for their
>     isnull flags.
> 
> 
> Based on Tom's comment, I have made the scope a little broader. If a 
> function's "Datum *" parameter is changed to const, then if it has a 
> pairing "bool *isnull" parameter, I make it const as well. Also, if the 
> function has other pointer parameters that can be const, I change them 
> to const as well. See v3 attached.

I have committed this.  Note that the documentation for the SPI 
functions needed to be updated.

As discussed in the other thread about ItemPointer etc., I removed from 
your patch changes that would have broken externally usable callback 
function signatures.  But that was only a small portion of your patch.




pgsql-hackers by date:

Previous
From: Bertrand Drouvot
Date:
Subject: Re: Consistently use the XLogRecPtrIsInvalid() macro
Next
From: Jakub Wartak
Date:
Subject: Re: pg_plan_advice