1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Extra tests for coverage of fts3 code.

FossilOrigin-Name: eee921a99e69a9cd868a89de620bf47c4e26e4b5
This commit is contained in:
dan
2009-12-12 13:16:09 +00:00
parent f5fff2a7b2
commit 45bcd6c274
5 changed files with 89 additions and 34 deletions

View File

@ -1228,12 +1228,10 @@ static int fts3WriteSegment(
int rc = fts3SqlStmt(p, SQL_INSERT_SEGMENTS, &pStmt, 0);
if( rc==SQLITE_OK ){
sqlite3_bind_int64(pStmt, 1, iBlock);
rc = sqlite3_bind_blob(pStmt, 2, z, n, SQLITE_STATIC);
if( rc==SQLITE_OK ){
sqlite3_bind_blob(pStmt, 2, z, n, SQLITE_STATIC);
sqlite3_step(pStmt);
rc = sqlite3_reset(pStmt);
}
}
return rc;
}
@ -1258,12 +1256,10 @@ static int fts3WriteSegdir(
sqlite3_bind_int64(pStmt, 3, iStartBlock);
sqlite3_bind_int64(pStmt, 4, iLeafEndBlock);
sqlite3_bind_int64(pStmt, 5, iEndBlock);
rc = sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);
if( rc==SQLITE_OK ){
sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);
sqlite3_step(pStmt);
rc = sqlite3_reset(pStmt);
}
}
return rc;
}
@ -1841,17 +1837,33 @@ static void fts3ColumnFilter(
** segments to create a single, larger segment.
*/
static int fts3MergeCallback(
Fts3Table *p,
void *pContext,
char *zTerm,
int nTerm,
char *aDoclist,
int nDoclist
Fts3Table *p, /* FTS3 Virtual table handle */
void *pContext, /* Pointer to SegmentWriter* to write with */
char *zTerm, /* Term to write to the db */
int nTerm, /* Number of bytes in zTerm */
char *aDoclist, /* Doclist associated with zTerm */
int nDoclist /* Number of bytes in doclist */
){
SegmentWriter **ppW = (SegmentWriter **)pContext;
return fts3SegWriterAdd(p, ppW, 1, zTerm, nTerm, aDoclist, nDoclist);
}
/*
** sqlite3Fts3SegReaderIterate() callback used when flushing the contents
** of the pending-terms hash table to the database.
*/
static int fts3FlushCallback(
Fts3Table *p, /* FTS3 Virtual table handle */
void *pContext, /* Pointer to SegmentWriter* to write with */
char *zTerm, /* Term to write to the db */
int nTerm, /* Number of bytes in zTerm */
char *aDoclist, /* Doclist associated with zTerm */
int nDoclist /* Number of bytes in doclist */
){
SegmentWriter **ppW = (SegmentWriter **)pContext;
return fts3SegWriterAdd(p, ppW, 0, zTerm, nTerm, aDoclist, nDoclist);
}
/*
** This function is used to iterate through a contiguous set of terms
** stored in the full-text index. It merges data contained in one or
@ -2176,7 +2188,7 @@ int sqlite3Fts3PendingTermsFlush(Fts3Table *p){
memset(&f, 0, sizeof(Fts3SegFilter));
f.flags = FTS3_SEGMENT_REQUIRE_POS;
rc = sqlite3Fts3SegReaderIterate(p, &pReader, 1, &f, fts3MergeCallback, c);
rc = sqlite3Fts3SegReaderIterate(p, &pReader, 1, &f, fts3FlushCallback, c);
}
assert( pWriter || rc!=SQLITE_OK );

View File

@ -1,5 +1,5 @@
C Add\scoverage\stest\scases\sfor\sfts3.
D 2009-12-12T09:51:25
C Extra\stests\sfor\scoverage\sof\sfts3\scode.
D 2009-12-12T13:16:10
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -68,7 +68,7 @@ F ext/fts3/fts3_snippet.c 6c2eb6d872d66b2a9aa5663f2662e993f18a6496
F ext/fts3/fts3_tokenizer.c 1a49ee3d79cbf0b9386250370d9cbfe4bb89c8ff
F ext/fts3/fts3_tokenizer.h 7ff73caa3327589bf6550f60d93ebdd1f6a0fb5c
F ext/fts3/fts3_tokenizer1.c 11a604a53cff5e8c28882727bf794e5252e5227b
F ext/fts3/fts3_write.c a8f2eb04ac4cc869b7d7ffbfff63a4805e5559a9
F ext/fts3/fts3_write.c 8fa73906993c46d1add03367d658b4b2f2214bb8
F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100
F ext/icu/README.txt 3b130aa66e7a681136f6add198b076a2f90d1e33
F ext/icu/icu.c 12e763d288d23b5a49de37caa30737b971a2f1e2
@ -396,14 +396,14 @@ F test/fts3ao.test 0aa29dd4fc1c8d46b1f7cfe5926f7ac97551bea9
F test/fts3atoken.test 25c2070e1e8755d414bf9c8200427b277a9f99fa
F test/fts3b.test e93bbb653e52afde110ad53bbd793f14fe7a8984
F test/fts3c.test fc723a9cf10b397fdfc2b32e73c53c8b1ec02958
F test/fts3cov.test 1a21eb90d994bc8dee3fb810ee663902d0796fa7
F test/fts3cov.test ce49852ac727c74cfce8e5a4cc017c7edfab7b7e
F test/fts3d.test 95fb3c862cbc4297c93fceb9a635543744e9ef52
F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851
F test/fts3expr.test 05dab77387801e4900009917bb18f556037d82da
F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a
F test/fts3malloc.test d02ee86b21edd2b43044e0d6dfdcd26cb6efddcb
F test/fts3near.test dc196dd17b4606f440c580d45b3d23aa975fd077
F test/fts3rnd.test 03e88da0bd300e48f9c9a154362d501fab259f9f
F test/fts3rnd.test 2a78df5478657fca6444ee03cf930437c47e9a5e
F test/func.test af106ed834001738246d276659406823e35cde7b
F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f
F test/fuzz.test a4174c3009a3e2c2e14b31b364ebf7ddb49de2c9
@ -779,7 +779,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 1342916fd350d06e1c1f3d7d380249f0c9282c7b
R 513a9c1fbf0e1a704528face3e7e0567
P 8fcb0478c82507403165719724b62a308cb83b57
R d40786c1d80a3afa7931ef13f5717bff
U dan
Z d3f9cc9a3767b7f1e5f0d0743941cc08
Z c1a18afcca5dea4da3d83da1f45ced06

View File

@ -1 +1 @@
8fcb0478c82507403165719724b62a308cb83b57
eee921a99e69a9cd868a89de620bf47c4e26e4b5

View File

@ -164,5 +164,39 @@ do_write_test fts3cov-4.2 t3_content {
SELECT 6, 'Home to your noble father''s hall.'''
}
#-------------------------------------------------------------------------
# When building the internal tree structure for each segment b-tree, FTS3
# assumes that the content of each internal node will be less than
# $nodesize bytes, where $nodesize is the advisory node size. If this turns
# out to be untrue, then an extra buffer must be malloc'd for each term.
# This test case tests these paths and the effects of said mallocs failing
# by inserting insert a document with some fairly large terms into a
# full-text table with a very small node-size.
#
do_test fts3cov-5.1 {
execsql {
CREATE VIRTUAL TABLE t4 USING fts3(x);
INSERT INTO t4(t4) VALUES('nodesize=24');
}
} {}
set DO_MALLOC_TEST 1
do_write_test fts3cov-5.2 t4_content {
INSERT INTO t4
SELECT 'ItisanancientMarinerAndhestoppethoneofthreeAA' UNION ALL
SELECT 'ItisanancientMarinerAndhestoppethoneofthreeBB' UNION ALL
SELECT 'ItisanancientMarinerAndhestoppethoneofthreeCC' UNION ALL
SELECT 'BythylonggreybeardandglitteringeyeNowwhereforestoppstAA' UNION ALL
SELECT 'BythylonggreybeardandglitteringeyeNowwhereforestoppstBB' UNION ALL
SELECT 'BythylonggreybeardandglitteringeyeNowwhereforestoppstCC'
}
do_test fts3cov-5.3 {
execsql { INSERT INTO t4 VALUES('extra!') }
} {}
do_write_test fts3cov-5.2 t4_segments {
INSERT INTO t4(t4) VALUES('optimize')
}
finish_test

View File

@ -94,9 +94,11 @@ expr srand(0)
#
set lChar {a b c d e f g h i j k l m n o p q r s t u v w x y z}
for {set i 0} {$i < $nVocab} {incr i} {
set len [expr int(rand()*3)+2]
set word [lindex $lChar [expr int(rand()*26)]]
append word [lindex $lChar [expr int(rand()*26)]]
append word [lindex $lChar [expr int(rand()*26)]]
if {$len>2} { append word [lindex $lChar [expr int(rand()*26)]] }
if {$len>3} { append word [lindex $lChar [expr int(rand()*26)]] }
lappend lVocab $word
}
@ -141,12 +143,19 @@ proc update_row {rowid} {
proc simple_phrase {zPrefix} {
set ret [list]
set pattern "*[string map {* \[a-z\]} $zPrefix]*"
set reg [string map {* {[^ ]*}} $zPrefix]
set reg " $reg "
foreach {key value} [array get ::t1] {
if {[string match $pattern $value]} { lappend ret $key }
foreach col $value {
if {[regexp $reg " $col "]} {lappend ret $key}
}
lsort -integer $ret
}
lsort -uniq -integer $ret
}
proc simple_near {termlist nNear} {
set ret [list]
@ -265,7 +274,7 @@ foreach nodesize {50 500 1000 2000} {
# as querying the FTS3 table for the prefix.
#
for {set i 0} {$i < $nRep} {incr i} {
set prefix [string range [random_term] 0 1]
set prefix [string range [random_term] 0 end-1]
set match "${prefix}*"
do_select_test fts3rnd-1.$nodesize.$iTest.2.$i {
SELECT docid FROM t1 WHERE t1 MATCH $match
@ -295,9 +304,9 @@ foreach nodesize {50 500 1000 2000} {
# Three word phrases made up of term-prefixes.
#
for {set i 0} {$i < $nRep} {incr i} {
set query "[string range [random_term] 0 1]* "
append query "[string range [random_term] 0 1]* "
append query "[string range [random_term] 0 1]*"
set query "[string range [random_term] 0 end-1]* "
append query "[string range [random_term] 0 end-1]* "
append query "[string range [random_term] 0 end-1]*"
set match "\"$query\""
do_select_test fts3rnd-1.$nodesize.$iTest.5.$i {