SQLite

Check-in [6e0ffa20]
Login

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

Overview
Comment:Fix another fts3 problem with processing corrupt records.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 6e0ffa205312416830340ea6e621dfb1a529e5603d569941ed6263930dc28c45
User & Date: dan 2020-06-29 13:33:56
Context
2020-06-29
16:30
Do not run resetAccumulator() after a malloc failure. (check-in: 1b426603 user: drh tags: trunk)
13:33
Fix another fts3 problem with processing corrupt records. (check-in: 6e0ffa20 user: dan tags: trunk)
13:12
Small performance improvement in the sqlite3_step() interface. (check-in: 61400ef9 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3.c.

5204
5205
5206
5207
5208
5209
5210

5211
5212
5213
5214

5215
5216
5217
5218
5219
5220
5221

  p2 = pOut = pPhrase->doclist.pList;
  res = fts3PoslistNearMerge(
    &pOut, aTmp, nParam1, nParam2, paPoslist, &p2
  );
  if( res ){
    nNew = (int)(pOut - pPhrase->doclist.pList) - 1;

    assert( pPhrase->doclist.pList[nNew]=='\0' );
    assert( nNew<=pPhrase->doclist.nList && nNew>0 );
    memset(&pPhrase->doclist.pList[nNew], 0, pPhrase->doclist.nList - nNew);
    pPhrase->doclist.nList = nNew;

    *paPoslist = pPhrase->doclist.pList;
    *pnToken = pPhrase->nToken;
  }

  return res;
}








>
|
|
|
|
>







5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223

  p2 = pOut = pPhrase->doclist.pList;
  res = fts3PoslistNearMerge(
    &pOut, aTmp, nParam1, nParam2, paPoslist, &p2
  );
  if( res ){
    nNew = (int)(pOut - pPhrase->doclist.pList) - 1;
    if( nNew>=0 ){
      assert( pPhrase->doclist.pList[nNew]=='\0' );
      assert( nNew<=pPhrase->doclist.nList && nNew>0 );
      memset(&pPhrase->doclist.pList[nNew], 0, pPhrase->doclist.nList - nNew);
      pPhrase->doclist.nList = nNew;
    }
    *paPoslist = pPhrase->doclist.pList;
    *pnToken = pPhrase->nToken;
  }

  return res;
}

Changes to test/fts3corrupt4.test.

6130
6131
6132
6133
6134
6135
6136















6137
6138
do_execsql_test 42.2 {
  INSERT INTO f_segdir VALUES(0,2,1111,0,0,X'00');
  INSERT INTO f_segdir VALUES(0,3,0   ,0,0,X'00013003010200');
}
do_execsql_test 42.3 {
  INSERT INTO f(f) VALUES ('merge=107,2');
}
















finish_test







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


6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
do_execsql_test 42.2 {
  INSERT INTO f_segdir VALUES(0,2,1111,0,0,X'00');
  INSERT INTO f_segdir VALUES(0,3,0   ,0,0,X'00013003010200');
}
do_execsql_test 42.3 {
  INSERT INTO f(f) VALUES ('merge=107,2');
}

#-------------------------------------------------------------------------
reset_db
set saved $sqlite_fts3_enable_parentheses
set sqlite_fts3_enable_parentheses 1
do_execsql_test 43.1 {
  CREATE VIRTUAL TABLE def USING fts3(xyz);
  INSERT INTO def_segdir VALUES(0,0,0,0,0, X'0001310301c9000103323334050d81');
} {}

do_execsql_test 43.2 {
  SELECT rowid FROM def WHERE def MATCH '1 NEAR 1'
} {1}

set sqlite_fts3_enable_parentheses $saved

finish_test