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

From Jacob Champion
Subject Re: Mark function arguments of type "T *" as "const T *" where possible
Date
Msg-id CAOYmi+=+LKvTwsPMYfLL0JE3zs=hK+BHtn6DzifeQhOe3R4NCQ@mail.gmail.com
Whole thread Raw
In response to Re: Mark function arguments of type "T *" as "const T *" where possible  (Bertrand Drouvot <bertranddrouvot.pg@gmail.com>)
List 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



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: [PATCH] Fix severe performance regression with gettext 0.20+ on Windows
Next
From: Daniel Gustafsson
Date:
Subject: Re: Serverside SNI support in libpq