On Fri, Jul 10, 2020 at 09:58:28AM +0530, vignesh C wrote: > Thanks for reviewing the patch. > This changes is already present in the document, no need to make any > changes as shown below: > > COPY table_name [ ( column_name [, ...] ) ] > FROM { 'filename' | PROGRAM 'command' | STDIN } > [ [ WITH ] ( option [, ...] ) ] > [ WHERE condition ]
Not completely actually. The page of psql for \copy does not mention the optional where clause, and I think that it would be better to add that for consistency (perhaps that's the point raised by Ahsan?). I don't see much point in splitting the description of the meta-command into two lines as we already mix stdin and stdout for example which only apply to respectively "FROM" and "TO", so let's just append the conditional where clause at its end. Attached is a patch doing so that I intend to back-patch down to v12. Coming back to your proposal, another thing is that with your patch you recommend a syntax still present for compatibility reasons, but I don't think that we should recommend it to the users anymore, giving priority to the new grammar of the post-9.0 era. I would actually go as far as removing BINARY from the completion when specified just after COPY to simplify the code, and specify the list of available options after typing "COPY ... WITH (FORMAT ", with "text", "csv" and "binary". Adding completion for WHERE after COPY FROM is of course a good idea. -- Michael
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 42e862cf17..d9a2920910 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -985,7 +985,8 @@ testdb=> <term><literal>\copy { <replaceable class="parameter">table</replaceable> [ ( <replaceable class="parameter">column_list</replaceable> ) ] | ( <replaceable class="parameter">query</replaceable> ) } { <literal>from</literal> | <literal>to</literal> } { <replaceable class="parameter">'filename'</replaceable> | program <replaceable class="parameter">'command'</replaceable> | stdin | stdout | pstdin | pstdout } - [ [ with ] ( <replaceable class="parameter">option</replaceable> [, ...] ) ]</literal></term> + [ [ with ] ( <replaceable class="parameter">option</replaceable> [, ...] ) ] + [ where <replaceable class="parameter">condition</replaceable> ]</literal></term> <listitem> <para>
signature.asc
Description: PGP signature