SQLite

Check-in [adc9283dd9]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: adc9283dd9bc3a6463f8c4fe23dd58a3712c349d
User & Date: dan 2015-01-27 19:01:26.607
Context
2015-01-27
21:24
Fix harmless compiler warnings. (check-in: e7d2ec048c 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: adc9283dd9 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: 245e873045 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to ext/fts3/fts3_snippet.c.
678
679
680
681
682
683
684
685

686



687
688
689
690
691
692
693
      );
      isShiftDone = 1;

      /* Now that the shift has been done, check if the initial "..." are
      ** required. They are required if (a) this is not the first fragment,
      ** or (b) this fragment does not begin at position 0 of its column. 
      */
      if( rc==SQLITE_OK && (iPos>0 || iFragment>0) ){

        rc = fts3StringAppend(pOut, zEllipsis, -1);



      }
      if( rc!=SQLITE_OK || iCurrent<iPos ) continue;
    }

    if( iCurrent>=(iPos+nSnippet) ){
      if( isLast ){
        rc = fts3StringAppend(pOut, zEllipsis, -1);







|
>
|
>
>
>







678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
      );
      isShiftDone = 1;

      /* Now that the shift has been done, check if the initial "..." are
      ** required. They are required if (a) this is not the first fragment,
      ** or (b) this fragment does not begin at position 0 of its column. 
      */
      if( rc==SQLITE_OK ){
        if( iPos>0 || iFragment>0 ){
          rc = fts3StringAppend(pOut, zEllipsis, -1);
        }else if( iBegin ){
          rc = fts3StringAppend(pOut, zDoc, iBegin);
        }
      }
      if( rc!=SQLITE_OK || iCurrent<iPos ) continue;
    }

    if( iCurrent>=(iPos+nSnippet) ){
      if( isLast ){
        rc = fts3StringAppend(pOut, zEllipsis, -1);
Changes to test/fts3snippet.test.
516
517
518
519
520
521
522


















523
524

  {five [one] two three [four]}
  {[four] five [one] two three}
  {three [four] five [one] two}
  {two three [four] five [one]}
  {[one] two three [four] five}
}



















set sqlite_fts3_enable_parentheses 0
finish_test








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


>
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
  {five [one] two three [four]}
  {[four] five [one] two three}
  {three [four] five [one] two}
  {two three [four] five [one]}
  {[one] two three [four] five}
}

#-------------------------------------------------------------------------
do_execsql_test 3 {
  CREATE VIRTUAL TABLE t3 USING fts4;
  INSERT INTO t3 VALUES('[one two three]');
}
do_execsql_test 3.1 {
  SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'one';
} {{[<b>one</b> two three]}}
do_execsql_test 3.2 {
  SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'two';
} {{[one <b>two</b> three]}}
do_execsql_test 3.3 {
  SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'three';
} {{[one two <b>three</b>]}}
do_execsql_test 3.4 {
  SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'one OR two OR three';
} {{[<b>one</b> <b>two</b> <b>three</b>]}}

set sqlite_fts3_enable_parentheses 0
finish_test