Fix indexes on expressions so that they can be actually used with

a COLLATE clause.

FossilOrigin-Name: e464b919f76520b45bb58983c6702db59d820ee4
This commit is contained in:
drh 2017-02-11 14:59:58 +00:00
parent 13ac46eea2
commit f9463dfbcf
6 changed files with 25 additions and 12 deletions

View File

@ -1,5 +1,5 @@
C Ensure\sthat\sindexed\sexpressions\swith\scollating\ssequences\sare\shandled\ncorrectly.\s\sProposed\sfix\sfor\sticket\s[eb703ba7b50c1a5].
D 2017-02-11T13:51:23.762
C Fix\sindexes\son\sexpressions\sso\sthat\sthey\scan\sbe\sactually\sused\swith\na\sCOLLATE\sclause.
D 2017-02-11T14:59:58.753
F Makefile.in edb6bcdd37748d2b1c3422ff727c748df7ffe918
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 067a6766f800cc8d72845ab61f8de4ffe8f3fc99
@ -347,7 +347,7 @@ F src/ctime.c 9f2296a4e5d26ebf0e0d95a0af4628f1ea694e7a
F src/date.c dc3f1391d9297f8c748132813aaffcb117090d6e
F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d
F src/delete.c 0d9d5549d42e79ce4d82ff1db1e6c81e36d2f67c
F src/expr.c c218ec8cfc12b2c5b354660ce7285dfaf43305e9
F src/expr.c 4748f51a680ded80332aca51cc51548c60758fe9
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c 2e9aabe1aee76273aff8a84ee92c464e095400ae
F src/func.c c67273e1ec08abbdcc14c189892a3ff6eeece86b
@ -399,7 +399,7 @@ F src/shell.c a84e453c213f3e0d6935a582024da4e242f85a19
F src/sqlite.h.in 751ff125eb159c8f92c182b8df980a5e4f50e966
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae
F src/sqliteInt.h 4dc66ec1948765f151899333f7a55267d807d099
F src/sqliteInt.h c3f878dcbe947938f9e0984644f1902dd9051094
F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247
F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
@ -475,10 +475,10 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
F src/wal.c 40c543f0a2195d1b0dc88ef12142bea690009344
F src/wal.h 06b2a0b599cc0f53ea97f497cf8c6b758c999f71
F src/walker.c 91a6df7435827e41cff6bb7df50ea00934ee78b0
F src/where.c b0d81c6f24ea6aebb249c92c5d78ec8ab1452523
F src/where.c 6397fab50fdbf9bde76c574ce07b3b776eb28b34
F src/whereInt.h 2bcc3d176e6091cb8f50a30b65c006e88a73614d
F src/wherecode.c 99a8ced164c75edf41b3a865a75381c9adb38b28
F src/whereexpr.c 980109826ba02750421c3fa7ab0ecabbac0a639d
F src/whereexpr.c 130cdd1a43af71b19755270fb1224874cf55158c
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd
F test/affinity3.test 6a101af2fc945ce2912f6fe54dd646018551710d
@ -1555,7 +1555,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 7520c238558346d421e3c24cb7d17a54d1aa56b2
R 89fd81518c2edceda83a282bdfdfc51e
P 9689d04b8250139e32078b2aa9748edcc6231bcd
R e95d56d566e83b0838849dba73bfcd3a
U drh
Z 86c7ba615f1277d92ec3bd479587e4c2
Z 0aabcf0e8948d008893cd3f00b6802af

View File

@ -1 +1 @@
9689d04b8250139e32078b2aa9748edcc6231bcd
e464b919f76520b45bb58983c6702db59d820ee4

View File

@ -4680,6 +4680,17 @@ int sqlite3ExprListCompare(ExprList *pA, ExprList *pB, int iTab){
return 0;
}
/*
** Like sqlite3ExprCompare() except COLLATE operators at the top-level
** are ignored.
*/
int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){
return sqlite3ExprCompare(
sqlite3ExprSkipCollate(pA),
sqlite3ExprSkipCollate(pB),
iTab);
}
/*
** Return true if we can prove the pE2 will always be true if pE1 is
** true. Return false if we cannot complete the proof or if pE2 might

View File

@ -3762,6 +3762,7 @@ void sqlite3Vacuum(Parse*,Token*);
int sqlite3RunVacuum(char**, sqlite3*, int);
char *sqlite3NameFromToken(sqlite3*, Token*);
int sqlite3ExprCompare(Expr*, Expr*, int);
int sqlite3ExprCompareSkip(Expr*, Expr*, int);
int sqlite3ExprListCompare(ExprList*, ExprList*, int);
int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);

View File

@ -209,7 +209,8 @@ static WhereTerm *whereScanNext(WhereScan *pScan){
if( pTerm->leftCursor==iCur
&& pTerm->u.leftColumn==iColumn
&& (iColumn!=XN_EXPR
|| sqlite3ExprCompare(pTerm->pExpr->pLeft,pScan->pIdxExpr,iCur)==0)
|| sqlite3ExprCompareSkip(pTerm->pExpr->pLeft,
pScan->pIdxExpr,iCur)==0)
&& (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin))
){
if( (pTerm->eOperator & WO_EQUIV)!=0

View File

@ -874,7 +874,7 @@ static int exprMightBeIndexed(
if( pIdx->aColExpr==0 ) continue;
for(i=0; i<pIdx->nKeyCol; i++){
if( pIdx->aiColumn[i]!=XN_EXPR ) continue;
if( sqlite3ExprCompare(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){
if( sqlite3ExprCompareSkip(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){
*piCur = iCur;
*piColumn = XN_EXPR;
return 1;