[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sqlite-users
Subject:    [sqlite] small bug using like/glob without wildcard?
From:       "gerim () iol ! it" <gerim () iol ! it>
Date:       2010-05-27 15:49:22
Message-ID: 14011447.1006111274975362472.JavaMail.defaultUser () defaultHost
[Download RAW message or body]

Dear all,
I'm looking to resolve a small problem using like/glob function with indexes 
starting from version 3.6.23.1 (It worked with 3.6.13)

Using a where condition such as  "WHERE MY_INDEXED_COLUMN LIKE 'X' " ,sqlite 
doesn't use the index on that column while it uses the index if I use a 
wildcard, for example "WHERE MY_INDEXED_COLUMN LIKE 'X%'".

This causes some problems in my application which uses prepared statements 
that accept string input by users, and it's expected to work with or without 
wildcard.
Looking into sqlite source code, in file "where.c", function "static int 
isLikeOrGlob", if I replace the following lines:

1)  line number 690: 

if( cnt!=0 && c!=0 && 255!=(u8)z[cnt-1] ){

with this:

if( cnt!=0 && 255!=(u8)z[cnt-1] ){

2) line number 692:

*pisComplete = z[cnt]==wc[0] && z[cnt+1]==0;

with this:

*pisComplete = z[cnt]==wc[0] && c==0;


It seems to work without problems in both cases.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic