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 1rsIjK-006C4R-Nr for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Apr 2024 08:45:55 +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 1rsIjI-000cuR-Vh for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Apr 2024 08:45:52 +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 1rsIjH-000cuI-O8 for pgsql-hackers@lists.postgresql.org; Thu, 04 Apr 2024 08:45:52 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rsIj9-000ZLc-9v for pgsql-hackers@lists.postgresql.org; Thu, 04 Apr 2024 08:45:51 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 64FC23200906; Thu, 4 Apr 2024 04:45:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 04 Apr 2024 04:45:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712220337; x= 1712306737; bh=L+5RSck0xzHAf90MFUrRJipkkqu4UcoPekPMrNpXBaA=; b=n Zkhs42aftTmP9ADqAEBvECilabquBEFLdChlmLIrClb2ab+6YW1jFNeQfBs8vw1h O9L/2OY17Yw/DvKaBW64zi7FkayaJwL3YgoQdW1XU9+pF8vj5TtQ5hmevwDbsuGe /gfdw6kiM+EOVYvMn1bjcVEernJbbv3kg5GC38bSMN6kL5moL3oXqlzzCUK6ihga NwPEAIpwBtXaiothmlySGWMEtbkEFFy6WkUZBrRyzNymh1jNYFDYUPw0+cbyC3I3 wtWglFjPaWMc7HGGMggH5zJ0Ke/olX9Je1b8yicxiDJE/6mtCR9T4aE/plnZ/RFr O9Ax2Pm1eG80fEcvxnNFA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefkedgtdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesmhekreertddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepudelkeekgfdttdettdekgfduvdeiffelteegjeeihfet heekveeftedtuddvhfeunecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 4 Apr 2024 04:45:36 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1712220333; bh=9M/P45rGD4XK6VFABverjG6D8q67CEd9RvK6ugrCQak=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=kFQvfola0oKJMqVFxWhQ+AUzXWE9jQHUdfwni4RoVO1KoOOJVmZCRXtTNsqcqs9h3 ngQq1vbymN6NRUHwhoPQKWRdBPWM2CXAwohlfL/sUEBi3kiRq0M0yZ34pOYLJ5nZ+1 oywDTg3p5oxkIYEM3zGsa0bJMcnRF1iWCRsPTGOGJuJpEYvuHfRpAQyKXK4Ca/Q6wU nsql+3yMOY5aMUfD+YzsT+HFzt81Dv6jXlKjKLFEGVFbmNiiCVleednZjuGIg6IZps TDWC/2r9bhK1F+P1NRHOfOrfBrl6JPwObX1IMQui6UOYY/uYloDvZ7RIcsJvHkvt0I uGln7Qee/Juiw== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id B3DBF41E; Thu, 4 Apr 2024 10:45:33 +0200 (CEST) Date: Thu, 4 Apr 2024 10:45:33 +0200 From: Alvaro Herrera To: Tom Lane Cc: Jelte Fennema-Nio , Noah Misch , Jacob Champion , Denis Laxalde , vignesh C , Thomas Munro , Greg Stark , "Gregory Stark (as CFM)" , Jelte Fennema , Daniel Gustafsson , Peter Eisentraut , Andres Freund , Justin Pryzby , Robert Haas , pgsql-hackers@lists.postgresql.org, Etsuro Fujita Subject: Re: [EXTERNAL] Re: Add non-blocking version of PQcancel Message-ID: <202404040845.i355zg4oimbw@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="4wi6zoifi5wy2upb" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <372769.1712179784@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --4wi6zoifi5wy2upb Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2024-Apr-03, Tom Lane wrote: > On my machine, headerscheck does not like this: > > $ src/tools/pginclude/headerscheck --cplusplus > In file included from /tmp/headerscheck.4gTaW5/test.cpp:3: > ./src/include/libpq/libpq-be-fe-helpers.h: In function 'char* libpqsrv_cancel(PGconn*, TimestampTz)': > ./src/include/libpq/libpq-be-fe-helpers.h:393:10: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] > return "out of memory"; > ^~~~~~~~~~~~~~~ > ./src/include/libpq/libpq-be-fe-helpers.h:421:13: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] > error = "cancel request timed out"; > ^~~~~~~~~~~~~~~~~~~~~~~~~~ > > The second part of that could easily be fixed by declaring "error" as > "const char *". As for the first part, can we redefine the whole > function as returning "const char *"? (If not, this coding is very > questionable anyway.) Yeah, this seems to work and I no longer get that complaint from headerscheck. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ --4wi6zoifi5wy2upb Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-Make-libpqsrv_cancel-s-return-type-const-char.patch" From 0af8c7039b2c8ed80bc0bddacfe4a9abb8f527b3 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Thu, 4 Apr 2024 10:13:07 +0200 Subject: [PATCH] Make libpqsrv_cancel's return type const char * --- contrib/dblink/dblink.c | 2 +- contrib/postgres_fdw/connection.c | 2 +- src/include/libpq/libpq-be-fe-helpers.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index de858e165a..755293456f 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -1347,7 +1347,7 @@ Datum dblink_cancel_query(PG_FUNCTION_ARGS) { PGconn *conn; - char *msg; + const char *msg; TimestampTz endtime; dblink_init(); diff --git a/contrib/postgres_fdw/connection.c b/contrib/postgres_fdw/connection.c index 2532e453c4..cac9d96d33 100644 --- a/contrib/postgres_fdw/connection.c +++ b/contrib/postgres_fdw/connection.c @@ -1332,7 +1332,7 @@ pgfdw_cancel_query(PGconn *conn) static bool pgfdw_cancel_query_begin(PGconn *conn, TimestampTz endtime) { - char *errormsg = libpqsrv_cancel(conn, endtime); + const char *errormsg = libpqsrv_cancel(conn, endtime); if (errormsg != NULL) ereport(WARNING, diff --git a/src/include/libpq/libpq-be-fe-helpers.h b/src/include/libpq/libpq-be-fe-helpers.h index 8be9aa1f2f..fe50829274 100644 --- a/src/include/libpq/libpq-be-fe-helpers.h +++ b/src/include/libpq/libpq-be-fe-helpers.h @@ -382,11 +382,11 @@ libpqsrv_get_result(PGconn *conn, uint32 wait_event_info) * Note: this function leaks a string's worth of memory when reporting * libpq errors. Make sure to call it in a transient memory context. */ -static inline char * +static inline const char * libpqsrv_cancel(PGconn *conn, TimestampTz endtime) { PGcancelConn *cancel_conn; - char *error = NULL; + const char *error = NULL; cancel_conn = PQcancelCreate(conn); if (cancel_conn == NULL) -- 2.39.2 --4wi6zoifi5wy2upb--