aboutsummaryrefslogtreecommitdiff
path: root/src/whereexpr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/whereexpr.c')
-rw-r--r--src/whereexpr.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/whereexpr.c b/src/whereexpr.c
index ae26e85d2..7ea2956a7 100644
--- a/src/whereexpr.c
+++ b/src/whereexpr.c
@@ -220,11 +220,20 @@ static int isLikeOrGlob(
}
if( z ){
- /* Count the number of prefix characters prior to the first wildcard */
+ /* Count the number of prefix characters prior to the first wildcard.
+ ** If the underlying database has a UTF16LE encoding, then only consider
+ ** ASCII characters. Note that the encoding of z[] is UTF8 - we are
+ ** dealing with only UTF8 here in this code, but the database engine
+ ** itself might be processing content using a different encoding. */
cnt = 0;
while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
cnt++;
- if( c==wc[3] && z[cnt]!=0 ) cnt++;
+ if( c==wc[3] && z[cnt]!=0 ){
+ cnt++;
+ }else if( c>=0x80 && ENC(db)==SQLITE_UTF16LE ){
+ cnt--;
+ break;
+ }
}
/* The optimization is possible only if (1) the pattern does not begin
@@ -239,7 +248,7 @@ static int isLikeOrGlob(
Expr *pPrefix;
/* A "complete" match if the pattern ends with "*" or "%" */
- *pisComplete = c==wc[0] && z[cnt+1]==0;
+ *pisComplete = c==wc[0] && z[cnt+1]==0 && ENC(db)!=SQLITE_UTF16LE;
/* Get the pattern prefix. Remove all escapes from the prefix. */
pPrefix = sqlite3Expr(db, TK_STRING, (char*)z);