aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2025-03-19 13:34:59 +0900
committerMichael Paquier <michael@paquier.xyz>2025-03-19 13:34:59 +0900
commit2cce0fe440fb3f252a7be70a89298168009a2c15 (patch)
tree4f01524de2895168ad33749afe6d94d9c71d956f /doc/src
parent0b53c08677a6515786bde9d4471b42ef7289759e (diff)
downloadpostgresql-2cce0fe440fb3f252a7be70a89298168009a2c15.tar.gz
postgresql-2cce0fe440fb3f252a7be70a89298168009a2c15.zip
psql: Allow queries terminated by semicolons while in pipeline mode
Currently, the only way to pipe queries in an ongoing pipeline (in a \startpipeline block) is to leverage the meta-commands able to create extended queries such as \bind, \parse or \bind_named. While this is good enough for testing the backend with pipelines, it has been mentioned that it can also be very useful to allow queries terminated by semicolons to be appended to a pipeline. For example, it would be possible to migrate existing psql scripts to use pipelines by just adding a set of \startpipeline and \endpipeline meta-commands, making such scripts more efficient. Doing such a change is proving to be simple in psql: queries terminated by semicolons can be executed through PQsendQueryParams() without any parameters set when the pipeline mode is active, instead of PQsendQuery(), the default, like pgbench. \watch is still forbidden while in a pipeline, as it expects its results to be processed synchronously. The large portion of this commit consists in providing more test coverage, with mixes of extended queries appended in a pipeline by \bind and friends, and queries terminated by semicolons. This improvement has been suggested by Daniel Vérité. Author: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com> Discussion: https://postgr.es/m/d67b9c19-d009-4a50-8020-1a0ea92366a1@manitou-mail.org
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/ref/psql-ref.sgml27
1 files changed, 12 insertions, 15 deletions
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index cddf6e07531..f083dba49a9 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -3698,14 +3698,15 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
</para>
<para>
- Pipeline mode requires the use of the extended query protocol. All
- queries need to be sent using the meta-commands
- <literal>\bind</literal>, <literal>\bind_named</literal>,
- <literal>\close</literal> or <literal>\parse</literal>. While a
- pipeline is ongoing, <literal>\sendpipeline</literal> will append the
- current query buffer to the pipeline. Other meta-commands like
- <literal>\g</literal>, <literal>\gx</literal> or <literal>\gdesc</literal>
- are not allowed in pipeline mode.
+ All queries executed while a pipeline is ongoing use the extended
+ query protocol. Queries are appended to the pipeline when ending with
+ a semicolon. The meta-commands <literal>\bind</literal>,
+ <literal>\bind_named</literal>, <literal>\close</literal> or
+ <literal>\parse</literal> can be used in an ongoing pipeline. While
+ a pipeline is ongoing, <literal>\sendpipeline</literal> will append
+ the current query buffer to the pipeline. Other meta-commands like
+ <literal>\g</literal>, <literal>\gx</literal> or
+ <literal>\gdesc</literal> are not allowed in pipeline mode.
</para>
<para>
@@ -3723,10 +3724,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
If provided, only the first
<replaceable class="parameter">number_results</replaceable> pending
results will be read. If not provided or <literal>0</literal>, all
- pending results are read. The commands <literal>\bind</literal>,
- <literal>\bind_named</literal>, <literal>\close</literal>,
- <literal>\parse</literal> and <literal>\syncpipeline</literal>
- generate one result to get.
+ pending results are read.
</para>
<para>
@@ -3739,6 +3737,7 @@ testdb=&gt; <userinput>\setenv LESS -imx4F</userinput>
Example:
<programlisting>
\startpipeline
+SELECT * FROM pg_class;
SELECT 1 \bind \sendpipeline
\flushrequest
\getresults
@@ -4513,9 +4512,7 @@ bar
<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.
+ The number of commands queued in an ongoing pipeline.
</para>
</listitem>
</varlistentry>