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 1tl1WT-008h2m-2q for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Feb 2025 08:03:05 +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 1tl1WQ-002pyd-UD for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Feb 2025 08:03:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tl1WP-002pyV-Fb for pgsql-hackers@lists.postgresql.org; Thu, 20 Feb 2025 08:03:02 +0000 Received: from fout-b1-smtp.messagingengine.com ([202.12.124.144]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tl1WN-001rYP-1j for pgsql-hackers@postgresql.org; Thu, 20 Feb 2025 08:03:00 +0000 Received: from phl-compute-02.internal (phl-compute-02.phl.internal [10.202.2.42]) by mailfout.stl.internal (Postfix) with ESMTP id 23B43114011C; Thu, 20 Feb 2025 03:02:58 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Thu, 20 Feb 2025 03:02:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1740038577; x=1740124977; bh=OGKJK8Tj+A zs4yL0ZnrspG1vRSO6uLVQHlQJTMBER1c=; b=mJFY9MUstBh6O3tiPVDVUXNG3t aBWwBkumNn0vE+Z8q/Fv5i3sPb/ZjSPC58eRz64Bhvm5qu48+kxTpO76fFZEPOwm Y6OxsGfbJr8j0cCzkqV55a+nJI2wcD9jVS2b/+Pi4QUwrDXILi4y8ki4q9GGXuzH n8CdFDm1MgiO9Iv+zOSY81qSIDLC/i8uRcLaSAgXsEF7p+LKwjiDhqtvP2voDh2o c+DHlqGSVqVCAPHXRWK/nbk0AMju8TIO8GipgYQZLO7m+c+oxQot+iaYxITdIf4o S23mA1y+/0yCW7QmBVnL+pK9Jpz+vHQ+gCvjmdl6OLg8FIiTVXHR9BhoLoUA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1740038577; x=1740124977; bh=OGKJK8Tj+Azs4yL0ZnrspG1vRSO6uLVQHlQ JTMBER1c=; b=TNzTS0RCdfZq5mZPuIPUYewOe+he2sMTZ2uah7GYDGioPUO8arf GhXGGDAk5JmupOwpT+XEYeKgAS0sLLP5neTqnb/0ja1E2t96U5u2q2VmksDDW+fz iMOWgHPhqWt4KptQ19KFpQNrp6N06sWBz0rlmIZ71E340bG8Bz+oksRriOTO94Kg pm3WJDFSg91tygi2hoASERo/pyySRHzLCaZQ8fT1jGxQuteLAIdTc0TyqgTpnXwX lcGgDK4QKRJ0P6Gij7h54PHcZmeGcDAJ8L01tJqPzm/UjZnGdHoEOCeoLiXuw5Iv 1D/aoB4IUjcwoUwRlAnJzc8yEky15s/3XCg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdeiieeifecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenfghrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuffk fhggtggujgesghdtreertddtjeenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrh cuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpeeu teduteejleetudeiheelfffgteelhefhgedvueevjeevgfekgeefgfeggfetheenucffoh hmrghinhepshhqlhdrhihouhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhep mhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhnsggprhgtph htthhopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegrnhhthhhonhhinhdr sghonhhnvghfohihsegurghtrgguohhghhhqrdgtohhmpdhrtghpthhtohepphhoshhtgh hrvghssehjvghlthgvfhdrnhhlpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrshes phhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 20 Feb 2025 03:02:55 -0500 (EST) Date: Thu, 20 Feb 2025 17:02:42 +0900 From: Michael Paquier To: Anthonin Bonnefoy Cc: Jelte Fennema-Nio , PostgreSQL Hackers Subject: Re: Add Pipelining support in psql Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="FSmocRcgjJx8v3k5" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --FSmocRcgjJx8v3k5 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Feb 18, 2025 at 06:34:20PM +0100, Anthonin Bonnefoy wrote: > On Tue, Feb 18, 2025 at 8:23=E2=80=AFAM Michael Paquier wrote: >> The tests in psql.sql are becoming really long. Perhaps it would be >> better to split that into its own file, say psql_pipeline.sql? The >> input file is already 2k lines, you are adding 15% more lines to that. >=20 > Agreed, I wasn't sure if this was enough to warrant a dedicated test > file. This is now separated in psql_pipeline.sql. You have forgotten the expected output. Not a big issue as the input was sent. >> What is the reasoning here behind this restriction? \gx is a wrapper >> of \g with expanded mode on, but it is also possible to call \g with >> expanded=3Don, bypassing this restriction. >=20 > The issue is that \gx enables expanded mode for the duration of the > query and immediately reset it in sendquery_cleanup. With pipelining, > the command is piped and displaying is done by either \endpipeline or > \getresults, so the flag change has no impact. Forbidding it was a way > to make it clearer that it won't have the expected effect. If we > wanted a similar feature, this would need to be done with something > like \endpipelinex or \getresultsx. Hmm, okay. If one wants one mode or the other it is always possible to force one with \pset expanded when getting the results. Not sure if there is any need for new specific commands for these two printing the results. Another option would be to authorize the command to run, but perhaps your option is just better as per the enforced behavior in the output. So fine by me. There is coverage so we'll know if there are arguments in favor of authorizing the command, if need be. > I've split the patch and created the 3 special variables: > PIPELINE_SYNC_COUNT, PIPELINE_COMMAND_COUNT, PIPELINE_RESULT_COUNT. Thanks. Looks sensible now. > For requested_results, I don't think there's value in exposing it > since it is used as an exit condition and thus will always be 0 > outside of ExecQueryAndProcessResults. I've been playing with this patch and this configuration: \set PROMPT1 '=3D(pipeline=3D%P,sync=3D%:PIPELINE_SYNC_COUNT:,cmd=3D%:PIPEL= INE_COMMAND_COUNT:,res=3D%:PIPELINE_RESULT_COUNT:)%#'=20 That's long, but seeing the evolution of the pipeline status is pretty cool depending on the meta-commands used. While testing, I have been able to run into an assertion failure by adding some tests in psql.sql to check for the case of inactive branches for \if. For example: --- a/src/test/regress/sql/psql.sql +++ b/src/test/regress/sql/psql.sql @@ -1047,11 +1047,15 @@ select \if false \\ (bogus \else \\ 42 \endif \\ fo= rty_two; \echo arg1 arg2 arg3 arg4 arg5 \echo arg1 \encoding arg1 + \endpipeline \errverbose And the report: +psql: mainloop.c:513: MainLoop: Assertion `conditional_active(cond_stack)'= failed. We should have tests for all new six meta-commands in psql.sql. MainLoop() is wrong when in pipeline mode for inactive branches. -- Michael --FSmocRcgjJx8v3k5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAme24aIACgkQnvQgOdby QH3iExAAhDz1A4VyiYNMWyK9auAtdher9q1pxpw8hh/NGgJihg3ZhMZB7MT2iUSp V9DG9KajLdTIsebNC5AmQ0swROAxgYgtU18myMpX9MqEwpBoUftHzl9kJ4s3xUAf Piwx7D1//G4SQVo5QWpSRGyWJ46pO6aKZ0KLAKpeaX93g5eIZ3JYi2jURSMzde7k RgrB3oN0WZad+qONqMA2KMYW0UVaa7nzFrAdw83ua37tRJl9ApoBa4twdm4pQMsl 2CjQEhDARto0mbdZi9kV0Syytdx9jbIPTCwLHIscYsvB6JpUWWBqPjLDpAW3HL4y IgDdUNNDJgseIsQh+P7eOhntM/kXxQbqrft95+rOeErnL3/AtxP7P58ULDuv/Sia x9Bpx2iD/3N4XT6Md9ttxWJ0IdMG6nqzobijUW3ZMqQHILVfQL7Xh3rpFrPtCwLN vkBRM1ZuqKtBF+KsLAf0Ao6tVxRE/aF4vN5vcVnZpIW1QH9I+pM/07Wg3msWv9+X IpY6cfcrCk9kxU1YoQ1zEXR+YpDT1R2eouXGqTXZIEsFMksqfFveSIpM8C16jVLS cwhhrWJChCKGCR7JKNN7pxqJ/Vpvly8oVUmGqPcsB88UeWG2UuYe/IiZ6QZxX2fF YYez9GXu4IsL4OvHEmAtqNyGGgyxUpfqA0Sc97ZU3Bx3i11UfVk= =044W -----END PGP SIGNATURE----- --FSmocRcgjJx8v3k5--