Nasty, propagating POLA violation in COPY CSV HEADER - Mailing list pgsql-hackers

From David Fetter
Subject Nasty, propagating POLA violation in COPY CSV HEADER
Date
Msg-id 20120620150254.GA11635@fetter.org
Whole thread Raw
Responses Re: Nasty, propagating POLA violation in COPY CSV HEADER  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Nasty, propagating POLA violation in COPY CSV HEADER  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
Folks,

A co-worker filed a bug against file_fdw where the columns in a
FOREIGN TABLE were scrambled on SELECT.  It turned out that this comes
from the (yes, it's documented, but since it's documented in a place
not obviously linked to the bug, it's pretty useless) "feature" of
COPY CSV HEADER whereby the header line is totally ignored in COPY
OUT.

Rather than being totally ignored in the COPY OUT (CSV HEADER) case,
the header line in should be parsed to establish which columns are
where and rearranging the output if needed.

I'm proposing to make the code change here:


http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/commands/copy.c;h=98bcb2fcf3370c72b0f0a7c0df76ebe4512e9ab0;hb=refs/heads/master#l2436

and a suitable doc change that talks about reading the header only for
the purpose of matching column names to columns, and throwing away the
output as before.

What say?

Cheers,
David.
-- 
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: sortsupport for text
Next
From: Alvaro Herrera
Date:
Subject: Re: libpq compression