COPY manual is ambiguous about column list - Mailing list pgsql-docs

From PG Doc comments form
Subject COPY manual is ambiguous about column list
Date
Msg-id 157487729344.7213.14245726713444755296@wrigleys.postgresql.org
Whole thread Raw
Responses Re: COPY manual is ambiguous about column list  (Laurenz Albe <laurenz.albe@cybertec.at>)
List pgsql-docs
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

pgsql-docs by date:

Previous
From: Jeff Janes
Date:
Subject: document effect of USAGE on foreign server to dblink
Next
From: Laurenz Albe
Date:
Subject: Re: COPY manual is ambiguous about column list