From 3ce357584e795762aa6dc45fafc21dccea7e5ec6 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Tue, 25 Feb 2025 10:07:24 +0900 Subject: psql: Add pipeline status to prompt and some state variables This commit adds %P to psql prompts, able to report the status of a pipeline depending on PQpipelineStatus(): on, off or abort. The following variables are added to report the state of an ongoing pipeline: - PIPELINE_SYNC_COUNT: reports the number of piped syncs. - PIPELINE_COMMAND_COUNT: reports the number of piped commands, a command being either \bind, \bind_named, \close or \parse. - PIPELINE_RESULT_COUNT: reports the results available to read with \getresults. These variables can be used with \echo or in a prompt, using "%:name:" in PROMPT1, PROMPT2 or PROMPT3. Some basic regression tests are added for these. The suggestion to use variables to show the details about the status counters comes from me. The original patch proposed was less extensible, hardcoding the output in the prompt. Author: Anthonin Bonnefoy Discussion: https://postgr.es/m/CAO6_XqroE7JuMEm1sWz55rp9fAYX2JwmcP_3m_v51vnOFdsLiQ@mail.gmail.com --- doc/src/sgml/ref/psql-ref.sgml | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 3edbd65e46c..cedccc14129 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -3728,6 +3728,12 @@ testdb=> \setenv LESS -imx4F generate one result to get. + + When pipeline mode is active, a dedicated prompt variable is available + to report the pipeline status. + See for more details + + Example: @@ -4502,6 +4508,39 @@ bar + + PIPELINE_COMMAND_COUNT + + + The number of commands generated by \bind, + \bind_named, \close or + \parse queued in an ongoing pipeline. + + + + + + PIPELINE_RESULT_COUNT + + + The number of commands of an ongoing pipeline that were followed + by either a \flushrequest or a + \syncpipeline, forcing the server to send the + results. These results can be retrieved with + \getresults. + + + + + + PIPELINE_SYNC_COUNT + + + The number of sync messages queued in an ongoing pipeline. + + + + PORT @@ -4901,6 +4940,17 @@ testdb=> INSERT INTO my_table VALUES (:'content'); + + %P + + + Pipeline status: off when not in a pipeline, + on when in an ongoing pipeline or + abort when in an aborted pipeline. + + + + %R -- cgit v1.2.3