@@ -127,11 +127,18 @@ echo '\x \\ SELECT * FROM foo;' | psql
127
127
commands included in the string to divide it into multiple
128
128
transactions. (See <xref linkend="protocol-flow-multi-statement"/>
129
129
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.
130
136
</para>
131
137
<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,
135
142
either using <application>echo</application> as illustrated above, or
136
143
via a shell here-document, for example:
137
144
<programlisting>
@@ -3525,6 +3532,10 @@ select 1\; select 2\; select 3;
3525
3532
commands included in the string to divide it into multiple
3526
3533
transactions. (See <xref linkend="protocol-flow-multi-statement"/>
3527
3534
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>.
3528
3539
</para>
3529
3540
</listitem>
3530
3541
</varlistentry>
@@ -4111,18 +4122,6 @@ bar
4111
4122
</varlistentry>
4112
4123
4113
4124
<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>
4126
4125
<term><varname>SHOW_CONTEXT</varname></term>
4127
4126
<listitem>
4128
4127
<para>
0 commit comments