/ Check-in [0bf438fc]
Login

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

Overview
Comment:Fix a crash in FTS incremental phrase processing that can occur if the second or subsequent token is much more common in the dataset than the first.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:0bf438fc30582a08fddfc3cec49366ee17ae2abe
User & Date: dan 2013-10-14 20:30:51
Context
2013-10-14
21:14
Move the tointeger() and toreal() functions out of core and make them into a run-time loadable extension. check-in: 9f66dd7e user: drh tags: trunk
20:30
Fix a crash in FTS incremental phrase processing that can occur if the second or subsequent token is much more common in the dataset than the first. check-in: 0bf438fc user: dan tags: trunk
19:35
Add implementations for the toInteger() and toReal() SQL functions. check-in: a0f7cbc0 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3.c.

4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341

    while( bEof==0 ){
      int bMaxSet = 0;
      sqlite3_int64 iMax = 0;     /* Largest docid for all iterators */
      int i;                      /* Used to iterate through tokens */

      /* Advance the iterator for each token in the phrase once. */
      for(i=0; rc==SQLITE_OK && i<p->nToken; i++){
        rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);
        if( a[i].bIgnore==0 && (bMaxSet==0 || DOCID_CMP(iMax, a[i].iDocid)<0) ){
          iMax = a[i].iDocid;
          bMaxSet = 1;
        }
      }
      assert( rc!=SQLITE_OK || a[p->nToken-1].bIgnore==0 );







|







4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341

    while( bEof==0 ){
      int bMaxSet = 0;
      sqlite3_int64 iMax = 0;     /* Largest docid for all iterators */
      int i;                      /* Used to iterate through tokens */

      /* Advance the iterator for each token in the phrase once. */
      for(i=0; rc==SQLITE_OK && i<p->nToken && bEof==0; i++){
        rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);
        if( a[i].bIgnore==0 && (bMaxSet==0 || DOCID_CMP(iMax, a[i].iDocid)<0) ){
          iMax = a[i].iDocid;
          bMaxSet = 1;
        }
      }
      assert( rc!=SQLITE_OK || a[p->nToken-1].bIgnore==0 );

Changes to test/fts4incr.test.

45
46
47
48
49
50
51
52






















53
  foreach s {0 1} {
    execsql "INSERT INTO t1(t1) VALUES('test-no-incr-doclist=$s')"
    do_execsql_test 2.$tn.$s $q $res
    set t($s) [lindex [time [list execsql $q] 100] 0]
  }
  puts "with optimization: $t(0)    without: $t(1)"
}























finish_test








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

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  foreach s {0 1} {
    execsql "INSERT INTO t1(t1) VALUES('test-no-incr-doclist=$s')"
    do_execsql_test 2.$tn.$s $q $res
    set t($s) [lindex [time [list execsql $q] 100] 0]
  }
  puts "with optimization: $t(0)    without: $t(1)"
}

do_test 2.1 {
  execsql {
    CREATE VIRTUAL TABLE t2 USING fts4(order=DESC);
  }
  set num [list one two three four five six seven eight nine ten]
  execsql BEGIN
  for {set i 0} {$i < 10000} {incr i} {
    set x "[lindex $num [expr $i%10]] zero"
    execsql { INSERT INTO t2(docid, content) VALUES($i, $x) }
  }
  execsql COMMIT
  execsql { INSERT INTO t2(t2) VALUES('optimize') }
} {}

do_execsql_test 2.2 {
  SELECT count(*) FROM t2 WHERE t2 MATCH '"never zero"'
} {0}

do_execsql_test 2.3 {
  SELECT count(*) FROM t2 WHERE t2 MATCH '"two zero"'
} {1000}

finish_test