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 1ihz3Z-0000e4-Qa for pgsql-docs@arkaria.postgresql.org; Thu, 19 Dec 2019 16:53:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ihz3Y-0001OZ-KQ for pgsql-docs@arkaria.postgresql.org; Thu, 19 Dec 2019 16:53:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ihz3Y-0001OP-9G for pgsql-docs@lists.postgresql.org; Thu, 19 Dec 2019 16:53:44 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ihz3V-0004sd-MD for pgsql-docs@lists.postgresql.org; Thu, 19 Dec 2019 16:53:43 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1ihz3U-0007sq-1F; Thu, 19 Dec 2019 11:53:40 -0500 Date: Thu, 19 Dec 2019 11:53:40 -0500 From: Bruce Momjian To: Pavlo Golub Cc: Laurenz Albe , pgsql-docs@lists.postgresql.org Subject: Re: COPY manual is ambiguous about column list Message-ID: <20191219165340.GP30116@momjian.us> References: <157487729344.7213.14245726713444755296@wrigleys.postgresql.org> <4f3e2f301646d94ad33558e21fc77d5bf1ea1cdd.camel@cybertec.at> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="pWyiEgJYm5f9v55/" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --pWyiEgJYm5f9v55/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Nov 28, 2019 at 02:53:03PM +0100, Pavlo Golub wrote: > On Thu, 28 Nov 2019 at 10:47, Laurenz Albe 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 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 + --pWyiEgJYm5f9v55/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="copy.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 { ta *** 63,71 **** 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. --- 63,72 ---- If a list of columns is specified, COPY will only copy the data in the specified columns to or from the file. ! In COPY FROM, the number of columns specified ! must match the number of fields in the file; any table columns not ! specified in the COPY FROM column list will insert ! their default values. --pWyiEgJYm5f9v55/--