Skip to content

Commit fae6562

Browse files
committed
Revert "psql: Show all query results by default"
This reverts commit 3a51306. Per discussion, this patch had too many issues to resolve at this point of the development cycle. We'll try again in the future. Discussion: https://www.postgresql.org/message-id/flat/alpine.DEB.2.21.1904132231510.8961@lancre
1 parent e2e2efc commit fae6562

File tree

13 files changed

+299
-603
lines changed

13 files changed

+299
-603
lines changed

contrib/pg_stat_statements/expected/pg_stat_statements.out

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,8 @@ BEGIN \;
5050
SELECT 2.0 AS "float" \;
5151
SELECT 'world' AS "text" \;
5252
COMMIT;
53-
float
54-
-------
55-
2.0
56-
(1 row)
57-
58-
text
59-
-------
60-
world
61-
(1 row)
62-
6353
-- compound with empty statements and spurious leading spacing
6454
\;\; SELECT 3 + 3 \;\;\; SELECT ' ' || ' !' \;\; SELECT 1 + 4 \;;
65-
?column?
66-
----------
67-
6
68-
(1 row)
69-
70-
?column?
71-
----------
72-
!
73-
(1 row)
74-
7555
?column?
7656
----------
7757
5
@@ -81,11 +61,6 @@ COMMIT;
8161
SELECT 1 + 1 + 1 AS "add" \gset
8262
SELECT :add + 1 + 1 AS "add" \;
8363
SELECT :add + 1 + 1 AS "add" \gset
84-
add
85-
-----
86-
5
87-
(1 row)
88-
8964
-- set operator
9065
SELECT 1 AS i UNION SELECT 2 ORDER BY i;
9166
i

doc/src/sgml/ref/psql-ref.sgml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,18 @@ echo '\x \\ SELECT * FROM foo;' | psql
127127
commands included in the string to divide it into multiple
128128
transactions. (See <xref linkend="protocol-flow-multi-statement"/>
129129
for more details about how the server handles multi-query strings.)
130+
Also, <application>psql</application> only prints the
131+
result of the last <acronym>SQL</acronym> command in the string.
132+
This is different from the behavior when the same string is read from
133+
a file or fed to <application>psql</application>'s standard input,
134+
because then <application>psql</application> sends
135+
each <acronym>SQL</acronym> command separately.
130136
</para>
131137
<para>
132-
If having several commands executed in one transaction is not desired,
133-
use repeated <option>-c</option> commands or feed multiple commands to
134-
<application>psql</application>'s standard input,
138+
Because of this behavior, putting more than one SQL command in a
139+
single <option>-c</option> string often has unexpected results.
140+
It's better to use repeated <option>-c</option> commands or feed
141+
multiple commands to <application>psql</application>'s standard input,
135142
either using <application>echo</application> as illustrated above, or
136143
via a shell here-document, for example:
137144
<programlisting>
@@ -3525,6 +3532,10 @@ select 1\; select 2\; select 3;
35253532
commands included in the string to divide it into multiple
35263533
transactions. (See <xref linkend="protocol-flow-multi-statement"/>
35273534
for more details about how the server handles multi-query strings.)
3535+
<application>psql</application> prints only the last query result
3536+
it receives for each request; in this example, although all
3537+
three <command>SELECT</command>s are indeed executed, <application>psql</application>
3538+
only prints the <literal>3</literal>.
35283539
</para>
35293540
</listitem>
35303541
</varlistentry>
@@ -4111,18 +4122,6 @@ bar
41114122
</varlistentry>
41124123

41134124
<varlistentry>
4114-
<term><varname>SHOW_ALL_RESULTS</varname></term>
4115-
<listitem>
4116-
<para>
4117-
When this variable is set to <literal>off</literal>, only the last
4118-
result of a combined query (<literal>\;</literal>) is shown instead of
4119-
all of them. The default is <literal>on</literal>. The off behavior
4120-
is for compatibility with older versions of psql.
4121-
</para>
4122-
</listitem>
4123-
</varlistentry>
4124-
4125-
<varlistentry>
41264125
<term><varname>SHOW_CONTEXT</varname></term>
41274126
<listitem>
41284127
<para>

0 commit comments

Comments
 (0)