Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1phnK9-00048Q-Po for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Mar 2023 08:07:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1phnK8-0004QY-Oa for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Mar 2023 08:07:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1phnK8-0004QP-Dy for pgsql-hackers@lists.postgresql.org; Thu, 30 Mar 2023 08:07:56 +0000 Received: from mail1.dalibo.net ([51.159.93.128] helo=mail.dalibo.com) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1phnK6-0006tq-4A for pgsql-hackers@lists.postgresql.org; Thu, 30 Mar 2023 08:07:56 +0000 Received: from dalibo.com (unknown [78.201.30.201]) by mail.dalibo.com (Postfix) with ESMTPSA id 6B6421F7F2; Thu, 30 Mar 2023 10:07:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.com; s=a; t=1680163650; bh=BVDrYPCg3VGF4j5p/BH5Iuf9BagYi5rqZRG/vMKz6Tk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kP86kkU9vmO99dhMhnNL/azFq3M+1EBOwFkNLC96EK8pCd3kMo6lSlmy1ITvz+WPy 6kthjGjVF5swc6gbSPPPX8kJGMcQDnQxq/zFZGNDgNPFGHL6RJj+MnA/xf3KUP/yo7 Ia+ImxtBvZL2ZhaCzp/lScq+P01MiHWViomLuS3s= Date: Thu, 30 Mar 2023 10:07:28 +0200 From: Denis Laxalde To: Jelte Fennema Cc: Greg Stark , Tom Lane , "Gregory Stark (as CFM)" , Jelte Fennema , Daniel Gustafsson , Peter Eisentraut , Jacob Champion , Andres Freund , Justin Pryzby , Robert Haas , "pgsql-hackers@lists.postgresql.org" Subject: Re: [EXTERNAL] Re: Add non-blocking version of PQcancel Message-ID: References: <2755358.1678816706@sss.pgh.pa.us> <20230328145318.upvrlslcbjyh47ce@dalibo.com> <20230329084314.higpoqp4aqpkg5iq@dalibo.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="uuvnty6HZk0W25lo" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --uuvnty6HZk0W25lo Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Jelte Fennema a écrit : > On Wed, 29 Mar 2023 at 10:43, Denis Laxalde wrote: > > More importantly, not having PQcancelSend() creating the PGcancelConn > > makes reuse of that value, passing through PQcancelReset(), more > > intuitive. E.g., in the tests: > > You convinced me. Attached is an updated patch where PQcancelSend > takes the PGcancelConn and returns 1 or 0. Patch 5 is missing respective changes; please find attached a fixup patch for these. --uuvnty6HZk0W25lo Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-fixup-Start-using-new-libpq-cancel-APIs.patch" From c9e59fb3e30db1bfab75be9fdd4afbc227a5270e Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Thu, 30 Mar 2023 09:19:18 +0200 Subject: [PATCH] fixup! Start using new libpq cancel APIs --- contrib/dblink/dblink.c | 4 ++-- src/fe_utils/connect_utils.c | 4 +++- src/test/isolation/isolationtester.c | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index e139f66e11..073795f088 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -1332,11 +1332,11 @@ dblink_cancel_query(PG_FUNCTION_ARGS) dblink_init(); conn = dblink_get_named_conn(text_to_cstring(PG_GETARG_TEXT_PP(0))); - cancelConn = PQcancelSend(conn); + cancelConn = PQcancelConn(conn); PG_TRY(); { - if (PQcancelStatus(cancelConn) == CONNECTION_BAD) + if (!PQcancelSend(cancelConn)) { msg = pchomp(PQcancelErrorMessage(cancelConn)); } diff --git a/src/fe_utils/connect_utils.c b/src/fe_utils/connect_utils.c index b32448c010..1cfd717217 100644 --- a/src/fe_utils/connect_utils.c +++ b/src/fe_utils/connect_utils.c @@ -161,7 +161,9 @@ disconnectDatabase(PGconn *conn) if (PQtransactionStatus(conn) == PQTRANS_ACTIVE) { - PQcancelFinish(PQcancelSend(conn)); + PGcancelConn *cancelConn = PQcancelConn(conn); + PQcancelSend(cancelConn); + PQcancelFinish(cancelConn); } PQfinish(conn); diff --git a/src/test/isolation/isolationtester.c b/src/test/isolation/isolationtester.c index 3781f7982b..de31a87571 100644 --- a/src/test/isolation/isolationtester.c +++ b/src/test/isolation/isolationtester.c @@ -946,9 +946,9 @@ try_complete_step(TestSpec *testspec, PermutationStep *pstep, int flags) */ if (td > max_step_wait && !canceled) { - PGcancelConn *cancel_conn = PQcancelSend(conn); + PGcancelConn *cancel_conn = PQcancelConn(conn); - if (PQcancelStatus(cancel_conn) == CONNECTION_OK) + if (PQcancelSend(cancel_conn)) { /* * print to stdout not stderr, as this should appear in -- 2.30.2 --uuvnty6HZk0W25lo--