Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tP1sy-009lkZ-7Y for pgsql-interfaces@arkaria.postgresql.org; Sat, 21 Dec 2024 15:59:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tP1sv-00A0pv-Kw for pgsql-interfaces@arkaria.postgresql.org; Sat, 21 Dec 2024 15:59:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tP1sv-00A0pn-Bj for pgsql-interfaces@lists.postgresql.org; Sat, 21 Dec 2024 15:59:21 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tP1ss-000vJH-2N for pgsql-interfaces@postgresql.org; Sat, 21 Dec 2024 15:59:20 +0000 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5d3d14336f0so5097158a12.3 for ; Sat, 21 Dec 2024 07:59:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734796754; x=1735401554; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=BTdaWro7N195KdaFG2wKFPhM4mHshKFjQHZ6gmuDbVw=; b=APvQQCknQDsMdB2dITMXF3046aoD579CHDk7ZBPyPc3DTPlXolaRubxzXCmpFq699W jjAgIJYLDRyFcPz9M674lrKcJap94y2zdykmzp6iKByXh1YS2BoBDJt+C0YcdUwUJDb0 Uk7QdV28rIUUDptB3rPJ45qKz9wyzXIZt9yK3HJ0qcCNRejLn/fnnXmcb1N2GR3DjKnr DyJorJJno+pJ7uFSf34A1bGUwWXtPGxBppb5AK5eDfEQM4hQVYtHq7Y7a53AxlzwA7ID Hp6Yy3/g1X5sRTxZiDpyqqGK4xlge/sa0eVaVrIaMDVHCIVBxl0tzOoHqwK5oMtcvXAn mrxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734796754; x=1735401554; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BTdaWro7N195KdaFG2wKFPhM4mHshKFjQHZ6gmuDbVw=; b=RWwcDlTT2TX6eqNK0CRyp8WSLwnKb8kBb7+KU3rl5dwKds2bV/lzprES6NzrlodMs5 9UFDBcm/BQNjxJNMTszkC54iGVdnDET460Ubhdsi1ZpCiXq5iBl8yvE0m1c9RCbFIKQT Bk9k4RCb5JUK2628FN2zXy+G22Ca0ew16T16BGMkVX+bWosBm6hzF1sjr0vBl45pLJyF Fud+RMI/A/samGMXaGD89f4XYqfBQ97mQZZer5DcD5LF3NfEzbkSPBB3A6gSaKylPFqF 8aG/B0RDuytV3F5Wja2ltI7SusPS+B23mVOGQgxJcCMGRlB45Z1XOyyl3UPF4e0UWsfv qW5A== X-Gm-Message-State: AOJu0YxRRj78jumegf94T9cS8p+bYf6m3CfBmTDjXmm2xNsJ9I08Xd4U wveL1SHnE7/CNRDeZ5hzOCdKE6dv5RFs5z79OW80fAUqWU5s1FO+O9C5+7IeJWa+leNaTACyIaf ODfZbDTmZttP5dE3eGR26Lav/CyjohQ== X-Gm-Gg: ASbGncv6EwSYbldzQQdpiGlJZo7aE5/Y5PZWObCbnF1cKsslpSiT8T1CtTsRxpHiG7n R8trXU9NDfYX007Eqng3NOxYkUjv0rvuh/tpNDkRzM3oUF3kjVHA79a7uRUar/J0+dMviqhg= X-Google-Smtp-Source: AGHT+IGw6BBJf4vhAcxiqLP5XDt10UxWuW41zZbkOs+mIxlzpk3u3NxHbD42BbRlCgOkL9t45cWttrm6u0Y2fklIykg= X-Received: by 2002:a05:6402:4405:b0:5d8:16ea:cfb4 with SMTP id 4fb4d7f45d1cf-5d81dd7d02cmr6332176a12.8.1734796754135; Sat, 21 Dec 2024 07:59:14 -0800 (PST) MIME-Version: 1.0 References: <859822.1734796591@sss.pgh.pa.us> In-Reply-To: <859822.1734796591@sss.pgh.pa.us> From: Jeroen Vermeulen Date: Sat, 21 Dec 2024 16:59:03 +0100 Message-ID: Subject: Re: libpq: make PGresult* "const" in PQcmdStatus()/PQcmdTuples()? To: Tom Lane Cc: pgsql-interfaces@postgresql.org Content-Type: multipart/alternative; boundary="00000000000049b1db0629c9d8b5" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000049b1db0629c9d8b5 Content-Type: text/plain; charset="UTF-8" Ah, that explains. Thanks. On Sat, Dec 21, 2024, 16:56 Tom Lane wrote: > Jeroen Vermeulen 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 > --00000000000049b1db0629c9d8b5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Ah, that explains.=C2=A0 Thanks.


On Sat, Dec 21, 2024, 16:56 Tom Lane <tgl@sss.pgh.pa.us> wrote:
Jeroen Vermeulen <jtvjtv@gmail.com> writes:
> Any objections to changing these two libpq functions' PGresult* pa= rameters
> 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.=C2=A0 I'm pretty=
sure we've explicitly rejected making this change for that reason.

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 regards, tom lane
--00000000000049b1db0629c9d8b5--