From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: psql: Add pipeline status to prompt and some state variables
Date: Tue, 25 Feb 2025 01:08:48 +0000
Message-ID: <E1tmjRH-000XTC-2X@gemulon.postgresql.org> (raw)
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 <anthonin.bonnefoy@datadoghq.com>
Discussion: https://postgr.es/m/CAO6_XqroE7JuMEm1sWz55rp9fAYX2JwmcP_3m_v51vnOFdsLiQ@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/3ce357584e795762aa6dc45fafc21dccea7e5ec6
Modified Files
--------------
doc/src/sgml/ref/psql-ref.sgml | 50 +++++++++++++++++++++++++++++
src/bin/psql/common.c | 27 +++++++++++++++-
src/bin/psql/prompt.c | 14 ++++++++
src/bin/psql/startup.c | 5 +++
src/test/regress/expected/psql_pipeline.out | 22 +++++++++++++
src/test/regress/sql/psql_pipeline.sql | 11 +++++++
6 files changed, 128 insertions(+), 1 deletion(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: psql: Add pipeline status to prompt and some state variables
In-Reply-To: <E1tmjRH-000XTC-2X@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox