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+=O2XCda6-gdSdWv=zaDdA5vWFfE+ySk_tCF5Qx2P_A4g@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>)
Responses Re: Mark function arguments of type "T *" as "const T *" where possible
List pgsql-hackers
On Wed, Dec 10, 2025 at 9:44 AM Bertrand Drouvot
<bertranddrouvot.pg@gmail.com> wrote:
> Thoughts?

Kneejerk reaction (as someone who wants better const-correctness!): I
suspect that this patch is not practically reviewable for most people.
Especially knowing that the patchset was formed via subtraction of
known-bad cases rather than addition of known-good cases. `const`
needs to be added with intent.

IMO this is especially problematic with our "context bag" structs. As
one example:

>  static int
> -InitializeLDAPConnection(Port *port, LDAP **ldap)
> +InitializeLDAPConnection(const Port *port, LDAP **ldap)

I don't see a good reason to constrain future developers in this way.
Why shouldn't the code that makes LDAP connections be allowed to take
notes inside the Port at some point in the future?

--Jacob



pgsql-hackers by date:

Previous
From: Stéphane Tachoires
Date:
Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Next
From: Bryan Green
Date:
Subject: Re: [PATCH] Allow complex data for GUC extra.