From dc3cd4b0208efa1f0b2ac78bd417cf511b510e2d Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 30 May 2013 23:21:20 +0000 Subject: [PATCH] Improvements to the ORDER BY suppressor in the NGQP. FossilOrigin-Name: 24a2e9ddcecd3926817d77abbb75d068ee7140ad --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/where.c | 20 +++++++++++++------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index e2d80171bf..f227274658 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Incremental\scheck-in\swith\svarious\sNGQP\sfixes.\s\sMany\stests\sstill\sfail. -D 2013-05-30T22:27:09.004 +C Improvements\sto\sthe\sORDER\sBY\ssuppressor\sin\sthe\sNGQP. +D 2013-05-30T23:21:20.132 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -289,7 +289,7 @@ F src/vtab.c b05e5f1f4902461ba9f5fc49bb7eb7c3a0741a83 F src/wal.c 436bfceb141b9423c45119e68e444358ee0ed35d F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 4fa43583d0a84b48f93b1e88f11adf2065be4e73 -F src/where.c 28e0cefe34698b6de4e6f5484cd987ae993c49f2 +F src/where.c 38beadcfdf477b0f9a07c4d0a479ab522843b14c F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6 @@ -1093,7 +1093,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P ae985db4fa08b5efbef5a834e852f0b05101264b -R 5e6d0ab71af5f0e6d4eac06636af5d1b +P a51d8c92496436488e1a6eabd85785e8fedf2736 +R 405146591851ecbfbac166e3c1b2db18 U drh -Z 130160475bcddf72f5447461f586642a +Z 4964f74ab7b0cf98172fb87fb30a1333 diff --git a/manifest.uuid b/manifest.uuid index 22be55a88a..ee070b19f5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a51d8c92496436488e1a6eabd85785e8fedf2736 \ No newline at end of file +24a2e9ddcecd3926817d77abbb75d068ee7140ad \ No newline at end of file diff --git a/src/where.c b/src/where.c index 5663e68491..9d454bc80c 100644 --- a/src/where.c +++ b/src/where.c @@ -4588,6 +4588,7 @@ static int wherePathSatisfiesOrderBy( j = 0; revSet = rev = 0; for(j=0; j<=nColumn && nUseda[nUsed].pExpr); assert( pOBExpr->op==TK_COLUMN ); if( pOBExpr->iTable!=iCur ) break; @@ -4602,20 +4603,25 @@ static int wherePathSatisfiesOrderBy( iColumn = -1; revIdx = 0; } + skipable = ju.btree.nEq && pLoop->aTerm[j]->eOperator!=WO_IN; if( pOBExpr->iColumn!=iColumn ){ - if( ju.btree.nEq ){ nUsed--; continue; } + if( skipable ){ nUsed--; continue; } return 0; } if( iColumn>=0 ){ pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[nUsed].pExpr); if( !pColl ) pColl = db->pDfltColl; - if( sqlite3StrICmp(pColl->zName, pIndex->azColl[j])!=0 ) return 0; + if( sqlite3StrICmp(pColl->zName, pIndex->azColl[j])!=0 ){ + return 0; + } } - if( revSet ){ - if( (rev ^ revIdx)!=pOrderBy->a[nUsed].sortOrder ) return 0; - }else{ - rev = revIdx ^ pOrderBy->a[nUsed].sortOrder; - revSet = 1; + if( !skipable ){ + if( revSet ){ + if( (rev ^ revIdx)!=pOrderBy->a[nUsed].sortOrder ) return 0; + }else{ + rev = revIdx ^ pOrderBy->a[nUsed].sortOrder; + revSet = 1; + } } } if( rev ) revMask |= ((Bitmask)1)<