SQLite

Check-in [0ea3ece988]
Login

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

Overview
Comment:Fix an fts5 bug that could cause a crash following an OOM error or sqlite3_interrupt() interrupt.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0ea3ece988883874bb88e3daaa220d7fc0cf36ef
User & Date: dan 2016-12-09 16:12:04.593
Context
2016-12-09
17:32
In sqlite3BtreeInsert() when replacing a re-existing row, try to overwrite the cell directly rather than deallocate and reallocate the cell. (check-in: 0b86fbca66 user: drh tags: trunk)
16:12
Fix an fts5 bug that could cause a crash following an OOM error or sqlite3_interrupt() interrupt. (check-in: 0ea3ece988 user: dan tags: trunk)
16:02
Avoid unnecessary zeroing of fields in the MemPage object that are going to be reinitialized before use anyhow. A smaller and faster binary results. (check-in: 01ada3d106 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to ext/fts5/fts5_expr.c.
1340
1341
1342
1343
1344
1345
1346


1347

1348
1349
1350
1351
1352
1353
1354

  p->pIndex = pIdx;
  p->bDesc = bDesc;
  rc = fts5ExprNodeFirst(p, pRoot);

  /* If not at EOF but the current rowid occurs earlier than iFirst in
  ** the iteration order, move to document iFirst or later. */


  if( pRoot->bEof==0 && fts5RowidCmp(p, pRoot->iRowid, iFirst)<0 ){

    rc = fts5ExprNodeNext(p, pRoot, 1, iFirst);
  }

  /* If the iterator is not at a real match, skip forward until it is. */
  while( pRoot->bNomatch ){
    assert( pRoot->bEof==0 && rc==SQLITE_OK );
    rc = fts5ExprNodeNext(p, pRoot, 0, 0);







>
>
|
>







1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357

  p->pIndex = pIdx;
  p->bDesc = bDesc;
  rc = fts5ExprNodeFirst(p, pRoot);

  /* If not at EOF but the current rowid occurs earlier than iFirst in
  ** the iteration order, move to document iFirst or later. */
  if( rc==SQLITE_OK 
   && 0==pRoot->bEof 
   && fts5RowidCmp(p, pRoot->iRowid, iFirst)<0 
  ){
    rc = fts5ExprNodeNext(p, pRoot, 1, iFirst);
  }

  /* If the iterator is not at a real match, skip forward until it is. */
  while( pRoot->bNomatch ){
    assert( pRoot->bEof==0 && rc==SQLITE_OK );
    rc = fts5ExprNodeNext(p, pRoot, 0, 0);
Changes to ext/fts5/test/fts5faultB.test.
74
75
76
77
78
79
80




























81
82
83

do_faultsim_test 2.4 -faults oom* -body {
  execsql { SELECT mit(matchinfo(t1, 's')) FROM t1('a b c') }
} -test {
  faultsim_test_result {0 {{3 2} {2 3}}} 
}






























finish_test








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



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

do_faultsim_test 2.4 -faults oom* -body {
  execsql { SELECT mit(matchinfo(t1, 's')) FROM t1('a b c') }
} -test {
  faultsim_test_result {0 {{3 2} {2 3}}} 
}

#-------------------------------------------------------------------------
#
reset_db 
do_execsql_test 3.0 {
  CREATE VIRTUAL TABLE x1 USING fts5(z);
}

do_faultsim_test 3.1 -faults oom* -body {
  execsql {
    SELECT rowid FROM x1('c') WHERE rowid>1;
  }
} -test {
  faultsim_test_result {0 {}}
}

do_execsql_test 3.2 {
  INSERT INTO x1 VALUES('a b c');
  INSERT INTO x1 VALUES('b c d');
  INSERT INTO x1 VALUES('c d e');
  INSERT INTO x1 VALUES('d e f');
}
do_faultsim_test 3.3 -faults oom* -body {
  execsql {
    SELECT rowid FROM x1('c') WHERE rowid>1;
  }
} -test {
  faultsim_test_result {0 {2 3}}
}

finish_test