>>>Tatsuo Ishii said:> >This worked, however it made all selects of ~* '^sometext' sequential.> > That's correct
behavior.>> >Why can't we use index searches in this case? I believe it is :-)> > No. It's due to the nature of the
Btreeindex.
But why it did use index scan when the case of the field and the expression
matched and did find the correct results?
> >But this> >> >SELECT key FROM t WHERE key ~* '^ sometext';> > Again, that should not be index scan.
SELECT key FROM t WHERE key ~* '^ ';
(space only) uses index and works correctly.... weird!
> BTW, if you want to play with regex, you might find retest.c be> useful. You can build the test tool by:> > make
retest>> enjoy:-)
In a wild guess I changed all 'char' to 'unsigned char' in regcomp.c, with no
positive or negative results. Maybe there are other places in regex where this
should be done, such as regexec.c? Is there an regex guru over here ... :-)
My long-time wondering about regex in Postgres has always been - isn't there
something better than this old regex code that we can use?
Daniel