Re: COPY formatting - Mailing list pgsql-hackers

From Karel Zak
Subject Re: COPY formatting
Date
Msg-id 20040319093900.GA16735@zf.jcu.cz
Whole thread Raw
In response to Re: COPY formatting  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: COPY formatting
Re: COPY formatting
List pgsql-hackers
On Thu, Mar 18, 2004 at 09:36:17AM -0500, Andrew Dunstan wrote:
> Lee Kindness wrote:
> 
> >To be honest this idea strikes me as overkill - over
> >engineering. While there is a clear need for proper CSV import
> >(i.e. just setting DELIMITER to ',' doesn't work due to ','s in
> >strings) I cannot see how this would prove useful, or who would use
> >it?
> >
> > 
> >
> I agree. My modest proposal for handling CSVs would be to extend the 
> DELIMITER parameter to allow up to 3 characters - separator, quote and 
> escape. Escape would default to the quote char and the quote char would 
> default to unspecified. This would involve no grammar changes and fairly 
> isolated and small code changes, I believe. In the most common CSV cases 
> you would just use $$,"$$ or $$,'$$. :-)
I look at backend COPY code and  it will better clean up this "party ofglobal static  values" before add  something to
this code. (My priviteopinion of course).
 
The problem with  CSV is that it will correctly  work with new protocolonly. Because old  versions of  clients are
newline sensitive. And CSVcan contains newline in by quotation marks defined attributes:
 
"John", "Smith", "The White House1600 Pennsylvania Avenue NWWashington, DC 20500", "male", "open source software
office"Itis one record.  It's difficult to say it :-), but your DELIMITER idea is better than mysuggested API. Andrew,
goahead. I thought about  some data streaming,but COPY is probably bad place for it.
 
   Karel

-- Karel Zak  <zakkr@zf.jcu.cz>http://home.zf.jcu.cz/~zakkr/


pgsql-hackers by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Authentication drop-down?
Next
From: Richard Huxton
Date:
Subject: Question on restoring and compiled plans