/ Check-in [58577135]
Login

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

Overview
Comment:When extending a database file, do so by writing one or more page-size chunks of data to the file, instead of just a single byte to the end.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 58577135a81d3f19667b1de6167d2e3f1b74cd53
User & Date: dan 2011-01-28 15:07:56
Context
2011-01-28
15:46
Change pager_truncate() to a different method for extending files while also ensuring that writes are page-size and page-aligned. check-in: 874bc884 user: drh tags: trunk
15:07
When extending a database file, do so by writing one or more page-size chunks of data to the file, instead of just a single byte to the end. check-in: 58577135 user: dan tags: trunk
2011-01-27
14:35
SQLite version 3.7.5 release candidate 1 check-in: 35ac78f5 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

  2481   2481       /* TODO: Is it safe to use Pager.dbFileSize here? */
  2482   2482       rc = sqlite3OsFileSize(pPager->fd, &currentSize);
  2483   2483       newSize = pPager->pageSize*(i64)nPage;
  2484   2484       if( rc==SQLITE_OK && currentSize!=newSize ){
  2485   2485         if( currentSize>newSize ){
  2486   2486           rc = sqlite3OsTruncate(pPager->fd, newSize);
  2487   2487         }else{
  2488         -        rc = sqlite3OsWrite(pPager->fd, "", 1, newSize-1);
         2488  +        char *pTmp = pPager->pTmpSpace;
         2489  +        memset(pTmp, 0, pPager->pageSize);
         2490  +        while( currentSize<newSize ){
         2491  +          rc = sqlite3OsWrite(pPager->fd, pTmp, pPager->pageSize, currentSize);
         2492  +          currentSize += pPager->pageSize;
         2493  +        }
  2489   2494         }
  2490   2495         if( rc==SQLITE_OK ){
  2491   2496           pPager->dbFileSize = nPage;
  2492   2497         }
  2493   2498       }
  2494   2499     }
  2495   2500     return rc;