From f70a78bc1f5556546d809a8164b9ba6a907f266f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 13 Mar 2014 13:49:03 -0400 Subject: Allow psql to print COPY command status in more cases. Previously, psql would print the "COPY nnn" command status only for COPY commands executed server-side. Now it will print that for frontend copies too (including \copy). However, we continue to suppress the command status for COPY TO STDOUT, since in that case the copy data has been routed to the same place that the command status would go, and there is a risk of the status line being mistaken for another line of COPY data. Doing that would break existing scripts, and it doesn't seem worth the benefit --- this case seems fairly analogous to SELECT, for which we also suppress the command status. Kumar Rajeev Rastogi, with substantial review by Amit Khandekar --- doc/src/sgml/ref/copy.sgml | 10 ++++++++++ doc/src/sgml/ref/psql-ref.sgml | 38 +++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 19 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/copy.sgml b/doc/src/sgml/ref/copy.sgml index 5be3514612e..0544c68bbc0 100644 --- a/doc/src/sgml/ref/copy.sgml +++ b/doc/src/sgml/ref/copy.sgml @@ -370,6 +370,16 @@ COPY count The count is the number of rows copied. + + + + psql will print this command tag only if the command + was not COPY ... TO STDOUT, or the + equivalent psql meta-command + \copy ... to stdout. This is to prevent confusing the + command tag with the data that was just printed. + + diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 8813be8f2a2..5dce06af26e 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -863,36 +863,36 @@ testdb=> When program is specified, command is - executed by psql and the data from + executed by psql and the data passed from or to command is routed between the server and the client. - This means that the execution privileges are those of + Again, the execution privileges are those of the local user, not the server, and no SQL superuser privileges are required. - \copy ... from stdin | to stdout - reads/writes based on the command input and output respectively. - All rows are read from the same source that issued the command, - continuing until \. is read or the stream - reaches EOF. Output is sent to the same place as - command output. To read/write from - psql's standard input or output, use - pstdin or pstdout. This option is useful + + For \copy ... from stdin, data rows are read from the same + source that issued the command, continuing until \. + is read or the stream reaches EOF. This option is useful for populating tables in-line within a SQL script file. + For \copy ... to stdout, output is sent to the same place + as psql command output, and + the COPY count command status is + not printed (since it might be confused with a data row). + To read/write psql's standard input or + output regardless of the current command source or \o + option, write from pstdin or to pstdout. - The syntax of the command is similar to that of the + The syntax of this command is similar to that of the SQL - command, and - option - must indicate one of the options of the - SQL command. - Note that, because of this, - special parsing rules apply to the \copy - command. In particular, the variable substitution rules and - backslash escapes do not apply. + command. All options other than the data source/destination are + as specified for . + Because of this, special parsing rules apply to the \copy + command. In particular, psql's variable substitution + rules and backslash escapes do not apply. -- cgit v1.2.3