Re: [PATCHES] WITH DELIMITERS in COPY - Mailing list pgsql-hackers

From Gavin Sherry
Subject Re: [PATCHES] WITH DELIMITERS in COPY
Date
Msg-id Pine.LNX.4.21.0204150132380.30483-101000@linuxworld.com.au
Whole thread Raw
In response to Re: [PATCHES] WITH DELIMITERS in COPY  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: [PATCHES] WITH DELIMITERS in COPY  (Peter Eisentraut <peter_e@gmx.net>)
Re: [PATCHES] WITH DELIMITERS in COPY  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-hackers
On Sun, 14 Apr 2002, Bruce Momjian wrote:

> 
> Gavin, I will do the legwork on this if you wish.  I think we need to

No matter. I intended to submit a patch to fix this.

> use DefElem to store the COPY params, rather than using specific fields
> in CopyStmt.

DefElem would have required modification of code outside the parser (to
keep utility.c and DoCopy() happy) or otherwise an even messier loop
executed as a result of CopyStmt than I have given in the attached patch, 
plus other issues with Yacc.

The patch attached maintains backward compatibility. The syntax is as
follows:

COPY [BINARY] <relname> [WITH OIDS] FROM/TO             [USING DELIMITERS <delimiter>]             [WITH [ DELIMITER
<delimiter>| NULL AS <char> | OIDS ]]
 

I was also going to allow BINARY in the WITH list, but there seems to be
little point.

Note that if you execute a query such as:

COPY pg_class TO '/some/path/file/out'USING DELIMITERS <tab>WITH DELIMITER '|';

The code will give preference to WITH DELIMITER.

If no one can find fault with this or my implementation, I'll follow up
with documentation and psql patches (not sure that there is much point
patching pg_dump).

Gavin

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [BUGS] Bug #633: CASE statement evaluation does not short-circut
Next
From: Peter Eisentraut
Date:
Subject: Re: [PATCHES] WITH DELIMITERS in COPY