Fix a problem causing an assert() to fail if a snippet containing 0 tokens was requested from fts3.

FossilOrigin-Name: eafd0a1e3f25f38d551603f177ff4634cf79de77
This commit is contained in:
dan 2015-04-15 08:20:50 +00:00
parent 347bdc39a7
commit 2deb12be2b
4 changed files with 30 additions and 9 deletions

View File

@ -3527,6 +3527,8 @@ static void fts3SnippetFunc(
}
if( !zEllipsis || !zEnd || !zStart ){
sqlite3_result_error_nomem(pContext);
}else if( nToken==0 ){
sqlite3_result_text(pContext, "", -1, SQLITE_STATIC);
}else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){
sqlite3Fts3Snippet(pContext, pCsr, zStart, zEnd, zEllipsis, iCol, nToken);
}

View File

@ -1,5 +1,5 @@
C Fix\sthe\serror\smessage\sgenerator\sfor\sillegal\stoken\serrors\sso\sthat\sit\sdoes\snot\nleak\smemory\sif\sit\simmediately\sfollows\sanother\serroneous\sSQL\sstatement.
D 2015-04-15T07:57:27.369
C Fix\sa\sproblem\scausing\san\sassert()\sto\sfail\sif\sa\ssnippet\scontaining\s0\stokens\swas\srequested\sfrom\sfts3.
D 2015-04-15T08:20:50.158
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5f78b1ab81b64e7c57a75d170832443e66c0880a
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -78,7 +78,7 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
F ext/fts3/fts3.c 57d863c3bd360e575ecc293570af7c9b0bdd2209
F ext/fts3/fts3.c ed6624d7c5fb5aee5d47f884b2d184169fa7a7d4
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
F ext/fts3/fts3Int.h 394858c12a17740f7a1f6bd372c4606d4425a8d1
F ext/fts3/fts3_aux.c 5c211e17a64885faeb16b9ba7772f9d5445c2365
@ -599,7 +599,7 @@ F test/fts3prefix2.test e1f0a822ca661dced7f12ce392e14eaf65609dce
F test/fts3query.test c838b18f2b859e15fd31c64be3d79ef1556803ca
F test/fts3rnd.test 1320d8826a845e38a96e769562bf83d7a92a15d0
F test/fts3shared.test 57e26a801f21027b7530da77db54286a6fe4997e
F test/fts3snippet.test 03c2f3be7d3b7c8bb105ed237f204833392bd57f
F test/fts3snippet.test 63dbd687d5bf5191f1b8e6a0977aa9c1e28a7004
F test/fts3sort.test ed34c716a11cc2009a35210e84ad5f9c102362ca
F test/fts3tok1.test c551043de056b0b1582a54e878991f57bad074bc
F test/fts3tok_err.test 52273cd193b9036282f7bacb43da78c6be87418d
@ -1250,7 +1250,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 eeb4bd06bf69e411736cc6077d1d64af6bd8fb09
R a12d30eac869033c520f48032e05590c
U drh
Z d83a0172461932509217291c59869b0d
P 3576973f8b88b6109fbefdebfa53468ffa137009
R 3265dd5ed99bf273b3517690abeeedc9
U dan
Z a6b618f03dfa759db2c6c3b930aa2a83

View File

@ -1 +1 @@
3576973f8b88b6109fbefdebfa53468ffa137009
eafd0a1e3f25f38d551603f177ff4634cf79de77

View File

@ -538,6 +538,25 @@ 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>]}}
#-------------------------------------------------------------------------
# Request a snippet 0 tokens in size. This is always an empty string.
do_execsql_test 4.1 {
CREATE VIRTUAL TABLE t4 USING fts4;
INSERT INTO t4 VALUES('a b c d');
SELECT snippet(t4, '[', ']', '...', 0, 0) FROM t4 WHERE t4 MATCH 'b';
} {{}}
do_test 4.2 {
set x35 [string trim [string repeat "x " 35]]
execsql "INSERT INTO t4 VALUES('$x35 E $x35 F $x35 G $x35');"
llength [db one {
SELECT snippet(t4, '', '', '', 0, 64) FROM t4 WHERE t4 MATCH 'E'
}]
} {64}
set sqlite_fts3_enable_parentheses 0
finish_test