/ Check-in [2ac5d96c]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:When closing a WAL database, if the exclusive lock on the database file is obtained and the database successfully checkpointed, delete the wal-index file from the file system.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2ac5d96c8e5831b392d83c86491d9ed8bc9c8db7
User & Date: dan 2010-05-05 15:33:05
Context
2010-05-05
16:23
Prohibit backup if the destination is using WAL and has a different page size from the source. check-in: 7bd44794 user: drh tags: trunk
15:33
When closing a WAL database, if the exclusive lock on the database file is obtained and the database successfully checkpointed, delete the wal-index file from the file system. check-in: 2ac5d96c user: dan tags: trunk
04:11
Make sure the page size of the main database is fixed following a failed VACUUM attempt. Otherwise, two consecutive failed VACUUM attempts with attempted page_size changes on encrypted or WAL databases could result in database corruption. check-in: 208e7d5d user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/wal.c.

   559    559   
   560    560   finished:
   561    561     walIndexWriteHdr(pWal, &hdr);
   562    562     return rc;
   563    563   }
   564    564   
   565    565   /*
   566         -** Close an open wal-index
          566  +** Close an open wal-index.
   567    567   */
   568         -static void walIndexClose(Wal *pWal){
          568  +static void walIndexClose(Wal *pWal, int isDelete){
   569    569     sqlite3_shm *pWIndex = pWal->pWIndex;
   570    570     if( pWIndex ){
   571    571       sqlite3_vfs *pVfs = pWal->pVfs;
   572    572       int notUsed;
   573    573       pVfs->xShmLock(pVfs, pWIndex, SQLITE_SHM_UNLOCK, &notUsed);
   574         -    pVfs->xShmClose(pVfs, pWIndex, 0);
          574  +    pVfs->xShmClose(pVfs, pWIndex, isDelete);
   575    575     }
   576    576   }
   577    577   
   578    578   /* 
   579    579   ** Open a connection to the log file associated with database zDb. The
   580    580   ** database file does not actually have to exist. zDb is used only to
   581    581   ** figure out the name of the log file to open. If the log file does not 
................................................................................
   622    622     /* Open file handle on the write-ahead log file. */
   623    623     if( rc==SQLITE_OK ){
   624    624       flags = (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MAIN_JOURNAL);
   625    625       rc = sqlite3OsOpen(pVfs, zWal, pRet->pFd, flags, &flags);
   626    626     }
   627    627   
   628    628     if( rc!=SQLITE_OK ){
   629         -    walIndexClose(pRet);
          629  +    walIndexClose(pRet, 0);
   630    630       sqlite3OsClose(pRet->pFd);
   631    631       sqlite3_free(pRet);
   632    632     }else{
   633    633       *ppWal = pRet;
   634    634     }
   635    635     return rc;
   636    636   }
................................................................................
   828    828         rc = walCheckpoint(pWal, pFd, sync_flags, nBuf, zBuf);
   829    829         if( rc==SQLITE_OK ){
   830    830           isDelete = 1;
   831    831         }
   832    832         walIndexUnmap(pWal);
   833    833       }
   834    834   
   835         -    walIndexClose(pWal);
          835  +    walIndexClose(pWal, isDelete);
   836    836       sqlite3OsClose(pWal->pFd);
   837    837       if( isDelete ){
   838    838         sqlite3OsDelete(pWal->pVfs, pWal->zName, 0);
   839    839       }
   840    840       sqlite3_free(pWal);
   841    841     }
   842    842     return rc;