Add tests to restore full coverage of fts5 code.
FossilOrigin-Name: 063755c81574800e7db12a42e17d982a8c1e5181
This commit is contained in:
parent
735ff4a809
commit
b06347a5dc
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
64
ext/fts5/test/fts5faultA.test
Normal file
64
ext/fts5/test/fts5faultA.test
Normal file
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
23
manifest
23
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
|
||||
|
@ -1 +1 @@
|
||||
62ea9e5ab8bc1a20245beebceb5ea62dcd7ec84e
|
||||
063755c81574800e7db12a42e17d982a8c1e5181
|
Loading…
Reference in New Issue
Block a user