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 1lqNQK-0004oO-9o for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Jun 2021 22:08:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lqNQJ-00051L-Am for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Jun 2021 22:08:43 +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 1lqNQJ-00051D-3Q for pgsql-hackers@lists.postgresql.org; Mon, 07 Jun 2021 22:08:43 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lqNQH-00059h-91 for pgsql-hackers@lists.postgresql.org; Mon, 07 Jun 2021 22:08:42 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 7E1235C01AA; Mon, 7 Jun 2021 18:08:39 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 07 Jun 2021 18:08:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=bLlJQ4f2JZc9V2IbT+z0MIlsFKXFQBUVzpRCeg+EsNY=; b=c6Cyk9Ga yy7Ig1mBDXpyQP14n8/J/MZcl4wz6iwD2UfkkvaLpORsOcmrwE3pj62OETCzL2mb Awd++j9Scswnng42k3xp/0C2KR2H2F2k9Ug2sSN1OfIp6J+pP3mglXsvpo2w6KPK Jw1H3P2r4k9y/tVgaU7hVIYmRficGsELi4GqIRiVSvN/5wQ9gjMNY5Ij81yrCHPQ Z8fHu5p2u7VALIxpaPySBV+qsBVYPQ3zo5LgcU9u9O0hLi2+I0IAmQ9x8blThhwo P9D3Bx5NTnYhyJg0AHP7VNuK0LomHfsjX19wSbo3X/j4NOS1Qrzn6tgo/qFKZPyj ahl95iEug+J+Qw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfedtjedgudeilecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkgggtugfgjgesmhekreertddtudenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepveeviedttefgjeehlefhveetveejheevgefflefhjedv heeuueevleehhfeuteehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 7 Jun 2021 18:08:37 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id EE3B02A097C; Mon, 7 Jun 2021 18:08:33 -0400 (-04) Date: Mon, 7 Jun 2021 18:08:33 -0400 From: Alvaro Herrera To: Yura Sokolov Cc: Tom Lane , pgsql-hackers@lists.postgresql.org Subject: Re: Add PortalDrop in exec_execute_message Message-ID: <202106072208.jeksdphlipvp@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="mg7clb7cv6aqlnag" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202106072107.d4i55hdscxqj@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --mg7clb7cv6aqlnag Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2021-Jun-07, Alvaro Herrera wrote: > The attached patch does it. Any opinions? Eh, really attached. -- Álvaro Herrera 39°49'30"S 73°17'W "No es bueno caminar con un hombre muerto" --mg7clb7cv6aqlnag Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Add-Portal-Close-to-pipelined-PQsendQuery.patch" From c5c6e8860e9d425ddea82e32868fedc7562ec51c Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Mon, 7 Jun 2021 18:06:28 -0400 Subject: [PATCH] Add 'Portal Close' to pipelined PQsendQuery() --- src/interfaces/libpq/fe-exec.c | 8 +++++++- .../modules/libpq_pipeline/traces/pipeline_abort.trace | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 03592bdce9..213e5576a1 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -1329,7 +1329,8 @@ PQsendQueryInternal(PGconn *conn, const char *query, bool newQuery) { /* * In pipeline mode we cannot use the simple protocol, so we send - * Parse, Bind, Describe Portal, Execute. + * Parse, Bind, Describe Portal, Execute, Close Portal (with the + * unnamed portal). */ if (pqPutMsgStart('P', conn) < 0 || pqPuts("", conn) < 0 || @@ -1355,6 +1356,11 @@ PQsendQueryInternal(PGconn *conn, const char *query, bool newQuery) pqPutInt(0, 4, conn) < 0 || pqPutMsgEnd(conn) < 0) goto sendFailed; + if (pqPutMsgStart('C', conn) < 0 || + pqPutc('P', conn) < 0 || + pqPuts("", conn) < 0 || + pqPutMsgEnd(conn) < 0) + goto sendFailed; entry->queryclass = PGQUERY_EXTENDED; entry->query = strdup(query); diff --git a/src/test/modules/libpq_pipeline/traces/pipeline_abort.trace b/src/test/modules/libpq_pipeline/traces/pipeline_abort.trace index 254e485997..3fce548b99 100644 --- a/src/test/modules/libpq_pipeline/traces/pipeline_abort.trace +++ b/src/test/modules/libpq_pipeline/traces/pipeline_abort.trace @@ -38,6 +38,7 @@ F 26 Parse "" "SELECT 1; SELECT 2" 0 F 12 Bind "" "" 0 0 0 F 6 Describe P "" F 9 Execute "" 0 +F 6 Close P "" F 4 Sync B NN ErrorResponse S "ERROR" V "ERROR" C "42601" M "cannot insert multiple commands into a prepared statement" F "SSSS" L "SSSS" R "SSSS" \x00 B 5 ReadyForQuery I @@ -45,6 +46,7 @@ F 54 Parse "" "SELECT 1.0/g FROM generate_series(3, -1, -1) g" 0 F 12 Bind "" "" 0 0 0 F 6 Describe P "" F 9 Execute "" 0 +F 6 Close P "" F 4 Sync B 4 ParseComplete B 4 BindComplete -- 2.20.1 --mg7clb7cv6aqlnag--