/ Check-in [adc9283d]
Login

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

Overview
Comment:Fix a bug in the fts3 snippet() function causing it to omit leading separator characters from snippets that begin with the first token in a column.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: adc9283dd9bc3a6463f8c4fe23dd58a3712c349d
User & Date: dan 2015-01-27 19:01:26
Context
2015-01-27
21:24
Fix harmless compiler warnings. check-in: e7d2ec04 user: mistachkin tags: trunk
19:01
Fix a bug in the fts3 snippet() function causing it to omit leading separator characters from snippets that begin with the first token in a column. check-in: adc9283d user: dan tags: trunk
18:43
Improve the performance of fts3/4 queries that use the OR operator and at least one auxiliary fts function. check-in: 245e8730 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3_snippet.c.

   678    678         );
   679    679         isShiftDone = 1;
   680    680   
   681    681         /* Now that the shift has been done, check if the initial "..." are
   682    682         ** required. They are required if (a) this is not the first fragment,
   683    683         ** or (b) this fragment does not begin at position 0 of its column. 
   684    684         */
   685         -      if( rc==SQLITE_OK && (iPos>0 || iFragment>0) ){
   686         -        rc = fts3StringAppend(pOut, zEllipsis, -1);
          685  +      if( rc==SQLITE_OK ){
          686  +        if( iPos>0 || iFragment>0 ){
          687  +          rc = fts3StringAppend(pOut, zEllipsis, -1);
          688  +        }else if( iBegin ){
          689  +          rc = fts3StringAppend(pOut, zDoc, iBegin);
          690  +        }
   687    691         }
   688    692         if( rc!=SQLITE_OK || iCurrent<iPos ) continue;
   689    693       }
   690    694   
   691    695       if( iCurrent>=(iPos+nSnippet) ){
   692    696         if( isLast ){
   693    697           rc = fts3StringAppend(pOut, zEllipsis, -1);

Changes to test/fts3snippet.test.

   516    516     {five [one] two three [four]}
   517    517     {[four] five [one] two three}
   518    518     {three [four] five [one] two}
   519    519     {two three [four] five [one]}
   520    520     {[one] two three [four] five}
   521    521   }
   522    522   
          523  +#-------------------------------------------------------------------------
          524  +do_execsql_test 3 {
          525  +  CREATE VIRTUAL TABLE t3 USING fts4;
          526  +  INSERT INTO t3 VALUES('[one two three]');
          527  +}
          528  +do_execsql_test 3.1 {
          529  +  SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'one';
          530  +} {{[<b>one</b> two three]}}
          531  +do_execsql_test 3.2 {
          532  +  SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'two';
          533  +} {{[one <b>two</b> three]}}
          534  +do_execsql_test 3.3 {
          535  +  SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'three';
          536  +} {{[one two <b>three</b>]}}
          537  +do_execsql_test 3.4 {
          538  +  SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'one OR two OR three';
          539  +} {{[<b>one</b> <b>two</b> <b>three</b>]}}
          540  +
   523    541   set sqlite_fts3_enable_parentheses 0
   524    542   finish_test
          543  +