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

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: Re: Mark function arguments of type "Datum *" as "const Datum *" where possible
Date: 2025-09-26 11:50:10
Message-ID: aNZ98hfppZk54ml1@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Álvaro Herrera 2025-09-26 11:55:50 splitting src/bin/scripts/vacuumdb.c
Previous Message Kirill Reshke 2025-09-26 11:39:21 Re: Remove custom redundant full page write description from GIN