]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Do not let the reverse_unordered_selects pragma force the use of an index that
authordrh <drh@noemail.net>
Wed, 10 Jun 2009 19:33:28 +0000 (19:33 +0000)
committerdrh <drh@noemail.net>
Wed, 10 Jun 2009 19:33:28 +0000 (19:33 +0000)
would not otherwise be used.  Ticket #3904.
Also: remove an test which is always true. (CVS 6745)

FossilOrigin-Name: 78a391dca05dbe3ad1d8124b80b31bc2ce75778f

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

index a05d3e7c5aff0c0c3b9bf58bbc316a53765d48c6..3a6ed3ef3d603d5a0a50979d2c2fe9d1d732b8f8 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\sa\sNEVER()\sthat\scan\ssometimes\soccur\son\san\sOOM\serror.\s(CVS\s6744)
-D 2009-06-10T11:07:01
+C Do\snot\slet\sthe\sreverse_unordered_selects\spragma\sforce\sthe\suse\sof\san\sindex\sthat\r\nwould\snot\sotherwise\sbe\sused.\s\sTicket\s#3904.\r\nAlso:\sremove\san\stest\swhich\sis\salways\strue.\s(CVS\s6745)
+D 2009-06-10T19:33:29
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 8b8fb7823264331210cddf103831816c286ba446
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -212,7 +212,7 @@ F src/vdbeblob.c c25d7e7bc6d5917feeb17270bd275fa771f26e5c
 F src/vdbemem.c 05183d46094aa99b8f8350e5761b9369dbef35a8
 F src/vtab.c e2f4c92df7d06330b151448718c4724742ff444b
 F src/walker.c ec4b9742a4077ef80346e2f9aaf0f44c2d95087a
-F src/where.c 70440f8c14ca866c6980153d2460840a88a729d7
+F src/where.c cbf29fc2b8b8011500f11523ccaa2bd86f33d1ba
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
 F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45
@@ -706,7 +706,7 @@ F test/where7.test b6e84b472a024e45c6dbdadc52bbcab3fcc8d0e1
 F test/where8.test 4839a0a1447e178a9a0725c5136fb963445e7708
 F test/where8m.test da346596e19d54f0aba35ebade032a7c47d79739
 F test/where9.test be19e1a92f80985c1a121b4678bf7d2123eaa623
-F test/whereA.test 522469ca013ff97c81b5367e730042290889a061
+F test/whereA.test 1d1674254614147c866ab9b59af6582f454a858c
 F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31
 F test/zeroblob.test 792124852ec61458a2eb527b5091791215e0be95
 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
@@ -733,7 +733,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P 9ace995910c8b0b9e95dc20fd70be487199e37af
-R 2cecd4983d351cd4a46724b94b6d66c5
+P c27f23bbafd2e4fa453c8e3b83667ea8173183a7
+R 77cbdb78ecef08356b37cf19f9a70883
 U drh
-Z ab21f098e14a1ba35a0f308bb93f9a53
+Z 1f50addb00094da913f2d4235a78d8cc
index 4f5567b828b801aa7b63e563a5ce9e3669ca8fa4..4af6b4e41730fd1f927b42b58c73c47718337519 100644 (file)
@@ -1 +1 @@
-c27f23bbafd2e4fa453c8e3b83667ea8173183a7
\ No newline at end of file
+78a391dca05dbe3ad1d8124b80b31bc2ce75778f
\ No newline at end of file
index 3c21325a9c3cc52b6cc4ef8ea37f28ca7d057bc0..d02dd6d4cdaa6e2170a8240ca94c0bc9bdde5981 100644 (file)
@@ -16,7 +16,7 @@
 ** so is applicable.  Because this module is responsible for selecting
 ** indices, you might also think of this module as the "query optimizer".
 **
-** $Id: where.c,v 1.404 2009/06/08 19:44:37 drh Exp $
+** $Id: where.c,v 1.405 2009/06/10 19:33:29 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -1884,7 +1884,7 @@ static void bestVirtualIndex(
     pCost->rCost = pIdxInfo->estimatedCost;
   }
   pCost->plan.u.pVtabIdx = pIdxInfo;
-  if( pIdxInfo && pIdxInfo->orderByConsumed ){
+  if( pIdxInfo->orderByConsumed ){
     pCost->plan.wsFlags |= WHERE_ORDERBY;
   }
   pCost->plan.nEq = 0;
@@ -2170,7 +2170,7 @@ static void bestBtreeIndex(
         cost += cost*estLog(cost);
         WHERETRACE(("...... orderby increases cost to %.9g\n", cost));
       }
-    }else if( pParse->db->flags & SQLITE_ReverseOrder ){
+    }else if( wsFlags!=0 && (pParse->db->flags & SQLITE_ReverseOrder)!=0 ){
       /* For application testing, randomly reverse the output order for
       ** SELECT statements that omit the ORDER BY clause.  This will help
       ** to find cases where
index a6f1723c610ed8833fccd8c33033db739751660a..64253adcd32f57def44748c3af963a30cd4f243d 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library. The
 # focus of this file is testing the reverse_select_order pragma.
 #
-# $Id: whereA.test,v 1.2 2009/04/06 12:26:58 drh Exp $
+# $Id: whereA.test,v 1.3 2009/06/10 19:33:29 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -86,6 +86,41 @@ do_test whereA-4.1 {
     SELECT x FROM t2;
   }
 } {2 1}
+# Do an SQL statement.  Append the search count to the end of the result.
+#
+proc count sql {
+  set ::sqlite_sort_count 0
+  return [concat [execsql $sql] $::sqlite_sort_count]
+}
+do_test whereA-4.2 {   ;# Ticket #3904
+  db eval {
+    CREATE INDEX t2x ON t2(x);
+  }
+  count {
+    SELECT x FROM t2;
+  }
+} {2 1 0}
+do_test whereA-4.3 {
+  count {
+    SELECT x FROM t2 ORDER BY x;
+  }
+} {1 2 0}
+do_test whereA-4.4 {
+  count {
+    SELECT x FROM t2 ORDER BY x DESC;
+  }
+} {2 1 0}
+do_test whereA-4.5 {
+  db eval {DROP INDEX t2x;}
+  count {
+    SELECT x FROM t2 ORDER BY x;
+  }
+} {1 2 1}
+do_test whereA-4.6 {
+  count {
+    SELECT x FROM t2 ORDER BY x DESC;
+  }
+} {2 1 1}
 
 
 finish_test