1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-21 16:02:15 +03:00

MB patches from Tatsuo Ishii

This commit is contained in:
Bruce Momjian
1998-09-25 01:46:25 +00:00
parent 31fea9777f
commit f52e7346ea
3 changed files with 46 additions and 3 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.39 1998/09/01 04:32:53 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.40 1998/09/25 01:46:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -147,7 +147,14 @@ bpchar(char *s, int32 len)
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");
@ -367,7 +374,14 @@ varchar(char *s, int32 slen)
/* only reach here if we need to truncate string... */
#ifdef MULTIBYTE
/* truncate multi-byte string in a way not to break
multi-byte boundary */
len = pg_mbcliplen(VARDATA(s), slen - VARHDRSZ, slen - VARHDRSZ);
slen = len + VARHDRSZ;
#else
len = slen - VARHDRSZ;
#endif
if (len > 4096)
elog(ERROR, "varchar: length of varchar() must be less than 4096");