From: "Thomas G. Lockhart"
authorMarc G. Fournier
Sun, 15 Mar 1998 08:07:01 +0000 (08:07 +0000)
committerMarc G. Fournier
Sun, 15 Mar 1998 08:07:01 +0000 (08:07 +0000)
For substr() and substring() on the text data type, the relevant code is in
varlena.c. You are right, there is a problem. I have a patch which I will
apply to the source tree soon. The copy enclosed below probably does not
preserve tabs correctly so cannot be applied directly; the relevant change
is simply changing the ">=" to ">"...

src/backend/utils/adt/varlena.c

index a6b45d209388f33e4b8522fc6dd472db7b0e33e3..c45a5d9a2e32fa5a7d2432c80eadb624aa80015e 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.31 1998/02/26 04:37:24 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.32 1998/03/15 08:07:01 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -291,7 +291,7 @@ text_substr(text *string, int32 m, int32 n)
    len = VARSIZE(string) - VARHDRSZ;
 
    /* m will now become a zero-based starting position */
-   if (m >= len)
+   if (m > len)
    {
        m = 0;
        n = 0;