Fix a bug in the fts3 snippet() function causing it to omit leading separator characters from snippets that begin with the first token in a column.

FossilOrigin-Name: adc9283dd9bc3a6463f8c4fe23dd58a3712c349d
This commit is contained in:
dan 2015-01-27 19:01:26 +00:00
parent 18f6ff9eb7
commit 6f0138e89e
4 changed files with 33 additions and 10 deletions

View File

@ -682,8 +682,12 @@ static int fts3SnippetText(
** required. They are required if (a) this is not the first fragment,
** or (b) this fragment does not begin at position 0 of its column.
*/
if( rc==SQLITE_OK && (iPos>0 || iFragment>0) ){
if( rc==SQLITE_OK ){
if( iPos>0 || iFragment>0 ){
rc = fts3StringAppend(pOut, zEllipsis, -1);
}else if( iBegin ){
rc = fts3StringAppend(pOut, zDoc, iBegin);
}
}
if( rc!=SQLITE_OK || iCurrent<iPos ) continue;
}

View File

@ -1,5 +1,5 @@
C Improve\sthe\sperformance\sof\sfts3/4\squeries\sthat\suse\sthe\sOR\soperator\sand\sat\sleast\sone\sauxiliary\sfts\sfunction.
D 2015-01-27T18:43:02.971
C Fix\sa\sbug\sin\sthe\sfts3\ssnippet()\sfunction\scausing\sit\sto\somit\sleading\sseparator\scharacters\sfrom\ssnippets\sthat\sbegin\swith\sthe\sfirst\stoken\sin\sa\scolumn.
D 2015-01-27T19:01:26.607
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5407a688f4d77a05c18a8142be8ae5a2829dd610
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -87,7 +87,7 @@ F ext/fts3/fts3_hash.c 29b986e43f4e9dd40110eafa377dc0d63c422c60
F ext/fts3/fts3_hash.h 39cf6874dc239d6b4e30479b1975fe5b22a3caaf
F ext/fts3/fts3_icu.c e319e108661147bcca8dd511cd562f33a1ba81b5
F ext/fts3/fts3_porter.c 3565faf04b626cddf85f03825e86056a4562c009
F ext/fts3/fts3_snippet.c 55c126e07158b2a705f52dee2cdc57208d3e999a
F ext/fts3/fts3_snippet.c f16ef6425f92339a8fecc87d9aaf2b12355c78e4
F ext/fts3/fts3_term.c a521f75132f9a495bdca1bdd45949b3191c52763
F ext/fts3/fts3_test.c 8a3a78c4458b2d7c631fcf4b152a5cd656fa7038
F ext/fts3/fts3_tokenize_vtab.c becc661223db7898b213f9e8a23d75bac02408c9
@ -593,7 +593,7 @@ F test/fts3prefix2.test e1f0a822ca661dced7f12ce392e14eaf65609dce
F test/fts3query.test 4fefd43ff24993bc2c9b2778f2bec0cc7629e7ed
F test/fts3rnd.test 1320d8826a845e38a96e769562bf83d7a92a15d0
F test/fts3shared.test 57e26a801f21027b7530da77db54286a6fe4997e
F test/fts3snippet.test d524af6bcef4714e059ef559113dbdc924cd33d1
F test/fts3snippet.test 03c2f3be7d3b7c8bb105ed237f204833392bd57f
F test/fts3sort.test ed34c716a11cc2009a35210e84ad5f9c102362ca
F test/fts3tok1.test c551043de056b0b1582a54e878991f57bad074bc
F test/fts3tok_err.test 52273cd193b9036282f7bacb43da78c6be87418d
@ -1237,7 +1237,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 e098de691002a78270540430b0df1e120582b53f
R 097e5fd012edfb2d64381b5476250a91
P 245e8730451fbdc1c729beff7295c452df604009
R 9b90e66d84773104aa9a7aba84baf66d
U dan
Z 72e3dfc5e16e519968e47157e86381d8
Z f8bb39ab94c5b09db26ae8d1068b8a66

View File

@ -1 +1 @@
245e8730451fbdc1c729beff7295c452df604009
adc9283dd9bc3a6463f8c4fe23dd58a3712c349d

View File

@ -520,5 +520,24 @@ do_execsql_test 2.6 {
{[one] two three [four] five}
}
#-------------------------------------------------------------------------
do_execsql_test 3 {
CREATE VIRTUAL TABLE t3 USING fts4;
INSERT INTO t3 VALUES('[one two three]');
}
do_execsql_test 3.1 {
SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'one';
} {{[<b>one</b> two three]}}
do_execsql_test 3.2 {
SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'two';
} {{[one <b>two</b> three]}}
do_execsql_test 3.3 {
SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'three';
} {{[one two <b>three</b>]}}
do_execsql_test 3.4 {
SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'one OR two OR three';
} {{[<b>one</b> <b>two</b> <b>three</b>]}}
set sqlite_fts3_enable_parentheses 0
finish_test