*** postgresql-7.0.2/src/backend/utils/adt/varchar.c.orig Tue Oct 17 09:07:02 2000 --- postgresql-7.0.2/src/backend/utils/adt/varchar.c Tue Oct 17 15:11:57 2000 *************** *** 79,85 **** --- 79,95 ---- atttypmod = len + VARHDRSZ; } else + #ifdef MULTIBYTE + { + /* + * truncate multi-byte string preserving multi-byte + * boundary + */ + len = pg_mbcliplen(s, atttypmod - VARHDRSZ, atttypmod - VARHDRSZ); + } + #else len = atttypmod - VARHDRSZ; + #endif result = (char *) palloc(atttypmod); VARSIZE(result) = atttypmod; *************** *** 96,102 **** --- 106,116 ---- #endif /* blank pad the string if necessary */ + #ifdef MULTIBYTE + for (; i < atttypmod - VARHDRSZ; i++) + #else for (; i < len; i++) + #endif *r++ = ' '; return result; } *************** *** 160,166 **** #ifdef MULTIBYTE /* ! * truncate multi-byte string in a way not to break multi-byte * boundary */ if (VARSIZE(s) > len) --- 174,180 ---- #ifdef MULTIBYTE /* ! * truncate multi-byte string preserving multi-byte * boundary */ if (VARSIZE(s) > len) *************** *** 325,331 **** len = strlen(s) + VARHDRSZ; if (atttypmod >= (int32) VARHDRSZ && len > atttypmod) ! len = atttypmod; /* clip the string at max length */ result = (char *) palloc(len); VARSIZE(result) = len; --- 339,352 ---- len = strlen(s) + VARHDRSZ; if (atttypmod >= (int32) VARHDRSZ && len > atttypmod) ! { ! /* clip the string at max length */ ! #ifdef MULTIBYTE ! len = pg_mbcliplen(s, len - VARHDRSZ, atttypmod - VARHDRSZ) + VARHDRSZ; ! #else ! len = atttypmod; ! #endif ! } result = (char *) palloc(len); VARSIZE(result) = len; *************** *** 386,392 **** #ifdef MULTIBYTE /* ! * truncate multi-byte string in a way not to break multi-byte * boundary */ len = pg_mbcliplen(VARDATA(s), slen - VARHDRSZ, slen - VARHDRSZ); --- 407,413 ---- #ifdef MULTIBYTE /* ! * truncate multi-byte string preserving the multi-byte * boundary */ len = pg_mbcliplen(VARDATA(s), slen - VARHDRSZ, slen - VARHDRSZ);