]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix the query planner so that it once again knows that queries without a
authordrh <drh@noemail.net>
Mon, 2 Jun 2014 11:26:33 +0000 (11:26 +0000)
committerdrh <drh@noemail.net>
Mon, 2 Jun 2014 11:26:33 +0000 (11:26 +0000)
FROM clause will never return more than one row and hence do not require
sorting.

FossilOrigin-Name: 9f18b303cd1bc5779d82669884f802c7889b4947

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

index 5e7b19d8e807e3c1276892ed16652310620ecf17..3d8587fb617d14a8a6e4bffef5486159477aef83 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sthe\s"valgrind-nolookaside"\spermutation\sto\spermutations.test.
-D 2014-06-02T09:39:24.180
+C Fix\sthe\squery\splanner\sso\sthat\sit\sonce\sagain\sknows\sthat\squeries\swithout\sa\nFROM\sclause\swill\snever\sreturn\smore\sthan\sone\srow\sand\shence\sdo\snot\srequire\nsorting.
+D 2014-06-02T11:26:33.102
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in dd2b1aba364ff9b05de41086f74407f285c57670
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -294,7 +294,7 @@ F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd
 F src/wal.c 76e7fc6de229bea8b30bb2539110f03a494dc3a8
 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
 F src/walker.c 11edb74d587bc87b33ca96a5173e3ec1b8389e45
-F src/where.c b3be5eb4193b6327c4a02fe91411df503fe770e8
+F src/where.c 308ed08c648fb7e3d7ba5896363dd86b2a0cc616
 F src/whereInt.h 6804c2e5010378568c2bb1350477537755296a46
 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
@@ -726,7 +726,7 @@ F test/notnull.test f8fcf58669ddba79274daa2770d61dfad8274f62
 F test/null.test a8b09b8ed87852742343b33441a9240022108993
 F test/numcast.test 5d126f7f581432e86a90d1e35cac625164aec4a1
 F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394
-F test/orderby1.test 9b524aff9147288da43a6d7ddfdcff47fa2303c6
+F test/orderby1.test 2a6164169199ed53c99089b087ef653e480f63ac
 F test/orderby2.test bc11009f7cd99d96b1b11e57b199b00633eb5b04
 F test/orderby3.test 8619d06a3debdcd80a27c0fdea5c40b468854b99
 F test/orderby4.test 4d39bfbaaa3ae64d026ca2ff166353d2edca4ba4
@@ -1173,7 +1173,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 39fafe0a19ff346a2354f00b03f8e8e4b8b0524c
-R 387ada14b86204efc12685ecd89ec07f
-U dan
-Z e06809476b8cf9300fa9e3eaa704baed
+P 8e8472d9b689d128eb11d3111e009161cf4580f7
+R 9d072715608349b4afa2f27606dc53c0
+U drh
+Z c7f9af8be8da856d6f5f7578b5205ca0
index e444e477978a275f614866ff20936c6f95dc73fb..9593e5bd41251dc8289c42f651d65623b5fa132f 100644 (file)
@@ -1 +1 @@
-8e8472d9b689d128eb11d3111e009161cf4580f7
\ No newline at end of file
+9f18b303cd1bc5779d82669884f802c7889b4947
\ No newline at end of file
index 25c1c04148ac4348851f7c0cb32051893c3d6fd2..ccecccb12e61d2b321c5b4d33ef0a93cb22c6df6 100644 (file)
@@ -5297,7 +5297,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
   /* TUNING: For simple queries, only the best path is tracked.
   ** For 2-way joins, the 5 best paths are followed.
   ** For joins of 3 or more tables, track the 10 best paths */
-  mxChoice = (nLoop==1) ? 1 : (nLoop==2 ? 5 : 10);
+  mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 10);
   assert( nLoop<=pWInfo->pTabList->nSrc );
   WHERETRACE(0x002, ("---- begin solver\n"));
 
@@ -5327,7 +5327,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
     aFrom[0].isOrdered = 0;
     nOrderBy = 0;
   }else{
-    aFrom[0].isOrdered = -1;
+    aFrom[0].isOrdered = nLoop>0 ? -1 : 1;
     nOrderBy = pWInfo->pOrderBy->nExpr;
   }
 
index d4795671ddb013d4fe893eba02058e455591a422..30c8df2d2222714673fab4c2765227eee650bb89 100644 (file)
@@ -452,6 +452,16 @@ do_test 4.0 {
   }
 } {1 13 1 14 1 15 1 16}
 
-
+# No sorting of queries that omit the FROM clause.
+#
+do_execsql_test 5.0 {
+  EXPLAIN QUERY PLAN SELECT 5 ORDER BY 1
+} {}
+do_execsql_test 5.1 {
+  EXPLAIN QUERY PLAN SELECT 5 UNION ALL SELECT 3 ORDER BY 1
+} {~/B-TREE/}
+do_execsql_test 5.2 {
+  SELECT 5 UNION ALL SELECT 3 ORDER BY 1
+} {3 5}
 
 finish_test