Re: [HACKERS] fix for multi-byte partial truncating

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: t-ishii(at)sra(dot)co(dot)jp
Cc: t-ishii(at)sra(dot)co(dot)jp, hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] fix for multi-byte partial truncating
Date: 1998-09-25 15:51:24
Message-ID: 199809251551.LAA04441@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(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

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1998-09-25 15:53:52 Re: [DOCS] Installation instructions
Previous Message Bruce Momjian 1998-09-25 15:50:03 Re: PL/pgSQL Makefile (was: Re: [HACKERS] SQL Triggers)