public inbox for [email protected]  
help / color / mirror / Atom feed
From: David G. Johnston <[email protected]>
To: Tom Lane <[email protected]>
Cc: Bruce Momjian <[email protected]>
Cc: Pavlo Golub <[email protected]>
Cc: Laurenz Albe <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: COPY manual is ambiguous about column list
Date: Fri, 20 Dec 2019 07:29:33 -0700
Message-ID: <CAKFQuwa5RToC3+mbVGydTJZsqZhACK+F_CDtpcrCzxqwGXk6Cg@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>
	<CAMtUEpBmq3Mefkyh=RmkC4Fuqq+YtbUrr_nHnzxUwEbwm+CPfg@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<CAKFQuwaxE-m5VKQkOapv+3kMnP2Q9hEb0NbGeBfqkQuX3UmVgQ@mail.gmail.com>
	<[email protected]>
	<CAKFQuwYHOpSfBcyX33Avt3ncrDsu6pxb-LXTm0SA+-nGWVSbhQ@mail.gmail.com>
	<[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.


view thread (16+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: COPY manual is ambiguous about column list
  In-Reply-To: <CAKFQuwa5RToC3+mbVGydTJZsqZhACK+F_CDtpcrCzxqwGXk6Cg@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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