Further improvements to test coverage in fts3.

FossilOrigin-Name: 352413eed469802665e7d2c17b7fe6e3a0b0b2209ce45bdc85fd4243cec50ea6
This commit is contained in:
dan 2017-04-17 16:07:25 +00:00
parent ddf4747053
commit 624edacf6a
8 changed files with 187 additions and 18 deletions

View File

@ -372,8 +372,8 @@ int sqlite3Fts3GetVarint(const char *pBuf, sqlite_int64 *v){
}
/*
** Similar to sqlite3Fts3GetVarint(), except that the output is truncated to a
** 32-bit integer before it is returned.
** Similar to sqlite3Fts3GetVarint(), except that the output is truncated to
** a non-negative 32-bit integer before it is returned.
*/
int sqlite3Fts3GetVarint32(const char *p, int *pi){
u32 a;
@ -389,7 +389,9 @@ int sqlite3Fts3GetVarint32(const char *p, int *pi){
GETVARINT_STEP(a, p, 14, 0x3FFF, 0x200000, *pi, 3);
GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *pi, 4);
a = (a & 0x0FFFFFFF );
*pi = (int)(a | ((u32)(*p & 0x0F) << 28));
*pi = (int)(a | ((u32)(*p & 0x07) << 28));
assert( 0==(a & 0x80000000) );
assert( *pi>=0 );
return 5;
}
@ -1847,7 +1849,8 @@ static int fts3ScanInteriorNode(
isFirstTerm = 0;
zCsr += fts3GetVarint32(zCsr, &nSuffix);
if( nPrefix<0 || nSuffix<0 || &zCsr[nSuffix]>zEnd ){
assert( nPrefix>=0 && nSuffix>=0 );
if( &zCsr[nSuffix]>zEnd ){
rc = FTS_CORRUPT_VTAB;
goto finish_scan;
}
@ -2657,7 +2660,7 @@ int sqlite3Fts3FirstFilter(
fts3ColumnlistCopy(0, &p);
}
while( p<pEnd && *p==0x01 ){
while( p<pEnd ){
sqlite3_int64 iCol;
p++;
p += sqlite3Fts3GetVarint(p, &iCol);

View File

@ -1,5 +1,5 @@
C Improve\scoverage\sof\scode\sin\sfts3.
D 2017-04-17T13:38:09.238
C Further\simprovements\sto\stest\scoverage\sin\sfts3.
D 2017-04-17T16:07:25.320
F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6
@ -70,7 +70,7 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
F ext/fts3/fts3.c a05d3acd671a2b5a76adcc5d01c05d93c18a7f6e8f0a8595d0dd12cdde4c9969
F ext/fts3/fts3.c 1db0b7086d187a0d10d2a5a7fd5c05336216d2f0dba4af76aca38e5d806bb0d0
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
F ext/fts3/fts3Int.h eb2502000148e80913b965db3e59f29251266d0a
F ext/fts3/fts3_aux.c 9edc3655fcb287f0467d0a4b886a01c6185fe9f1
@ -752,7 +752,7 @@ F test/fts2r.test b154c30b63061d8725e320fba1a39e2201cadd5e
F test/fts2token.test d8070b241a15ff13592a9ae4a8b7c171af6f445a
F test/fts3.test 672a040ea57036fb4b6fdc09027c18d7d24ab654
F test/fts3_common.tcl 99cf6659b87c0f74f55963c2aea03b3a7d66ceb0
F test/fts3aa.test 8bf242c0a59867ac2fb0cd5b9f71dabb3cbe9c18a859f61f6e0853d52e483183
F test/fts3aa.test 39b65c11913d277c91d7426c62cfc1d147d1b4e9a48fecd9e38f60d0b5a5f505
F test/fts3ab.test 7f6cf260ae80dda064023df8e8e503e9a412b91f
F test/fts3ac.test 636ed7486043055d4f126a0e385f2d5a82ebbf63
F test/fts3ad.test e40570cb6f74f059129ad48bcef3d7cbc20dda49
@ -777,7 +777,7 @@ F test/fts3comp1.test a0f5b16a2df44dd0b15751787130af2183167c0c
F test/fts3conf.test 60317efd562080e198b5bdc9fcd222ce32cf01d7
F test/fts3corrupt.test 2710b77983cc7789295ddbffea52c1d3b7506dbb
F test/fts3corrupt2.test 6d96efae2f8a6af3eeaf283aba437e6d0e5447ba
F test/fts3corrupt3.test d371712ce1ddaa09f8fa59b6bd8d6512210be3c09855554ebc8b882fb69a929a
F test/fts3corrupt3.test 56e0ee83e90b57f5f3644cb7d1b36a067b7b8b19cdf0dedce45e5e13cf752f65
F test/fts3cov.test e0fb00d8b715ddae4a94c305992dfc3ef70353d7
F test/fts3d.test d3e9c8fb75135ada06bf3bab4f9666224965d708
F test/fts3defer.test 0be4440b73a2e651fc1e472066686d6ada4b9963
@ -791,11 +791,12 @@ F test/fts3expr3.test c4d4a7d6327418428c96e0a3a1137c251b8dfbf8
F test/fts3expr4.test c39a15d676b14fc439d9bf845aa7bddcf4a74dc3
F test/fts3expr5.test f9abfffbf5e53d48a33e12a1e8f8ba2c551c9b49
F test/fts3fault.test 268e9589f44f49d6694ef39a293f0e0f80c6230fb01cc6f34325412acceb99ae
F test/fts3fault2.test f953bb3cf903988172270a9a0aafd5a890b0f98f
F test/fts3fault2.test 0e38e9ccd5b13a9b9ac9b66dff24534f998279a0dd21a991115b0dafaaa88b46
F test/fts3first.test dbdedd20914c8d539aa3206c9b34a23775644641
F test/fts3join.test 34750f3ce1e29b2749eaf0f1be2fa6301c5d50da
F test/fts3malloc.test b0e4c133b8d61d4f6d112d8110f8320e9e453ef6
F test/fts3matchinfo.test ce864e0bd92429df8008f31cf557269ba172482a
F test/fts3misc.test 744c53bde5969f4c22e9fb4c11cd3a2fc6c2edfb4c254919fd425663b1781137
F test/fts3near.test 7e3354d46f155a822b59c0e957fd2a70c1d7e905
F test/fts3offsets.test b85fd382abdc78ebce721d8117bd552dfb75094c
F test/fts3prefix.test fa794eaab0bdae466494947b0b153d7844478ab2
@ -1031,7 +1032,7 @@ F test/parser1.test 391b9bf9a229547a129c61ac345ed1a6f5eb1854
F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b
F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442
F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff
F test/permutations.test cb5e80dd5a00ad3e1f2ecbd5d78d8345c7f47c554b5409d4f242afcc6afcbdf5
F test/permutations.test 8aaa22a0f428a7e6b8446b97bc7691a273eaeff5dc290fb9129bf79fa9813a6e
F test/pragma.test 1e94755164a3a3264cd39836de4bebcb7809e5f8
F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f
F test/pragma3.test 14c12bc5352b1e100e0b6b44f371053a81ccf8ed
@ -1574,8 +1575,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P f508aff8d1782abdff4d03726ae098607a0ee6cfd2e35b130097ee5043e98960
Q +9fe229cdf3d4684f4feb0dea0ca14aebd028e64f9be8c3ec9435cf2103aad2bd
R 1f0577dbe9b73d480704c675ac83362f
P 1a08a836fa919524216a16faf5212eebc9ad788c9e15463b68b0576dfccd4387
Q +e00aa665903d2328bab3f192ad364e43d5d8483509671626d8ef5384b305557f
R e503b12d92602617090d73924f6d0603
U dan
Z 3f6cd808adfc219b5f58b1c64aa88fca
Z 3da6b7e6b10076610ce2d669ba020b22

View File

@ -1 +1 @@
1a08a836fa919524216a16faf5212eebc9ad788c9e15463b68b0576dfccd4387
352413eed469802665e7d2c17b7fe6e3a0b0b2209ce45bdc85fd4243cec50ea6

View File

@ -243,7 +243,6 @@ do_execsql_test 8.5 {
SELECT docid FROM t0 WHERE t0 MATCH '"abc abc"';
} {}
do_execsql_test 9.1 {
CREATE VIRTUAL TABLE t9 USING fts4(a, "", '---');
}

View File

@ -18,7 +18,11 @@ ifcapable !fts3 { finish_test ; return }
set ::testprefix fts3corrupt3
#-------------------------------------------------------------------------
# Test that fts3 does not choke on an oversized varint.
#
do_execsql_test 1.0 {
PRAGMA page_size = 512;
CREATE VIRTUAL TABLE t1 USING fts3;
BEGIN;
INSERT INTO t1 VALUES('one');
@ -36,6 +40,25 @@ do_catchsql_test 1.3 {
SELECT rowid FROM t1 WHERE t1 MATCH 'one'
} {0 -1}
#-------------------------------------------------------------------------
# Interior node with the prefix or suffix count of an entry set to a
# negative value.
#
set doc1 [string repeat "x " 600]
set doc2 [string repeat "y " 600]
set doc3 [string repeat "z " 600]
do_execsql_test 2.0 {
CREATE VIRTUAL TABLE t2 USING fts3;
BEGIN;
INSERT INTO t2 VALUES($doc1);
INSERT INTO t2 VALUES($doc2);
INSERT INTO t2 VALUES($doc3);
COMMIT;
}
do_execsql_test 2.1 {
SELECT quote(root) from t2_segdir;
} {X'0101017900017A'}

View File

@ -174,4 +174,22 @@ do_faultsim_test 6.1 -faults oom* -prep {
faultsim_test_result {0 -1}
}
#-------------------------------------------------------------------------
# Inject faults into a query for an N-byte prefix that uses a prefix=N+1
# index.
reset_db
do_execsql_test 7.0 {
CREATE VIRTUAL TABLE t7 USING fts4(x,prefix=2);
INSERT INTO t7 VALUES('the quick brown fox');
INSERT INTO t7 VALUES('jumped over the');
INSERT INTO t7 VALUES('lazy dog');
}
do_faultsim_test 7.1 -faults oom* -body {
execsql { SELECT docid FROM t7 WHERE t7 MATCH 't*' }
} -test {
faultsim_test_result {0 {1 2}}
}
finish_test

124
test/fts3misc.test Normal file
View File

@ -0,0 +1,124 @@
# 2017 March 22
#
# 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 implements regression tests for SQLite library. The
# focus of this script is testing the FTS3 module.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix fts3misc
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
ifcapable !fts3 {
finish_test
return
}
#-------------------------------------------------------------------------
# A self-join.
#
do_execsql_test 1.0 {
CREATE VIRTUAL TABLE t1 USING fts3(a, b);
INSERT INTO t1 VALUES('one', 'i');
INSERT INTO t1 VALUES('one', 'ii');
INSERT INTO t1 VALUES('two', 'i');
INSERT INTO t1 VALUES('two', 'ii');
}
do_execsql_test 1.1 {
SELECT a.a, b.b FROM t1 a, t1 b WHERE a.t1 MATCH 'two' AND b.t1 MATCH 'i'
} {two i two i two i two i}
#-------------------------------------------------------------------------
# FTS tables with 128 or more columns.
#
proc v1 {v} {
set vector [list a b c d e f g h]
set res [list]
for {set i 0} {$i<8} {incr i} {
if {$v & (1 << $i)} { lappend res [lindex $vector $i] }
}
set res
}
proc v2 {v} {
set vector [list d e f g h i j k]
set res [list]
for {set i 0} {$i<8} {incr i} {
if {$v & (1 << $i)} { lappend res [lindex $vector $i] }
}
set res
}
db func v1 v1
db func v2 v2
do_test 2.0 {
set cols [list]
for {set i 0} {$i<200} {incr i} {
lappend cols "c$i"
}
execsql "CREATE VIRTUAL TABLE t2 USING fts3([join $cols ,])"
execsql {
WITH data(i) AS (
SELECT 1 UNION ALL SELECT i+1 FROM data WHERE i<200
)
INSERT INTO t2(c198, c199) SELECT v1(i), v2(i) FROM data;
}
} {}
do_execsql_test 2.1 {
SELECT rowid FROM t2 WHERE t2 MATCH '"a b c"'
} {
7 15 23 31 39 47 55 63 71 79 87 95 103 111
119 127 135 143 151 159 167 175 183 191 199
}
do_execsql_test 2.2 {
SELECT rowid FROM t2 WHERE t2 MATCH '"g h i"'
} {
56 57 58 59 60 61 62 63 120 121 122 123 124
125 126 127 184 185 186 187 188 189 190 191
}
do_execsql_test 2.3 {
SELECT rowid FROM t2 WHERE t2 MATCH '"i h"'
} {
}
do_execsql_test 2.4 {
SELECT rowid FROM t2 WHERE t2 MATCH '"f e"'
} {
}
do_execsql_test 2.5 {
SELECT rowid FROM t2 WHERE t2 MATCH '"e f"'
} {
6 7 14 15 22 23 30 31 38 39 46 47 48 49 50 51 52 53 54 55 56
57 58 59 60 61 62 63 70 71 78 79 86 87 94 95 102 103 110
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
134 135 142 143 150 151 158 159 166 167 174 175 176 177 178 179 180
181 182 183 184 185 186 187 188 189 190 191 198 199
}
# Range constraints on the docid using non-integer values.
#
do_execsql_test 2.6 {
SELECT rowid FROM t2 WHERE t2 MATCH 'e' AND rowid BETWEEN NULL AND 45;
} {}
do_execsql_test 2.7 {
SELECT rowid FROM t2 WHERE t2 MATCH 'e' AND rowid BETWEEN 11.5 AND 48.2;
} {
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
29 30 31 34 35 38 39 42 43 46 47 48
}
do_execsql_test 2.8 {
SELECT rowid FROM t2 WHERE t2 MATCH 'e' AND rowid BETWEEN '11.5' AND '48.2';
} {
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
29 30 31 34 35 38 39 42 43 46 47 48
}
finish_test

View File

@ -266,6 +266,7 @@ test_suite "fts3" -prefix "" -description {
fts4merge4.test fts4merge.test fts4noti.test fts4onepass.test
fts4opt.test fts4unicode.test
fts3corrupt3.test
fts3misc.test
}
test_suite "fts5" -prefix "" -description {