Daniel Kalchev <daniel@digsys.bg> writes:
> In fact, after giving it some though... the expression in gram.y
> (strcmp(opname,"~*")
> == 0 && isalpha(n->val.val.str[pos])))
> is wrong. The statement in my view decides that a regular expression is not
> indexable if it contains special characters or if it contains non-alpha
> characters. Therefore, the statement should be written as:
> (strcmp(opname,"~*")
> == 0 && !isalpha((unsigned char)n->val.val.str[pos])))
No, it's not wrong, at least not in that way! You've missed the point
entirely. ~* is the *case insensitive* regexp match operator.
Therefore if I have a pattern like '^abc' it can match anything
beginning with either 'a' or 'A'. If the index restriction were to
include the letter 'a' then it would exclude valid matches starting with
'A'. The simplest solution, which is what's in makeIndexable(), is
to exclude case-foldable characters from the index restriction pattern.
In this particular case you end up getting no index restriction at all,
but that is indeed what's supposed to happen.
I am not sure that isalpha() is an adequate test for case-foldable
characters in non-ASCII locales, but inverting it is definitely wrong ;-)
regards, tom lane