OSDN Git Service

> It seems there is a mistake in substr function:
authorMarc G. Fournier <scrappy@hub.org>
Tue, 13 Jan 1998 03:49:51 +0000 (03:49 +0000)
committerMarc G. Fournier <scrappy@hub.org>
Tue, 13 Jan 1998 03:49:51 +0000 (03:49 +0000)
> then you try get substr, which consists only of last char in string
> you get all string
>
> For example:
> userbase=> select substr('123456', 6,1) ;
> substr
> ------
> 123456
> (1 row)
>

From Edmund Mergl <E.Mergl@bawue.de>

src/backend/utils/adt/oracle_compat.c

index 27216ab..e39c83a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     Edmund Mergl <E.Mergl@bawue.de>
  *
- *     $Id: oracle_compat.c,v 1.10 1997/09/08 21:48:39 momjian Exp $
+ *     $Id: oracle_compat.c,v 1.11 1998/01/13 03:49:51 scrappy Exp $
  *
  */
 
@@ -512,7 +512,7 @@ substr(text *string, int4 m, int4 n)
 
        if ((string == (text *) NULL) ||
                (m <= 0) || (n <= 0) ||
-               ((len = VARSIZE(string) - VARHDRSZ - m) <= 0))
+               ((len = VARSIZE(string) - VARHDRSZ - m + 1) <= 0))
                return string;
 
        len = len + 1 < n ? len + 1 : n;