Fix text_substr bug intrduced in 7.3 development
using Joe Conway's patches (submitted at pgsql-patches on 2002/04/08) + small fix.
This commit is contained in:
parent
3767970cbf
commit
c4e0c113b8
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.82 2002/04/03 05:39:32 petere Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.83 2002/04/15 07:54:37 ishii Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -373,7 +373,10 @@ text_substr(PG_FUNCTION_ARGS)
|
|||||||
if (eml > 1)
|
if (eml > 1)
|
||||||
{
|
{
|
||||||
sm = 0;
|
sm = 0;
|
||||||
sn = (m + n) * eml + 3; /* +3 to avoid mb characters overhanging slice end */
|
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
|
#endif
|
||||||
|
|
||||||
@ -387,7 +390,10 @@ text_substr(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_NULL(); /* notreached: suppress compiler warning */
|
PG_RETURN_NULL(); /* notreached: suppress compiler warning */
|
||||||
#endif
|
#endif
|
||||||
#ifdef MULTIBYTE
|
#ifdef MULTIBYTE
|
||||||
len = pg_mbstrlen_with_len (VARDATA (string), sn - 3);
|
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_with_len (VARDATA (string), VARSIZE(string)-VARHDRSZ);
|
||||||
|
|
||||||
if (m > len)
|
if (m > len)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user