/ Check-in [3126754c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a floating-point exception that can occur when an FTS4 query contains a large number of tokens connected by AND or NEAR operators.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3126754c72351c724be29d75a194bfc3e7b67205
User & Date: dan 2011-10-18 12:44:04
References
2011-10-18
12:49
Cherrypick patch [3126754c72] from the trunk into the content= branch. check-in: f9b5b217 user: dan tags: fts4-content
Context
2011-10-18
18:10
Improved handling of USING and NATURAL JOIN in 3-way and higher joins. Ticket [3338b3fa19ac4ab] check-in: 551ce407 user: drh tags: trunk
12:44
Fix a floating-point exception that can occur when an FTS4 query contains a large number of tokens connected by AND or NEAR operators. check-in: 3126754c user: dan tags: trunk
2011-10-17
23:15
Change the OP_JournalMode implementation so that it works even if a substitute sqlite3PagerFilename() that might return NULL is used. check-in: 491ff5fb user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3.c.

  3962   3962         ** that will be loaded if all subsequent tokens are deferred.
  3963   3963         */
  3964   3964         Fts3PhraseToken *pToken = pTC->pToken;
  3965   3965         rc = sqlite3Fts3DeferToken(pCsr, pToken, pTC->iCol);
  3966   3966         fts3SegReaderCursorFree(pToken->pSegcsr);
  3967   3967         pToken->pSegcsr = 0;
  3968   3968       }else{
  3969         -      nLoad4 = nLoad4*4;
         3969  +      /* Set nLoad4 to the value of (4^nOther) for the next iteration of the
         3970  +      ** for-loop. Except, limit the value to 2^24 to prevent it from 
         3971  +      ** overflowing the 32-bit integer it is stored in. */
         3972  +      if( ii<12 ) nLoad4 = nLoad4*4;
         3973  +
  3970   3974         if( ii==0 || pTC->pPhrase->nToken>1 ){
  3971   3975           /* Either this is the cheapest token in the entire query, or it is
  3972   3976           ** part of a multi-token phrase. Either way, the entire doclist will
  3973   3977           ** (eventually) be loaded into memory. It may as well be now. */
  3974   3978           Fts3PhraseToken *pToken = pTC->pToken;
  3975   3979           int nList = 0;
  3976   3980           char *pList = 0;

Changes to test/fts3defer.test.

   444    444     );
   445    445     INSERT INTO x1(x1) VALUES('optimize');
   446    446   "
   447    447   
   448    448   do_execsql_test 3.3 {
   449    449     SELECT count(*) FROM x1 WHERE x1 MATCH '"d e f"'
   450    450   } {16}
          451  +
          452  +# At one point the following was causing a floating-point exception.
          453  +#
          454  +do_execsql_test 4.1 {
          455  +  CREATE VIRTUAL TABLE x2 USING FTS4(x);
          456  +  BEGIN;
          457  +  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');
          458  +  INSERT INTO x2 SELECT * FROM x2;
          459  +  INSERT INTO x2 SELECT * FROM x2;
          460  +  INSERT INTO x2 SELECT * FROM x2;
          461  +  INSERT INTO x2 SELECT * FROM x2;
          462  +  INSERT INTO x2 SELECT * FROM x2;
          463  +  INSERT INTO x2 SELECT * FROM x2;
          464  +  INSERT INTO x2 SELECT * FROM x2;
          465  +  INSERT INTO x2 SELECT * FROM x2;
          466  +  INSERT INTO x2 SELECT * FROM x2;
          467  +  INSERT INTO x2 SELECT * FROM x2;
          468  +  INSERT INTO x2 SELECT * FROM x2;
          469  +  INSERT INTO x2 SELECT * FROM x2;
          470  +  INSERT INTO x2 SELECT * FROM x2;
          471  +  INSERT INTO x2 SELECT * FROM x2;
          472  +  INSERT INTO x2 SELECT * FROM x2;
          473  +  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');
          474  +  COMMIT;
          475  +}
          476  +do_execsql_test 4.2 {
          477  +  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';
          478  +} {{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}}
   451    479   
   452    480   
   453    481   finish_test