SQLite

Check-in [cf3d1e0b8a]
Login

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

Overview
Comment:When an attempt to change journal_mode fails due to locks, be sure to leave internal structures in a consistent state.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: cf3d1e0b8a739302cf2848ac3e6eaaae04e6a44c
User & Date: drh 2010-05-11 14:00:40.000
Context
2010-05-11
16:29
Have os_unix.c use the suffix "-wal-index" for wal-index files instead of "-wal-inde". (check-in: 885e854e7c user: dan tags: trunk)
14:00
When an attempt to change journal_mode fails due to locks, be sure to leave internal structures in a consistent state. (check-in: cf3d1e0b8a user: drh tags: trunk)
12:19
Changes so that WAL and exclusive-locking mode work together. (check-in: 71e7b1cf9f user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pager.c.
5955
5956
5957
5958
5959
5960
5961




5962
5963
5964
5965
5966
5967
5968
    rc = sqlite3OsLock(pPager->fd, SQLITE_LOCK_EXCLUSIVE);
    if( rc==SQLITE_OK ){
      rc = sqlite3WalClose(pPager->pWal, pPager->fd,
        (pPager->noSync ? 0 : pPager->sync_flags), 
        pPager->pageSize, (u8*)pPager->pTmpSpace
      );
      pPager->pWal = 0;




    }
  }
  return rc;
}
#endif

#endif /* SQLITE_OMIT_DISKIO */







>
>
>
>







5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
    rc = sqlite3OsLock(pPager->fd, SQLITE_LOCK_EXCLUSIVE);
    if( rc==SQLITE_OK ){
      rc = sqlite3WalClose(pPager->pWal, pPager->fd,
        (pPager->noSync ? 0 : pPager->sync_flags), 
        pPager->pageSize, (u8*)pPager->pTmpSpace
      );
      pPager->pWal = 0;
    }else{
      /* If we cannot get an EXCLUSIVE lock, downgrade the PENDING lock
      ** that we did get back to SHARED. */
      sqlite3OsUnlock(pPager->fd, SQLITE_LOCK_SHARED);
    }
  }
  return rc;
}
#endif

#endif /* SQLITE_OMIT_DISKIO */
Changes to src/vdbe.c.
5305
5306
5307
5308
5309
5310
5311

5312
5313
5314
5315
5316
5317
5318
        */
        assert( sqlite3BtreeIsInTrans(pBt)==0 );
        if( rc==SQLITE_OK ){
          rc = sqlite3BtreeSetVersion(pBt, 
                                      (eNew==PAGER_JOURNALMODE_WAL ? 2 : 1));
          if( rc==SQLITE_BUSY && pOp->p5==0 ) goto abort_due_to_error;
        }else if( rc==SQLITE_BUSY ){

          rc = SQLITE_OK;
        }
      }
    }
  }
#endif /* ifndef SQLITE_OMIT_WAL */








>







5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
        */
        assert( sqlite3BtreeIsInTrans(pBt)==0 );
        if( rc==SQLITE_OK ){
          rc = sqlite3BtreeSetVersion(pBt, 
                                      (eNew==PAGER_JOURNALMODE_WAL ? 2 : 1));
          if( rc==SQLITE_BUSY && pOp->p5==0 ) goto abort_due_to_error;
        }else if( rc==SQLITE_BUSY ){
          eNew = PAGER_JOURNALMODE_QUERY;
          rc = SQLITE_OK;
        }
      }
    }
  }
#endif /* ifndef SQLITE_OMIT_WAL */