SQLite

Check-in [c733a1dea3]
Login

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

Overview
Comment:Avoid unnecessary calls to fstat() to determine the database file size.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | io-opt
Files: files | file ages | folders
SHA3-256: c733a1dea37e4678e7bd0d3d0ca9b8eae1fbdc28615f75d8f1e5141aa53567d9
User & Date: drh 2017-05-29 14:57:23.932
Context
2017-05-29
16:45
Avoid unnecessary fstat() calls to determine the database size when transitioning into a read transaction on a rollback-mode database. (Closed-Leaf check-in: 6c3476b513 user: drh tags: io-opt)
14:57
Avoid unnecessary calls to fstat() to determine the database file size. (check-in: c733a1dea3 user: drh tags: io-opt)
14:30
Fix a typo in a comment. No code changes. (check-in: cb29b83888 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pager.c.
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275

5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
      ** other bytes change randomly with each file change when
      ** a codec is in use.
      ** 
      ** There is a vanishingly small chance that a change will not be 
      ** detected.  The chance of an undetected change is so small that
      ** it can be neglected.
      */
      Pgno nPage = 0;
      char dbFileVers[sizeof(pPager->dbFileVers)];

      rc = pagerPagecount(pPager, &nPage);
      if( rc ) goto failed;

      if( nPage>0 ){
        IOTRACE(("CKVERS %p %d\n", pPager, sizeof(dbFileVers)));
        rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);
        if( rc!=SQLITE_OK && rc!=SQLITE_IOERR_SHORT_READ ){

          goto failed;
        }
      }else{
        memset(dbFileVers, 0, sizeof(dbFileVers));
      }

      if( memcmp(pPager->dbFileVers, dbFileVers, sizeof(dbFileVers))!=0 ){
        pager_reset(pPager);

        /* Unmap the database file. It is possible that external processes







<


<
<
<
<
|
|
|
>


<







5259
5260
5261
5262
5263
5264
5265

5266
5267




5268
5269
5270
5271
5272
5273

5274
5275
5276
5277
5278
5279
5280
      ** other bytes change randomly with each file change when
      ** a codec is in use.
      ** 
      ** There is a vanishingly small chance that a change will not be 
      ** detected.  The chance of an undetected change is so small that
      ** it can be neglected.
      */

      char dbFileVers[sizeof(pPager->dbFileVers)];





      IOTRACE(("CKVERS %p %d\n", pPager, sizeof(dbFileVers)));
      rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);
      if( rc!=SQLITE_OK ){
        if( rc!=SQLITE_IOERR_SHORT_READ ){
          goto failed;
        }

        memset(dbFileVers, 0, sizeof(dbFileVers));
      }

      if( memcmp(pPager->dbFileVers, dbFileVers, sizeof(dbFileVers))!=0 ){
        pager_reset(pPager);

        /* Unmap the database file. It is possible that external processes