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

From: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Mark function arguments of type "T *" as "const T *" where possible
Date: 2025-12-10 20:22:22
Message-ID: CAOYmi+=O2XCda6-gdSdWv=zaDdA5vWFfE+ySk_tCF5Qx2P_A4g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Dec 10, 2025 at 9:44 AM Bertrand Drouvot
<bertranddrouvot(dot)pg(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bryan Green 2025-12-10 21:06:36 Re: [PATCH] Allow complex data for GUC extra.
Previous Message Stéphane Tachoires 2025-12-10 20:04:11 Re: Add SPLIT PARTITION/MERGE PARTITIONS commands