/ Check-in [b30dfba8]
Login

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

Overview
Comment:Ensure pointer map entries are always added when a row that does use overflow pages replaces one that does not in an auto-vacuum database. Fix for [fda22108].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b30dfba811cb531b09ff2e71a1a18ed53c816cb39155dd52ca3e2701425fe17b
User & Date: dan 2017-06-08 11:14:08
Context
2017-06-12
23:44
Ensure pointer map entries are always added when a row that does use overflow pages replaces one that does not in an auto-vacuum database. Fix for [fda22108]. check-in: 30c50f0e user: drh tags: branch-3.18
2017-06-08
14:35
Add a testcase() to confirm that an OOM on sqlite3DbStrNDup() is handled correctly in trigger.c. check-in: 343e5599 user: drh tags: trunk
11:26
Ensure pointer map entries are always added when a row that does use overflow pages replaces one that does not in an auto-vacuum database. Fix for [fda22108]. check-in: 9478106c user: drh tags: branch-3.19
11:14
Ensure pointer map entries are always added when a row that does use overflow pages replaces one that does not in an auto-vacuum database. Fix for [fda22108]. check-in: b30dfba8 user: dan tags: trunk
2017-06-07
22:32
In SQLITE_DEBUG mode, attempt to log the page number of the database that contained the problem when SQLITE_CORRUPT errors are seen. check-in: e39795d7 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  8169   8169         goto end_insert;
  8170   8170       }
  8171   8171       oldCell = findCell(pPage, idx);
  8172   8172       if( !pPage->leaf ){
  8173   8173         memcpy(newCell, oldCell, 4);
  8174   8174       }
  8175   8175       rc = clearCell(pPage, oldCell, &info);
  8176         -    if( info.nSize==szNew && info.nLocal==info.nPayload ){
         8176  +    if( info.nSize==szNew && info.nLocal==info.nPayload 
         8177  +     && (!ISAUTOVACUUM || szNew<pPage->minLocal)
         8178  +    ){
  8177   8179         /* Overwrite the old cell with the new if they are the same size.
  8178   8180         ** We could also try to do this if the old cell is smaller, then add
  8179   8181         ** the leftover space to the free list.  But experiments show that
  8180   8182         ** doing that is no faster then skipping this optimization and just
  8181         -      ** calling dropCell() and insertCell(). */
         8183  +      ** calling dropCell() and insertCell(). 
         8184  +      **
         8185  +      ** This optimization cannot be used on an autovacuum database if the
         8186  +      ** new entry uses overflow pages, as the insertCell() call below is
         8187  +      ** necessary to add the PTRMAP_OVERFLOW1 pointer-map entry.  */
  8182   8188         assert( rc==SQLITE_OK ); /* clearCell never fails when nLocal==nPayload */
  8183   8189         if( oldCell+szNew > pPage->aDataEnd ) return SQLITE_CORRUPT_BKPT;
  8184   8190         memcpy(oldCell, newCell, szNew);
  8185   8191         return SQLITE_OK;
  8186   8192       }
  8187   8193       dropCell(pPage, idx, info.nSize, &rc);
  8188   8194       if( rc ) goto end_insert;

Changes to test/autovacuum.test.

   701    701     execsql { INSERT INTO t1 SELECT NULL, randstr(50,50) FROM t1 }
   702    702   } {}
   703    703   do_test autovacuum-9.5 {
   704    704     execsql { DELETE FROM t1 WHERE rowid > (SELECT max(a)/2 FROM t1) }
   705    705     file size test.db
   706    706   } $::sqlite_pending_byte
   707    707    
          708  +do_execsql_test autovacuum-10.1 {
          709  +  DROP TABLE t1;
          710  +  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
          711  +  INSERT INTO t1 VALUES(25, randomblob(104));
          712  +  REPLACE INTO t1 VALUES(25, randomblob(1117));
          713  +  PRAGMA integrity_check;
          714  +} {ok}
   708    715   
   709    716   finish_test