Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc4e0c11

Browse files
committed
Fix text_substr bug intrduced in 7.3 development
using Joe Conway's patches (submitted at pgsql-patches on 2002/04/08) + small fix.
1 parent3767970 commitc4e0c11

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

‎src/backend/utils/adt/varlena.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.82 2002/04/03 05:39:32 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.83 2002/04/15 07:54:37 ishii Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -373,7 +373,10 @@ text_substr(PG_FUNCTION_ARGS)
373373
if (eml>1)
374374
{
375375
sm=0;
376-
sn= (m+n)*eml+3;/* +3 to avoid mb characters overhanging slice end */
376+
if (n>-1)
377+
sn= (m+n)*eml+3;/* +3 to avoid mb characters overhanging slice end */
378+
else
379+
sn=n;/* n < 0 is special-cased by heap_tuple_untoast_attr_slice */
377380
}
378381
#endif
379382

@@ -387,7 +390,10 @@ text_substr(PG_FUNCTION_ARGS)
387390
PG_RETURN_NULL();/* notreached: suppress compiler warning */
388391
#endif
389392
#ifdefMULTIBYTE
390-
len=pg_mbstrlen_with_len (VARDATA (string),sn-3);
393+
if (n>-1)
394+
len=pg_mbstrlen_with_len (VARDATA (string),sn-3);
395+
else/* n < 0 is special-cased; need full string length */
396+
len=pg_mbstrlen_with_len (VARDATA (string),VARSIZE(string)-VARHDRSZ);
391397

392398
if (m>len)
393399
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp