/ Check-in [d8c2d55f]
Login

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 | begin-concurrent-wal2
Files: files | file ages | folders
SHA3-256: d8c2d55fa4ec95c6506201edcd1cb2ef108a233bd87a6154f3593909977f7d3f
User & Date: dan 2018-12-05 16:45:38
Wiki:begin-concurrent-wal2
Context
2018-12-05
17:20
Fix a problem causing "PRAGMA journal_mode" to report the wrong journal mode (wal instead of wal2) under some circumstances. check-in: bf309107 user: dan tags: begin-concurrent-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-04
19:41
First attempt at making features work together. Only the most minimal testing so far. check-in: fd707001 user: dan tags: begin-concurrent-wal2
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/wal.c.

  3247   3247   ** SQLITE_OK is returned if successful, or an SQLite error code if an
  3248   3248   ** error occurs. It is not an error if nBackfillAttempted cannot be
  3249   3249   ** decreased at all.
  3250   3250   */
  3251   3251   int sqlite3WalSnapshotRecover(Wal *pWal){
  3252   3252     int rc;
  3253   3253   
         3254  +  /* Snapshots may not be used with wal2 mode databases. */
         3255  +  if( isWalMode2(pWal) ) return SQLITE_ERROR;
         3256  +
  3254   3257     assert( pWal->readLock>=0 );
  3255   3258     rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);
  3256   3259     if( rc==SQLITE_OK ){
  3257   3260       volatile WalCkptInfo *pInfo = walCkptInfo(pWal);
  3258   3261       int szPage = (int)pWal->szPage;
  3259   3262       i64 szDb;                   /* Size of db file in bytes */
  3260   3263   
................................................................................
  3321   3324   int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){
  3322   3325     int rc;                         /* Return code */
  3323   3326     int cnt = 0;                    /* Number of TryBeginRead attempts */
  3324   3327   
  3325   3328   #ifdef SQLITE_ENABLE_SNAPSHOT
  3326   3329     int bChanged = 0;
  3327   3330     WalIndexHdr *pSnapshot = pWal->pSnapshot;
         3331  +  if( pSnapshot && isWalMode2(pWal) ) return SQLITE_ERROR;
  3328   3332     if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){
  3329   3333       bChanged = 1;
  3330   3334     }
  3331   3335   #endif
  3332   3336   
  3333   3337     do{
  3334   3338       rc = walTryBeginRead(pWal, pChanged, 0, ++cnt);
................................................................................
  4789   4793   ** every other subsystem, so the WAL module can put whatever it needs
  4790   4794   ** in the object.
  4791   4795   */
  4792   4796   int sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot){
  4793   4797     int rc = SQLITE_OK;
  4794   4798     WalIndexHdr *pRet;
  4795   4799     static const u32 aZero[4] = { 0, 0, 0, 0 };
         4800  +
         4801  +  /* Snapshots may not be used with wal2 mode databases. */
         4802  +  if( isWalMode2(pWal) ) return SQLITE_ERROR;
  4796   4803   
  4797   4804     assert( pWal->readLock>=0 && pWal->writeLock==0 );
  4798   4805   
  4799         -  if( memcmp(&pWal->hdr.aFrameCksum[0],aZero,16)==0 ){
         4806  +  if( memcmp(&pWal->hdr.aFrameCksum[0],aZero,8)==0 ){
  4800   4807       *ppSnapshot = 0;
  4801   4808       return SQLITE_ERROR;
  4802   4809     }
  4803   4810     pRet = (WalIndexHdr*)sqlite3_malloc(sizeof(WalIndexHdr));
  4804   4811     if( pRet==0 ){
  4805   4812       rc = SQLITE_NOMEM_BKPT;
  4806   4813     }else{
................................................................................
  4843   4850   ** If the snapshot is not available, SQLITE_ERROR is returned. Or, if
  4844   4851   ** the CHECKPOINTER lock cannot be obtained, SQLITE_BUSY. If any error
  4845   4852   ** occurs (any value other than SQLITE_OK is returned), the CHECKPOINTER
  4846   4853   ** lock is released before returning.
  4847   4854   */
  4848   4855   int sqlite3WalSnapshotCheck(Wal *pWal, sqlite3_snapshot *pSnapshot){
  4849   4856     int rc;
         4857  +
         4858  +  /* Snapshots may not be used with wal2 mode databases. */
         4859  +  if( isWalMode2(pWal) ) return SQLITE_ERROR;
         4860  +
  4850   4861     rc = walLockShared(pWal, WAL_CKPT_LOCK);
  4851   4862     if( rc==SQLITE_OK ){
  4852   4863       WalIndexHdr *pNew = (WalIndexHdr*)pSnapshot;
  4853   4864       if( memcmp(pNew->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))
  4854   4865        || pNew->mxFrame<walCkptInfo(pWal)->nBackfillAttempted
  4855   4866       ){
  4856   4867         rc = SQLITE_ERROR_SNAPSHOT;