Re: [PATCHES] v7.4.1 text_position() patch - Mailing list pgsql-hackers

From Joe Conway
Subject Re: [PATCHES] v7.4.1 text_position() patch
Date
Msg-id 401BDD5A.3050903@joeconway.com
Whole thread Raw
In response to Re: [PATCHES] v7.4.1 text_position() patch  (Tatsuo Ishii <t-ishii@sra.co.jp>)
Responses Re: [PATCHES] v7.4.1 text_position() patch
List pgsql-hackers
Tatsuo Ishii wrote:
> It's surprising that nobody noticed the bug until now. It seems it has
> been there since 7.3 days. I would like to make a back patch for
> 7.3-stable if nobody objects.

It's my bug :( -- sorry about that. Here's a 7.3 patch per Tom's nearby
advice. I'll apply if you'd like.

Joe
Index: src/backend/utils/adt/varlena.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/utils/adt/varlena.c,v
retrieving revision 1.92.2.2
diff -c -r1.92.2.2 varlena.c
*** src/backend/utils/adt/varlena.c    30 Nov 2003 20:52:37 -0000    1.92.2.2
--- src/backend/utils/adt/varlena.c    31 Jan 2004 16:50:37 -0000
***************
*** 665,673 ****
      len1 = (VARSIZE(t1) - VARHDRSZ);
      len2 = (VARSIZE(t2) - VARHDRSZ);

-     /* no use in searching str past point where search_str will fit */
-     px = (len1 - len2);
-
      if (eml == 1)                /* simple case - single byte encoding */
      {
          char       *p1,
--- 665,670 ----
***************
*** 676,681 ****
--- 673,681 ----
          p1 = VARDATA(t1);
          p2 = VARDATA(t2);

+         /* no use in searching str past point where search_str will fit */
+         px = (len1 - len2);
+
          for (p = 0; p <= px; p++)
          {
              if ((*p2 == *p1) && (strncmp(p1, p2, len2) == 0))
***************
*** 702,707 ****
--- 702,710 ----
          ps2 = p2 = (pg_wchar *) palloc((len2 + 1) * sizeof(pg_wchar));
          (void) pg_mb2wchar_with_len((unsigned char *) VARDATA(t2), p2, len2);
          len2 = pg_wchar_strlen(p2);
+
+         /* no use in searching str past point where search_str will fit */
+         px = (len1 - len2);

          for (p = 0; p <= px; p++)
          {

pgsql-hackers by date:

Previous
From: "Thomas Hallgren"
Date:
Subject: Transaction callback
Next
From: Tom Lane
Date:
Subject: Re: dump + restore didn't include schemas