]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add a few more tests to where8.test. (CVS 6081)
authordanielk1977 <danielk1977@noemail.net>
Tue, 30 Dec 2008 15:26:29 +0000 (15:26 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Tue, 30 Dec 2008 15:26:29 +0000 (15:26 +0000)
FossilOrigin-Name: ac28aa8b618d59628c5b8fc6fe649ec14f554b11

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

index 37cd9666fc356d4e118e7f9b566d1daff3b77f5a..c44a076e3040a41a7efbffb438a879702700fd05 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Still\smore\stest\scases\sin\swhere7.test.\s(CVS\s6080)
-D 2008-12-30T14:40:07
+C Add\sa\sfew\smore\stests\sto\swhere8.test.\s(CVS\s6081)
+D 2008-12-30T15:26:30
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 77635d0909c2067cee03889a1e04ce910d8fb809
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -207,7 +207,7 @@ F src/vdbeblob.c b0dcebfafedcf9c0addc7901ad98f6f986c08935
 F src/vdbemem.c f9c859ac17e2e05a0f249868ce4f191f69edd31d
 F src/vtab.c e39e011d7443a8d574b1b9cde207a35522e6df43
 F src/walker.c 488c2660e13224ff70c0c82761118efb547f8f0d
-F src/where.c 924e77c6ebeb5980a32a4653c77e6838efa47da9
+F src/where.c 44df523c544a5ed7f835204cace4ef822f62e9c5
 F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
 F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911
@@ -656,7 +656,7 @@ F test/where4.test e9b9e2f2f98f00379e6031db6a6fca29bae782a2
 F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2
 F test/where6.test 42c4373595f4409d9c6a9987b4a60000ad664faf
 F test/where7.test c56c34e84f2bf8d4c787cf8ee6ce8b705468b8cb
-F test/where8.test 81036f3f79054309da744fcffc9ce7ed97b5b4a9
+F test/where8.test f569052bbcb1a4cdf51253601a5f842ef7214596
 F test/where8m.test c1010d61826412ff66abd29bfb32e5d6b37d965c
 F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31
 F test/zeroblob.test 792124852ec61458a2eb527b5091791215e0be95
@@ -688,7 +688,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 174985831f9c8f5c393556d3248b01852573abc7
-R 17851a9df220a820ebc78b7af26f16ec
-U drh
-Z 43c0beeea443c43af52158e52be780a2
+P eb9ba5fe70df56ee00828f7dbaf71ae6f825737d
+R be8fa39373cf50cd69d05e36043c5b90
+U danielk1977
+Z a0d645d228413702b70dae200239a68c
index d842132c3db7a9cdf3f66368210a508336202177..0f0c29c5bd0c0ac72ca790747d9cdf21363c59dc 100644 (file)
@@ -1 +1 @@
-eb9ba5fe70df56ee00828f7dbaf71ae6f825737d
\ No newline at end of file
+ac28aa8b618d59628c5b8fc6fe649ec14f554b11
\ No newline at end of file
index 061b38a6d86d460d1cc7096021e79804909ad6ee..c0a5481fe458343e60296daa42908da2c05ae479 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.352 2008/12/30 12:00:12 danielk1977 Exp $
+** $Id: where.c,v 1.353 2008/12/30 15:26:30 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 
@@ -576,14 +576,12 @@ static WhereTerm *findTerm(
         */
         assert(pX->pLeft);
         pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight);
-        if( !pColl ){
-          pColl = pParse->db->pDfltColl;
-        }
+        assert(pColl || pParse->nErr);
 
         for(j=0; pIdx->aiColumn[j]!=iColumn; j++){
           if( NEVER(j>=pIdx->nColumn) ) return 0;
         }
-        if( sqlite3StrICmp(pColl->zName, pIdx->azColl[j]) ) continue;
+        if( pColl && sqlite3StrICmp(pColl->zName, pIdx->azColl[j]) ) continue;
       }
       return pTerm;
     }
index ecda8cf8da04c346c8f871d1fc4e805baf6fafd7..eacc0b472e7ce31a35c8e5569353d07fa8b71bbc 100644 (file)
@@ -12,7 +12,7 @@
 # is testing of where.c. More specifically, the focus is the optimization
 # of WHERE clauses that feature the OR operator.
 #
-# $Id: where8.test,v 1.2 2008/12/30 12:00:12 danielk1977 Exp $
+# $Id: where8.test,v 1.3 2008/12/30 15:26:30 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -296,10 +296,182 @@ do_test where8-3.15 {
 #
 do_test where8-4.1 {
   execsql {
+    BEGIN;
     CREATE TABLE t3(a INTEGER, b REAL, c TEXT);
     CREATE TABLE t4(f INTEGER, g REAL, h TEXT);
+    INSERT INTO t3 VALUES('hills', NULL, 1415926535);
+    INSERT INTO t3 VALUES('and', 'of', NULL);
+    INSERT INTO t3 VALUES('have', 'towering', 53594.08128);
+    INSERT INTO t3 VALUES(NULL, 45.64856692, 'Not');
+    INSERT INTO t3 VALUES('same', 5028841971, NULL);
+    INSERT INTO t3 VALUES('onlookers', 'in', 8214808651);
+    INSERT INTO t3 VALUES(346.0348610, 2643383279, NULL);
+    INSERT INTO t3 VALUES(1415926535, 'of', 'are');
+    INSERT INTO t3 VALUES(NULL, 0.4811174502, 'snapshots');
+    INSERT INTO t3 VALUES('over', 'the', 8628034825);
+    INSERT INTO t3 VALUES(8628034825, 66.59334461, 2847564.823);
+    INSERT INTO t3 VALUES('onlookers', 'same', 'and');
+    INSERT INTO t3 VALUES(NULL, 'light', 6939937510);
+    INSERT INTO t3 VALUES('from', 'their', 'viewed');
+    INSERT INTO t3 VALUES('from', 'Alpine', 'snapshots');
+    INSERT INTO t3 VALUES('from', 'sometimes', 'unalike');
+    INSERT INTO t3 VALUES(1339.360726, 'light', 'have');
+    INSERT INTO t3 VALUES(6939937510, 3282306647, 'other');
+    INSERT INTO t3 VALUES('paintings', 8628034825, 'all');
+    INSERT INTO t3 VALUES('paintings', NULL, 'same');
+    INSERT INTO t3 VALUES('Alpine', 378678316.5, 'unalike');
+    INSERT INTO t3 VALUES('Alpine', NULL, 'same');
+    INSERT INTO t3 VALUES(1339.360726, 2847564.823, 'over');
+    INSERT INTO t3 VALUES('villages', 'their', 'have');
+    INSERT INTO t3 VALUES('unalike', 'remarkably', 'in');
+    INSERT INTO t3 VALUES('and', 8979323846, 'and');
+    INSERT INTO t3 VALUES(NULL, 1415926535, 'an');
+    INSERT INTO t3 VALUES(271.2019091, 8628034825, 0.4811174502);
+    INSERT INTO t3 VALUES('all', 3421170679, 'the');
+    INSERT INTO t3 VALUES('Not', 'and', 1415926535);
+    INSERT INTO t3 VALUES('of', 'other', 'light');
+    INSERT INTO t3 VALUES(NULL, 'towering', 'Not');
+    INSERT INTO t3 VALUES(346.0348610, NULL, 'other');
+    INSERT INTO t3 VALUES('Not', 378678316.5, NULL);
+    INSERT INTO t3 VALUES('snapshots', 8628034825, 'of');
+    INSERT INTO t3 VALUES(3282306647, 271.2019091, 'and');
+    INSERT INTO t3 VALUES(50.58223172, 378678316.5, 5028841971);
+    INSERT INTO t3 VALUES(50.58223172, 2643383279, 'snapshots');
+    INSERT INTO t3 VALUES('writings', 8979323846, 8979323846);
+    INSERT INTO t3 VALUES('onlookers', 'his', 'in');
+    INSERT INTO t3 VALUES('unalike', 8628034825, 1339.360726);
+    INSERT INTO t3 VALUES('of', 'Alpine', 'and');
+    INSERT INTO t3 VALUES('onlookers', NULL, 'from');
+    INSERT INTO t3 VALUES('writings', 'it', 1339.360726);
+    INSERT INTO t3 VALUES('it', 'and', 'villages');
+    INSERT INTO t3 VALUES('an', 'the', 'villages');
+    INSERT INTO t3 VALUES(8214808651, 8214808651, 'same');
+    INSERT INTO t3 VALUES(346.0348610, 'light', 1415926535);
+    INSERT INTO t3 VALUES(NULL, 8979323846, 'and');
+    INSERT INTO t3 VALUES(NULL, 'same', 1339.360726);
+    INSERT INTO t4 VALUES('his', 'from', 'an');
+    INSERT INTO t4 VALUES('snapshots', 'or', NULL);
+    INSERT INTO t4 VALUES('Alpine', 'have', 'it');
+    INSERT INTO t4 VALUES('have', 'peak', 'remarkably');
+    INSERT INTO t4 VALUES('hills', NULL, 'Not');
+    INSERT INTO t4 VALUES('same', 'from', 2643383279);
+    INSERT INTO t4 VALUES('have', 'angle', 8628034825);
+    INSERT INTO t4 VALUES('sometimes', 'it', 2847564.823);
+    INSERT INTO t4 VALUES(0938446095, 'peak', 'of');
+    INSERT INTO t4 VALUES(8628034825, 'and', 'same');
+    INSERT INTO t4 VALUES('and', 271.2019091, 'their');
+    INSERT INTO t4 VALUES('the', 'of', 'remarkably');
+    INSERT INTO t4 VALUES('and', 3421170679, 1415926535);
+    INSERT INTO t4 VALUES('and', 'in', 'all');
+    INSERT INTO t4 VALUES(378678316.5, 0.4811174502, 'snapshots');
+    INSERT INTO t4 VALUES('it', 'are', 'have');
+    INSERT INTO t4 VALUES('angle', 'snapshots', 378678316.5);
+    INSERT INTO t4 VALUES('from', 1415926535, 8628034825);
+    INSERT INTO t4 VALUES('snapshots', 'angle', 'have');
+    INSERT INTO t4 VALUES(3421170679, 0938446095, 'Not');
+    INSERT INTO t4 VALUES('peak', NULL, 0.4811174502);
+    INSERT INTO t4 VALUES('same', 'have', 'Alpine');
+    INSERT INTO t4 VALUES(271.2019091, 66.59334461, 0938446095);
+    INSERT INTO t4 VALUES(8979323846, 'his', 'an');
+    INSERT INTO t4 VALUES(NULL, 'and', 3282306647);
+    INSERT INTO t4 VALUES('remarkably', NULL, 'Not');
+    INSERT INTO t4 VALUES('villages', 4543.266482, 'his');
+    INSERT INTO t4 VALUES(2643383279, 'paintings', 'onlookers');
+    INSERT INTO t4 VALUES(1339.360726, 'of', 'the');
+    INSERT INTO t4 VALUES('peak', 'other', 'peak');
+    INSERT INTO t4 VALUES('it', 'or', 8979323846);
+    INSERT INTO t4 VALUES('onlookers', 'Not', 'towering');
+    INSERT INTO t4 VALUES(NULL, 'peak', 'Not');
+    INSERT INTO t4 VALUES('of', 'have', 6939937510);
+    INSERT INTO t4 VALUES('light', 'hills', 0.4811174502);
+    INSERT INTO t4 VALUES(5028841971, 'Not', 'it');
+    INSERT INTO t4 VALUES('and', 'Not', NULL);
+    INSERT INTO t4 VALUES(346.0348610, 'villages', NULL);
+    INSERT INTO t4 VALUES(8979323846, NULL, 6939937510);
+    INSERT INTO t4 VALUES('an', 'light', 'peak');
+    INSERT INTO t4 VALUES(5028841971, 6939937510, 'light');
+    INSERT INTO t4 VALUES('sometimes', 'peak', 'peak');
+    INSERT INTO t4 VALUES(378678316.5, 5028841971, 'an');
+    INSERT INTO t4 VALUES(378678316.5, 'his', 'Alpine');
+    INSERT INTO t4 VALUES('from', 'of', 'all');
+    INSERT INTO t4 VALUES(0938446095, 'same', NULL);
+    INSERT INTO t4 VALUES(0938446095, 'Alpine', NULL);
+    INSERT INTO t4 VALUES('his', 'of', 378678316.5);
+    INSERT INTO t4 VALUES(271.2019091, 'viewed', 3282306647);
+    INSERT INTO t4 VALUES('hills', 'all', 'peak');
+    COMMIT;
   }
 } {}
 
+catch {unset results}
+set A 2
+foreach idxsql {
+  { 
+    /* No indexes */ 
+  } {
+    CREATE INDEX i5 ON t3(a);
+  } {
+    CREATE INDEX i5 ON t3(a, b);
+    CREATE INDEX i6 ON t4(f);
+  } {
+    CREATE UNIQUE INDEX i5 ON t3(a, b);
+    CREATE INDEX i7 ON t3(c);
+    CREATE INDEX i6 ON t4(f);
+    CREATE INDEX i8 ON t4(h);
+  } {
+    CREATE INDEX i5 ON t3(a, b, c);
+    CREATE INDEX i6 ON t4(f, g, h);
+    CREATE INDEX i7 ON t3(c, b, a);
+    CREATE INDEX i8 ON t4(h, g, f);
+  }
+} {
+
+  execsql {
+    DROP INDEX IF EXISTS i5;
+    DROP INDEX IF EXISTS i6;
+    DROP INDEX IF EXISTS i7;
+    DROP INDEX IF EXISTS i8;
+  }
+  execsql $idxsql
+
+  foreach {B sql} {
+ 1  { SELECT * FROM t3 WHERE c LIKE b }
+ 2  { SELECT * FROM t3 WHERE c||'' LIKE 'the%' }
+ 3  { SELECT * FROM t3 WHERE rowid LIKE '12%' }
+ 4  { SELECT * FROM t3 WHERE +c LIKE 'the%' }
+ 5  { SELECT * FROM t3 WHERE c LIKE 'the%' }
+ 6  { SELECT * FROM t3 WHERE c GLOB '*llo' }
+
+ 7  { SELECT * FROM t3 WHERE a = 'angle' }
+ 8  { SELECT * FROM t3 WHERE a = 'it' OR b = 6939937510 }
+ 9  { SELECT * FROM t3, t4 WHERE a = 'painting' OR a = 'are' OR a = f }
+10  { SELECT * FROM t3, t4 WHERE a = 'all' OR a = 'and' OR a = h }
+11  { SELECT * FROM t3, t4 WHERE a < 'of' OR b > 346 AND c IS NULL }
+12  { SELECT * FROM t3, t4 WHERE 'the' > a OR b > 'have' AND c = 1415926535 }
+
+13  { SELECT * FROM t3 WHERE a BETWEEN 'one' AND 'two' OR a = 3421170679 }
+14  { SELECT * FROM t3 WHERE a BETWEEN 'one' AND 'two' OR a IS NULL }
+15  { SELECT * FROM t3 WHERE c > 'one' OR c >= 'one' OR c LIKE 'one%' }
+16  { SELECT * FROM t3 WHERE c > 'one' OR c = c OR c = a }
+17  { SELECT * FROM t3 WHERE c IS NULL OR a >= 'peak' }
+18  { SELECT * FROM t3 WHERE c IN ('other', 'all', 'snapshots') OR a>1 }
+19  { SELECT * FROM t3 WHERE c IN ('other', 'all', 'snapshots') AND a>1 }
+20  { SELECT * FROM t3 WHERE c IS NULL AND a>'one' }
+21  { SELECT * FROM t3 WHERE c IS NULL OR a>'one' }
+
+  } {
+    do_test where8-4.$A.$B.1 {
+      set R [execsql $sql]
+      if {![info exists results($B)]} {
+        set results($B) $R
+      }
+      list
+    } {}
+
+    do_test where8-4.$A.$B.2 { lsort $R } [lsort $results($B)]
+  }
+  incr A
+}
+
 finish_test