aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordan <dan@noemail.net>2010-11-24 15:02:22 +0000
committerdan <dan@noemail.net>2010-11-24 15:02:22 +0000
commitd6e12384bd54e38da5f19b940ae81c75e3384560 (patch)
tree8832375662296b5ac3510017ca20c7aebd0a3b8c
parentad3acbbfb3846bb062dfa103b202ebfb951a9590 (diff)
downloadsqlite-d6e12384bd54e38da5f19b940ae81c75e3384560.tar.gz
sqlite-d6e12384bd54e38da5f19b940ae81c75e3384560.zip
Fix crashes that can occur when queries are run on an FTS4 table containing zero rows.
FossilOrigin-Name: ed61fd20adef44d0f6b2345e0205b25f3641a15e
-rw-r--r--ext/fts3/fts3.c12
-rw-r--r--manifest14
-rw-r--r--manifest.uuid2
-rw-r--r--test/fts3matchinfo.test6
4 files changed, 22 insertions, 12 deletions
diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c
index 96a9736a9..c9a763ebc 100644
--- a/ext/fts3/fts3.c
+++ b/ext/fts3/fts3.c
@@ -2298,8 +2298,9 @@ static int fts3PhraseSelect(
if( pCsr->eEvalmode==FTS3_EVAL_NEXT && pTok->pDeferred ){
rc = fts3DeferredTermSelect(pTok->pDeferred, isTermPos, &nList, &pList);
}else{
- assert( pTok->pArray );
- rc = fts3TermSelect(p, pTok, iCol, isTermPos, &nList, &pList);
+ if( pTok->pArray ){
+ rc = fts3TermSelect(p, pTok, iCol, isTermPos, &nList, &pList);
+ }
pTok->bFulltext = 1;
}
assert( rc!=SQLITE_OK || pCsr->eEvalmode || pTok->pArray==0 );
@@ -2527,7 +2528,10 @@ static int fts3ExprCost(Fts3Expr *pExpr){
int ii;
nCost = 0;
for(ii=0; ii<pPhrase->nToken; ii++){
- nCost += pPhrase->aToken[ii].pArray->nCost;
+ Fts3SegReaderArray *pArray = pPhrase->aToken[ii].pArray;
+ if( pArray ){
+ nCost += pPhrase->aToken[ii].pArray->nCost;
+ }
}
}else{
nCost = fts3ExprCost(pExpr->pLeft) + fts3ExprCost(pExpr->pRight);
@@ -2555,7 +2559,7 @@ static void fts3ExprAssignCosts(
fts3ExprAssignCosts(pExpr->pRight, ppExprCost);
}else{
(*ppExprCost)->pExpr = pExpr;
- (*ppExprCost)->nCost = fts3ExprCost(pExpr);;
+ (*ppExprCost)->nCost = fts3ExprCost(pExpr);
(*ppExprCost)++;
}
}
diff --git a/manifest b/manifest
index 34f01f697..6722a26b9 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\ssome\sunused\scode\sfrom\sfts3.\sAdd\stests\sto\sfts3matchinfo.test.
-D 2010-11-24T11:51:56
+C Fix\scrashes\sthat\scan\soccur\swhen\squeries\sare\srun\son\san\sFTS4\stable\scontaining\szero\srows.
+D 2010-11-24T15:02:23
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in e7a59672eaeb04408d1fa8501618d7501a3c5e39
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -61,7 +61,7 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
-F ext/fts3/fts3.c 916091c7aeeefa8a7017865d97d10d13a5949b52
+F ext/fts3/fts3.c 0e207ae8008bb37e5c8a10581da328709b318354
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
F ext/fts3/fts3Int.h 52c818623c60943bc4ac4a22d77b2e8f28395e78
F ext/fts3/fts3_expr.c ee48b9278b8b2432a05a03320fbcacba151dbaa5
@@ -446,7 +446,7 @@ F test/fts3expr.test 5e745b2b6348499d9ef8d59015de3182072c564c
F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a
F test/fts3fault.test 81fd40ceb12f33f9d16c5637d0f8d95d4556c456
F test/fts3malloc.test 9c8cc3f885bb4dfc66d0460c52f68f45e4710d1b
-F test/fts3matchinfo.test cf3d0149f749abdb228c7bfe2350cf799b1809f4
+F test/fts3matchinfo.test 2dfdf80a927e3dc02f2e42337e5aa0b835994f6e
F test/fts3near.test 2e318ee434d32babd27c167142e2b94ddbab4844
F test/fts3query.test ef79d31fdb355d094baec1c1b24b60439a1fb8a2
F test/fts3rnd.test 707533ce943f490443ce5e696236bb1675a37635
@@ -889,7 +889,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 9cf0f2b76bc68c168e3fa861b7235f384db21d38
-R 9d3e5478b917e1cb6e46d1d7c8efa28d
+P ae40b34cf7c24c9601bdfb5cbe5b20f05a376ea8
+R bf9b07886b7dc4c93620c54d1a7703f7
U dan
-Z 2747212062c29415eaa46cf5d82fabf7
+Z c507e6c3579e8a599c5f904476d64b95
diff --git a/manifest.uuid b/manifest.uuid
index cea5ccd06..753f2ab88 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-ae40b34cf7c24c9601bdfb5cbe5b20f05a376ea8 \ No newline at end of file
+ed61fd20adef44d0f6b2345e0205b25f3641a15e \ No newline at end of file
diff --git a/test/fts3matchinfo.test b/test/fts3matchinfo.test
index 88166411c..03c4f22c8 100644
--- a/test/fts3matchinfo.test
+++ b/test/fts3matchinfo.test
@@ -66,6 +66,12 @@ do_execsql_test 3.1 {
SELECT mtchinfo FROM t3;
} {{Beside the lake, beneath the trees}}
+do_execsql_test 3.2 {
+ CREATE VIRTUAL TABLE xx USING FTS4;
+ SELECT * FROM xx WHERE xx MATCH 'abc';
+ SELECT * FROM xx WHERE xx MATCH 'a b c';
+}
+
#--------------------------------------------------------------------------
# Proc [do_matchinfo_test] is used to test the FTSX matchinfo() function.