From 3a5130672296ed4e682403a77a9a3ad3d21cef75 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 6 Apr 2021 16:58:10 +0200 Subject: 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. Author: Fabien COELHO Reviewed-by: "Iwata, Aya" Reviewed-by: Daniel Verite Reviewed-by: Peter Eisentraut Reviewed-by: Kyotaro Horiguchi Reviewed-by: vignesh C Discussion: https://www.postgresql.org/message-id/flat/alpine.DEB.2.21.1904132231510.8961@lancre --- doc/src/sgml/ref/psql-ref.sgml | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 0ba1e2d44d4..c1451c16727 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 for more details about how the server handles multi-query strings.) - Also, psql only prints the - result of the last SQL command in the string. - This is different from the behavior when the same string is read from - a file or fed to psql's standard input, - because then psql sends - each SQL command separately. - Because of this behavior, putting more than one SQL command in a - single string often has unexpected results. - It's better to use repeated commands or feed - multiple commands to psql's standard input, + If having several commands executed in one transaction is not desired, + use repeated commands or feed multiple commands to + psql's standard input, either using echo as illustrated above, or via a shell here-document, for example: @@ -3527,10 +3520,6 @@ select 1\; select 2\; select 3; commands included in the string to divide it into multiple transactions. (See for more details about how the server handles multi-query strings.) - psql prints only the last query result - it receives for each request; in this example, although all - three SELECTs are indeed executed, psql - only prints the 3. @@ -4117,6 +4106,18 @@ bar + SHOW_ALL_RESULTS + + + When this variable is set to off, only the last + result of a combined query (\;) is shown instead of + all of them. The default is on. The off behavior + is for compatibility with older versions of psql. + + + + + SHOW_CONTEXT -- cgit v1.2.3