mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
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
This commit is contained in:
@ -3728,6 +3728,12 @@ testdb=> <userinput>\setenv LESS -imx4F</userinput>
|
||||
generate one result to get.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
When pipeline mode is active, a dedicated prompt variable is available
|
||||
to report the pipeline status.
|
||||
See <xref linkend="app-psql-prompting-p-uc"/> for more details
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Example:
|
||||
<programlisting>
|
||||
@ -4502,6 +4508,39 @@ bar
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="app-psql-variables-pipeline-command-count">
|
||||
<term><varname>PIPELINE_COMMAND_COUNT</varname></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The number of commands generated by <literal>\bind</literal>,
|
||||
<literal>\bind_named</literal>, <literal>\close</literal> or
|
||||
<literal>\parse</literal> queued in an ongoing pipeline.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="app-psql-variables-pipeline-result-count">
|
||||
<term><varname>PIPELINE_RESULT_COUNT</varname></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The number of commands of an ongoing pipeline that were followed
|
||||
by either a <command>\flushrequest</command> or a
|
||||
<command>\syncpipeline</command>, forcing the server to send the
|
||||
results. These results can be retrieved with
|
||||
<command>\getresults</command>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="app-psql-variables-pipeline-sync-count">
|
||||
<term><varname>PIPELINE_SYNC_COUNT</varname></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The number of sync messages queued in an ongoing pipeline.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="app-psql-variables-port">
|
||||
<term><varname>PORT</varname></term>
|
||||
<listitem>
|
||||
@ -4901,6 +4940,17 @@ testdb=> <userinput>INSERT INTO my_table VALUES (:'content');</userinput>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="app-psql-prompting-p-uc">
|
||||
<term><literal>%P</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Pipeline status: <literal>off</literal> when not in a pipeline,
|
||||
<literal>on</literal> when in an ongoing pipeline or
|
||||
<literal>abort</literal> when in an aborted pipeline.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="app-psql-prompting-r">
|
||||
<term><literal>%R</literal></term>
|
||||
<listitem>
|
||||
|
Reference in New Issue
Block a user