File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -373,7 +373,10 @@ text_substr(PG_FUNCTION_ARGS)
373
373
if (eml > 1 )
374
374
{
375
375
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 */
377
380
}
378
381
#endif
379
382
@@ -387,7 +390,10 @@ text_substr(PG_FUNCTION_ARGS)
387
390
PG_RETURN_NULL (); /* notreached: suppress compiler warning */
388
391
#endif
389
392
#ifdef MULTIBYTE
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 );
391
397
392
398
if (m > len )
393
399
{
You can’t perform that action at this time.
0 commit comments