On Sun, Jan 29, 2006 at 10:20:47PM -0500, Neil Conway wrote:
> On Sun, 2006-01-29 at 17:03 -0800, David Fetter wrote:
> > Another followup, this time with the comment done right.
>
> + /* Disallow the forbidden_delimiter strings */
> + if (strcspn(cstate->delim, BADCHARS) != 1)
> + elog(ERROR, "COPY delimiter cannot be %#02x",
> + *cstate->delim);
> +
>
> The comment is still wrong: referencing "forbidden_delimiter" makes
> it sound like there is something named forbidden_delimiter, but
> there is not (at least in the patch as submitted).
>
> The patch should also use ereport rather than elog, because this
> error message might reasonably be encountered by the user.
Patch with BADCHARS attached :)
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 06:44:10 -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,869 ----
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("COPY delimiter must be a single
character")));
+ /* Disallow BADCHARS characters */
+ if (strcspn(cstate->delim, BADCHARS) != 1)
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("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