From: dan Date: Tue, 27 Jan 2015 19:01:26 +0000 (+0000) Subject: Fix a bug in the fts3 snippet() function causing it to omit leading separator charact... X-Git-Tag: version-3.8.9~151 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6f0138e89ecaac3561fbfa297417adbe0a49798d;p=thirdparty%2Fsqlite.git 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 --- diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index 93ee86f6af..e40750502b 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -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) ){ - rc = fts3StringAppend(pOut, zEllipsis, -1); + 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 || iCurrentone two three]}} +do_execsql_test 3.2 { + SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'two'; +} {{[one two three]}} +do_execsql_test 3.3 { + SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'three'; +} {{[one two three]}} +do_execsql_test 3.4 { + SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'one OR two OR three'; +} {{[one two three]}} + set sqlite_fts3_enable_parentheses 0 finish_test +