]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix test cases so that they work when the query planner uses index size
authordrh <drh@noemail.net>
Fri, 4 Oct 2013 15:58:59 +0000 (15:58 +0000)
committerdrh <drh@noemail.net>
Fri, 4 Oct 2013 15:58:59 +0000 (15:58 +0000)
estimates to determine whether or not to try an covering index scan.

FossilOrigin-Name: 2f394de88f23dacd3c61e586a4214ffc6f927d97

manifest
manifest.uuid
test/eqp.test
test/subquery.test
test/tkt-78e04e52ea.test
test/where.test
test/where2.test

index 2f950ae9310f6d0d87e52df7334e9d5435945740..9866008b21702ef0ea61797d820564b81e489a97 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Improved\sestimates\sof\sthe\srelative\sspeed\sof\sindex\sscans\sbased\son\sdeclared\ndatatypes\sof\scolumns\sin\sthe\stable.\s\sAdd\s"r"\scolumn\sto\sPRAGMA\sindex_info,\nshowing\sthe\sestimated\srelative\sscan\srate.
-D 2013-10-04T15:30:21.142
+C Fix\stest\scases\sso\sthat\sthey\swork\swhen\sthe\squery\splanner\suses\sindex\ssize\nestimates\sto\sdetermine\swhether\sor\snot\sto\stry\san\scovering\sindex\sscan.
+D 2013-10-04T15:58:59.585
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -446,7 +446,7 @@ F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea
 F test/enc2.test 83437a79ba1545a55fb549309175c683fb334473
 F test/enc3.test 90683ad0e6ea587b9d5542ca93568af9a9858c40
 F test/enc4.test c8f1ce3618508fd0909945beb8b8831feef2c020
-F test/eqp.test d4386348af3088a01fd21fb27badaa553c3ba7bd
+F test/eqp.test 57c6c604c2807fb5531731c5323133453c24afac
 F test/errmsg.test 050717f1c6a5685de9c79f5f9f6b83d7c592f73a
 F test/eval.test bc269c365ba877554948441e91ad5373f9f91be3
 F test/exclusive.test c7ebbc756eacf544c108b15eed64d7d4e5f86b75
@@ -808,7 +808,7 @@ F test/spellfix.test 8c40b169b104086d8795781f670ba3c786d6d8be
 F test/sqllimits1.test b1aae27cc98eceb845e7f7adf918561256e31298
 F test/stat.test be8d477306006ec696bc86757cfb34bec79447ce
 F test/stmt.test 25d64e3dbf9a3ce89558667d7f39d966fe2a71b9
-F test/subquery.test 3b97763ada8b3a4092d2c80db3ebc0e7870e7eaf
+F test/subquery.test 666fdecceac258f5fd84bed09a64e49d9f37edd9
 F test/subquery2.test 91e1e364072aeff431d1f9689b15147e421d88c7
 F test/subselect.test d24fd8757daf97dafd2e889c73ea4c4272dcf4e4
 F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a
@@ -854,7 +854,7 @@ F test/tkt-5e10420e8d.test 904d1687b3c06d43e5b3555bbcf6802e7c0ffd84
 F test/tkt-5ee23731f.test 9db6e1d7209dc0794948b260d6f82b2b1de83a9f
 F test/tkt-6bfb98dfc0.test 24780633627b5cfc0635a5500c2389ebfb563336
 F test/tkt-752e1646fc.test ea78d88d14fe9866bdd991c634483334639e13bf
-F test/tkt-78e04e52ea.test 787b70cfb0488c356266bb8d5ad8a657f9efceb8
+F test/tkt-78e04e52ea.test b0190d3375cf88b97d32188149cc99ccf22f556b
 F test/tkt-7a31705a7e6.test e75a2bba4eec801b92c8040eb22096ac6d35e844
 F test/tkt-7bbfb7d442.test 7b2cd79c7a17ae6750e75ec1a7846712a69c9d18
 F test/tkt-80ba201079.test 105a721e6aad0ae3c5946d7615d1e4d03f6145b8
@@ -1048,8 +1048,8 @@ F test/walro.test 6cc247a0cc9b36aeea2057dd28a922a1cdfbd630
 F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417
 F test/walslow.test e7be6d9888f83aa5d3d3c7c08aa9b5c28b93609a
 F test/walthread.test de8dbaf6d9e41481c460ba31ca61e163d7348f8e
-F test/where.test 8d66dfbfd4d12816f74f854dbf67dee492c06267
-F test/where2.test 76d5346f7edb2a6a0442dcf3e9d088ac6903e0b5
+F test/where.test 701a633ed16c661cd597b9d504b485197a0f49d7
+F test/where2.test ed6baa9420a109d8be683dbef5d153d186f3690b
 F test/where3.test d28c51f257e60be30f74308fa385ceeddfb54a6e
 F test/where4.test e9b9e2f2f98f00379e6031db6a6fca29bae782a2
 F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2
@@ -1119,7 +1119,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
-P 6c352edbba85a15ca356b5e131f4b3b2723d1774
-R bacabbd9616babddd027da683b20e83a
+P 07462bb6059f023c22a6c84a4a02afbd84e69255
+R c53ee7ecd2949869b611b9550600e22e
 U drh
-Z 469f9776554648d8f1435b44fd89545f
+Z 3b4f199613fede1bea11e11c52c662ed
index 4822e4715eac7d3d8efe838ffe91dd630a1121a8..e4be6b3824f99c841e672c93f61d3ed89b3db559 100644 (file)
@@ -1 +1 @@
-07462bb6059f023c22a6c84a4a02afbd84e69255
\ No newline at end of file
+2f394de88f23dacd3c61e586a4214ffc6f927d97
\ No newline at end of file
index 89bda719e3832f2602ee247be4c3939b60b687c2..610ebdc5ca1eb708d42b451b20cd63afcf8021a2 100644 (file)
@@ -496,7 +496,7 @@ det 5.11 "SELECT a, b FROM (SELECT * FROM t2 WHERE c=1), t1" {
 # 2|0|0|SCAN TABLE t2
 # 0|0|0|COMPOUND SUBQUERIES 1 AND 2 USING TEMP B-TREE (UNION)
 #
-det 5.12 "SELECT a FROM t1 UNION SELECT c FROM t2" {
+det 5.12 "SELECT a,b FROM t1 UNION SELECT c, 99 FROM t2" {
   1 0 0 {SCAN TABLE t1 USING COVERING INDEX i2}
   2 0 0 {SCAN TABLE t2 USING COVERING INDEX i4}
   0 0 0 {COMPOUND SUBQUERIES 1 AND 2 USING TEMP B-TREE (UNION)}
@@ -509,7 +509,7 @@ det 5.12 "SELECT a FROM t1 UNION SELECT c FROM t2" {
 # 0|0|0|COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)
 #
 det 5.13 "SELECT a FROM t1 EXCEPT SELECT d FROM t2 ORDER BY 1" {
-  1 0 0 {SCAN TABLE t1 USING COVERING INDEX i2}
+  1 0 0 {SCAN TABLE t1 USING COVERING INDEX i1}
   2 0 0 {SCAN TABLE t2}
   2 0 0 {USE TEMP B-TREE FOR ORDER BY}
   0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)}
@@ -548,7 +548,7 @@ proc do_peqp_test {tn sql res} {
 }
 
 do_peqp_test 6.1 {
-  SELECT a FROM t1 EXCEPT SELECT d FROM t2 ORDER BY 1
+  SELECT a, b FROM t1 EXCEPT SELECT d, 99 FROM t2 ORDER BY 1
 } [string trimleft {
 1 0 0 SCAN TABLE t1 USING COVERING INDEX i2
 2 0 0 SCAN TABLE t2
@@ -563,8 +563,8 @@ do_peqp_test 6.1 {
 drop_all_tables
 
 do_execsql_test 7.0 {
-  CREATE TABLE t1(a INT, b INT, ex TEXT);
-  CREATE TABLE t2(a INT, b INT, ex TEXT);
+  CREATE TABLE t1(a INT, b INT, ex CHAR(100));
+  CREATE TABLE t2(a INT, b INT, ex CHAR(100));
   CREATE INDEX i1 ON t2(a);
 }
 
@@ -577,12 +577,12 @@ det 7.2 "SELECT count(*) FROM t2" {
 }
 
 do_execsql_test 7.3 {
-  INSERT INTO t1 VALUES(1, 2);
-  INSERT INTO t1 VALUES(3, 4);
+  INSERT INTO t1(a,b) VALUES(1, 2);
+  INSERT INTO t1(a,b) VALUES(3, 4);
 
-  INSERT INTO t2 VALUES(1, 2);
-  INSERT INTO t2 VALUES(3, 4);
-  INSERT INTO t2 VALUES(5, 6);
+  INSERT INTO t2(a,b) VALUES(1, 2);
+  INSERT INTO t2(a,b) VALUES(3, 4);
+  INSERT INTO t2(a,b) VALUES(5, 6);
  
   ANALYZE;
 }
index da0a44cc5cca16932ee60002c0440108e7f6b409..93c3f28ddbb7e17f06cf406026f96acc808bfbcc 100644 (file)
@@ -245,7 +245,7 @@ do_test subquery-2.5.3.2 {
     EXPLAIN QUERY PLAN
     SELECT * FROM t4 WHERE x IN (SELECT a FROM t3);
   }
-} {/SCAN TABLE t4 /}
+} {~/t4i/}
 do_test subquery-2.5.4 {
   execsql {
     DROP TABLE t3;
index e906d3b7f986044748b2237c1dee7f47fd840ad7..dde6502a9de60d0c8be6caf37641bc74f21b783a 100644 (file)
@@ -18,23 +18,23 @@ source $testdir/tester.tcl
 
 do_test tkt-78e04-1.0 {
   execsql {
-    CREATE TABLE ""("" UNIQUE);
+    CREATE TABLE ""("" UNIQUE, x CHAR(100));
     CREATE TABLE t2(x);
-    INSERT INTO "" VALUES(1);
+    INSERT INTO ""("") VALUES(1);
     INSERT INTO t2 VALUES(2);
     SELECT * FROM "", t2;
   }
-} {1 2}
+} {1 {} 2}
 do_test tkt-78e04-1.1 {
   catchsql {
-    INSERT INTO "" VALUES(1);
+    INSERT INTO ""("") VALUES(1);
   }
 } {1 {column  is not unique}}
 do_test tkt-78e04-1.2 {
   execsql {
     PRAGMA table_info("");
   }
-} {0 {} {} 0 {} 0}
+} {0 {} {} 0 {} 0 1 x CHAR(100) 0 {} 0}
 do_test tkt-78e04-1.3 {
   execsql {
     CREATE INDEX i1 ON ""("" COLLATE nocase);
@@ -42,7 +42,7 @@ do_test tkt-78e04-1.3 {
 } {}
 do_test tkt-78e04-1.4 {
   execsql {
-    EXPLAIN QUERY PLAN SELECT * FROM "" WHERE "" LIKE 'abc%';
+    EXPLAIN QUERY PLAN SELECT "" FROM "" WHERE "" LIKE 'abc%';
   }
 } {0 0 0 {SCAN TABLE  USING COVERING INDEX i1}}
 do_test tkt-78e04-1.5 {
index 09ad0bce6d9c2be4a6ed2e1d36e6ca4acf5f8303..a50fe7ebcf0858e8e34171127e92cd395d4689ad 100644 (file)
@@ -1125,9 +1125,9 @@ do_test where-13.12 {
 if {[permutation] != "no_optimization"} {
 do_test where-14.1 {
   execsql {
-    CREATE TABLE t8(a INTEGER PRIMARY KEY, b TEXT UNIQUE);
-    INSERT INTO t8 VALUES(1,'one');
-    INSERT INTO t8 VALUES(4,'four');
+    CREATE TABLE t8(a INTEGER PRIMARY KEY, b TEXT UNIQUE, c CHAR(100));
+    INSERT INTO t8(a,b) VALUES(1,'one');
+    INSERT INTO t8(a,b) VALUES(4,'four');
   }
   cksort {
     SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, y.b
index a3858c59093fa389fdb570b070371a73ac0e72f9..45ea486d959577608eba0eae22060cd39491a743 100644 (file)
@@ -314,9 +314,9 @@ if {[permutation] != "no_optimization"} {
 #
 do_test where2-6.7 {
   execsql {
-    CREATE TABLE t2249a(a TEXT UNIQUE);
+    CREATE TABLE t2249a(a TEXT UNIQUE, x CHAR(100));
     CREATE TABLE t2249b(b INTEGER);
-    INSERT INTO t2249a VALUES('0123');
+    INSERT INTO t2249a(a) VALUES('0123');
     INSERT INTO t2249b VALUES(123);
   }
   queryplan {
@@ -324,7 +324,7 @@ do_test where2-6.7 {
     -- will attempt to convert to NUMERIC before the comparison.
     -- They will thus compare equal.
     --
-    SELECT * FROM t2249b CROSS JOIN t2249a WHERE a=b;
+    SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE a=b;
   }
 } {123 0123 nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
 do_test where2-6.9 {
@@ -332,13 +332,13 @@ do_test where2-6.9 {
     -- The + operator removes affinity from the rhs.  No conversions
     -- occur and the comparison is false.  The result is an empty set.
     --
-    SELECT * FROM t2249b CROSS JOIN t2249a WHERE a=+b;
+    SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE a=+b;
   }
 } {nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
 do_test where2-6.9.2 {
   # The same thing but with the expression flipped around.
   queryplan {
-    SELECT * FROM t2249b CROSS JOIN t2249a WHERE +b=a
+    SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE +b=a
   }
 } {nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
 do_test where2-6.10 {
@@ -346,32 +346,32 @@ do_test where2-6.10 {
     -- Use + on both sides of the comparison to disable indices
     -- completely.  Make sure we get the same result.
     --
-    SELECT * FROM t2249b CROSS JOIN t2249a WHERE +a=+b;
+    SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE +a=+b;
   }
 } {nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
 do_test where2-6.11 {
   # This will not attempt the OR optimization because of the a=b
   # comparison.
   queryplan {
-    SELECT * FROM t2249b CROSS JOIN t2249a WHERE a=b OR a='hello';
+    SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE a=b OR a='hello';
   }
 } {123 0123 nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
 do_test where2-6.11.2 {
   # Permutations of the expression terms.
   queryplan {
-    SELECT * FROM t2249b CROSS JOIN t2249a WHERE b=a OR a='hello';
+    SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE b=a OR a='hello';
   }
 } {123 0123 nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
 do_test where2-6.11.3 {
   # Permutations of the expression terms.
   queryplan {
-    SELECT * FROM t2249b CROSS JOIN t2249a WHERE 'hello'=a OR b=a;
+    SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE 'hello'=a OR b=a;
   }
 } {123 0123 nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
 do_test where2-6.11.4 {
   # Permutations of the expression terms.
   queryplan {
-    SELECT * FROM t2249b CROSS JOIN t2249a WHERE a='hello' OR b=a;
+    SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE a='hello' OR b=a;
   }
 } {123 0123 nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
 ifcapable explain&&subquery {
@@ -385,7 +385,7 @@ ifcapable explain&&subquery {
     # the OR optimization to be used again.  The result is now an empty
     # set, the same as in where2-6.9.
     queryplan {
-      SELECT * FROM t2249b CROSS JOIN t2249a WHERE a=+b OR a='hello';
+      SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE a=+b OR a='hello';
     }
   } {nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
   do_test where2-6.12.2 {
@@ -393,7 +393,7 @@ ifcapable explain&&subquery {
     # the OR optimization to be used again.  The result is now an empty
     # set, the same as in where2-6.9.
     queryplan {
-      SELECT * FROM t2249b CROSS JOIN t2249a WHERE a='hello' OR +b=a;
+      SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE a='hello' OR +b=a;
     }
   } {nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
   do_test where2-6.12.3 {
@@ -401,14 +401,14 @@ ifcapable explain&&subquery {
     # the OR optimization to be used again.  The result is now an empty
     # set, the same as in where2-6.9.
     queryplan {
-      SELECT * FROM t2249b CROSS JOIN t2249a WHERE +b=a OR a='hello';
+      SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE +b=a OR a='hello';
     }
   } {nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
   do_test where2-6.13 {
     # The addition of +a on the second term disabled the OR optimization.
     # But we should still get the same empty-set result as in where2-6.9.
     queryplan {
-      SELECT * FROM t2249b CROSS JOIN t2249a WHERE a=+b OR +a='hello';
+      SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE a=+b OR +a='hello';
     }
   } {nosort t2249b * t2249a sqlite_autoindex_t2249a_1}
 }
@@ -417,7 +417,7 @@ ifcapable explain&&subquery {
 # to make sure the OR optimizer can recognize them all.
 do_test where2-6.20 {
   queryplan {
-    SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE x.a=y.a
+    SELECT x.a, y.a FROM t2249a x CROSS JOIN t2249a y WHERE x.a=y.a
   }
 } {0123 0123 nosort x sqlite_autoindex_t2249a_1 y sqlite_autoindex_t2249a_1}
 ifcapable explain&&subquery {
@@ -428,17 +428,20 @@ ifcapable explain&&subquery {
   #
   do_test where2-6.21 {
     queryplan {
-      SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE x.a=y.a OR y.a='hello'
+      SELECT x.a,y.a FROM t2249a x CROSS JOIN t2249a y
+       WHERE x.a=y.a OR y.a='hello'
     }
   } {0123 0123 nosort x sqlite_autoindex_t2249a_1 y sqlite_autoindex_t2249a_1}
   do_test where2-6.22 {
     queryplan {
-      SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE y.a=x.a OR y.a='hello'
+      SELECT x.a,y.a FROM t2249a x CROSS JOIN t2249a y
+       WHERE y.a=x.a OR y.a='hello'
     }
   } {0123 0123 nosort x sqlite_autoindex_t2249a_1 y sqlite_autoindex_t2249a_1}
   do_test where2-6.23 {
     queryplan {
-      SELECT * FROM t2249a x CROSS JOIN t2249a y WHERE y.a='hello' OR x.a=y.a
+      SELECT x.a,y.a FROM t2249a x CROSS JOIN t2249a y
+       WHERE y.a='hello' OR x.a=y.a
     }
   } {0123 0123 nosort x sqlite_autoindex_t2249a_1 y sqlite_autoindex_t2249a_1}
 }
@@ -703,7 +706,7 @@ do_test where2-11.4 {
 # the OR clause scores slightly better on an inner loop.
 if {[permutation] != "no_optimization"} {
 do_execsql_test where2-12.1 {
-  CREATE TABLE t12(x INTEGER PRIMARY KEY, y);
+  CREATE TABLE t12(x INTEGER PRIMARY KEY, y INT, z CHAR(100));
   CREATE INDEX t12y ON t12(y);
   EXPLAIN QUERY PLAN
     SELECT a.x, b.x