Re: COPY enhancements

From: Emmanuel Cecchet <manu(at)asterdata(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Josh Berkus <josh(at)agliodbs(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY enhancements
Date: 2009-09-11 13:16:19
Message-ID: 4AAA4DA3.4010006@asterdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Robert,

> I like this idea, perhaps not surprisingly (for those not following at
> home: that was my patch). Unfortunately, it looks to me like there is
> no way to do this without overhauling the syntax. If the existing
> syntax required a comma between options (i.e. "copy blah to stdout
> binary, oids" rather than "copy to stdout binary oids", this would be
> pretty straightforward; but it doesn't even allow one).
>
Well some options like CSV FORCE ... take a comma separated list of
columns. This would require all options to become reserved keywords or
force parenthesis around option parameters.
> I wonder if we should consider allowing COPY options to be
> comma-separated beginning with 8.5, and then require it in 8.6. Other
> options include continuing to support the old syntax for the existing
> options, but allowing some new syntax as well and requiring its use
> for all new options (this is what we did with EXPLAIN, but there were
> only two pre-existing options there), and just changing the syntax
> incompatibly and telling users to suck it up. But I'm not sure I like
> either of those choices.
>
We could keep the current syntax for backward compatibility only (can be
dropped in a future release) and have a new syntax (starting in 8.5). To
avoid confusion between both, we could just replace WITH with something
else (or just drop it) to indicate that this is the new syntax.

The new syntax could look like:

COPY /tablename/ [ ( /column/ [, ...] ) ]
FROM { '/filename/' | STDIN }
[ [, BINARY ]
[, OIDS ]
[, DELIMITER [ AS ] '/delimiter/' ]
[, NULL [ AS ] '/null string/' ]
[, CSV [ HEADER ]
[ QUOTE [ AS ] '/quote/' ]
[ ESCAPE [ AS ] '/escape/' ]
[ FORCE NOT NULL (/column/ [, ...]) ]
[, ERRORS { SKIP |
LOG INTO { tablename | 'filename' }
[ LABEL label_name ]
[ KEY key_name ]
[ MAX ERRORS /count/ ] } ]

Is this what you had in mind?

Emmanuel

--
Emmanuel Cecchet
Aster Data Systems
Web: http://www.asterdata.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2009-09-11 13:23:27 Re: RfD: more powerful "any" types
Previous Message Hannu Krosing 2009-09-11 12:57:22 Re: RfD: more powerful "any" types