mirror of
https://github.com/sqlite/sqlite.git
synced 2025-12-24 14:17:58 +03:00
Fix minor problems in term matching.
FossilOrigin-Name: 94eeb077d08a1d2607f3ff3a9fbf18229ba475bb
This commit is contained in:
@@ -461,8 +461,9 @@ static int fts5ParseTokenize(
|
||||
|
||||
pTerm = &pPhrase->aTerm[pPhrase->nTerm++];
|
||||
pTerm->bPrefix = 0;
|
||||
|
||||
pTerm->pIter = 0;
|
||||
pTerm->zTerm = fts5Strdup(pToken, nToken);
|
||||
|
||||
return pTerm->zTerm ? SQLITE_OK : SQLITE_NOMEM;
|
||||
}
|
||||
|
||||
|
||||
@@ -1097,8 +1097,8 @@ static void fts5SegIterNextPage(
|
||||
){
|
||||
Fts5StructureSegment *pSeg = pIter->pSeg;
|
||||
if( pIter->pLeaf ) fts5DataRelease(pIter->pLeaf);
|
||||
if( pIter->iLeafPgno<pSeg->pgnoLast ){
|
||||
pIter->iLeafPgno++;
|
||||
pIter->iLeafPgno++;
|
||||
if( pIter->iLeafPgno<=pSeg->pgnoLast ){
|
||||
pIter->pLeaf = fts5DataRead(p,
|
||||
FTS5_SEGMENT_ROWID(pIter->iIdx, pSeg->iSegid, 0, pIter->iLeafPgno)
|
||||
);
|
||||
@@ -1196,11 +1196,13 @@ static void fts5SegIterSeekInit(
|
||||
|
||||
iPg = node.iChild;
|
||||
for(fts5NodeIterNext(&p->rc, &node);
|
||||
node.aData && fts5BufferCompareBlob(&node.term, pTerm, nTerm)>=0;
|
||||
node.aData && fts5BufferCompareBlob(&node.term, pTerm, nTerm)<=0;
|
||||
fts5NodeIterNext(&p->rc, &node)
|
||||
){
|
||||
iPg = node.iChild;
|
||||
}
|
||||
fts5NodeIterFree(&node);
|
||||
fts5DataRelease(pNode);
|
||||
}
|
||||
|
||||
if( iPg>=pSeg->pgnoFirst ){
|
||||
@@ -1215,12 +1217,25 @@ static void fts5SegIterSeekInit(
|
||||
fts5SegIterLoadTerm(p, pIter, 0);
|
||||
|
||||
while( (res = fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)) ){
|
||||
if( res<0 ){
|
||||
/* Search for the end of the position list within the current page. */
|
||||
if( res<0 && pIter->iLeafPgno==iPg ){
|
||||
/* Search for the end of the current doclist within the current
|
||||
** page. The end of a doclist is marked by a pair of successive
|
||||
** 0x00 bytes. */
|
||||
int iOff;
|
||||
for(iOff=pIter->iLeafOffset; iOff<n && a[iOff]; iOff++);
|
||||
pIter->iLeafOffset = iOff+1;
|
||||
if( iOff<n ) continue;
|
||||
for(iOff=pIter->iLeafOffset+1; iOff<n; iOff++){
|
||||
if( a[iOff]==0 && a[iOff-1]==0 ) break;
|
||||
}
|
||||
iOff++;
|
||||
|
||||
/* If the iterator is not yet at the end of the next page, load
|
||||
** the next term and jump to the next iteration of the while()
|
||||
** loop. */
|
||||
if( iOff<n ){
|
||||
int nKeep;
|
||||
pIter->iLeafOffset = iOff + getVarint32(&a[iOff], nKeep);
|
||||
fts5SegIterLoadTerm(p, pIter, nKeep);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* No matching term on this page. Set the iterator to EOF. */
|
||||
|
||||
16
manifest
16
manifest
@@ -1,5 +1,5 @@
|
||||
C Begin\sadding\squery\ssupport\sto\sfts5.
|
||||
D 2014-06-25T20:28:38.917
|
||||
C Fix\sminor\sproblems\sin\sterm\smatching.
|
||||
D 2014-06-26T12:31:41.784
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@@ -106,8 +106,8 @@ F ext/fts3/unicode/mkunicode.tcl dc6f268eb526710e2c6e496c372471d773d0c368
|
||||
F ext/fts5/fts5.c 1af3184dd9c0e5c1686f71202d6b6cac8f225f05
|
||||
F ext/fts5/fts5Int.h 3fd1ebeb58963727cae0ccc8e4e80751bd870296
|
||||
F ext/fts5/fts5_config.c 94f1b4cb4de6a7cd5780c14adb0198e289df8cef
|
||||
F ext/fts5/fts5_expr.c 9666362ff500ce21262f355194c1f4b164261b5d
|
||||
F ext/fts5/fts5_index.c 3e6fbae93eb4dbaaa4bbba4bb11719aafefe363d
|
||||
F ext/fts5/fts5_expr.c 1874b17f10a38d0b21e0c38a28637f74e4d2570a
|
||||
F ext/fts5/fts5_index.c c8b21d12f15ca6fe028ede3f8e040dcb2aaef6f6
|
||||
F ext/fts5/fts5_storage.c 7848d8f8528d798bba159900ea310a6d4a279da8
|
||||
F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43
|
||||
F ext/icu/icu.c d415ccf984defeb9df2c0e1afcfaa2f6dc05eacb
|
||||
@@ -592,7 +592,7 @@ F test/fts4merge4.test d895b1057a7798b67e03455d0fa50e9ea836c47b
|
||||
F test/fts4noti.test 524807f0c36d49deea7920cdd4cd687408b58849
|
||||
F test/fts4unicode.test 01ec3fe2a7c3cfff3b4c0581b83caa11b33efa36
|
||||
F test/fts5aa.test c8d3b9694f6b2864161c7437408464a535d19343
|
||||
F test/fts5ab.test 79841ddc1645900b17dcf25d3767dcb05f82a4d4
|
||||
F test/fts5ab.test 6436ad345d1e7eb5ab198c0174834380805f609c
|
||||
F test/fts5ea.test ff43b40f8879ba50b82def70f2ab67c195d1a1d4
|
||||
F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d
|
||||
F test/func.test ae97561957aba6ca9e3a7b8a13aac41830d701ef
|
||||
@@ -1188,7 +1188,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
P 3515da85d09220c464979467b476c611da4a6a7a
|
||||
R 71f18cc20edef985f8bf9c192ad2143e
|
||||
P 47a9f3cc92deefe163108e3507bd4614bf1f5da7
|
||||
R b3c853e0de2f65908d06e4caafc2bc71
|
||||
U dan
|
||||
Z a8b08260950e139985bb661309680a76
|
||||
Z 840b486e1cfb6171cd4015bc26a5f123
|
||||
|
||||
@@ -1 +1 @@
|
||||
47a9f3cc92deefe163108e3507bd4614bf1f5da7
|
||||
94eeb077d08a1d2607f3ff3a9fbf18229ba475bb
|
||||
@@ -59,6 +59,7 @@ do_execsql_test 1.6 {
|
||||
reset_db
|
||||
do_execsql_test 2.1 {
|
||||
CREATE VIRTUAL TABLE t1 USING fts5(x);
|
||||
INSERT INTO t1(t1) VALUES('pgsz=32');
|
||||
INSERT INTO t1 VALUES('one');
|
||||
INSERT INTO t1 VALUES('two');
|
||||
INSERT INTO t1 VALUES('three');
|
||||
@@ -72,6 +73,32 @@ do_execsql_test 2.3 { SELECT rowid, * FROM t1 WHERE t1 MATCH 'two' } {2 two}
|
||||
do_execsql_test 2.4 { SELECT rowid, * FROM t1 WHERE t1 MATCH 'three' } {3 three}
|
||||
do_execsql_test 2.5 { SELECT rowid, * FROM t1 WHERE t1 MATCH 'one' } {1 one}
|
||||
|
||||
do_execsql_test 2.6 {
|
||||
INSERT INTO t1 VALUES('a b c d e f g');
|
||||
INSERT INTO t1 VALUES('b d e a a a i');
|
||||
INSERT INTO t1 VALUES('x y z b c c c');
|
||||
}
|
||||
|
||||
foreach {tn expr res} {
|
||||
1 a {5 4}
|
||||
2 b {6 5 4}
|
||||
3 c {6 4}
|
||||
4 d {5 4}
|
||||
5 e {5 4}
|
||||
6 f {4}
|
||||
7 g {4}
|
||||
8 x {6}
|
||||
9 y {6}
|
||||
10 z {6}
|
||||
} {
|
||||
do_execsql_test 2.7.$tn { SELECT rowid FROM t1 WHERE t1 MATCH $expr } $res
|
||||
}
|
||||
|
||||
#db eval {
|
||||
# SELECT fts5_decode(rowid, block) AS t FROM t1_data;
|
||||
#} {
|
||||
# puts $t
|
||||
#}
|
||||
|
||||
finish_test
|
||||
|
||||
|
||||
Reference in New Issue
Block a user