]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
More lenient handling of ORDER BY optimization in joins with mixed ASC/DESC.
authordrh <drh@noemail.net>
Tue, 2 Oct 2012 15:19:19 +0000 (15:19 +0000)
committerdrh <drh@noemail.net>
Tue, 2 Oct 2012 15:19:19 +0000 (15:19 +0000)
This is a better and less restrictive fix for the problem addressed by
the previous check-in.

FossilOrigin-Name: abcf6a5d054559ee5a093ba39180c47b4958d9cd

manifest
manifest.uuid
src/where.c
test/orderby1.test

index a0b9b77d8a09f5af34a1aefc939609846670d969..58498bcbfee4c62168066ce23b6adaa8c96583eb 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Only\scontinue\san\sORDER\sBY\soptimization\sinto\sinner\sloops\sif\sthe\sequality\nconstraints\son\sthe\sinner\sloop\smatch\sterms\sof\san\souter\sordered\sindex\sthat\nare\sactually\sused\sby\sthe\sORDER\sBY\sclause.
-D 2012-10-02T14:11:29.949
+C More\slenient\shandling\sof\sORDER\sBY\soptimization\sin\sjoins\swith\smixed\sASC/DESC.\nThis\sis\sa\sbetter\sand\sless\srestrictive\sfix\sfor\sthe\sproblem\saddressed\sby\nthe\sprevious\scheck-in.
+D 2012-10-02T15:19:19.625
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -249,7 +249,7 @@ F src/vtab.c d8020c0a0e8ccc490ca449d7e665311b6e9f3ba9
 F src/wal.c e1fe8f92a0ea0fef8faa87ec43a127a478589d22
 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6
 F src/walker.c 3d75ba73de15e0f8cd0737643badbeb0e002f07b
-F src/where.c d40f2fa13bbda673cc681a2baeb490fe7a22f17e
+F src/where.c 69398e95e9c1012ae07ce9ea00f21b0e7bab8df1
 F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
 F test/aggnested.test 0be144b453e0622a085fae8665c32f5676708e00
@@ -634,7 +634,7 @@ F test/notify3.test a86259abbfb923aa27d30f0fc038c88e5251488a
 F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347
 F test/null.test a8b09b8ed87852742343b33441a9240022108993
 F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394
-F test/orderby1.test 1f7e942aec6074725d823edfff258e9187dd255f
+F test/orderby1.test 4875a2a0a87d81920f3600a3405dc42f233b8c82
 F test/orderby2.test d8fa5991d8948ae1f335c2f91d751e955bfee815
 F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3
 F test/pager1.test 2163c6ef119f497a71a84137c957c63763e640ab
@@ -1018,7 +1018,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9
-P 545bb33688663066cf3f09e4cdc4d5cfe59fb8db
-R 0244ec6263deff2d19e204ecc996e53d
+P b0e7b4df6c2a8c479f8d210bde50c737eaa248f0
+R a1842b2ba16ad28b21201e48479c524d
 U drh
-Z 17cee407676b72dedd8bc51219c654fe
+Z 4c91eefd164f9f4e974324de15060f38
index 73689c0af941965b427d6c9faba29f247180e478..22cffbf9b5949d234a64abae4acb3ee6fac88cfe 100644 (file)
@@ -1 +1 @@
-b0e7b4df6c2a8c479f8d210bde50c737eaa248f0
\ No newline at end of file
+abcf6a5d054559ee5a093ba39180c47b4958d9cd
\ No newline at end of file
index ca998269b96286ef6867efe3d7d285de0e956d3e..16b0c1c710ece0e14146d4dc1d0bdfb69f1906ad 100644 (file)
@@ -2736,9 +2736,7 @@ static int isOrderedColumn(WhereBestIdx *p, int iTab, int iCol, int *pbRev){
         sortOrder = 0;
         testcase( (pLevel->plan.wsFlags & WHERE_REVERSE)!=0 );
       }else{
-        int n = pLevel->plan.nOBSat;
-        if( p->i>=2 ) n -= pLevel[-1].plan.nOBSat;
-        assert( n<=pIdx->nColumn );
+        int n = pIdx->nColumn;
         for(j=0; j<n; j++){
           if( iCol==pIdx->aiColumn[j] ) break;
         }
@@ -2840,7 +2838,7 @@ static int isSortingIndex(
   }else{
     if( nEqCol==0 ) return nPriorSat;
     sortOrder = bOuterRev;
-    nEqOneRow = 0;
+    nEqOneRow = -1;
   }
   pOrderBy = p->pOrderBy;
   assert( pOrderBy!=0 );
@@ -2917,7 +2915,7 @@ static int isSortingIndex(
     if( i>nEqOneRow ){
       if( termSortOrder!=sortOrder ){
         /* Indices can only be used if all ORDER BY terms past the
-        ** equality constraints are all either DESC or ASC. */
+        ** equality constraints have the correct DESC or ASC. */
         break;
       }
     }else{
index 77ceadae093600a761b050b492f4e75489d12661..8087857931b28bac3fa3f3a22cf9911f0dbbcccb 100644 (file)
@@ -194,7 +194,7 @@ do_test 2.1b {
     EXPLAIN QUERY PLAN
     SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn
   }
-} {/ORDER BY/}  ;# ORDER BY required because of missing aid term in ORDER BY
+} {~/ORDER BY/}  ;# ORDER BY optimized out
 
 do_test 2.1c {
   db eval {
@@ -296,7 +296,7 @@ do_test 2.6c {
     EXPLAIN QUERY PLAN
     SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn DESC
   }
-} {/ORDER BY/}  ;# ORDER BY required
+} {~/ORDER BY/}  ;# ORDER BY optimized out
 
 
 # Generate another test dataset, but this time using mixed ASC/DESC indices.