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

From Tatsuo Ishii
Subject Re: [HACKERS] fix for multi-byte partial truncating
Date
Msg-id 199809250904.SAA23096@srapc451.sra.co.jp
Whole thread Raw
In response to Re: [HACKERS] fix for multi-byte partial truncating  (Bruce Momjian <maillist@candle.pha.pa.us>)
Responses Re: [HACKERS] fix for multi-byte partial truncating
List pgsql-hackers
>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

pgsql-hackers by date:

Previous
From: jwieck@debis.com (Jan Wieck)
Date:
Subject: PL/pgSQL Makefile (was: Re: [HACKERS] SQL Triggers)
Next
From: jwieck@debis.com (Jan Wieck)
Date:
Subject: Re: [HACKERS] crash on new system views