]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add tests to restore full coverage of fts5 code.
authordan <dan@noemail.net>
Tue, 2 Feb 2016 21:19:21 +0000 (21:19 +0000)
committerdan <dan@noemail.net>
Tue, 2 Feb 2016 21:19:21 +0000 (21:19 +0000)
FossilOrigin-Name: 063755c81574800e7db12a42e17d982a8c1e5181

ext/fts5/fts5_expr.c
ext/fts5/test/fts5fault1.test
ext/fts5/test/fts5fault2.test
ext/fts5/test/fts5fault7.test
ext/fts5/test/fts5fault8.test
ext/fts5/test/fts5faultA.test [new file with mode: 0644]
ext/fts5/test/fts5simple3.test
manifest
manifest.uuid

index 1df173cfcc31a528fe4a9dacaa176158cb7038bc..5006d88d0faa8c27cb4bebd2cb4e838557f2b70f 100644 (file)
@@ -1337,7 +1337,8 @@ int sqlite3Fts5ExprFirst(Fts5Expr *p, Fts5Index *pIdx, i64 iFirst, int bDesc){
     }
 
     /* If the iterator is not at a real match, skip forward until it is. */
-    while( pRoot->bNomatch && rc==SQLITE_OK && pRoot->bEof==0 ){
+    while( pRoot->bNomatch ){
+      assert( pRoot->bEof==0 && rc==SQLITE_OK );
       rc = fts5ExprNodeNext(p, pRoot, 0, 0);
     }
   }
index 429ea39af0cd576bc7946db62169a41106668590..9d63a1175f20e644bea70850b593ceb70f257f3b 100644 (file)
@@ -72,7 +72,7 @@ do_faultsim_test 3 -prep {
 reset_db
 do_execsql_test 4.0 {
   CREATE VIRTUAL TABLE t2 USING fts5(a, b);
-  INSERT INTO t2 VALUES('m f a jj th q jr ar',   'hj n h h sg j i m');
+  INSERT INTO t2 VALUES('m f a jj th q gi ar',   'hj n h h sg j i m');
   INSERT INTO t2 VALUES('nr s t g od j kf h',    'sb h aq rg op rb n nl');
   INSERT INTO t2 VALUES('do h h pb p p q fr',    'c rj qs or cr a l i');
   INSERT INTO t2 VALUES('lk gp t i lq mq qm p',  'h mr g f op ld aj h');
@@ -95,6 +95,7 @@ foreach {tn expr res} {
   7 { NEAR(r a, 5) }  {9}
   8 { m* f* }         {1 4 6 8 9 10}
   9 { m* + f* }       {1 8}
+  10 { c NOT p }       {5 6 7 10}
 } {
   do_faultsim_test 4.$tn -prep {
     faultsim_restore_and_reopen
index ef1df8826ab4dfb483c44c741de83f9958af1bdc..43c7c7a3dda1e1e0c5dc2ab872bd5f3c4388bd69 100644 (file)
@@ -16,7 +16,7 @@ source [file join [file dirname [info script]] fts5_common.tcl]
 source $testdir/malloc_common.tcl
 set testprefix fts5fault2
 
-# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+# If SQLITE_ENABLE_FTS5 is not defined, omit this file.
 ifcapable !fts5 {
   finish_test
   return
index bfe6420615a31e2c19b23196bc389a3f5216a26d..a35b19ade2093754d2e13160212e33b09a14f0f9 100644 (file)
@@ -99,7 +99,7 @@ do_execsql_test 2.0 {
 }
 faultsim_save_and_close
 
-do_faultsim_test 2 -faults oom-* -prep {
+do_faultsim_test 2.1 -faults oom-* -prep {
   faultsim_restore_and_reopen
 } -body {
   db eval { UPDATE OR REPLACE xy SET rowid=3 WHERE rowid = 2 }
@@ -107,6 +107,13 @@ do_faultsim_test 2 -faults oom-* -prep {
   faultsim_test_result {0 {}}
 }
 
+# Test fault-injection when an empty expression is parsed.
+#
+do_faultsim_test 2.2 -faults oom-* -body {
+  db eval { SELECT * FROM xy('""') }
+} -test {
+  faultsim_test_result {0 {}}
+}
 
 finish_test
 
index d93066c6c09fddca487a79919fb503558b2c65ca..ae5849495bfe4bca90df24f3a400743dff3c35d8 100644 (file)
@@ -24,32 +24,37 @@ ifcapable !fts5 {
 
 foreach_detail_mode $testprefix {
 
-fts5_aux_test_functions db
-do_execsql_test 1.0 {
-  CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%);
-  INSERT INTO t1 VALUES('a b c d', '1 2 3 4');
-  INSERT INTO t1 VALUES('a b a b', NULL);
-  INSERT INTO t1 VALUES(NULL, '1 2 1 2');
-}
-
-do_faultsim_test 1 -faults oom-* -body {
-  execsql { 
-    SELECT rowid, fts5_test_poslist(t1) FROM t1 WHERE t1 MATCH 'b OR 2' 
+  fts5_aux_test_functions db
+  do_execsql_test 1.0 {
+    CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%);
+    INSERT INTO t1 VALUES('a b c d', '1 2 3 4');
+    INSERT INTO t1 VALUES('a b a b', NULL);
+    INSERT INTO t1 VALUES(NULL, '1 2 1 2');
   }
-} -test {
-  faultsim_test_result {0 {1 {0.0.1 1.1.1} 2 {0.0.1 0.0.3} 3 {1.1.1 1.1.3}}} \
-                       {1 SQLITE_NOMEM}
-}
-
-do_faultsim_test 2 -faults oom-* -body {
-  execsql { 
-    INSERT INTO t1(t1) VALUES('integrity-check');
+  
+  do_faultsim_test 1 -faults oom-* -body {
+    execsql { 
+      SELECT rowid, fts5_test_poslist(t1) FROM t1 WHERE t1 MATCH 'b OR 2' 
+    }
+  } -test {
+    faultsim_test_result {0 {1 {0.0.1 1.1.1} 2 {0.0.1 0.0.3} 3 {1.1.1 1.1.3}}} \
+                         {1 SQLITE_NOMEM}
+  }
+  
+  do_faultsim_test 2 -faults oom-* -body {
+    execsql { INSERT INTO t1(t1) VALUES('integrity-check') }
+  } -test {
+    faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
   }
-} -test {
-  faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
-}
 
-}
+  if {[detail_is_none]==0} {
+    do_faultsim_test 3 -faults oom-* -body {
+      execsql { SELECT rowid FROM t1('b:2') }
+    } -test {
+      faultsim_test_result {0 {1 3}} {1 SQLITE_NOMEM}
+    }
+  }
+} ;# foreach_detail_mode...
 
 finish_test
 
diff --git a/ext/fts5/test/fts5faultA.test b/ext/fts5/test/fts5faultA.test
new file mode 100644 (file)
index 0000000..817ccb4
--- /dev/null
@@ -0,0 +1,64 @@
+# 2016 February 2
+#
+# 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 file is focused on OOM errors.
+#
+
+source [file join [file dirname [info script]] fts5_common.tcl]
+source $testdir/malloc_common.tcl
+set testprefix fts5faultA
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts5 {
+  finish_test
+  return
+}
+
+foreach_detail_mode $testprefix {
+  do_execsql_test 1.0 {
+    CREATE VIRTUAL TABLE o1 USING fts5(a, detail=%DETAIL%);
+    INSERT INTO o1(o1, rank) VALUES('pgsz', 32);
+  
+    WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<300 )
+    INSERT INTO o1 SELECT 'A B C' FROM s;
+  
+    INSERT INTO o1 VALUES('A X C');
+  
+    WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<300 )
+    INSERT INTO o1 SELECT 'A B C' FROM s;
+  }
+  
+  do_faultsim_test 1 -faults oom* -prep {
+    sqlite3 db test.db
+  } -body {
+    execsql { SELECT rowid FROM o1('a NOT b') }
+  } -test {
+    faultsim_test_result {0 301}
+  }
+}
+
+do_execsql_test 2.0 {
+  CREATE VIRTUAL TABLE o2 USING fts5(a);
+  
+  INSERT INTO o2 VALUES('A B C');
+  WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<300 )
+  INSERT INTO o2 SELECT group_concat('A B C ') FROM s;
+}
+
+do_faultsim_test 2 -faults oom* -prep {
+  sqlite3 db test.db
+} -body {
+  execsql { SELECT rowid FROM o2('a+b+c NOT xyz') }
+} -test {
+  faultsim_test_result {0 {1 2}}
+}
+finish_test
+
index b84a3e56ddd8c8ea69fb3ddddbcfdc1790187f05..b6922f84dd7b33dd88c3692d94b20cd4114a1859 100644 (file)
@@ -39,6 +39,47 @@ do_execsql_test 1.3 {
   SELECT rowid, fts5_test_collist(t1) FROM t1('b:a');
 } {}
 
+#-------------------------------------------------------------------------
+# Create detail=col and detail=full tables with 998 columns.
+#
+foreach_detail_mode $testprefix {
+  if {[detail_is_none]} continue
+
+  do_test 2.1 {
+    execsql { DROP TABLE IF EXISTS t2 }
+    set cols [list]
+    set vals [list]
+    for {set i 1} {$i <= 998} {incr i} {
+      lappend cols "c$i"
+      lappend vals "'val$i'"
+    }
+    execsql "CREATE VIRTUAL TABLE t2 USING fts5(detail=%DETAIL%,[join $cols ,])"
+  } {}
+  
+  do_test 2.2 {
+    execsql "INSERT INTO t2 VALUES([join $vals ,])"
+  } {}
+  
+  foreach {tn q res} {
+    1 { c1:val1 }     1
+    2 { c300:val300 } 1
+    3 { c300:val1 } {}
+    4 { c1:val300 } {}
+  } {
+    do_execsql_test 2.3.$tn {
+      SELECT rowid FROM t2($q)
+    } $res
+  }
+}
+
+do_execsql_test 3.0 {
+  CREATE VIRTUAL TABLE x3 USING fts5(one);
+  INSERT INTO x3 VALUES('a b c');
+  INSERT INTO x3 VALUES('c b a');
+  INSERT INTO x3 VALUES('o t t');
+  SELECT * FROM x3('x OR y OR z');
+}
+
 
 finish_test
 
index 44101197f72a02a90fd9cc9c5a39a7e700d26aff..c1cd05951c7712992471dd83ad10e9ac00eb2f34 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Enhance\sthe\sperformance\sof\sfts5\sAND\sand\sOR\squeries.
-D 2016-02-02T17:40:41.411
+C Add\stests\sto\srestore\sfull\scoverage\sof\sfts5\scode.
+D 2016-02-02T21:19:21.156
 F Makefile.in 027c1603f255390c43a426671055a31c0a65fdb4
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 72b7858f02017611c3ac1ddc965251017fed0845
@@ -102,7 +102,7 @@ F ext/fts5/fts5Int.h 9505f3bc8d0b2ca4cd2b112e7e042e3c6a3222a7
 F ext/fts5/fts5_aux.c b9bcce753ef5b451267b2232f0ca153ddeb3951d
 F ext/fts5/fts5_buffer.c f6e0c6018ffc8e39fc0b333b5daa8b8d528ae6e4
 F ext/fts5/fts5_config.c 0c384ebdd23fd055e2e50a93277b8d59da538238
-F ext/fts5/fts5_expr.c 304b22448ee0c3056d4177e327ed62dc80cbe23a
+F ext/fts5/fts5_expr.c ff5c451a6d025909639ac0f0d0af0cc595b50feb
 F ext/fts5/fts5_hash.c 1b113977296cf4212c6ec667d5e3f2bd18036955
 F ext/fts5/fts5_index.c 471ff6935068a4579830474249e1046b57137103
 F ext/fts5/fts5_main.c 7e8a5f27d504bc04e3de7f1cba8867f0332aee9d
@@ -147,15 +147,16 @@ F ext/fts5/test/fts5dlidx.test 13871a14641017ae42f6f1055a8067bafd44cb3d
 F ext/fts5/test/fts5doclist.test 8edb5b57e5f144030ed74ec00ef6fa4294fed79b
 F ext/fts5/test/fts5ea.test b01e3a18cdfabbff8104a96a5242a06a68a998a0
 F ext/fts5/test/fts5eb.test 021aa80b7ac09b964249aa32ced9ee908703e4aa
-F ext/fts5/test/fts5fault1.test 4b39c47ca3544615daa8a2f733b911fa08022c77
-F ext/fts5/test/fts5fault2.test 28c36c843bb39ae855ba79827417ecc37f114341
+F ext/fts5/test/fts5fault1.test e09040d3e17b8c0837101e8c79c8a874c4376fb7
+F ext/fts5/test/fts5fault2.test d8c6c7f916ccbdfc10b2c69530e9dd3bc8313232
 F ext/fts5/test/fts5fault3.test d6e9577d4312e331a913c72931bf131704efc8f3
 F ext/fts5/test/fts5fault4.test 532b6dacb963016cbf7003196bd87fb366540277
 F ext/fts5/test/fts5fault5.test 10c13a783de3f42a21e3e53e123b62ed0c3a1618
 F ext/fts5/test/fts5fault6.test 9682664d679643ac6736e90c225526cc84073cda
-F ext/fts5/test/fts5fault7.test 01be274bfc8d9bf22451a3bf5892e9399d044f1b
-F ext/fts5/test/fts5fault8.test f2d8a2b673a5f72ca1fa0e85bdbfb2041ffd347d
+F ext/fts5/test/fts5fault7.test cb14ea3c1f42394f06f2284abc58eecee6ff8080
+F ext/fts5/test/fts5fault8.test 430837fe6dd0511fd3aea52bd602ac02441bcb58
 F ext/fts5/test/fts5fault9.test e10e395428a9ea0596ebe752ff7123d16ab78e08
+F ext/fts5/test/fts5faultA.test fa5d59c0ff62b7125cd14eee38ded1c46e15a7ea
 F ext/fts5/test/fts5full.test 6f6143af0c6700501d9fd597189dfab1555bb741
 F ext/fts5/test/fts5hash.test 00668f6fa9b9bffbd7c1be29f408aa2bdade0451
 F ext/fts5/test/fts5integrity.test f5e4f8d284385875068ad0f3e894ce43e9de835d
@@ -177,7 +178,7 @@ F ext/fts5/test/fts5restart.test c17728fdea26e7d0f617d22ad5b4b2862b994c17
 F ext/fts5/test/fts5rowid.test 16908a99d6efc9ba21081b4f2b86b3fc699839a6
 F ext/fts5/test/fts5simple.test 7fcacfa473a37355af2e60096650c87b5ba8f3ba
 F ext/fts5/test/fts5simple2.test 98377ae1ff7749a42c21fe1a139c1ed312522c46
-F ext/fts5/test/fts5simple3.test e671b36bc4dbd4f5095e66cb04473cba9f680f53
+F ext/fts5/test/fts5simple3.test 8e71733b3d1b0e695011d02c68ebc5ca40b6124e
 F ext/fts5/test/fts5synonym.test 6475d189c2e20d60795808f83e36bf9318708d48
 F ext/fts5/test/fts5synonym2.test aa4c43bd3b691ff80f658cb064f5ab40690e834e
 F ext/fts5/test/fts5tok1.test beb894c6f3468f10a574302f69ebe4436b0287c7
@@ -1422,7 +1423,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P d8b7b1996eefae7768bfcb82d4ff22c69392aa63
-R e61034725c181be1c4702281e2c951bc
+P 62ea9e5ab8bc1a20245beebceb5ea62dcd7ec84e
+R e3a290a62981c78902a14c3c2f0729a7
 U dan
-Z e59ee5dbb82eef632e47f5b2b9e1cde6
+Z 6792ae7332aab4430b100fd43f303a7d
index 0a6e70dd4efb10858c53b1b086437909705d801d..0d75e9b7c9dfb064d2d046659301c1408d916f47 100644 (file)
@@ -1 +1 @@
-62ea9e5ab8bc1a20245beebceb5ea62dcd7ec84e
\ No newline at end of file
+063755c81574800e7db12a42e17d982a8c1e5181
\ No newline at end of file