Patch to bring \copy syntax more in line with SQL copy

From: Bill Moran <wmoran(at)potentialtech(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: Patch to bring \copy syntax more in line with SQL copy
Date: 2004-01-18 05:22:34
Message-ID: 400A181A.4010304@potentialtech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

This patch brings the \copy syntax of psql more in line with the SQL copy
syntax as described in the reference manual, while maintaining backward
compatibility with what was there prior to the patch.

The change to the syntax is to the DELIMITER[S] portion.

The man page for psql refers the reader to the SQL copy command docs for
details of syntax. The SQL docs state that the syntax for COPY is
... [ DELIMITER [ AS ] 'delimiter' ] ...
(7.4 docs), while 7.2 docs
use the syntax:
... [ [USING] DELIMITERS 'delimiter' ]
Reading through the psql source code, it's obvious that at one time, the
syntax was
... [ WITH DELIMITER 'delimiter' ] ...

The patch results in the following syntax for the DELIMITER clause of
\copy:
[ [WITH|USING] DELIMITER[S] 'delimiter' ]

Ideally, this should cover all cases of old and new syntax, except where
"AS" is present. The only drawback I can see is that \copy is now more
liberal in what it accepts, and may accept incomplete statements
without issuing an error (i.e. a WITH or USING clause at the end of a
\copy statement will simply be ignored, and no error generated)

This patch is against version 1.36 of src/bin/psql/copy.c
The resulting psql binary (based off a cvsup from HEAD on 1/18) compiles
and works for me on FreeBSD 5.1.

--
Bill Moran
Potential Technologies
http://www.potentialtech.com

Attachment Content-Type Size
copy.diff text/plain 2.4 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Peter Eisentraut 2004-01-18 21:47:18 Re: [patch] Postgres 7.4 - doc INSTALL/Cygwin
Previous Message Jari Aalto 2004-01-17 11:37:48 [patch] INSTALL doc note (was Re: BUG #1051: Cannot remove groups)