*** pgsql/src/backend/utils/adt/varlena.c Sun Apr 7 11:44:54 2002 --- pgsql.orig/src/backend/utils/adt/varlena.c Mon Apr 8 22:32:16 2002 *************** *** 413,419 **** if (eml > 1) { sm = 0; ! sn = (m + n) * eml + 3; /* +3 to avoid mb characters overhanging slice end */ } #endif --- 373,382 ---- if (eml > 1) { sm = 0; ! if (n > -1) ! sn = (m + n) * eml + 3; /* +3 to avoid mb characters overhanging slice end */ ! else ! sn = n; /* n < 0 is special-cased by heap_tuple_untoast_attr_slice */ } #endif *************** *** 427,433 **** PG_RETURN_NULL(); /* notreached: suppress compiler warning */ #endif #ifdef MULTIBYTE ! len = pg_mbstrlen_with_len (VARDATA (string), sn - 3); if (m > len) { --- 390,399 ---- PG_RETURN_NULL(); /* notreached: suppress compiler warning */ #endif #ifdef MULTIBYTE ! if (n > -1) ! len = pg_mbstrlen_with_len (VARDATA (string), sn - 3); ! else /* n < 0 is special-cased; need full string length */ ! len = pg_mbstrlen (VARDATA (string)); if (m > len) {