Re: [PATCHES] WITH DELIMITERS in COPY

From: Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] WITH DELIMITERS in COPY
Date: 2002-04-14 17:34:06
Message-ID: Pine.LNX.4.21.0204150132380.30483-101000@linuxworld.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

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

Attachment Content-Type Size
copy2.diff.gz application/x-gzip 1.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-04-14 17:37:18 Re: 7.2 crash...
Previous Message Tom Lane 2002-04-14 17:30:00 Re: Bug #633: CASE statement evaluation does not short-circut

Browse pgsql-patches by date

  From Date Subject
Next Message Peter Eisentraut 2002-04-14 17:46:39 Re: [PATCHES] WITH DELIMITERS in COPY
Previous Message Bruce Momjian 2002-04-14 17:24:41 Re: JDBC PreparedStatement Memory Leak.