SQLite

Check-in [2ac5d96c8e]
Login

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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2ac5d96c8e5831b392d83c86491d9ed8bc9c8db7
User & Date: dan 2010-05-05 15:33:05.000
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: 7bd44794c4 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: 2ac5d96c8e 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: 208e7d5d3a user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/wal.c.
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581

finished:
  walIndexWriteHdr(pWal, &hdr);
  return rc;
}

/*
** Close an open wal-index
*/
static void walIndexClose(Wal *pWal){
  sqlite3_shm *pWIndex = pWal->pWIndex;
  if( pWIndex ){
    sqlite3_vfs *pVfs = pWal->pVfs;
    int notUsed;
    pVfs->xShmLock(pVfs, pWIndex, SQLITE_SHM_UNLOCK, &notUsed);
    pVfs->xShmClose(pVfs, pWIndex, 0);
  }
}

/* 
** Open a connection to the log file associated with database zDb. The
** database file does not actually have to exist. zDb is used only to
** figure out the name of the log file to open. If the log file does not 







|

|





|







559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581

finished:
  walIndexWriteHdr(pWal, &hdr);
  return rc;
}

/*
** Close an open wal-index.
*/
static void walIndexClose(Wal *pWal, int isDelete){
  sqlite3_shm *pWIndex = pWal->pWIndex;
  if( pWIndex ){
    sqlite3_vfs *pVfs = pWal->pVfs;
    int notUsed;
    pVfs->xShmLock(pVfs, pWIndex, SQLITE_SHM_UNLOCK, &notUsed);
    pVfs->xShmClose(pVfs, pWIndex, isDelete);
  }
}

/* 
** Open a connection to the log file associated with database zDb. The
** database file does not actually have to exist. zDb is used only to
** figure out the name of the log file to open. If the log file does not 
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
  /* Open file handle on the write-ahead log file. */
  if( rc==SQLITE_OK ){
    flags = (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MAIN_JOURNAL);
    rc = sqlite3OsOpen(pVfs, zWal, pRet->pFd, flags, &flags);
  }

  if( rc!=SQLITE_OK ){
    walIndexClose(pRet);
    sqlite3OsClose(pRet->pFd);
    sqlite3_free(pRet);
  }else{
    *ppWal = pRet;
  }
  return rc;
}







|







622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
  /* Open file handle on the write-ahead log file. */
  if( rc==SQLITE_OK ){
    flags = (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MAIN_JOURNAL);
    rc = sqlite3OsOpen(pVfs, zWal, pRet->pFd, flags, &flags);
  }

  if( rc!=SQLITE_OK ){
    walIndexClose(pRet, 0);
    sqlite3OsClose(pRet->pFd);
    sqlite3_free(pRet);
  }else{
    *ppWal = pRet;
  }
  return rc;
}
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
      rc = walCheckpoint(pWal, pFd, sync_flags, nBuf, zBuf);
      if( rc==SQLITE_OK ){
        isDelete = 1;
      }
      walIndexUnmap(pWal);
    }

    walIndexClose(pWal);
    sqlite3OsClose(pWal->pFd);
    if( isDelete ){
      sqlite3OsDelete(pWal->pVfs, pWal->zName, 0);
    }
    sqlite3_free(pWal);
  }
  return rc;







|







828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
      rc = walCheckpoint(pWal, pFd, sync_flags, nBuf, zBuf);
      if( rc==SQLITE_OK ){
        isDelete = 1;
      }
      walIndexUnmap(pWal);
    }

    walIndexClose(pWal, isDelete);
    sqlite3OsClose(pWal->pFd);
    if( isDelete ){
      sqlite3OsDelete(pWal->pVfs, pWal->zName, 0);
    }
    sqlite3_free(pWal);
  }
  return rc;