diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2022-04-04 14:57:17 +0200 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2022-04-04 20:00:33 +0200 |
commit | 7844c9918a43b494adde3575891d217a37062378 (patch) | |
tree | 0f1d5a45abcaef3982545f68a53444bb5e059065 /doc/src | |
parent | cbf4177f2ca0b9bbfdb78a6ab51e3876e9ff6eac (diff) |
psql: Show all query results by default
Previously, psql printed only the last result if a command string
returned multiple result sets. Now it prints all of them. The
previous behavior can be obtained by setting the psql variable
SHOW_ALL_RESULTS to off.
This is a significantly enhanced version of
3a5130672296ed4e682403a77a9a3ad3d21cef75 (that was later reverted).
There is also much more test coverage for various psql features now.
Author: Fabien COELHO <coelho@cri.ensmp.fr>
Reviewed-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Reviewed-by: "Iwata, Aya" <iwata.aya@jp.fujitsu.com> (earlier version)
Reviewed-by: Daniel Verite <daniel@manitou-mail.org> (earlier version)
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com> (earlier version)
Reviewed-by: vignesh C <vignesh21@gmail.com> (earlier version)
Discussion: https://www.postgresql.org/message-id/flat/alpine.DEB.2.21.1904132231510.8961@lancre
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/ref/psql-ref.sgml | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index caabb06c537..f01adb1fd27 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -127,18 +127,11 @@ echo '\x \\ SELECT * FROM foo;' | psql commands included in the string to divide it into multiple transactions. (See <xref linkend="protocol-flow-multi-statement"/> for more details about how the server handles multi-query strings.) - Also, <application>psql</application> only prints the - result of the last <acronym>SQL</acronym> command in the string. - This is different from the behavior when the same string is read from - a file or fed to <application>psql</application>'s standard input, - because then <application>psql</application> sends - each <acronym>SQL</acronym> command separately. </para> <para> - Because of this behavior, putting more than one SQL command in a - single <option>-c</option> string often has unexpected results. - It's better to use repeated <option>-c</option> commands or feed - multiple commands to <application>psql</application>'s standard input, + If having several commands executed in one transaction is not desired, + use repeated <option>-c</option> commands or feed multiple commands to + <application>psql</application>'s standard input, either using <application>echo</application> as illustrated above, or via a shell here-document, for example: <programlisting> @@ -3570,10 +3563,6 @@ select 1\; select 2\; select 3; commands included in the string to divide it into multiple transactions. (See <xref linkend="protocol-flow-multi-statement"/> for more details about how the server handles multi-query strings.) - <application>psql</application> prints only the last query result - it receives for each request; in this example, although all - three <command>SELECT</command>s are indeed executed, <application>psql</application> - only prints the <literal>3</literal>. </para> </listitem> </varlistentry> @@ -4160,6 +4149,18 @@ bar </varlistentry> <varlistentry> + <term><varname>SHOW_ALL_RESULTS</varname></term> + <listitem> + <para> + When this variable is set to <literal>off</literal>, only the last + result of a combined query (<literal>\;</literal>) is shown instead of + all of them. The default is <literal>on</literal>. The off behavior + is for compatibility with older versions of psql. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><varname>SHOW_CONTEXT</varname></term> <listitem> <para> |