Index: src/whereexpr.c ================================================================== --- src/whereexpr.c +++ src/whereexpr.c @@ -276,11 +276,11 @@ ** be converted into "x<0", which is incorrect. */ if( sqlite3Isdigit(zNew[0]) || zNew[0]=='-' || zNew[0]=='+' - || (zNew[0]+1=='0' && iTo==1) + || (iTo>0 && zNew[iTo-1]=='0'-1) ){ if( pLeft->op!=TK_COLUMN || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT || IsVirtual(pLeft->y.pTab) /* Value might be numeric */ ){ Index: test/like3.test ================================================================== --- test/like3.test +++ test/like3.test @@ -177,18 +177,29 @@ QUERY PLAN `--SEARCH TABLE t5b USING COVERING INDEX sqlite_autoindex_t5b_1 (x>? AND x