/ Check-in [eafd0a1e]
Login

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

Overview
Comment:Fix a problem causing an assert() to fail if a snippet containing 0 tokens was requested from fts3.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: eafd0a1e3f25f38d551603f177ff4634cf79de77
User & Date: dan 2015-04-15 08:20:50
Context
2015-04-15
08:37
Remove a branch that became unreachable due to one of the earlier check-ins today. check-in: fa0956ed user: drh tags: trunk
08:20
Fix a problem causing an assert() to fail if a snippet containing 0 tokens was requested from fts3. check-in: eafd0a1e user: dan tags: trunk
07:57
Fix the error message generator for illegal token errors so that it does not leak memory if it immediately follows another erroneous SQL statement. check-in: 3576973f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3.c.

  3523   3523       case 5: iCol = sqlite3_value_int(apVal[4]);
  3524   3524       case 4: zEllipsis = (const char*)sqlite3_value_text(apVal[3]);
  3525   3525       case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]);
  3526   3526       case 2: zStart = (const char*)sqlite3_value_text(apVal[1]);
  3527   3527     }
  3528   3528     if( !zEllipsis || !zEnd || !zStart ){
  3529   3529       sqlite3_result_error_nomem(pContext);
         3530  +  }else if( nToken==0 ){
         3531  +    sqlite3_result_text(pContext, "", -1, SQLITE_STATIC);
  3530   3532     }else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){
  3531   3533       sqlite3Fts3Snippet(pContext, pCsr, zStart, zEnd, zEllipsis, iCol, nToken);
  3532   3534     }
  3533   3535   }
  3534   3536   
  3535   3537   /*
  3536   3538   ** Implementation of the offsets() function for FTS3

Changes to test/fts3snippet.test.

   533    533   } {{[one <b>two</b> three]}}
   534    534   do_execsql_test 3.3 {
   535    535     SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'three';
   536    536   } {{[one two <b>three</b>]}}
   537    537   do_execsql_test 3.4 {
   538    538     SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'one OR two OR three';
   539    539   } {{[<b>one</b> <b>two</b> <b>three</b>]}}
          540  +
          541  +#-------------------------------------------------------------------------
          542  +# Request a snippet 0 tokens in size. This is always an empty string.
          543  +do_execsql_test 4.1 {
          544  +  CREATE VIRTUAL TABLE t4 USING fts4;
          545  +  INSERT INTO t4 VALUES('a b c d');
          546  +  SELECT snippet(t4, '[', ']', '...', 0, 0) FROM t4 WHERE t4 MATCH 'b';
          547  +} {{}}
          548  +
          549  +do_test 4.2 {
          550  +  set x35 [string trim [string repeat "x " 35]]
          551  +  execsql "INSERT INTO t4 VALUES('$x35 E $x35 F $x35 G $x35');"
          552  +  llength [db one {
          553  +    SELECT snippet(t4, '', '', '', 0, 64) FROM t4 WHERE t4 MATCH 'E'
          554  +  }]
          555  +} {64}
          556  +
          557  +
          558  +
   540    559   
   541    560   set sqlite_fts3_enable_parentheses 0
   542    561   finish_test
   543    562