public inbox for [email protected]  
help / color / mirror / Atom feed
SQL Commands COPY
4+ messages / 4 participants
[nested] [flat]

* SQL Commands COPY
@ 2021-06-09 19:54 PG Doc comments form <[email protected]>
  2021-06-09 21:31 ` Re: SQL Commands COPY Laurenz Albe <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: PG Doc comments form @ 2021-06-09 19:54 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/13/sql-copy.html
Description:

The synopsis and parameters for the COPY command show the FORCE_QUOTE option
with an underscore and requires column names to be enclosed with round
brackets, but the example in the compatibility section shows the option name
as FORCE QUOTE (no underscore) and has no requirement to enclose the column
names with round brackets.

When using psql (version 13.3) against a version 13 cluster, the method
shown in the compatibility section works whereas the methods shown in the
synopsis and parameters sections do not work and will throw a syntax
error.

My usage is
COPY (query)
TO STDOUT
CSV HEADER
DELIMITER E'\t'
NULL ''
QUOTE '"'
FORCE QUOTE column_name [, ...]


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: SQL Commands COPY
  2021-06-09 19:54 SQL Commands COPY PG Doc comments form <[email protected]>
@ 2021-06-09 21:31 ` Laurenz Albe <[email protected]>
  2021-06-09 21:47   ` Re: SQL Commands COPY Tom Lane <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Laurenz Albe @ 2021-06-09 21:31 UTC (permalink / raw)
  To: [email protected]; [email protected]

On Wed, 2021-06-09 at 19:54 +0000, PG Doc comments form wrote:
> Page: https://www.postgresql.org/docs/13/sql-copy.html
> Description:
> 
> The synopsis and parameters for the COPY command show the FORCE_QUOTE option
> with an underscore and requires column names to be enclosed with round
> brackets, but the example in the compatibility section shows the option name
> as FORCE QUOTE (no underscore) and has no requirement to enclose the column
> names with round brackets.
> 
> When using psql (version 13.3) against a version 13 cluster, the method
> shown in the compatibility section works whereas the methods shown in the
> synopsis and parameters sections do not work and will throw a syntax
> error.

You must be misreading something, the new syntax works:

COPY (SELECT 42 AS x) TO STDOUT (FORMAT 'csv', FORCE_QUOTE (x));

Yours,
Laurenz Albe






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: SQL Commands COPY
  2021-06-09 19:54 SQL Commands COPY PG Doc comments form <[email protected]>
  2021-06-09 21:31 ` Re: SQL Commands COPY Laurenz Albe <[email protected]>
@ 2021-06-09 21:47   ` Tom Lane <[email protected]>
  2021-06-11 19:16     ` Re: SQL Commands COPY Neil Bower <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2021-06-09 21:47 UTC (permalink / raw)
  To: Laurenz Albe <[email protected]>; +Cc: [email protected]; [email protected]

Laurenz Albe <[email protected]> writes:
> On Wed, 2021-06-09 at 19:54 +0000, PG Doc comments form wrote:
>> When using psql (version 13.3) against a version 13 cluster, the method
>> shown in the compatibility section works whereas the methods shown in the
>> synopsis and parameters sections do not work and will throw a syntax
>> error.

> You must be misreading something, the new syntax works:
> COPY (SELECT 42 AS x) TO STDOUT (FORMAT 'csv', FORCE_QUOTE (x));

The most probable explanation seems to be that the OP is actually
connecting to an 8.4 (or older) PG server.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: SQL Commands COPY
  2021-06-09 19:54 SQL Commands COPY PG Doc comments form <[email protected]>
  2021-06-09 21:31 ` Re: SQL Commands COPY Laurenz Albe <[email protected]>
  2021-06-09 21:47   ` Re: SQL Commands COPY Tom Lane <[email protected]>
@ 2021-06-11 19:16     ` Neil Bower <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Neil Bower @ 2021-06-11 19:16 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: Laurenz Albe <[email protected]>; [email protected]

It was a picnic. I was confusing the 9+ version syntax with the pre-9
version syntax at the bottom of the page. Most of the options between the
two versions are the same and the pre-9 version still works with the newer
versions of PostgreSQL.

I was connecting to a version 13 server at the time. I've been using this
same syntax for several years and never noticed the one key difference
between the older and newer versions of the syntax of having to enclose the
options within round brackets until Laurenz's example.

Thanks!

On Wed, 9 Jun 2021 at 15:47, Tom Lane <[email protected]> wrote:

> Laurenz Albe <[email protected]> writes:
> > On Wed, 2021-06-09 at 19:54 +0000, PG Doc comments form wrote:
> >> When using psql (version 13.3) against a version 13 cluster, the method
> >> shown in the compatibility section works whereas the methods shown in
> the
> >> synopsis and parameters sections do not work and will throw a syntax
> >> error.
>
> > You must be misreading something, the new syntax works:
> > COPY (SELECT 42 AS x) TO STDOUT (FORMAT 'csv', FORCE_QUOTE (x));
>
> The most probable explanation seems to be that the OP is actually
> connecting to an 8.4 (or older) PG server.
>
>                         regards, tom lane
>


^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2021-06-11 19:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 19:54 SQL Commands COPY PG Doc comments form <[email protected]>
2021-06-09 21:31 ` Laurenz Albe <[email protected]>
2021-06-09 21:47   ` Tom Lane <[email protected]>
2021-06-11 19:16     ` Neil Bower <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox