1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Simplify the previous commit by removing the pagerCheckForOrDeleteWAL() wrapper.

FossilOrigin-Name: a1324d125e2dd7004eaf8680f5f832ef17285087
This commit is contained in:
dan
2010-07-05 19:13:26 +00:00
parent 3e875ef3b5
commit db10f08282
3 changed files with 15 additions and 38 deletions

View File

@@ -2438,32 +2438,6 @@ static int pagerBeginReadTransaction(Pager *pPager){
return rc;
}
/*
** Check for the existence of or delete the *-wal file that corresponds to
** the database opened by pPager.
**
** When pExists!=NULL, set *pExists to 1 if the *-wal file exists, or 0
** if the *-wal file does not exist.
**
** When pExists==NULL, delete the *-wal file if it exists, or the do
** nothing if the *-wal file does not exist.
**
** Return SQLITE_OK on success. If on an IO or OOM error occurs, return
** an SQLite error code.
*/
static int pagerCheckForOrDeleteWAL(Pager *pPager, int *pExists){
int rc; /* Return code */
char *zWal = pPager->zWal; /* Name of the WAL file */
assert( !pPager->tempFile );
if( pExists ){
rc = sqlite3OsAccess(pPager->pVfs, zWal, SQLITE_ACCESS_EXISTS, pExists);
}else{
rc = sqlite3OsDelete(pPager->pVfs, zWal, 0);
}
return rc;
}
/*
** Check if the *-wal file that corresponds to the database opened by pPager
** exists if the database is not empy, or verify that the *-wal file does
@@ -2493,10 +2467,12 @@ static int pagerOpenWalIfPresent(Pager *pPager){
rc = sqlite3PagerPagecount(pPager, &nPage);
if( rc ) return rc;
if( nPage==0 ){
rc = pagerCheckForOrDeleteWAL(pPager, 0);
rc = sqlite3OsDelete(pPager->pVfs, pPager->zWal, 0);
isWal = 0;
}else{
rc = pagerCheckForOrDeleteWAL(pPager, &isWal);
rc = sqlite3OsAccess(
pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &isWal
);
}
if( rc==SQLITE_OK ){
if( isWal ){
@@ -6084,8 +6060,7 @@ int sqlite3PagerOpenWal(
** (e.g. due to malloc() failure), unlock the database file and
** return an error code.
*/
rc = sqlite3WalOpen(pPager->pVfs, pPager->fd,
pPager->zWal, &pPager->pWal);
rc = sqlite3WalOpen(pPager->pVfs, pPager->fd, pPager->zWal, &pPager->pWal);
if( rc==SQLITE_OK ){
pPager->journalMode = PAGER_JOURNALMODE_WAL;
}
@@ -6118,7 +6093,9 @@ int sqlite3PagerCloseWal(Pager *pPager){
int logexists = 0;
rc = sqlite3OsLock(pPager->fd, SQLITE_LOCK_SHARED);
if( rc==SQLITE_OK ){
rc = pagerCheckForOrDeleteWAL(pPager, &logexists);
rc = sqlite3OsAccess(
pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &logexists
);
}
if( rc==SQLITE_OK && logexists ){
rc = sqlite3WalOpen(pPager->pVfs, pPager->fd,