Subject: libpq: make PGresult* "const" in PQcmdStatus()/PQcmdTuples()?

From: Jeroen Vermeulen <[email-masked]>
Date: Sat, 21 Dec 2024 13:54:32 +0100

Any objections to changing these two libpq functions' PGresult* parameters
to be const?

So "char * PQcmdStatus(PGresult *)" would become "char *PQcmdStatus(const
PGresult *)", and "char *PQcmdTuples(PGresult *)" would become "char
*PQcmdTuples(const PGresult *)".

Jeroen

---

From: Tom Lane <[email-masked]>
Date: Sat, 21 Dec 2024 10:56:31 -0500

> *PQcmdTuples(const PGresult *)".

Both of those return pointers to res->cmdStatus, so it would not make
any sense to const-ify the argument unless you also const-ify the
result; which would cause compiler warnings for users.  I'm pretty
sure we've explicitly rejected making this change for that reason.

			regards, tom lane

---

From: Jeroen Vermeulen <[email-masked]>
Date: Sat, 21 Dec 2024 16:59:03 +0100

Ah, that explains.  Thanks.

---

From: Tom Lane <[email-masked]>
Date: Sat, 21 Dec 2024 11:06:58 -0500

> sure we've explicitly rejected making this change for that reason.

[ digs in archives... ]

See previous discussions here:

https://www.postgresql.org/message-id/flat/NCBBLFLGLEIDHCJLONHNKEDGFJAA.mdklatt%40ou.edu

and here:

https://www.postgresql.org/message-id/flat/E1RaRtZ-0008aS-MK%40hans3

			regards, tom lane