Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4588e33

Browse files
committed
Suggest shell here-documents instead of psql -c for multiple commands.
The documentation suggested using "echo | psql", but not the often-superioralternative of a here-document. Also, be more direct about suggestingthat people avoid -c for multiple commands. Per discussion.
1 parent218dd20 commit4588e33

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ PostgreSQL documentation
9090
or a single backslash command. Thus you cannot mix
9191
<acronym>SQL</acronym> and <application>psql</application>
9292
meta-commands with this option. To achieve that, you could
93-
pipe the string into <application>psql</application>,like
94-
this:<literal>echo '\x \\ SELECT * FROM foo;' | psql</literal>.
93+
pipe the string into <application>psql</application>,for example:
94+
<literal>echo '\x \\ SELECT * FROM foo;' | psql</literal>.
9595
(<literal>\\</> is the separator meta-command.)
9696
</para>
9797
<para>
@@ -100,7 +100,21 @@ PostgreSQL documentation
100100
<command>BEGIN</>/<command>COMMIT</> commands included in the
101101
string to divide it into multiple transactions. This is
102102
different from the behavior when the same string is fed to
103-
<application>psql</application>'s standard input.
103+
<application>psql</application>'s standard input. Also, only
104+
the result of the last SQL command is returned.
105+
</para>
106+
<para>
107+
Because of these legacy behaviors, putting more than one command in
108+
the <option>-c</option> string often has unexpected results. It's
109+
better to feed multiple commands to <application>psql</application>'s
110+
standard input, either using <application>echo</application> as
111+
illustrated above, or via a shell here-document, for example:
112+
<programlisting>
113+
psql &lt;&lt;EOF
114+
\x
115+
SELECT * FROM foo;
116+
EOF
117+
</programlisting>
104118
</para>
105119
</listitem>
106120
</varlistentry>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp