Re: [v9.2] make_greater_string() does not return a string in some cases - Mailing list pgsql-hackers

From Greg Stark
Subject Re: [v9.2] make_greater_string() does not return a string in some cases
Date
Msg-id CAM-w4HMUJox19HkuJJK-vWNJLe0RTQK+P0O6NtfB_mF78zE5Rw@mail.gmail.com
Whole thread Raw
In response to Re: [v9.2] make_greater_string() does not return a string in some cases  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: [v9.2] make_greater_string() does not return a string in some cases
List pgsql-hackers
On Thu, Sep 22, 2011 at 1:49 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> My thought was that it would avoid the need to do any character
> incrementing at all.  You could just start scanning forward as if the
> operator were >= and then stop when you hit the first string that
> doesn't have the same initial substring.

But the whole problem is that not all the strings with the initial
substring are in a contiguous block. The best we can hope for is that
they're fairly dense within a block without too many non-matching
strings. The example with / shows how that can happen.

If you're looking for foo/% and you start with foo/ you'll find:

foo/
foo0
foo/0
foo1
foo/1
...

Even just case-insensitive collations don't put all the strings with a
common prefix in a contiguous block. If you're searching for foo%
you'll find:

foo
Foobar
foobar


--
greg


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [v9.2] make_greater_string() does not return a string in some cases
Next
From: Robert Haas
Date:
Subject: Re: Adding CORRESPONDING to Set Operations