Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iiJI1-0002A2-2r for pgsql-docs@arkaria.postgresql.org; Fri, 20 Dec 2019 14:30:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iiJHz-00062x-NT for pgsql-docs@arkaria.postgresql.org; Fri, 20 Dec 2019 14:29:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iiJHz-00062q-DC for pgsql-docs@lists.postgresql.org; Fri, 20 Dec 2019 14:29:59 +0000 Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iiJHs-000128-G8 for pgsql-docs@lists.postgresql.org; Fri, 20 Dec 2019 14:29:58 +0000 Received: by mail-qt1-x82e.google.com with SMTP id q20so8344451qtp.3 for ; Fri, 20 Dec 2019 06:29:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dUX4QRJz+pMe3AaRanSoapkRe42+xJgoBrtxKiJNHNs=; b=RHRNJpYXnn9XaxLAJW4dOluOYj4gdFi+8LCNezz5L4wV7LGP5CDb1F1TiA/O7a5xjt dhWI34kTJXB5OiQp/cVuQht/8WYvKf08J5zlxoZyZEez4yd6Ilu2LuXDrr5BrKc8YHmp E2om+RtndoyVF1F0AO78H/qr36O6zaAXnjz0dX7iQ4eMozQviOUZesC7srRu4J8SDXVh LtuKHM8SwGxWdbe4htCq2KC2TL+DkDvIew6dDIT4MU2hIEevwCkfFMQVXOUuIbvw+L7s xX6qVqtBNULRS+/QYP44LW4F/yff55pZTEIzpvf4nxOzo05JUV+kCX1aG7EZ/PrAikBp MaJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dUX4QRJz+pMe3AaRanSoapkRe42+xJgoBrtxKiJNHNs=; b=fljPcvSmM09d8Wh31WqqMv/n3tHMTTeXhstFnVUJdBozVjzuTBDNYqyJz0/9Ri00ql Mq3xmzW3UPnKpAN9+Wwn6/G5cbaxY7jcIRJukmwbdXCtsak4YuCybf7sjnw6a9hz5nL0 Mx1Btt7Fw4Ksm8QQ3jtjMO6LzRHNijA8lIW3D6C9Z9E+N6hlQQ43dcZThJMArOAJu/H7 G2/WUWxJS9XcaXYJDNtjWifM0i+C77Dh64/J1/kcpnfBTA3si4GkeYJlGR3JmgIg1ZIK Ww8LhAQNTvCqWjYGiLcyxdnufdiLuIhnezuDLirzR80prE+21nEqu6zaurD/ujjNWgse 8dVg== X-Gm-Message-State: APjAAAU5kL6dWnZAOO9RE95oET4ncP1S3Cuvm2NBy0o7wUw9ugJIrv4p 4wLASMHI+h7PAdaD3DzCxCMkflvPOXsmNlJweUU= X-Google-Smtp-Source: APXvYqwOBo06SL+j7PzwsjHyqEWNsdh9NwyW3oJDeFGRrT6kZ5C38MjND0HytbAYEdXhI+xLcXsS7mLpIbDAbVir8u4= X-Received: by 2002:ac8:3364:: with SMTP id u33mr12015148qta.267.1576852190257; Fri, 20 Dec 2019 06:29:50 -0800 (PST) MIME-Version: 1.0 References: <157487729344.7213.14245726713444755296@wrigleys.postgresql.org> <4f3e2f301646d94ad33558e21fc77d5bf1ea1cdd.camel@cybertec.at> <20191219165340.GP30116@momjian.us> <12751.1576817197@sss.pgh.pa.us> <14696.1576819950@sss.pgh.pa.us> <20191220134541.GB29807@momjian.us> <3148.1576851213@sss.pgh.pa.us> In-Reply-To: <3148.1576851213@sss.pgh.pa.us> From: "David G. Johnston" Date: Fri, 20 Dec 2019 07:29:33 -0700 Message-ID: Subject: Re: COPY manual is ambiguous about column list To: Tom Lane Cc: Bruce Momjian , Pavlo Golub , Laurenz Albe , "pgsql-docs@lists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000a9e589059a2382c8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000a9e589059a2382c8 Content-Type: text/plain; charset="UTF-8" On Fri, Dec 20, 2019 at 7:13 AM Tom Lane wrote: > Bruce Momjian writes: > > OK, how is this? > > I do not like the phrasing of > > If a column list is > specified in COPY FROM, 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 COPY FROM, 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: COPY FROM 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. --000000000000a9e589059a2382c8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Dec 20, 2019 at 7:13 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Bruce Momjian <bruce@momjian.us> writes:
> OK, how is this?

I do not like the phrasing of

=C2=A0 =C2=A0 If a column list is
=C2=A0 =C2=A0 specified in <command>COPY FROM</command>, the nu= mber and position of
=C2=A0 =C2=A0 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<= br> will identify columns of the file by name and match them up.=C2=A0 Or at least it could be read that way by somebody who was predisposed to
believe it.=C2=A0 I'd go with something more like

=C2=A0 =C2=A0 If a column list is
=C2=A0 =C2=A0 specified in <command>COPY FROM</command>, only t= he listed columns
=C2=A0 =C2=A0 are read from the file (whose fields must match the column li= st).

This has the same "match by nam= e" 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.=C2=A0 To a lesser extent the same go= es for the second repetition=C2=A0of COPY FROM.

I agre= e with the general goal of trying to get rid of the parenthetical; to that = end:
<command>COPY FROM</command> will match a= ll listed columns in the table=C2=A0to *all* file columns by position.
<= /div>

That sufficiently implies the "must have equal nu= mbers" and, frankly, if someone gets that part wrong the immediate fai= lure combined with re-reading the word "all" should provide suffi= cient clarity.

So I'm still for Tom and mine combi= ned 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 val= ues but the columns are receiving them.=C2=A0 The sentence is relative to t= he table columns though so "receive" seems like the better fit.= =C2=A0 Minor point overall though.

David J.
<= br>
--000000000000a9e589059a2382c8--