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

Jacob Champion <jacob.champion@enterprisedb.com>

From: Jacob Champion <jacob.champion@enterprisedb.com>
To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2025-12-11T17:51:49Z
Lists: pgsql-hackers
On Wed, Dec 10, 2025 at 11:22 PM Bertrand Drouvot
<bertranddrouvot.pg@gmail.com> wrote:
> Also, with the patch in place that would mean "think twice before changing
> from const to no const" and that could create doubts and waste of time for future
> patch authors.

Yeah, exactly.

> Let me try to focus on functions that really
> deserve the change. I could look at function names that contain "copy" or "cmp",
> functions that are used for formatting/printing and size/length calculations as
> examples.

Sure, that sounds reasonable, and I would hope that those sorts of
functions are not very high on the list of backport contention.

> Any other ideas?

Just that the most useful const additions (IMHO) are going to be
places at the top of a big hierarchy, where callers expect something
not to be modified, but the lowest levels are too far removed from
that expectation for developers to easily remember. I imagine those
cases are not going to be easy to find automatically (but that
shouldn't discourage incremental improvements that can be found that
way).

Thanks!
--Jacob