Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 4DE111CF17EB for ; Tue, 13 Mar 2012 04:55:36 -0300 (ADT) Received: from sd-17937.dedibox.fr ([88.191.100.74]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S7MZv-0008IA-MZ for pgsql-bugs@postgresql.org; Tue, 13 Mar 2012 07:55:35 +0000 Received: from [192.168.10.3] (AMontsouris-552-1-64-187.w92-140.abo.wanadoo.fr [92.140.95.187]) by sd-17937.dedibox.fr (Postfix) with ESMTPA id EE3853B914; Tue, 13 Mar 2012 08:55:18 +0100 (CET) Message-ID: <1331625318.2293.7.camel@localhost.localdomain> Subject: Re: BUG #6527: Error in COPY documentation syntax From: Guillaume Lelarge To: samuel.gilbert@ec.gc.ca Cc: pgsql-bugs@postgresql.org Date: Tue, 13 Mar 2012 08:55:18 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3 (3.2.3-1.fc16) Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201203/99 X-Sequence-Number: 32660 On Mon, 2012-03-12 at 19:34 +0000, samuel.gilbert@ec.gc.ca wrote: > The following bug has been logged on the website: > > Bug reference: 6527 > Logged by: Samuel Gilbert > Email address: samuel.gilbert@ec.gc.ca > PostgreSQL version: 9.0.4 > Operating system: Linux > Description: > > There is an error in the syntax of the COPY statement in the documentation > for versions 9.0.x and 9.1.x. I tested on 9.0.4 and 9.1.3. > > According to the documentation, given the table exists and is compatible > with the CSV file, the following statement should work : > > COPY improve_station FROM '/local/improve.csv' FORMAT CSV HEADER TRUE; > No, it shouldn't work. You forgot parentheses, and commas. This should work: COPY improve_station FROM '/local/improve.csv' (FORMAT CSV, HEADER TRUE); > However, it doesn't work. Instead I get the following error : > > ERROR: syntax error at or near "FORMAT" > LINE 1: ...ns FROM '/local/improve.csv' FORMAT CSV... > ^ > > After trying a few trials and errors, I managed to find that ommiting FORMAT > gave me another error instead : > > COPY improve_stations FROM '/local/improve.csv' CSV HEADER TRUE; > ERROR: syntax error at or near "TRUE" > LINE 1: ...M '/local/improve.csv' CSV HEADER TRUE; > ^ > > Removing the boolean value (TRUE) actually works. This means that there are > at least two errors in the syntax specification in the documentation. > Instead of "FORMAT format_name", it should be "[ TEXT | CSV | BINARY ]" and > "HEADER [ boolean ]" should be "[ HEADER ]". > No error, and no bug. The documentation says (even if it's hard to see) that you need parentheses and commas. The examples show it too. -- Guillaume http://blog.guillaume.lelarge.info http://www.dalibo.com