Skip to content

Commit

Permalink
Revert "psql: Show all query results by default"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
petere committed Apr 15, 2021
1 parent e2e2efc commit fae6562
Show file tree
Hide file tree
Showing 13 changed files with 299 additions and 603 deletions.
25 changes: 0 additions & 25 deletions contrib/pg_stat_statements/expected/pg_stat_statements.out
Expand Up @@ -50,28 +50,8 @@ BEGIN \;
SELECT 2.0 AS "float" \;
SELECT 'world' AS "text" \;
COMMIT;
float
-------
2.0
(1 row)

text
-------
world
(1 row)

-- compound with empty statements and spurious leading spacing
\;\; SELECT 3 + 3 \;\;\; SELECT ' ' || ' !' \;\; SELECT 1 + 4 \;;
?column?
----------
6
(1 row)

?column?
----------
!
(1 row)

?column?
----------
5
Expand All @@ -81,11 +61,6 @@ COMMIT;
SELECT 1 + 1 + 1 AS "add" \gset
SELECT :add + 1 + 1 AS "add" \;
SELECT :add + 1 + 1 AS "add" \gset
add
-----
5
(1 row)

-- set operator
SELECT 1 AS i UNION SELECT 2 ORDER BY i;
i
Expand Down
29 changes: 14 additions & 15 deletions doc/src/sgml/ref/psql-ref.sgml
Expand Up @@ -127,11 +127,18 @@ 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>
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,
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,
either using <application>echo</application> as illustrated above, or
via a shell here-document, for example:
<programlisting>
Expand Down Expand Up @@ -3525,6 +3532,10 @@ 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>
Expand Down Expand Up @@ -4111,18 +4122,6 @@ 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>
Expand Down

0 comments on commit fae6562

Please sign in to comment.