/ 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 Unified Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3.c.

3523
3524
3525
3526
3527
3528
3529


3530
3531
3532
3533
3534
3535
3536
    case 5: iCol = sqlite3_value_int(apVal[4]);
    case 4: zEllipsis = (const char*)sqlite3_value_text(apVal[3]);
    case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]);
    case 2: zStart = (const char*)sqlite3_value_text(apVal[1]);
  }
  if( !zEllipsis || !zEnd || !zStart ){
    sqlite3_result_error_nomem(pContext);


  }else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){
    sqlite3Fts3Snippet(pContext, pCsr, zStart, zEnd, zEllipsis, iCol, nToken);
  }
}

/*
** Implementation of the offsets() function for FTS3







>
>







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

/*
** Implementation of the offsets() function for FTS3

Changes to test/fts3snippet.test.

533
534
535
536
537
538
539



















540
541
542
543
} {{[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








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




533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
} {{[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>]}}

#-------------------------------------------------------------------------
# Request a snippet 0 tokens in size. This is always an empty string.
do_execsql_test 4.1 {
  CREATE VIRTUAL TABLE t4 USING fts4;
  INSERT INTO t4 VALUES('a b c d');
  SELECT snippet(t4, '[', ']', '...', 0, 0) FROM t4 WHERE t4 MATCH 'b';
} {{}}

do_test 4.2 {
  set x35 [string trim [string repeat "x " 35]]
  execsql "INSERT INTO t4 VALUES('$x35 E $x35 F $x35 G $x35');"
  llength [db one {
    SELECT snippet(t4, '', '', '', 0, 64) FROM t4 WHERE t4 MATCH 'E'
  }]
} {64}




set sqlite_fts3_enable_parentheses 0
finish_test