From: drh Date: Fri, 26 Aug 2016 19:31:29 +0000 (+0000) Subject: Enhance sqlite3FindInIndex() so that it is able to make use of the X-Git-Tag: version-3.15.0~110^2~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6fc8f364908faf289d19ebd349c0a4c2995bcd95;p=thirdparty%2Fsqlite.git Enhance sqlite3FindInIndex() so that it is able to make use of the primary keys at the end of an index. FossilOrigin-Name: 4b589fbfcc4265902de0f552961d2df497a184da --- diff --git a/manifest b/manifest index 59c570e2f8..55a6113c35 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\spost-OOM\scrash\sin\supdateRangeAffinityStr().\s\sAdd\sseveral\sALWAYS()\nmacros\son\sunreachable\sbranches. -D 2016-08-26T18:17:08.713 +C Enhance\ssqlite3FindInIndex()\sso\sthat\sit\sis\sable\sto\smake\suse\sof\sthe\nprimary\skeys\sat\sthe\send\sof\san\sindex. +D 2016-08-26T19:31:29.011 F Makefile.in cfd8fb987cd7a6af046daa87daa146d5aad0e088 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5017381e4853b1472e01d5bb926be1268eba429c @@ -338,7 +338,7 @@ F src/ctime.c e77f3dc297b4b65c96da78b4ae4272fdfae863d7 F src/date.c 95c9a8d00767e7221a8e9a31f4e913fc8029bf6b F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d F src/delete.c 76c084f0265f4a3cd1ecf17eee112a94f1ccbc05 -F src/expr.c 1f2ddbec8bf6de323cc0da3ff73e80b0ad21769d +F src/expr.c 192dac6da7ff380fde35861d3f9d40bab39fab2c F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e2be0968c1adc679c87e467aa5b4f167588f38a8 F src/func.c 29cc9acb170ec1387b9f63eb52cd85f8de96c771 @@ -1521,7 +1521,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 b34413ac7e34369b4420e57b0132249dca68a7b0 -R e94f28a1c30d92b873747a9f1cb33b94 +P 87d40195ae5cc2abd9bae45073a615db81263285 +R c0ed51d5af8253a23448fcfb693a50e8 U drh -Z a3a8a387b6b2455df60af55b1e2df964 +Z 3b9104524847b85ed5a08921e98408a8 diff --git a/manifest.uuid b/manifest.uuid index 1ac92a55f8..3562568838 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -87d40195ae5cc2abd9bae45073a615db81263285 \ No newline at end of file +4b589fbfcc4265902de0f552961d2df497a184da \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index a62538c556..3a5075719e 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2099,11 +2099,11 @@ static int sqlite3InRhsIsConstant(Expr *pIn){ */ #ifndef SQLITE_OMIT_SUBQUERY int sqlite3FindInIndex( - Parse *pParse, - Expr *pX, - u32 inFlags, - int *prRhsHasNull, - int *aiMap + Parse *pParse, /* Parsing context */ + Expr *pX, /* The right-hand side (RHS) of the IN operator */ + u32 inFlags, /* IN_INDEX_LOOP, _MEMBERSHIP, and/or _NOOP_OK */ + int *prRhsHasNull, /* Register holding NULL status. See notes */ + int *aiMap /* Mapping from Index fields to RHS fields */ ){ Select *p; /* SELECT to the right of IN operator */ int eType = 0; /* Type of RHS table. IN_INDEX_* */ @@ -2200,9 +2200,13 @@ int sqlite3FindInIndex( ** to this collation sequence. */ for(pIdx=pTab->pIndex; pIdx && eType==0 && affinity_ok; pIdx=pIdx->pNext){ - if( pIdx->nKeyColnKeyCol!=nExpr || !IsUniqueIndex(pIdx)) ){ - continue; + if( pIdx->nColumnnKeyCol>nExpr + ||(pIdx->nColumn>nExpr && !IsUniqueIndex(pIdx)) + ){ + continue; + } } for(i=0; iiColumn==XN_ROWID || pParse->nErr ); for(j=0; jaiColumn[j]!=pRhs->iColumn ) continue; assert( pIdx->azColl[j] ); + if( pReq==0 ) continue; if( sqlite3StrICmp(pReq->zName, pIdx->azColl[j])!=0 ) continue; break; }