Re: [HACKERS] fix for multi-byte partial truncating - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [HACKERS] fix for multi-byte partial truncating
Date
Msg-id 199809251551.LAA04441@candle.pha.pa.us
Whole thread Raw
In response to Re: [HACKERS] fix for multi-byte partial truncating  (Tatsuo Ishii <t-ishii@sra.co.jp>)
List pgsql-hackers
Applied.



> >Applied, but for some reason patch did not like the normal cvs/rcs diff
> >format.  Not sure why.  Please check to see it is OK.  Looks OK here.
>
> Thank you, Bruce. Everything seems OK too.
>
> But I found a mistake with my patches. bpchar does not pad blanks
> anymore! Could you apply following patches to
> backend/utils/adt/varchar.c? (the diff is against the current source
> tree)
>
> *** varchar.c.orig    Fri Sep 25 15:12:34 1998
> --- varchar.c    Fri Sep 25 17:59:47 1998
> ***************
> *** 147,160 ****
>       if ((len == -1) || (len == VARSIZE(s)))
>           return s;
>
> - #ifdef MULTIBYTE
> -     /* truncate multi-byte string in a way not to break
> -        multi-byte boundary */
> -     rlen = pg_mbcliplen(VARDATA(s), len - VARHDRSZ, len - VARHDRSZ);
> -     len = rlen + VARHDRSZ;
> - #else
>       rlen = len - VARHDRSZ;
> - #endif
>
>       if (rlen > 4096)
>           elog(ERROR, "bpchar: length of char() must be less than 4096");
> --- 147,153 ----
> ***************
> *** 167,173 ****
> --- 160,172 ----
>       result = (char *) palloc(len);
>       VARSIZE(result) = len;
>       r = VARDATA(result);
> + #ifdef MULTIBYTE
> +     /* truncate multi-byte string in a way not to break
> +        multi-byte boundary */
> +     slen = pg_mbcliplen(VARDATA(s), rlen, rlen);
> + #else
>       slen = VARSIZE(s) - VARHDRSZ;
> + #endif
>       s = VARDATA(s);
>
>   #ifdef STRINGDEBUG
>


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


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: PL/pgSQL Makefile (was: Re: [HACKERS] SQL Triggers)
Next
From: Bruce Momjian
Date:
Subject: Re: [DOCS] Installation instructions