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

From Michael Paquier
Subject Re: Mark function arguments of type "Datum *" as "const Datum *" where possible
Date
Msg-id aNZ98hfppZk54ml1@paquier.xyz
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>)
Responses Re: Mark function arguments of type "Datum *" as "const Datum *" where possible
List pgsql-hackers
On Fri, Sep 26, 2025 at 03:35:54PM +0800, Chao Li wrote:
>> I noticed that many functions take "Datum *" parameters while they don't
>> update the data. So I created this patch to change "Datum *" to "const
>> Datum *" wherever possible, which should improve type safety and make the
>> interfaces clearer about their intent, also helps the compiler catch
>> accidental modifications.

I have not looked at the patch in details and we need a careful
case-by-case review, but being more protective with the Datums that
travel across the stack may be a good idea in the long-term depending
on the code path dealt with, so I like the initiative you are taking
here.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Kirill Reshke
Date:
Subject: Re: Remove custom redundant full page write description from GIN
Next
From: Álvaro Herrera
Date:
Subject: splitting src/bin/scripts/vacuumdb.c