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

Commit1ea081b

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 parent02b61dd commit1ea081b

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
@@ -83,14 +83,15 @@ PostgreSQL documentation
8383
(<filename>psqlrc</filename> and <filename>~/.psqlrc</filename>) are
8484
ignored with this option.
8585
</para>
86-
<para><replaceable class="parameter">command</replaceable> must be either
86+
<para>
87+
<replaceable class="parameter">command</replaceable> must be either
8788
a command string that is completely parsable by the server (i.e.,
8889
it contains no <application>psql</application>-specific features),
8990
or a single backslash command. Thus you cannot mix
9091
<acronym>SQL</acronym> and <application>psql</application>
9192
meta-commands with this option. To achieve that, you could
92-
pipe the string into <application>psql</application>,like
93-
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>.
9495
(<literal>\\</> is the separator meta-command.)
9596
</para>
9697
<para>
@@ -102,6 +103,19 @@ PostgreSQL documentation
102103
<application>psql</application>'s standard input. Also, only
103104
the result of the last SQL command is returned.
104105
</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>
118+
</para>
105119
</listitem>
106120
</varlistentry>
107121

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp