public inbox for [email protected]help / color / mirror / Atom feed
libpq: make PGresult* "const" in PQcmdStatus()/PQcmdTuples()? 4+ messages / 2 participants [nested] [flat]
* libpq: make PGresult* "const" in PQcmdStatus()/PQcmdTuples()? @ 2024-12-21 12:54 Jeroen Vermeulen <[email protected]> 0 siblings, 1 reply; 4+ messages in thread From: Jeroen Vermeulen @ 2024-12-21 12:54 UTC (permalink / raw) To: pgsql-interfaces 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 ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: libpq: make PGresult* "const" in PQcmdStatus()/PQcmdTuples()? @ 2024-12-21 15:56 Tom Lane <[email protected]> parent: Jeroen Vermeulen <[email protected]> 0 siblings, 2 replies; 4+ messages in thread From: Tom Lane @ 2024-12-21 15:56 UTC (permalink / raw) To: Jeroen Vermeulen <[email protected]>; +Cc: pgsql-interfaces Jeroen Vermeulen <[email protected]> writes: > 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 *)". 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 ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: libpq: make PGresult* "const" in PQcmdStatus()/PQcmdTuples()? @ 2024-12-21 15:59 Jeroen Vermeulen <[email protected]> parent: Tom Lane <[email protected]> 1 sibling, 0 replies; 4+ messages in thread From: Jeroen Vermeulen @ 2024-12-21 15:59 UTC (permalink / raw) To: Tom Lane <[email protected]>; +Cc: pgsql-interfaces Ah, that explains. Thanks. On Sat, Dec 21, 2024, 16:56 Tom Lane <[email protected]> wrote: > Jeroen Vermeulen <[email protected]> writes: > > 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 *)". > > 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 > ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: libpq: make PGresult* "const" in PQcmdStatus()/PQcmdTuples()? @ 2024-12-21 16:06 Tom Lane <[email protected]> parent: Tom Lane <[email protected]> 1 sibling, 0 replies; 4+ messages in thread From: Tom Lane @ 2024-12-21 16:06 UTC (permalink / raw) To: Jeroen Vermeulen <[email protected]>; +Cc: pgsql-interfaces I wrote: > 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. [ 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 ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2024-12-21 16:06 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2024-12-21 12:54 libpq: make PGresult* "const" in PQcmdStatus()/PQcmdTuples()? Jeroen Vermeulen <[email protected]> 2024-12-21 15:56 ` Tom Lane <[email protected]> 2024-12-21 15:59 ` Jeroen Vermeulen <[email protected]> 2024-12-21 16:06 ` Tom Lane <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox