Re: COPY FROM is not 8bit clean

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Darcy Buskermolen <darcy(at)ok-connect(dot)com>
Cc: Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp>, pgsql-bugs(at)postgresql(dot)org,pgsql-hackers(at)postgresql(dot)org
Subject: Re: COPY FROM is not 8bit clean
Date: 2002-02-26 18:05:37
Message-ID: 200202261805.g1QI5b817006@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-bugspgsql-hackers


Can someone explain why this fixes the problem. I thought it was safe
to assign a char to an int and do a compare. The compare I see is:

if (c == delimc)
break;

---------------------------------------------------------------------------

Darcy Buskermolen wrote:
> This patch solves the problem.
>
> At 09:16 PM 2/26/02 +0900, Tatsuo Ishii wrote:
> >> When useing COPY FROM 'file' DELIMITER '\254' copyfrom reads past the
> >> delimiter and ends up with parse errors when trying to do the insert
> >>
> >>
> >> What the ?? why dind' tthat go through with the body of the text.. *sigh*
> >> I'll resend in the AM..
> >
> >Good catch. It's definitely a bug in copy command. Please try
> >following patches (this is against 7.2).
> >
> >*** src/backend/commands/copy.c.orig Tue Feb 26 21:11:05 2002
> >--- src/backend/commands/copy.c Tue Feb 26 21:11:35 2002
> >***************
> >*** 1024,1030 ****
> > CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline,
> char *null_print)
> > {
> > int c;
> >! int delimc = delim[0];
> >
> > #ifdef MULTIBYTE
> > int mblen;
> >--- 1024,1030 ----
> > CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline,
> char *null_print)
> > {
> > int c;
> >! int delimc = (unsigned char)delim[0];
> >
> > #ifdef MULTIBYTE
> > int mblen;
> >
> >
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Clift 2002-02-26 18:09:32 Re: PostgreSQL 8.0 ??
Previous Message Bruce Momjian 2002-02-26 17:56:50 Re: quotes in SET grammar

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2002-02-26 23:33:27 Re: COPY FROM is not 8bit clean
Previous Message Tom Lane 2002-02-26 17:48:12 Re: COPY FROM is not 8bit clean