From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com> |
Cc: | Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Add Pipelining support in psql |
Date: | 2025-02-20 08:02:42 |
Message-ID: | Z7bhohOpNVqh7TGc@paquier.xyz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Feb 18, 2025 at 06:34:20PM +0100, Anthonin Bonnefoy wrote:
> On Tue, Feb 18, 2025 at 8:23 AM Michael Paquier <michael(at)paquier(dot)xyz> 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.
>
> 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=on, bypassing this restriction.
>
> 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 '=(pipeline=%P,sync=%:PIPELINE_SYNC_COUNT:,cmd=%:PIPELINE_COMMAND_COUNT:,res=%:PIPELINE_RESULT_COUNT:)%#'
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 \\ forty_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
From | Date | Subject | |
---|---|---|---|
Next Message | Bertrand Drouvot | 2025-02-20 08:11:12 | Re: Remove wal_[sync|write][_time] from pg_stat_wal and track_wal_io_timing |
Previous Message | Peter Smith | 2025-02-20 07:53:26 | Re: Enhance 'pg_createsubscriber' to retrieve databases automatically when no database is provided. |