From: dan Date: Tue, 18 Oct 2011 12:44:04 +0000 (+0000) Subject: Fix a floating-point exception that can occur when an FTS4 query contains a large... X-Git-Tag: version-3.7.9~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=42495cd46fb4c41b29306e5f61ae259ab3758225;p=thirdparty%2Fsqlite.git Fix a floating-point exception that can occur when an FTS4 query contains a large number of tokens connected by AND or NEAR operators. FossilOrigin-Name: 3126754c72351c724be29d75a194bfc3e7b67205 --- diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index c2047437f0..754f3b5cb7 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -3966,7 +3966,11 @@ static int fts3EvalSelectDeferred( fts3SegReaderCursorFree(pToken->pSegcsr); pToken->pSegcsr = 0; }else{ - nLoad4 = nLoad4*4; + /* Set nLoad4 to the value of (4^nOther) for the next iteration of the + ** for-loop. Except, limit the value to 2^24 to prevent it from + ** overflowing the 32-bit integer it is stored in. */ + if( ii<12 ) nLoad4 = nLoad4*4; + if( ii==0 || pTC->pPhrase->nToken>1 ){ /* Either this is the cheapest token in the entire query, or it is ** part of a multi-token phrase. Either way, the entire doclist will diff --git a/manifest b/manifest index 05041e4872..ecd1811831 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sOP_JournalMode\simplementation\sso\sthat\sit\sworks\seven\sif\sa\nsubstitute\ssqlite3PagerFilename()\sthat\smight\sreturn\sNULL\sis\sused. -D 2011-10-17T23:15:31.767 +C Fix\sa\sfloating-point\sexception\sthat\scan\soccur\swhen\san\sFTS4\squery\scontains\sa\slarge\snumber\sof\stokens\sconnected\sby\sAND\sor\sNEAR\soperators. +D 2011-10-18T12:44:04.580 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -62,7 +62,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 d02bb1b3212f8ec9b98433630233d35278b43db2 +F ext/fts3/fts3.c 19f36945148cfd4ee3655b5fac0879ba4e0f3117 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 59c5a9475fed5d76c70a4763103b3c8e60424a68 F ext/fts3/fts3_aux.c 0ebfa7b86cf8ff6a0861605fcc63b83ec1b70691 @@ -471,7 +471,7 @@ F test/fts3corrupt.test 7b0f91780ca36118d73324ec803187208ad33b32 F test/fts3corrupt2.test 6d96efae2f8a6af3eeaf283aba437e6d0e5447ba F test/fts3cov.test e0fb00d8b715ddae4a94c305992dfc3ef70353d7 F test/fts3d.test 95fb3c862cbc4297c93fceb9a635543744e9ef52 -F test/fts3defer.test 7c8a38d5f617d7b52ae1c43ed73c536e7e895a35 +F test/fts3defer.test ffd4e07f79a09660d4b3e2613b041ab9b6100d91 F test/fts3defer2.test 35867d33ba6db03f6c73bd6f5fc333ae14f68c81 F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851 F test/fts3expr.test 5e745b2b6348499d9ef8d59015de3182072c564c @@ -970,7 +970,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 4becc47eb4d48686faca4f61e93e5f379b227fcc -R 39fd2a2cf30de71b2b3450062d311602 -U drh -Z 7b2456baf32ad39dc2142b8f75916654 +P 491ff5fb2504173d6905e38b8ea35737338aaa84 +R 58f061e71ad84767d73477085e2bfcf6 +U dan +Z b0882f47410096d3d98223e9ef02aa47 diff --git a/manifest.uuid b/manifest.uuid index 5d7b80b5e6..40229f72ff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -491ff5fb2504173d6905e38b8ea35737338aaa84 \ No newline at end of file +3126754c72351c724be29d75a194bfc3e7b67205 \ No newline at end of file diff --git a/test/fts3defer.test b/test/fts3defer.test index 4bc0b0a7c3..ab30bbe2c3 100644 --- a/test/fts3defer.test +++ b/test/fts3defer.test @@ -449,5 +449,33 @@ do_execsql_test 3.3 { SELECT count(*) FROM x1 WHERE x1 MATCH '"d e f"' } {16} +# At one point the following was causing a floating-point exception. +# +do_execsql_test 4.1 { + CREATE VIRTUAL TABLE x2 USING FTS4(x); + BEGIN; + INSERT INTO x2 VALUES('m m m m m m m m m m m m m m m m m m m m m m m m m m'); + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 SELECT * FROM x2; + INSERT INTO x2 VALUES('a b c d e f g h i j k l m n o p q r s t u v w x y m'); + COMMIT; +} +do_execsql_test 4.2 { + SELECT * FROM x2 WHERE x2 MATCH 'a b c d e f g h i j k l m n o p q r s'; +} {{a b c d e f g h i j k l m n o p q r s t u v w x y m}} + finish_test