Re: [HACKERS] another locale problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Daniel Kalchev <daniel(at)digsys(dot)bg>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] another locale problem
Date: 1999-06-11 21:41:13
Message-ID: 13629.929137273@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Daniel Kalchev <daniel(at)digsys(dot)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

Browse pgsql-hackers by date

  From Date Subject
Next Message Oleg Bartunov 1999-06-12 01:51:58 BUG: ERROR: regcomp failed with error empty (sub)expression
Previous Message Tom Lane 1999-06-11 21:26:25 Re: [HACKERS] Re: locales and MB (was: Postgres 6.5 beta2 and beta3 problem)