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_step(pStmt);
- rc = sqlite3_reset(pStmt);
- }
+ sqlite3_bind_blob(pStmt, 2, z, n, SQLITE_STATIC);
+ sqlite3_step(pStmt);
+ rc = sqlite3_reset(pStmt);
}
return rc;
}
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_step(pStmt);
- rc = sqlite3_reset(pStmt);
- }
+ sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);
+ sqlite3_step(pStmt);
+ rc = sqlite3_reset(pStmt);
}
return rc;
}
** 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
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 );
-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
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
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
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
-8fcb0478c82507403165719724b62a308cb83b57
\ No newline at end of file
+eee921a99e69a9cd868a89de620bf47c4e26e4b5
\ No newline at end of file
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
#
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
}
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]
# 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
# 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 {