/ Check-in [19c61ab7]
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:Fixes for snapshots API on this branch. Also ensure that the snapshots API cannot be used with wal2 mode databases (for now anyhow).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wal2
Files: files | file ages | folders
SHA3-256: 19c61ab79458936ff4dfca46cf4d1fb1ab16d7bdb5024f502eb4339ec4eef32c
User & Date: dan 2018-12-05 16:31:02
Wiki:wal2
Context
2018-12-05
17:14
Fix a problem causing "PRAGMA journal_mode" to report the wrong journal mode (wal instead of wal2) under some circumstances. check-in: 1d8d4f68 user: dan tags: wal2
16:45
Fixes for snapshots API on this branch. Also ensure that the snapshots API cannot be used with wal2 mode databases (for now anyhow). check-in: d8c2d55f user: dan tags: begin-concurrent-wal2
16:31
Fixes for snapshots API on this branch. Also ensure that the snapshots API cannot be used with wal2 mode databases (for now anyhow). check-in: 19c61ab7 user: dan tags: wal2
2018-12-03
18:13
Increase a timeout in test file walprotocol2.test. To account for unix builds without HAVE_USLEEP. check-in: 480be916 user: dan tags: wal2
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/wal.c.

  3230   3230   ** SQLITE_OK is returned if successful, or an SQLite error code if an
  3231   3231   ** error occurs. It is not an error if nBackfillAttempted cannot be
  3232   3232   ** decreased at all.
  3233   3233   */
  3234   3234   int sqlite3WalSnapshotRecover(Wal *pWal){
  3235   3235     int rc;
  3236   3236   
         3237  +  /* Snapshots may not be used with wal2 mode databases. */
         3238  +  if( isWalMode2(pWal) ) return SQLITE_ERROR;
         3239  +
  3237   3240     assert( pWal->readLock>=0 );
  3238   3241     rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);
  3239   3242     if( rc==SQLITE_OK ){
  3240   3243       volatile WalCkptInfo *pInfo = walCkptInfo(pWal);
  3241   3244       int szPage = (int)pWal->szPage;
  3242   3245       i64 szDb;                   /* Size of db file in bytes */
  3243   3246   
................................................................................
  3304   3307   int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){
  3305   3308     int rc;                         /* Return code */
  3306   3309     int cnt = 0;                    /* Number of TryBeginRead attempts */
  3307   3310   
  3308   3311   #ifdef SQLITE_ENABLE_SNAPSHOT
  3309   3312     int bChanged = 0;
  3310   3313     WalIndexHdr *pSnapshot = pWal->pSnapshot;
         3314  +  if( pSnapshot && isWalMode2(pWal) ) return SQLITE_ERROR;
  3311   3315     if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){
  3312   3316       bChanged = 1;
  3313   3317     }
  3314   3318   #endif
  3315   3319   
  3316   3320     do{
  3317   3321       rc = walTryBeginRead(pWal, pChanged, 0, ++cnt);
................................................................................
  4529   4533   ** every other subsystem, so the WAL module can put whatever it needs
  4530   4534   ** in the object.
  4531   4535   */
  4532   4536   int sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot){
  4533   4537     int rc = SQLITE_OK;
  4534   4538     WalIndexHdr *pRet;
  4535   4539     static const u32 aZero[4] = { 0, 0, 0, 0 };
         4540  +
         4541  +  /* Snapshots may not be used with wal2 mode databases. */
         4542  +  if( isWalMode2(pWal) ) return SQLITE_ERROR;
  4536   4543   
  4537   4544     assert( pWal->readLock>=0 && pWal->writeLock==0 );
  4538   4545   
  4539         -  if( memcmp(&pWal->hdr.aFrameCksum[0],aZero,16)==0 ){
         4546  +  if( memcmp(&pWal->hdr.aFrameCksum[0],aZero,8)==0 ){
  4540   4547       *ppSnapshot = 0;
  4541   4548       return SQLITE_ERROR;
  4542   4549     }
  4543   4550     pRet = (WalIndexHdr*)sqlite3_malloc(sizeof(WalIndexHdr));
  4544   4551     if( pRet==0 ){
  4545   4552       rc = SQLITE_NOMEM_BKPT;
  4546   4553     }else{
................................................................................
  4583   4590   ** If the snapshot is not available, SQLITE_ERROR is returned. Or, if
  4584   4591   ** the CHECKPOINTER lock cannot be obtained, SQLITE_BUSY. If any error
  4585   4592   ** occurs (any value other than SQLITE_OK is returned), the CHECKPOINTER
  4586   4593   ** lock is released before returning.
  4587   4594   */
  4588   4595   int sqlite3WalSnapshotCheck(Wal *pWal, sqlite3_snapshot *pSnapshot){
  4589   4596     int rc;
         4597  +
         4598  +  /* Snapshots may not be used with wal2 mode databases. */
         4599  +  if( isWalMode2(pWal) ) return SQLITE_ERROR;
         4600  +
  4590   4601     rc = walLockShared(pWal, WAL_CKPT_LOCK);
  4591   4602     if( rc==SQLITE_OK ){
  4592   4603       WalIndexHdr *pNew = (WalIndexHdr*)pSnapshot;
  4593   4604       if( memcmp(pNew->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))
  4594   4605        || pNew->mxFrame<walCkptInfo(pWal)->nBackfillAttempted
  4595   4606       ){
  4596   4607         rc = SQLITE_ERROR_SNAPSHOT;