Received: from maia.hub.org (unknown [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 5BEDB1337C2C for ; Mon, 9 May 2011 15:45:18 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 94060-08-2 for ; Mon, 9 May 2011 18:44:51 +0000 (UTC) Received: from mx2.hub.org (mx2.hub.org [200.46.204.254]) by mail.postgresql.org (Postfix) with ESMTP id 1C94F1337C01 for ; Mon, 9 May 2011 15:08:52 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mx2.hub.org (Postfix) with ESMTP id B982E3EAA87D for ; Mon, 9 May 2011 15:08:41 -0300 (ADT) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id p49I7P1L047245 for ; Mon, 9 May 2011 18:07:25 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p49I7P3F047244; Mon, 9 May 2011 18:07:25 GMT (envelope-from www) Date: Mon, 9 May 2011 18:07:25 GMT Message-Id: <201105091807.p49I7P3F047244@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6017: COPY from CSV file, WITH CSV HEADER fields order not respected From: "pedro mg" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201105/52 X-Sequence-Number: 30191 The following bug has been logged online: Bug reference: 6017 Logged by: pedro mg Email address: pedro@tquadrado.com PostgreSQL version: 8.4.8 Operating system: Ubuntu Linux 10.10 Description: COPY from CSV file, WITH CSV HEADER fields order not respected Details: Documentation says HEADER is discarded for reads. When uploading millions of records from other legacy databases, would be an awesome addition to have Header fields order not discarded for reads. -Have a table: \d test1 key | integer | not null default nextval('teste1_key_seq'::regclass) c1 | character varying(10) | c2 | double precision | Indexes: "teste1_pkey" PRIMARY KEY, btree (key) - Have a CSV file, /tmp/test1.csv with an HEADER first line with the following order (note:different from the table): key,c2,c1 1,1,"Kg" 2,2,"g" 3,3,"mg" 4,4,"µg" 5,11,"l" 6,12,"ml" 7,13,"µl" - Issue a COPY command: # COPY test1 FROM '/tmp/test1.csv' WITH CSV HEADER - Returns: ERROR: invalid input syntax for type double precision: "Kg" CONTEXT: COPY teste1, line 2, column c2: "Kg"