Re: [HACKERS] another locale problem
От | Daniel Kalchev |
---|---|
Тема | Re: [HACKERS] another locale problem |
Дата | |
Msg-id | 199906140740.KAA17559@dcave.digsys.bg обсуждение исходный текст |
Ответ на | Re: [HACKERS] another locale problem (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-hackers |
Tom, So you say that this check prevents the use of indexes, when we use the ~* operator and have alpha characters in the pattern, because apparently the index cannot do case insensitive matching. I was under the (apparently wrong impression) that it was possible to use indexes for case insensitive matching. Dreaming... :-) For your information, isalpha() is the correct match for case foldable characters, at least in the cp1251 (windows-1251) locale. I believe a more correct test could be to access the locale's MAPLOWER and MAPUPPER tables. It is not the case in Bulgarian, but there might be languages where an letter does not exist in both upper and lower cases and therefore requires more complex handling. Perhaps such situation exists in the multibyte locales. Please excuse my confusion. :-) Daniel >>>Tom Lane said:> Daniel Kalchev <daniel@digsys.bg> writes:> > In fact, after giving it some though... the expression ingram.y> > > (strcmp(opname,"~*")> > == 0 && isalpha(n->val.val.str[pos])))> > > is wrong. The statementin my view decides that a regular expression is no t > > indexable if it contains special characters or if itcontains 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 thatway! You've missed the point> entirely. ~* is the *case insensitive* regexp match operator.> Therefore if I have apattern like '^abc' it can match anything> beginning with either 'a' or 'A'. If the index restriction were to> includethe letter 'a' then it would exclude valid matches starting with> 'A'. The simplest solution, which is what's inmakeIndexable(), is> to exclude case-foldable characters from the index restriction pattern.> In this particular case youend 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
В списке pgsql-hackers по дате отправления: