On Sun, Jan 29, 2006 at 04:41:43PM -0800, David Fetter wrote:
> On Sun, Jan 29, 2006 at 09:50:08PM +0000, David Fetter wrote:
> >
> > The following bug has been logged online:
> >
> > Bug reference: 2221
> > Logged by: David Fetter
> > Email address: [EMAIL PROTECTED]
> > PostgreSQL version: all
> > Operating system: all
> > Description: Bad delimiters allowed in COPY ... TO
> > Details:
> >
> > This came up while I was testing my pg_dump "specify DELIMITER AS and/or
> > NULL AS" patch.
>
> Folks,
>
> Please pardon the self-followup. I believe that this patch fixes
> the problem in COPY.
Another followup, this time with the comment done right.
Cheers,
D
--
David Fetter [EMAIL PROTECTED] http://fetter.org/
phone: +1 415 235 3778
Remember to vote!
Index: src/backend/commands/copy.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/commands/copy.c,v
retrieving revision 1.257
diff -c -r1.257 copy.c
*** src/backend/commands/copy.c 28 Dec 2005 03:25:32 -0000 1.257
--- src/backend/commands/copy.c 30 Jan 2006 01:01:20 -0000
***************
*** 51,56 ****
--- 51,57 ----
#define ISOCTAL(c) (((c) >= '0') && ((c) <= '7'))
#define OCTVALUE(c) ((c) - '0')
+ #define BADCHARS "\r\n\\"
/*
* Represents the different source/dest cases we need to worry about at
***************
*** 856,861 ****
--- 857,867 ----
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("COPY delimiter must be a single
character")));
+ /* Disallow the forbidden_delimiter strings */
+ if (strcspn(cstate->delim, BADCHARS) != 1)
+ elog(ERROR, "COPY delimiter cannot be %#02x",
+ *cstate->delim);
+
/* Check header */
if (!cstate->csv_mode && cstate->header_line)
ereport(ERROR,
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq