public inbox for [email protected]
help / color / mirror / Atom feedCOPY manual is ambiguous about column list
16+ messages / 6 participants
[nested] [flat]
* COPY manual is ambiguous about column list
@ 2019-11-27 17:54 PG Doc comments form <[email protected]>
2019-11-28 09:47 ` Re: COPY manual is ambiguous about column list Laurenz Albe <[email protected]>
0 siblings, 1 reply; 16+ messages in thread
From: PG Doc comments form @ 2019-11-27 17: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/12/sql-copy.html
Description:
"If a list of columns is specified, COPY will only copy the data in the
specified columns to or from the file. If there are any columns in the table
that are not in the column list, COPY FROM will insert the default values
for those columns."
I clearly see "to or from" file here. But if one tries to COPY FROM filename
with more columns than list specified, the process fails:
```
pasha@PG480 MINGW64 ~
$ echo "col1,col2,col3" > test.csv
pasha@PG480 MINGW64 ~
$ cat test.csv
col1,col2,col3
pasha@PG480 MINGW64 ~
$ psql -d migrator
migrator=# CREATE TABLE copy_test(col1 text, col2 text);
CREATE TABLE
migrator=# COPY copy_test(col1, col2) FROM 'test.csv' (FORMAT csv);
ERROR: extra data after last expected column
CONTEXT: COPY copy_test, line 1: "col1,col2,col3"
```
I believe this statement should be rewritten, e.g.
"If a list of columns is specified, COPY will only copy the data in the
specified columns to the file. The input file should contain the same number
of columns as the list specified, otherwise COPY FROM will fail. One may use
`awk` to preprocess the input file and remove extra columns. If there are
any columns in the table that are not in the column list, COPY FROM will
insert the default values for those columns."
https://www.postgresql.org/docs/12/sql-copy.html
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: COPY manual is ambiguous about column list
2019-11-27 17:54 COPY manual is ambiguous about column list PG Doc comments form <[email protected]>
@ 2019-11-28 09:47 ` Laurenz Albe <[email protected]>
2019-11-28 13:53 ` Re: COPY manual is ambiguous about column list Pavlo Golub <[email protected]>
0 siblings, 1 reply; 16+ messages in thread
From: Laurenz Albe @ 2019-11-28 09:47 UTC (permalink / raw)
To: [email protected]; [email protected]
On Wed, 2019-11-27 at 17:54 +0000, PG Doc comments form wrote:
> "If a list of columns is specified, COPY will only copy the data in the
> specified columns to or from the file. If there are any columns in the table
> that are not in the column list, COPY FROM will insert the default values
> for those columns."
>
> I clearly see "to or from" file here. But if one tries to COPY FROM filename
> with more columns than list specified, the process fails:
I think you misunderstood the documentation.
Nowhere in that sentence is the documentation talking about columns in
the file, only columns in the table.
But if you got it wrong, maybe a clarification would be a good idea.
Yours,
Laurenz Albe
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: COPY manual is ambiguous about column list
2019-11-27 17:54 COPY manual is ambiguous about column list PG Doc comments form <[email protected]>
2019-11-28 09:47 ` Re: COPY manual is ambiguous about column list Laurenz Albe <[email protected]>
@ 2019-11-28 13:53 ` Pavlo Golub <[email protected]>
2019-12-19 16:53 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
0 siblings, 1 reply; 16+ messages in thread
From: Pavlo Golub @ 2019-11-28 13:53 UTC (permalink / raw)
To: Laurenz Albe <[email protected]>; +Cc: [email protected]
On Thu, 28 Nov 2019 at 10:47, Laurenz Albe <[email protected]> wrote:
>
> On Wed, 2019-11-27 at 17:54 +0000, PG Doc comments form wrote:
> > "If a list of columns is specified, COPY will only copy the data in the
> > specified columns to or from the file. If there are any columns in the table
> > that are not in the column list, COPY FROM will insert the default values
> > for those columns."
> >
> > I clearly see "to or from" file here. But if one tries to COPY FROM filename
> > with more columns than list specified, the process fails:
>
> I think you misunderstood the documentation.
Yeap, I did. Even two of us. Laetitia was helping me :)
>
> Nowhere in that sentence is the documentation talking about columns in
> the file, only columns in the table.
>
> But if you got it wrong, maybe a clarification would be a good idea.
I think it better to have more details to avoid confusion.
>
> Yours,
> Laurenz Albe
>
--
--
Hoc est vivere bis, vita posse priore frui.
Nullus est in vitae sensus, ipsa vera est sensus.
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: COPY manual is ambiguous about column list
2019-11-27 17:54 COPY manual is ambiguous about column list PG Doc comments form <[email protected]>
2019-11-28 09:47 ` Re: COPY manual is ambiguous about column list Laurenz Albe <[email protected]>
2019-11-28 13:53 ` Re: COPY manual is ambiguous about column list Pavlo Golub <[email protected]>
@ 2019-12-19 16:53 ` Bruce Momjian <[email protected]>
2019-12-19 16:56 ` Re: COPY manual is ambiguous about column list Pavlo Golub <[email protected]>
2019-12-20 04:46 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
0 siblings, 2 replies; 16+ messages in thread
From: Bruce Momjian @ 2019-12-19 16:53 UTC (permalink / raw)
To: Pavlo Golub <[email protected]>; +Cc: Laurenz Albe <[email protected]>; [email protected]
On Thu, Nov 28, 2019 at 02:53:03PM +0100, Pavlo Golub wrote:
> On Thu, 28 Nov 2019 at 10:47, Laurenz Albe <[email protected]> wrote:
> >
> > On Wed, 2019-11-27 at 17:54 +0000, PG Doc comments form wrote:
> > > "If a list of columns is specified, COPY will only copy the data in the
> > > specified columns to or from the file. If there are any columns in the table
> > > that are not in the column list, COPY FROM will insert the default values
> > > for those columns."
> > >
> > > I clearly see "to or from" file here. But if one tries to COPY FROM filename
> > > with more columns than list specified, the process fails:
> >
> > I think you misunderstood the documentation.
>
> Yeap, I did. Even two of us. Laetitia was helping me :)
>
> >
> > Nowhere in that sentence is the documentation talking about columns in
> > the file, only columns in the table.
> >
> > But if you got it wrong, maybe a clarification would be a good idea.
>
> I think it better to have more details to avoid confusion.
How is the attached patch?
--
Bruce Momjian <[email protected]> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
Attachments:
[text/x-diff] copy.diff (1.0K, 2-copy.diff)
download | inline diff:
diff --git a/doc/src/sgml/ref/copy.sgml b/doc/src/sgml/ref/copy.sgml
new file mode 100644
index d9b7c4d..475d40c
*** a/doc/src/sgml/ref/copy.sgml
--- b/doc/src/sgml/ref/copy.sgml
*************** COPY { <replaceable class="parameter">ta
*** 63,71 ****
<para>
If a list of columns is specified, <command>COPY</command> will
only copy the data in the specified columns to or from the file.
! If there are any columns in the table that are not in the column list,
! <command>COPY FROM</command> will insert the default values for
! those columns.
</para>
<para>
--- 63,72 ----
<para>
If a list of columns is specified, <command>COPY</command> will
only copy the data in the specified columns to or from the file.
! In <command>COPY FROM</command>, the number of columns specified
! must match the number of fields in the file; any table columns not
! specified in the <command>COPY FROM</command> column list will insert
! their default values.
</para>
<para>
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: COPY manual is ambiguous about column list
2019-11-27 17:54 COPY manual is ambiguous about column list PG Doc comments form <[email protected]>
2019-11-28 09:47 ` Re: COPY manual is ambiguous about column list Laurenz Albe <[email protected]>
2019-11-28 13:53 ` Re: COPY manual is ambiguous about column list Pavlo Golub <[email protected]>
2019-12-19 16:53 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
@ 2019-12-19 16:56 ` Pavlo Golub <[email protected]>
1 sibling, 0 replies; 16+ messages in thread
From: Pavlo Golub @ 2019-12-19 16:56 UTC (permalink / raw)
To: Bruce Momjian <[email protected]>; +Cc: Laurenz Albe <[email protected]>; [email protected]
On Thu, 19 Dec 2019 at 17:53, Bruce Momjian <[email protected]> wrote:
>
> On Thu, Nov 28, 2019 at 02:53:03PM +0100, Pavlo Golub wrote:
> > On Thu, 28 Nov 2019 at 10:47, Laurenz Albe <[email protected]> wrote:
> > >
> > > On Wed, 2019-11-27 at 17:54 +0000, PG Doc comments form wrote:
> > > > "If a list of columns is specified, COPY will only copy the data in the
> > > > specified columns to or from the file. If there are any columns in the table
> > > > that are not in the column list, COPY FROM will insert the default values
> > > > for those columns."
> > > >
> > > > I clearly see "to or from" file here. But if one tries to COPY FROM filename
> > > > with more columns than list specified, the process fails:
> > >
> > > I think you misunderstood the documentation.
> >
> > Yeap, I did. Even two of us. Laetitia was helping me :)
> >
> > >
> > > Nowhere in that sentence is the documentation talking about columns in
> > > the file, only columns in the table.
> > >
> > > But if you got it wrong, maybe a clarification would be a good idea.
> >
> > I think it better to have more details to avoid confusion.
>
> How is the attached patch?
Sounds great to me! Thanks!
>
> --
> Bruce Momjian <[email protected]> http://momjian.us
> EnterpriseDB http://enterprisedb.com
>
> + As you are, so once was I. As I am, so you will be. +
> + Ancient Roman grave inscription +
--
--
Hoc est vivere bis, vita posse priore frui.
Nullus est in vitae sensus, ipsa vera est sensus.
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: COPY manual is ambiguous about column list
2019-11-27 17:54 COPY manual is ambiguous about column list PG Doc comments form <[email protected]>
2019-11-28 09:47 ` Re: COPY manual is ambiguous about column list Laurenz Albe <[email protected]>
2019-11-28 13:53 ` Re: COPY manual is ambiguous about column list Pavlo Golub <[email protected]>
2019-12-19 16:53 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
@ 2019-12-20 04:46 ` Tom Lane <[email protected]>
2019-12-20 05:07 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
1 sibling, 1 reply; 16+ messages in thread
From: Tom Lane @ 2019-12-20 04:46 UTC (permalink / raw)
To: Bruce Momjian <[email protected]>; +Cc: Pavlo Golub <[email protected]>; Laurenz Albe <[email protected]>; [email protected]
Bruce Momjian <[email protected]> writes:
> How is the attached patch?
! In <command>COPY FROM</command>, the number of columns specified
! must match the number of fields in the file; any table columns not
! specified in the <command>COPY FROM</command> column list will insert
! their default values.
Phrasing seems a bit weird to me: you've run two nearly independent
observations into one sentence. But s/; any/. Any/ might be enough
to fix it.
regards, tom lane
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: COPY manual is ambiguous about column list
2019-11-27 17:54 COPY manual is ambiguous about column list PG Doc comments form <[email protected]>
2019-11-28 09:47 ` Re: COPY manual is ambiguous about column list Laurenz Albe <[email protected]>
2019-11-28 13:53 ` Re: COPY manual is ambiguous about column list Pavlo Golub <[email protected]>
2019-12-19 16:53 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
2019-12-20 04:46 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
@ 2019-12-20 05:07 ` David G. Johnston <[email protected]>
2019-12-20 05:32 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
0 siblings, 1 reply; 16+ messages in thread
From: David G. Johnston @ 2019-12-20 05:07 UTC (permalink / raw)
To: Tom Lane <[email protected]>; +Cc: Bruce Momjian <[email protected]>; Pavlo Golub <[email protected]>; Laurenz Albe <[email protected]>; [email protected]
On Thu, Dec 19, 2019 at 9:46 PM Tom Lane <[email protected]> wrote:
> Bruce Momjian <[email protected]> writes:
> > How is the attached patch?
>
> ! In <command>COPY FROM</command>, the number of columns specified
> ! must match the number of fields in the file; any table columns not
> ! specified in the <command>COPY FROM</command> column list will insert
> ! their default values.
>
> Phrasing seems a bit weird to me: you've run two nearly independent
> observations into one sentence. But s/; any/. Any/ might be enough
> to fix it.
>
Seems better to simply talk about each form independently:
If a list of columns is specified, <command>COPY TO</command> will only
copy the data in the specified columns to the file. <command>COPY
FROM</command> will, by position (i.e., the number of columns listed must
match the number of columns in the file), match each file column to the
named column in the table. Any additional columns present in the table
will receive their default value.
David J.
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: COPY manual is ambiguous about column list
2019-11-27 17:54 COPY manual is ambiguous about column list PG Doc comments form <[email protected]>
2019-11-28 09:47 ` Re: COPY manual is ambiguous about column list Laurenz Albe <[email protected]>
2019-11-28 13:53 ` Re: COPY manual is ambiguous about column list Pavlo Golub <[email protected]>
2019-12-19 16:53 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
2019-12-20 04:46 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 05:07 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
@ 2019-12-20 05:32 ` Tom Lane <[email protected]>
2019-12-20 05:33 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
0 siblings, 1 reply; 16+ messages in thread
From: Tom Lane @ 2019-12-20 05:32 UTC (permalink / raw)
To: David G. Johnston <[email protected]>; +Cc: Bruce Momjian <[email protected]>; Pavlo Golub <[email protected]>; Laurenz Albe <[email protected]>; [email protected]
"David G. Johnston" <[email protected]> writes:
> Seems better to simply talk about each form independently:
> If a list of columns is specified, <command>COPY TO</command> will only
> copy the data in the specified columns to the file. <command>COPY
> FROM</command> will, by position (i.e., the number of columns listed must
> match the number of columns in the file), match each file column to the
> named column in the table. Any additional columns present in the table
> will receive their default value.
+1 for separating it like that, but your middle sentence reads awkwardly
to me. How about something like
<command>COPY FROM</command> will match each listed column in the table
to a file column by position (so the number of columns listed must match
the number of columns in the file).
regards, tom lane
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: COPY manual is ambiguous about column list
2019-11-27 17:54 COPY manual is ambiguous about column list PG Doc comments form <[email protected]>
2019-11-28 09:47 ` Re: COPY manual is ambiguous about column list Laurenz Albe <[email protected]>
2019-11-28 13:53 ` Re: COPY manual is ambiguous about column list Pavlo Golub <[email protected]>
2019-12-19 16:53 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
2019-12-20 04:46 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 05:07 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
2019-12-20 05:32 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
@ 2019-12-20 05:33 ` David G. Johnston <[email protected]>
2019-12-20 13:45 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
0 siblings, 1 reply; 16+ messages in thread
From: David G. Johnston @ 2019-12-20 05:33 UTC (permalink / raw)
To: Tom Lane <[email protected]>; +Cc: Bruce Momjian <[email protected]>; Pavlo Golub <[email protected]>; Laurenz Albe <[email protected]>; [email protected] <[email protected]>
On Thursday, December 19, 2019, Tom Lane <[email protected]> wrote:
> "David G. Johnston" <[email protected]> writes:
> > Seems better to simply talk about each form independently:
>
> > If a list of columns is specified, <command>COPY TO</command> will only
> > copy the data in the specified columns to the file. <command>COPY
> > FROM</command> will, by position (i.e., the number of columns listed must
> > match the number of columns in the file), match each file column to the
> > named column in the table. Any additional columns present in the table
> > will receive their default value.
>
> +1 for separating it like that, but your middle sentence reads awkwardly
> to me. How about something like
>
> <command>COPY FROM</command> will match each listed column in the table
> to a file column by position (so the number of columns listed must match
> the number of columns in the file).
>
>
>
+1
David J.
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: COPY manual is ambiguous about column list
2019-11-27 17:54 COPY manual is ambiguous about column list PG Doc comments form <[email protected]>
2019-11-28 09:47 ` Re: COPY manual is ambiguous about column list Laurenz Albe <[email protected]>
2019-11-28 13:53 ` Re: COPY manual is ambiguous about column list Pavlo Golub <[email protected]>
2019-12-19 16:53 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
2019-12-20 04:46 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 05:07 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
2019-12-20 05:32 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 05:33 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
@ 2019-12-20 13:45 ` Bruce Momjian <[email protected]>
2019-12-20 14:13 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
0 siblings, 1 reply; 16+ messages in thread
From: Bruce Momjian @ 2019-12-20 13:45 UTC (permalink / raw)
To: David G. Johnston <[email protected]>; +Cc: Tom Lane <[email protected]>; Pavlo Golub <[email protected]>; Laurenz Albe <[email protected]>; [email protected] <[email protected]>
On Thu, Dec 19, 2019 at 10:33:48PM -0700, David G. Johnston wrote:
> On Thursday, December 19, 2019, Tom Lane <[email protected]> wrote:
>
> "David G. Johnston" <[email protected]> writes:
> > Seems better to simply talk about each form independently:
>
> > If a list of columns is specified, <command>COPY TO</command> will only
> > copy the data in the specified columns to the file. <command>COPY
> > FROM</command> will, by position (i.e., the number of columns listed must
> > match the number of columns in the file), match each file column to the
> > named column in the table. Any additional columns present in the table
> > will receive their default value.
>
> +1 for separating it like that, but your middle sentence reads awkwardly
> to me. How about something like
>
> <command>COPY FROM</command> will match each listed column in the table
> to a file column by position (so the number of columns listed must match
> the number of columns in the file).
>
>
>
>
> +1
OK, how is this?
--
Bruce Momjian <[email protected]> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
Attachments:
[text/x-diff] copy.diff (1.0K, 2-copy.diff)
download | inline diff:
diff --git a/doc/src/sgml/ref/copy.sgml b/doc/src/sgml/ref/copy.sgml
new file mode 100644
index d9b7c4d..cf19706
*** a/doc/src/sgml/ref/copy.sgml
--- b/doc/src/sgml/ref/copy.sgml
*************** COPY { <replaceable class="parameter">ta
*** 61,71 ****
</para>
<para>
! If a list of columns is specified, <command>COPY</command> will
! only copy the data in the specified columns to or from the file.
! If there are any columns in the table that are not in the column list,
! <command>COPY FROM</command> will insert the default values for
! those columns.
</para>
<para>
--- 61,72 ----
</para>
<para>
! If a column list is specified, <command>COPY TO</command> copies only
! the data in the specified columns to the file. If a column list is
! specified in <command>COPY FROM</command>, the number and position of
! the columns must match those fields in the file. Table columns not
! specified in the <command>COPY FROM</command> column list will insert
! their default values.
</para>
<para>
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: COPY manual is ambiguous about column list
2019-11-27 17:54 COPY manual is ambiguous about column list PG Doc comments form <[email protected]>
2019-11-28 09:47 ` Re: COPY manual is ambiguous about column list Laurenz Albe <[email protected]>
2019-11-28 13:53 ` Re: COPY manual is ambiguous about column list Pavlo Golub <[email protected]>
2019-12-19 16:53 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
2019-12-20 04:46 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 05:07 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
2019-12-20 05:32 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 05:33 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
2019-12-20 13:45 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
@ 2019-12-20 14:13 ` Tom Lane <[email protected]>
2019-12-20 14:29 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
0 siblings, 1 reply; 16+ messages in thread
From: Tom Lane @ 2019-12-20 14:13 UTC (permalink / raw)
To: Bruce Momjian <[email protected]>; +Cc: David G. Johnston <[email protected]>; Pavlo Golub <[email protected]>; Laurenz Albe <[email protected]>; [email protected] <[email protected]>
Bruce Momjian <[email protected]> writes:
> OK, how is this?
I do not like the phrasing of
If a column list is
specified in <command>COPY FROM</command>, the number and position of
the columns must match those fields in the file.
I'm not quite sure why, but that reads to me as implying that the COPY
will identify columns of the file by name and match them up. Or at
least it could be read that way by somebody who was predisposed to
believe it. I'd go with something more like
If a column list is
specified in <command>COPY FROM</command>, only the listed columns
are read from the file (whose fields must match the column list).
regards, tom lane
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: COPY manual is ambiguous about column list
2019-11-27 17:54 COPY manual is ambiguous about column list PG Doc comments form <[email protected]>
2019-11-28 09:47 ` Re: COPY manual is ambiguous about column list Laurenz Albe <[email protected]>
2019-11-28 13:53 ` Re: COPY manual is ambiguous about column list Pavlo Golub <[email protected]>
2019-12-19 16:53 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
2019-12-20 04:46 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 05:07 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
2019-12-20 05:32 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 05:33 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
2019-12-20 13:45 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
2019-12-20 14:13 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
@ 2019-12-20 14:29 ` David G. Johnston <[email protected]>
2019-12-20 15:01 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
0 siblings, 1 reply; 16+ messages in thread
From: David G. Johnston @ 2019-12-20 14:29 UTC (permalink / raw)
To: Tom Lane <[email protected]>; +Cc: Bruce Momjian <[email protected]>; Pavlo Golub <[email protected]>; Laurenz Albe <[email protected]>; [email protected] <[email protected]>
On Fri, Dec 20, 2019 at 7:13 AM Tom Lane <[email protected]> wrote:
> Bruce Momjian <[email protected]> writes:
> > OK, how is this?
>
> I do not like the phrasing of
>
> If a column list is
> specified in <command>COPY FROM</command>, the number and position of
> the columns must match those fields in the file.
>
> I'm not quite sure why, but that reads to me as implying that the COPY
> will identify columns of the file by name and match them up. Or at
> least it could be read that way by somebody who was predisposed to
> believe it. I'd go with something more like
>
> If a column list is
> specified in <command>COPY FROM</command>, only the listed columns
> are read from the file (whose fields must match the column list).
>
This has the same "match by name" possibility when I read it...
I don't see the benefit of repeating "If a column list is specified" a
second time in the three sentence paragraph. To a lesser extent the same
goes for the second repetition of COPY FROM.
I agree with the general goal of trying to get rid of the parenthetical; to
that end:
<command>COPY FROM</command> will match all listed columns in the table to
*all* file columns by position.
That sufficiently implies the "must have equal numbers" and, frankly, if
someone gets that part wrong the immediate failure combined with re-reading
the word "all" should provide sufficient clarity.
So I'm still for Tom and mine combined proposal with cleaning up the middle
sentence even more.
The other point of note is the difference between:
will receive their default value
and
will insert the default values
The system is inserting default values but the columns are receiving them.
The sentence is relative to the table columns though so "receive" seems
like the better fit. Minor point overall though.
David J.
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: COPY manual is ambiguous about column list
2019-11-27 17:54 COPY manual is ambiguous about column list PG Doc comments form <[email protected]>
2019-11-28 09:47 ` Re: COPY manual is ambiguous about column list Laurenz Albe <[email protected]>
2019-11-28 13:53 ` Re: COPY manual is ambiguous about column list Pavlo Golub <[email protected]>
2019-12-19 16:53 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
2019-12-20 04:46 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 05:07 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
2019-12-20 05:32 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 05:33 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
2019-12-20 13:45 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
2019-12-20 14:13 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 14:29 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
@ 2019-12-20 15:01 ` Bruce Momjian <[email protected]>
2019-12-20 16:21 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
0 siblings, 1 reply; 16+ messages in thread
From: Bruce Momjian @ 2019-12-20 15:01 UTC (permalink / raw)
To: David G. Johnston <[email protected]>; +Cc: Tom Lane <[email protected]>; Pavlo Golub <[email protected]>; Laurenz Albe <[email protected]>; [email protected] <[email protected]>
On Fri, Dec 20, 2019 at 07:29:33AM -0700, David G. Johnston wrote:
> This has the same "match by name" possibility when I read it...
>
> I don't see the benefit of repeating "If a column list is specified" a second
> time in the three sentence paragraph. To a lesser extent the same goes for the
> second repetition of COPY FROM.
>
> I agree with the general goal of trying to get rid of the parenthetical; to
> that end:
> <command>COPY FROM</command> will match all listed columns in the table to
> *all* file columns by position.
>
> That sufficiently implies the "must have equal numbers" and, frankly, if
> someone gets that part wrong the immediate failure combined with re-reading the
> word "all" should provide sufficient clarity.
>
> So I'm still for Tom and mine combined proposal with cleaning up the middle
> sentence even more.
>
> The other point of note is the difference between:
>
> will receive their default value
> and
> will insert the default values
>
> The system is inserting default values but the columns are receiving them. The
> sentence is relative to the table columns though so "receive" seems like the
> better fit. Minor point overall though.
OK, this wording is obviously harder than I thought. Updated patch
attached.
--
Bruce Momjian <[email protected]> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
Attachments:
[text/x-diff] copy.diff (1.0K, 2-copy.diff)
download | inline diff:
diff --git a/doc/src/sgml/ref/copy.sgml b/doc/src/sgml/ref/copy.sgml
new file mode 100644
index d9b7c4d..a99f815
*** a/doc/src/sgml/ref/copy.sgml
--- b/doc/src/sgml/ref/copy.sgml
*************** COPY { <replaceable class="parameter">ta
*** 61,71 ****
</para>
<para>
! If a list of columns is specified, <command>COPY</command> will
! only copy the data in the specified columns to or from the file.
! If there are any columns in the table that are not in the column list,
! <command>COPY FROM</command> will insert the default values for
! those columns.
</para>
<para>
--- 61,71 ----
</para>
<para>
! If a column list is specified, <command>COPY TO</command> copies only
! the data in the specified columns to the file. For <command>COPY
! FROM</command>, each field in the file is inserted, in order, into the
! specified column. Table columns not specified in the <command>COPY
! FROM</command> column list will receive their default values.
</para>
<para>
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: COPY manual is ambiguous about column list
2019-11-27 17:54 COPY manual is ambiguous about column list PG Doc comments form <[email protected]>
2019-11-28 09:47 ` Re: COPY manual is ambiguous about column list Laurenz Albe <[email protected]>
2019-11-28 13:53 ` Re: COPY manual is ambiguous about column list Pavlo Golub <[email protected]>
2019-12-19 16:53 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
2019-12-20 04:46 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 05:07 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
2019-12-20 05:32 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 05:33 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
2019-12-20 13:45 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
2019-12-20 14:13 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 14:29 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
2019-12-20 15:01 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
@ 2019-12-20 16:21 ` Tom Lane <[email protected]>
2019-12-20 16:45 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
0 siblings, 1 reply; 16+ messages in thread
From: Tom Lane @ 2019-12-20 16:21 UTC (permalink / raw)
To: Bruce Momjian <[email protected]>; +Cc: David G. Johnston <[email protected]>; Pavlo Golub <[email protected]>; Laurenz Albe <[email protected]>; [email protected] <[email protected]>
Bruce Momjian <[email protected]> writes:
> OK, this wording is obviously harder than I thought. Updated patch
> attached.
That one works for me.
regards, tom lane
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: COPY manual is ambiguous about column list
2019-11-27 17:54 COPY manual is ambiguous about column list PG Doc comments form <[email protected]>
2019-11-28 09:47 ` Re: COPY manual is ambiguous about column list Laurenz Albe <[email protected]>
2019-11-28 13:53 ` Re: COPY manual is ambiguous about column list Pavlo Golub <[email protected]>
2019-12-19 16:53 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
2019-12-20 04:46 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 05:07 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
2019-12-20 05:32 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 05:33 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
2019-12-20 13:45 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
2019-12-20 14:13 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 14:29 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
2019-12-20 15:01 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
2019-12-20 16:21 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
@ 2019-12-20 16:45 ` David G. Johnston <[email protected]>
2019-12-21 17:45 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
0 siblings, 1 reply; 16+ messages in thread
From: David G. Johnston @ 2019-12-20 16:45 UTC (permalink / raw)
To: Tom Lane <[email protected]>; +Cc: Bruce Momjian <[email protected]>; Pavlo Golub <[email protected]>; Laurenz Albe <[email protected]>; [email protected] <[email protected]>
On Fri, Dec 20, 2019 at 9:21 AM Tom Lane <[email protected]> wrote:
> Bruce Momjian <[email protected]> writes:
> > OK, this wording is obviously harder than I thought. Updated patch
> > attached.
>
> That one works for me.
>
Me too.
David J.
^ permalink raw reply [nested|flat] 16+ messages in thread
* Re: COPY manual is ambiguous about column list
2019-11-27 17:54 COPY manual is ambiguous about column list PG Doc comments form <[email protected]>
2019-11-28 09:47 ` Re: COPY manual is ambiguous about column list Laurenz Albe <[email protected]>
2019-11-28 13:53 ` Re: COPY manual is ambiguous about column list Pavlo Golub <[email protected]>
2019-12-19 16:53 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
2019-12-20 04:46 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 05:07 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
2019-12-20 05:32 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 05:33 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
2019-12-20 13:45 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
2019-12-20 14:13 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 14:29 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
2019-12-20 15:01 ` Re: COPY manual is ambiguous about column list Bruce Momjian <[email protected]>
2019-12-20 16:21 ` Re: COPY manual is ambiguous about column list Tom Lane <[email protected]>
2019-12-20 16:45 ` Re: COPY manual is ambiguous about column list David G. Johnston <[email protected]>
@ 2019-12-21 17:45 ` Bruce Momjian <[email protected]>
0 siblings, 0 replies; 16+ messages in thread
From: Bruce Momjian @ 2019-12-21 17:45 UTC (permalink / raw)
To: David G. Johnston <[email protected]>; +Cc: Tom Lane <[email protected]>; Pavlo Golub <[email protected]>; Laurenz Albe <[email protected]>; [email protected] <[email protected]>
On Fri, Dec 20, 2019 at 09:45:35AM -0700, David G. Johnston wrote:
> On Fri, Dec 20, 2019 at 9:21 AM Tom Lane <[email protected]> wrote:
>
> Bruce Momjian <[email protected]> writes:
> > OK, this wording is obviously harder than I thought. Updated patch
> > attached.
>
> That one works for me.
>
>
> Me too.
Patch applied to all supported releases. Thanks for the feedback.
--
Bruce Momjian <[email protected]> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
^ permalink raw reply [nested|flat] 16+ messages in thread
end of thread, other threads:[~2019-12-21 17:45 UTC | newest]
Thread overview: 16+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-11-27 17:54 COPY manual is ambiguous about column list PG Doc comments form <[email protected]>
2019-11-28 09:47 ` Laurenz Albe <[email protected]>
2019-11-28 13:53 ` Pavlo Golub <[email protected]>
2019-12-19 16:53 ` Bruce Momjian <[email protected]>
2019-12-19 16:56 ` Pavlo Golub <[email protected]>
2019-12-20 04:46 ` Tom Lane <[email protected]>
2019-12-20 05:07 ` David G. Johnston <[email protected]>
2019-12-20 05:32 ` Tom Lane <[email protected]>
2019-12-20 05:33 ` David G. Johnston <[email protected]>
2019-12-20 13:45 ` Bruce Momjian <[email protected]>
2019-12-20 14:13 ` Tom Lane <[email protected]>
2019-12-20 14:29 ` David G. Johnston <[email protected]>
2019-12-20 15:01 ` Bruce Momjian <[email protected]>
2019-12-20 16:21 ` Tom Lane <[email protected]>
2019-12-20 16:45 ` David G. Johnston <[email protected]>
2019-12-21 17:45 ` Bruce Momjian <[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