File tree Expand file tree Collapse file tree 2 files changed +24
-14
lines changed
Expand file tree Collapse file tree 2 files changed +24
-14
lines changed Original file line number Diff line number Diff line change @@ -4711,7 +4711,6 @@ static void fts5DoSecureDelete(
47114711 int iIdx = 0 ;
47124712 int iStart = 0 ;
47134713 int iKeyOff = 0 ;
4714- int iPrevKeyOff = 0 ;
47154714 int iDelKeyOff = 0 ; /* Offset of deleted key, if any */
47164715
47174716 nIdx = nPg - iPgIdx ;
@@ -4893,26 +4892,24 @@ static void fts5DoSecureDelete(
48934892 }
48944893
48954894 if ( p -> rc == SQLITE_OK ){
4896- const int nMove = nPg - iNextOff ;
4897- int nShift = 0 ;
4895+ const int nMove = nPg - iNextOff ; /* Number of bytes to move */
4896+ int nShift = iNextOff - iOff ; /* Distance to move them */
4897+ int iPrevKeyOut = 0 ;
4898+ int iKeyIn = 0 ;
48984899
48994900 memmove (& aPg [iOff ], & aPg [iNextOff ], nMove );
4900- iPgIdx -= ( iNextOff - iOff ) ;
4901+ iPgIdx -= nShift ;
49014902 nPg = iPgIdx ;
49024903 fts5PutU16 (& aPg [2 ], iPgIdx );
49034904
4904- nShift = iNextOff - iOff ;
4905- for (iIdx = 0 , iKeyOff = 0 , iPrevKeyOff = 0 ; iIdx < nIdx ; /* no-op */ ){
4905+ for (iIdx = 0 ; iIdx < nIdx ; /* no-op */ ){
49064906 u32 iVal = 0 ;
49074907 iIdx += fts5GetVarint32 (& aIdx [iIdx ], iVal );
4908- iKeyOff += iVal ;
4909- if ( iKeyOff != iDelKeyOff ){
4910- if ( iKeyOff > iOff ){
4911- iKeyOff -= nShift ;
4912- nShift = 0 ;
4913- }
4914- nPg += sqlite3Fts5PutVarint (& aPg [nPg ], iKeyOff - iPrevKeyOff );
4915- iPrevKeyOff = iKeyOff ;
4908+ iKeyIn += iVal ;
4909+ if ( iKeyIn != iDelKeyOff ){
4910+ int iKeyOut = (iKeyIn - (iKeyIn > iOff ? nShift : 0 ));
4911+ nPg += sqlite3Fts5PutVarint (& aPg [nPg ], iKeyOut - iPrevKeyOut );
4912+ iPrevKeyOut = iKeyOut ;
49164913 }
49174914 }
49184915
Original file line number Diff line number Diff line change @@ -273,6 +273,19 @@ do_execsql_test 5.3 {
273273do_execsql_test 5.4 { SELECT rowid FROM t1('abc'); } 2
274274do_execsql_test 5.5 { SELECT rowid FROM t1('aa'); } 2
275275
276+ #-------------------------------------------------------------------------
277+ reset_db
278+
279+ do_execsql_test 6.0 {
280+ CREATE VIRTUAL TABLE fts USING fts5(content);
281+ INSERT INTO fts(fts, rank) VALUES ('secure-delete', 1);
282+ INSERT INTO fts(rowid, content) VALUES
283+ (3407, 'profile profile profile profile profile profile profile profile pull pulling pulling really');
284+ DELETE FROM fts WHERE rowid IS 3407;
285+ INSERT INTO fts(fts) VALUES ('integrity-check');
286+ }
287+
288+
276289
277290finish_test
278291
You can’t perform that action at this time.
0 commit comments