]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add new test cases to increase coverage of where.c. (CVS 6138)
authordrh <drh@noemail.net>
Wed, 7 Jan 2009 20:58:57 +0000 (20:58 +0000)
committerdrh <drh@noemail.net>
Wed, 7 Jan 2009 20:58:57 +0000 (20:58 +0000)
FossilOrigin-Name: 2e1ab51f05447f9c1f291636b53b1ec584003841

manifest
manifest.uuid
src/where.c
test/mallocK.test [new file with mode: 0644]

index 197b00fb3f142aa43ba17aaddc60098ea488405e..6ef819edc8ef78a07e81a3e5303ebb88ef6e6c24 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sbug\sin\sthe\sLIKE\squery\soptimization.\s\s(Found\sby\scoverage\stesting.)\s(CVS\s6137)
-D 2009-01-07T18:24:03
+C Add\snew\stest\scases\sto\sincrease\scoverage\sof\swhere.c.\s(CVS\s6138)
+D 2009-01-07T20:58:57
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 05461a9b5803d5ad10c79f989801e9fd2cc3e592
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -207,7 +207,7 @@ F src/vdbeblob.c b0dcebfafedcf9c0addc7901ad98f6f986c08935
 F src/vdbemem.c 19f94b504d3da44b31aef200fa6c8e07862de2e8
 F src/vtab.c e39e011d7443a8d574b1b9cde207a35522e6df43
 F src/walker.c 488c2660e13224ff70c0c82761118efb547f8f0d
-F src/where.c 9852acecfeee1f8650fdec46f20e2368e6c159a0
+F src/where.c 92ef9d964b06ad2f6cba1ee4d19233ac229b2cb3
 F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
 F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911
@@ -448,6 +448,7 @@ F test/mallocG.test 4584d0d8ddb8009f16ca0c8bab1fa37f6358efa2
 F test/mallocH.test 79b65aed612c9b3ed2dcdaa727c85895fd1bfbdb
 F test/mallocI.test 6e24fe6444bd2999ccc81f984977b44c0d6e5591
 F test/mallocJ.test 44dfbbaca731cb933818ad300b4566265d652609
+F test/mallocK.test c2404dc5f33ba1c3d0adffa1d9686a5b0e9b000b
 F test/malloc_common.tcl 984baeb6c6b185e798827d1187d426acc2bc4962
 F test/manydb.test b3d3bc4c25657e7f68d157f031eb4db7b3df0d3c
 F test/memdb.test a67c85a29d3187ac81d3628fcf9417d8a1be9ecb
@@ -693,7 +694,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P ccc9c211a285fd4da68b69e15594f080371be522
-R 3780da89c170554b5cb3d38edab02288
+P fe90e9116b6e1e25cf3119d2777a8e9c135153ce
+R 8adc87d95beb7782c7b1575af0e0d7a6
 U drh
-Z 9ba15e241fcdcbb40439174ae087420f
+Z 3fd090ae0444fbaab790074cb8a7ba0e
index 0da10d38c027d3a5ac4a74e44d31e35d6d09fef6..6daf107d1787fe7e33d5b931cdeaae4a75e05d53 100644 (file)
@@ -1 +1 @@
-fe90e9116b6e1e25cf3119d2777a8e9c135153ce
\ No newline at end of file
+2e1ab51f05447f9c1f291636b53b1ec584003841
\ No newline at end of file
index 451dce9cb99b9962600b76ebf2e41c45906a661c..5d63179e4b0968fd19ee241fa31bcf7ead150f59 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.358 2009/01/07 18:24:03 drh Exp $
+** $Id: where.c,v 1.359 2009/01/07 20:58:57 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -843,8 +843,10 @@ static void exprAnalyzeOrTerm(
         whereClauseInit(pAndWC, pWC->pParse, pMaskSet);
         whereSplit(pAndWC, pOrTerm->pExpr, TK_AND);
         exprAnalyzeAll(pSrc, pAndWC);
+        testcase( db->mallocFailed );
         for(j=0, pAndTerm=pAndWC->a; j<pAndWC->nTerm; j++, pAndTerm++){
-          if( pAndTerm->pExpr && allowedOp(pAndTerm->pExpr->op) ){
+          assert( pAndTerm->pExpr );
+          if( allowedOp(pAndTerm->pExpr->op) ){
             b |= getMask(pMaskSet, pAndTerm->leftCursor);
           }
         }
diff --git a/test/mallocK.test b/test/mallocK.test
new file mode 100644 (file)
index 0000000..c636185
--- /dev/null
@@ -0,0 +1,61 @@
+# 2008 August 01
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This test script checks malloc failures in WHERE clause analysis.
+# 
+# $Id: mallocK.test,v 1.1 2009/01/07 20:58:57 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/malloc_common.tcl
+
+
+set sql {SELECT * FROM t1, t2 WHERE (a=1 OR a=2)}
+for {set x 1} {$x<5} {incr x} {
+  append sql " AND b=y"
+  do_malloc_test mallocK-1.$x -sqlbody $sql -sqlprep {
+    CREATE TABLE t1(a,b);
+    CREATE TABLE t2(x,y);
+  }
+}
+
+set sql {SELECT * FROM t1 WHERE a LIKE 'abc%'}
+for {set x 1} {$x<5} {incr x} {
+  append sql " AND b!=$x"
+  do_malloc_test mallocK-2.$x -sqlbody $sql -sqlprep {
+    CREATE TABLE t1(a,b);
+  }
+}
+
+set sql {SELECT * FROM t1 WHERE a BETWEEN 5 AND 10}
+for {set x 1} {$x<5} {incr x} {
+  append sql " AND b!=$x"
+  do_malloc_test mallocK-3.$x -sqlbody $sql -sqlprep {
+    CREATE TABLE t1(a,b);
+  }
+}
+
+ifcapable vtab {
+  set sql {SELECT * FROM t2 WHERE a MATCH 'xyz'}
+  for {set x 1} {$x<5} {incr x} {
+    append sql " AND b!=$x"
+    do_malloc_test mallocK-4.$x -sqlbody $sql -tclprep {
+      register_echo_module [sqlite3_connection_pointer db]
+      db eval {
+        CREATE TABLE t1(a,b);
+        CREATE VIRTUAL TABLE t2 USING echo(t1);
+      }
+    }
+  }
+}
+
+
+finish_test