Fix string_to_array() to correctly handle the case where there are
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 7 Oct 2006 00:12:05 +0000 (00:12 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 7 Oct 2006 00:12:05 +0000 (00:12 +0000)
commit3e712cb80b59bcfc0896cb9bc248d4c5deb24995
treef624dafd9c5064fa05a688ceb6b85e7e8805bed6
parent9df6786923f3b07361bf06d8c088704568759282
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.
src/backend/utils/adt/varlena.c