Re: Mark function arguments of type "Datum *" as "const Datum *" where possible

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Chao Li <li.evan.chao@gmail.com>
Cc: Postgres hackers <pgsql-hackers@lists.postgresql.org>, Peter Eisentraut <peter@eisentraut.org>
Date: 2025-09-26T11:50:10Z
Lists: 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

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Mark function arguments of type "Datum *" as "const Datum *" where possible