]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
More test cases for the OR optimization.
authordrh <drh@noemail.net>
Fri, 7 Oct 2011 16:08:28 +0000 (16:08 +0000)
committerdrh <drh@noemail.net>
Fri, 7 Oct 2011 16:08:28 +0000 (16:08 +0000)
FossilOrigin-Name: 4997d8b81cd3ea7c708911bfece00020d11224f9

manifest
manifest.uuid
test/where7.test
test/where9.test

index d40e0138a71f4a32a0aa19d2fbc2573079d1dfa8..67d3608db63f9f0dbe216bb5abfb78e8f8ccdfd8 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Prevent\sinfinite\srecursion\sof\sin\sthe\squery\splanner\sfor\ssome\spathological\ntest\scases\sby\sdisabling\sOR-clause\sprocessing\supon\sfirst\srecursion.
-D 2011-10-07T14:40:59.269
+C More\stest\scases\sfor\sthe\sOR\soptimization.
+D 2011-10-07T16:08:28.818
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -916,10 +916,10 @@ F test/where3.test 8e1175c7ef710c70502858fc4fb08d784b3620b9
 F test/where4.test e9b9e2f2f98f00379e6031db6a6fca29bae782a2
 F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2
 F test/where6.test 5da5a98cec820d488e82708301b96cb8c18a258b
-F test/where7.test aa4cfcd6f66e2a4ef87b6717327325bf4d547502
+F test/where7.test 814d7373413398e074f134cff5f8872e2c08bd3b
 F test/where8.test a6c740fd286d7883e274e17b6230a9d672a7ab1f
 F test/where8m.test da346596e19d54f0aba35ebade032a7c47d79739
-F test/where9.test 24f19ad14bb1b831564ced5273e681e495662848
+F test/where9.test bed66dcfc69a54a99661c0c9906189cb5e58f4e2
 F test/whereA.test 24c234263c8fe358f079d5e57d884fb569d2da0a
 F test/whereB.test 0def95db3bdec220a731c7e4bec5930327c1d8c5
 F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31
@@ -967,7 +967,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5
 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
-P 876bd21aaac444c7e056730e35696a74e9a1af0a
-R 2e052ba91d5f74c653875a92f40f0614
+P 9fca05eac503d712886a05d03794f76c61fb39ed
+R bd6384414b9b60e15876987ee9f999e9
 U drh
-Z ec0c9bad465d9d136336e81b2a3d87e4
+Z 427731fab44d769232d079e056d051e3
index a9d34afed4dc5b11ea572d8afb2bc79f8cfc0ea0..937b15f8435efcb63c6097a9cc0a2f8d9abb13ef 100644 (file)
@@ -1 +1 @@
-9fca05eac503d712886a05d03794f76c61fb39ed
\ No newline at end of file
+4997d8b81cd3ea7c708911bfece00020d11224f9
\ No newline at end of file
index e34778c76311f076a8f54da088090125c7b7a8a6..ffb7173d21f6fa327f375b4c975f10fc6eeaa164 100644 (file)
@@ -10,8 +10,6 @@
 #***********************************************************************
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the multi-index OR clause optimizer.
-#
-# $Id: where7.test,v 1.9 2009/06/07 23:45:11 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -23341,7 +23339,7 @@ do_execsql_test where7-3.1 {
            OR t301.c8 = 1407424651264000)
    ORDER BY t302.c5 LIMIT 200;
 } {
-  0 0 1 {SEARCH TABLE t301 USING COVERING INDEX t301_c4 (c4=?) (~10 rows)} 
+  0 0 1 {SEARCH TABLE t301 USING COVERING INDEX t301_c4 (c4=?) (~5 rows)} 
   0 0 1 {SEARCH TABLE t301 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)} 
   0 1 0 {SEARCH TABLE t302 USING INDEX t302_c8_c3 (c8=? AND c3>?) (~2 rows)} 
   0 0 0 {USE TEMP B-TREE FOR ORDER BY}
index 9a180116a83947fc9a2ccb44d5c0c9798b1d5509..b4a2d8d130ebf828f336f7bc2d405149309f677f 100644 (file)
@@ -11,7 +11,6 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the multi-index OR clause optimizer.
 #
-# $Id: where9.test,v 1.9 2009/06/05 17:09:12 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -365,7 +364,7 @@ ifcapable explain {
   } {
     0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)} 
     0 1 1 {SEARCH TABLE t2 USING INDEX t2d (d=?) (~2 rows)} 
-    0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~10 rows)}
+    0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~5 rows)}
   }
   do_execsql_test where9-3.2 {
     EXPLAIN QUERY PLAN
@@ -375,7 +374,7 @@ ifcapable explain {
   } {
     0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)} 
     0 1 1 {SEARCH TABLE t2 USING INDEX t2d (d=?) (~2 rows)} 
-    0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~10 rows)}
+    0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?) (~5 rows)}
   }
 } 
 
@@ -454,8 +453,8 @@ ifcapable explain {
   do_execsql_test where9-5.1 {
     EXPLAIN QUERY PLAN SELECT a FROM t1 WHERE b>1000 AND (c=31031 OR d IS NULL)
   } {
-    0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c=?) (~10 rows)} 
-    0 0 0 {SEARCH TABLE t1 USING INDEX t1d (d=?) (~10 rows)}
+    0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c=?) (~2 rows)} 
+    0 0 0 {SEARCH TABLE t1 USING INDEX t1d (d=?) (~2 rows)}
   }
 
   # In contrast, b=1000 is preferred over any OR-clause.
@@ -783,4 +782,79 @@ do_test where9-6.8.2 {
   }
 } {1 {cannot use index: t1b}}
 
+############################################################################
+# Test cases where terms inside an OR series are combined with AND terms
+# external to the OR clause.  In other words, cases where
+#
+#              x AND (y OR z)
+#
+# is able to use indices on x,y and x,z, or indices y,x and z,x.
+#
+do_test where9-7.0 {
+  execsql {
+    CREATE TABLE t5(a, b, c, d, e, f, g, x, y);
+    INSERT INTO t5
+     SELECT a, b, c, e, d, f, g,
+            CASE WHEN (a&1)!=0 THEN 'y' ELSE 'n' END,
+            CASE WHEN (a&2)!=0 THEN 'y' ELSE 'n' END
+       FROM t1;
+    CREATE INDEX t5xb ON t5(x, b);
+    CREATE INDEX t5xc ON t5(x, c);
+    CREATE INDEX t5xd ON t5(x, d);
+    CREATE INDEX t5xe ON t5(x, e);
+    CREATE INDEX t5xf ON t5(x, f);
+    CREATE INDEX t5xg ON t5(x, g);
+    CREATE INDEX t5yb ON t5(y, b);
+    CREATE INDEX t5yc ON t5(y, c);
+    CREATE INDEX t5yd ON t5(y, d);
+    CREATE INDEX t5ye ON t5(y, e);
+    CREATE INDEX t5yf ON t5(y, f);
+    CREATE INDEX t5yg ON t5(y, g);
+    CREATE TABLE t6(a, b, c, e, d, f, g, x, y);
+    INSERT INTO t6 SELECT * FROM t5;
+    ANALYZE t5;
+  }
+} {}
+do_test where9-7.1.1 {
+  count_steps {
+    SELECT a FROM t5 WHERE x='y' AND (b=913 OR c=27027) ORDER BY a;
+  }
+} {79 81 83 scan 0 sort 1}
+do_test where9-7.1.2 {
+  execsql {
+    SELECT a FROM t6 WHERE x='y' AND (b=913 OR c=27027) ORDER BY a;
+  }
+} {79 81 83}
+do_test where9-7.1.3 {
+  count_steps {
+    SELECT a FROM t5 WHERE x='n' AND (b=913 OR c=27027) ORDER BY a;
+  }
+} {80 scan 0 sort 1}
+do_test where9-7.1.4 {
+  execsql {
+    SELECT a FROM t6 WHERE x='n' AND (b=913 OR c=27027) ORDER BY a;
+  }
+} {80}
+do_test where9-7.2.1 {
+  count_steps {
+    SELECT a FROM t5 WHERE (x='y' OR y='y') AND b=913 ORDER BY a;
+  }
+} {83 scan 0 sort 1}
+do_test where9-7.2.2 {
+  execsql {
+    SELECT a FROM t6 WHERE (x='y' OR y='y') AND b=913 ORDER BY a;
+  }
+} {83}
+do_test where9-7.3.1 {
+  count_steps {
+    SELECT a FROM t5 WHERE (x='y' OR y='y') AND c=27027 ORDER BY a;
+  }
+} {79 81 scan 0 sort 1}
+do_test where9-7.3.2 {
+  execsql {
+    SELECT a FROM t6 WHERE (x='y' OR y='y') AND c=27027 ORDER BY a;
+  }
+} {79 81}
+
+
 finish_test