aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-10-07 00:12:12 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-10-07 00:12:12 +0000
commit9cd5c4fca24206bca84ff323dbd8cf76df8dfa4c (patch)
tree5b8d934dc89ce41071f0f0af4ca01e5bafcda086 /src/backend/utils
parente0c6d9761cf7c774a1d141febe1b484365ae01ce (diff)
downloadpostgresql-9cd5c4fca24206bca84ff323dbd8cf76df8dfa4c.tar.gz
postgresql-9cd5c4fca24206bca84ff323dbd8cf76df8dfa4c.zip
Fix string_to_array() to correctly handle the case where there are
overlapping possible matches for the separator string, such as string_to_array('123xx456xxx789', 'xx'). Also, revise the logic of replace(), split_part(), and string_to_array() to avoid O(N^2) work from redundant searches and conversions to pg_wchar format when there are N matches to the separator string. Backpatched the full patch as far as 8.0. 7.4 also has the bug, but the code has diverged a lot, so I just went for a quick-and-dirty fix of the bug itself in that branch.
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/adt/varlena.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 81f8726c3b4..37de64b46a0 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.106.2.6 2006/05/21 20:06:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.106.2.7 2006/10/07 00:12:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -779,6 +779,8 @@ text_position(Datum str, Datum search_str, int matchnum)
pos = p + 1;
break;
}
+ p1 += len2 - 1;
+ p += len2 - 1;
}
p1++;
}
@@ -809,6 +811,8 @@ text_position(Datum str, Datum search_str, int matchnum)
pos = p + 1;
break;
}
+ p1 += len2 - 1;
+ p += len2 - 1;
}
p1++;
}