Bruce Momjian <br...@momjian.us> writes: > Tom Lane wrote: >> I have a feeling that this represents still another bug in the >> special-case path for % followed by _ (cf bug #4821). If so, >> maybe we ought to just toss out that optimization?
> Yea, looks like it is this code in like_match.c: No, actually it's the bit right after that: /* Look for a place that matches the rest of the pattern */ while (tlen > 0) { int matched = MatchText(t, tlen, p, plen); if (matched != LIKE_FALSE) return matched; /* TRUE or ABORT */ NextChar(t, tlen); } If tlen == 0 when we reach this loop, we'll fall through and fail. But that is wrong since we need to consider the possibility that the remaining pattern can match a zero-length substring. So the loop needs to be changed to attempt a recursive MatchText for tlen equal to zero as well as greater than zero. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs