Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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
[ [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

Attachment: copy.diff
Description: text/plain (2.4 KB)


pgsql-patches by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group