dbTalk Databases Forums  

Re: [PATCHES] [BUGS] BUG #2221: Bad delimiters allowed in COPY ... TO

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss Re: [PATCHES] [BUGS] BUG #2221: Bad delimiters allowed in COPY ... TO in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David Fetter
 
Posts: n/a

Default Re: [PATCHES] [BUGS] BUG #2221: Bad delimiters allowed in COPY ... TO - 01-29-2006 , 07:03 PM






--S1BNGpv0yoYahz37
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Sun, Jan 29, 2006 at 04:41:43PM -0800, David Fetter wrote:
Quote:
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: david (AT) fetter (DOT) org
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 david (AT) fetter (DOT) org http://fetter.org/
phone: +1 415 235 3778

Remember to vote!

--S1BNGpv0yoYahz37
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="forbid_badchars_copy.diff"

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,

--S1BNGpv0yoYahz37
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

--S1BNGpv0yoYahz37--


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.