/ 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 Unified Diffs Show Whitespace Changes Patch

Changes to src/pager.c.

2481
2482
2483
2484
2485
2486
2487



2488


2489
2490
2491
2492
2493
2494
2495
    /* TODO: Is it safe to use Pager.dbFileSize here? */
    rc = sqlite3OsFileSize(pPager->fd, &currentSize);
    newSize = pPager->pageSize*(i64)nPage;
    if( rc==SQLITE_OK && currentSize!=newSize ){
      if( currentSize>newSize ){
        rc = sqlite3OsTruncate(pPager->fd, newSize);
      }else{



        rc = sqlite3OsWrite(pPager->fd, "", 1, newSize-1);


      }
      if( rc==SQLITE_OK ){
        pPager->dbFileSize = nPage;
      }
    }
  }
  return rc;







>
>
>
|
>
>







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