SQLite

Changes On Branch io-opt
Login

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

Changes In Branch io-opt Excluding Merge-Ins

This is equivalent to a diff from cb29b838 to 6c3476b5

2017-05-29
17:59
Omit unnecessary fstat() calls for determining the database file size, resulting in smaller and faster code. (check-in: dd61c736 user: drh tags: trunk)
17:43
Fix an issue with OPT_FEATURE_FLAGS in configure.ac. (check-in: 43ce3bd3 user: drh tags: trunk)
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: 6c3476b5 user: drh tags: io-opt)
14:57
Avoid unnecessary calls to fstat() to determine the database file size. (check-in: c733a1de user: drh tags: io-opt)
14:30
Fix a typo in a comment. No code changes. (check-in: cb29b838 user: drh tags: trunk)
14:26
Optimizations to the Walker object and its methods to make the code a little smaller and to help it run a little faster. (check-in: 6854a34e user: drh tags: trunk)

Changes to src/pager.c.

3300
3301
3302
3303
3304
3305
3306





3307

3308
3309
3310
3311
3312




3313
3314
3315

3316
3317
3318
3319
3320
3321
3322
3323



3324
3325
3326
3327
3328
3329
3330
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311

3312
3313




3314
3315
3316
3317



3318








3319
3320
3321
3322
3323
3324
3325
3326
3327
3328







+
+
+
+
+
-
+

-
-
-
-
+
+
+
+
-
-
-
+
-
-
-
-
-
-
-
-
+
+
+







static int pagerOpenWalIfPresent(Pager *pPager){
  int rc = SQLITE_OK;
  assert( pPager->eState==PAGER_OPEN );
  assert( pPager->eLock>=SHARED_LOCK );

  if( !pPager->tempFile ){
    int isWal;                    /* True if WAL file exists */
    rc = sqlite3OsAccess(
        pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &isWal
    );
    if( rc==SQLITE_OK ){
      if( isWal ){
    Pgno nPage;                   /* Size of the database file */
        Pgno nPage;                   /* Size of the database file */

    rc = pagerPagecount(pPager, &nPage);
    if( rc ) return rc;
    if( nPage==0 ){
      rc = sqlite3OsDelete(pPager->pVfs, pPager->zWal, 0);
        rc = pagerPagecount(pPager, &nPage);
        if( rc ) return rc;
        if( nPage==0 ){
          rc = sqlite3OsDelete(pPager->pVfs, pPager->zWal, 0);
      if( rc==SQLITE_IOERR_DELETE_NOENT ) rc = SQLITE_OK;
      isWal = 0;
    }else{
        }else{
      rc = sqlite3OsAccess(
          pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &isWal
      );
    }
    if( rc==SQLITE_OK ){
      if( isWal ){
        testcase( sqlite3PcachePagecount(pPager->pPCache)==0 );
        rc = sqlite3PagerOpenWal(pPager, 0);
          testcase( sqlite3PcachePagecount(pPager->pPCache)==0 );
          rc = sqlite3PagerOpenWal(pPager, 0);
        }
      }else if( pPager->journalMode==PAGER_JOURNALMODE_WAL ){
        pPager->journalMode = PAGER_JOURNALMODE_DELETE;
      }
    }
  }
  return rc;
}
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
5257
5258
5259
5260
5261
5262
5263

5264
5265







5266
5267
5268
5269
5270
5271

5272
5273
5274
5275
5276
5277
5278







-


-
-
-
-
-
-
-
+
+
+
+


-







      ** 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 ){
      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;
        }
      }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