/ Check-in [9e1502e1]
Login

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

Overview
Comment:Fix a bug in recovering wal2 mode databases introduced by the previous commit.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wal2
Files: files | file ages | folders
SHA3-256: 9e1502e1b650217efc361732a3dfe686caa2e6352d040c73865f1faf09bf4591
User & Date: dan 2017-10-06 14:08:39
Wiki:wal2
Context
2017-10-06
14:25
Merge latest trunk changes into this branch. check-in: 7e435178 user: dan tags: wal2
14:08
Fix a bug in recovering wal2 mode databases introduced by the previous commit. check-in: 9e1502e1 user: dan tags: wal2
13:43
Fix frame overwriting in wal2 mode. check-in: a4b02bc9 user: dan tags: wal2
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/wal.c.

  3545   3545     ** previous frame.  */
  3546   3546     assert( pWal->iReCksum>0 );
  3547   3547     if( pWal->iReCksum==1 ){
  3548   3548       iCksumOff = 24;
  3549   3549     }else{
  3550   3550       iCksumOff = walFrameOffset(pWal->iReCksum-1, szPage) + 16;
  3551   3551     }
  3552         -  rc = sqlite3OsRead(pWal->apWalFd[0], aBuf, sizeof(u32)*2, iCksumOff);
         3552  +  rc = sqlite3OsRead(pWalFd, aBuf, sizeof(u32)*2, iCksumOff);
  3553   3553     pWal->hdr.aFrameCksum[0] = sqlite3Get4byte(aBuf);
  3554   3554     pWal->hdr.aFrameCksum[1] = sqlite3Get4byte(&aBuf[sizeof(u32)]);
  3555   3555   
  3556   3556     iRead = pWal->iReCksum;
  3557   3557     pWal->iReCksum = 0;
  3558   3558     for(; rc==SQLITE_OK && iRead<=iLast; iRead++){
  3559   3559       i64 iOff = walFrameOffset(iRead, szPage);
  3560         -    rc = sqlite3OsRead(pWal->apWalFd[0], aBuf, szPage+WAL_FRAME_HDRSIZE, iOff);
         3560  +    rc = sqlite3OsRead(pWalFd, aBuf, szPage+WAL_FRAME_HDRSIZE, iOff);
  3561   3561       if( rc==SQLITE_OK ){
  3562   3562         u32 iPgno, nDbSize;
  3563   3563         iPgno = sqlite3Get4byte(aBuf);
  3564   3564         nDbSize = sqlite3Get4byte(&aBuf[4]);
  3565   3565   
  3566   3566         walEncodeFrame(pWal, iPgno, nDbSize, &aBuf[WAL_FRAME_HDRSIZE], aFrame);
  3567         -      rc = sqlite3OsWrite(pWal->apWalFd[0], aFrame, sizeof(aFrame), iOff);
         3567  +      rc = sqlite3OsWrite(pWalFd, aFrame, sizeof(aFrame), iOff);
  3568   3568       }
  3569   3569     }
  3570   3570   
  3571   3571     sqlite3_free(aBuf);
  3572   3572     return rc;
  3573   3573   }
  3574   3574   

Changes to test/wal2rewrite.test.

    67     67         UPDATE t1 SET b=b+10, c=randomblob(800);
    68     68         UPDATE t1 SET b=b+10, c=randomblob(800);
    69     69       }
    70     70       execsql COMMIT
    71     71   
    72     72       do_test $tn.$i.3 { expr [filesize test.db-wal]  < 100000 } 1
    73     73       do_test $tn.$i.4 { expr [filesize test.db-wal2] < 100000 } 1
    74         -  }
           74  +
           75  +    set sum [db eval {SELECT sum(b), md5sum(c) FROM t1}]
           76  +
           77  +    do_test $tn.$i.5 {
           78  +      foreach f [glob -nocomplain test.db2*] {forcedelete $f}
           79  +      foreach f [glob -nocomplain test.db*] {
           80  +        forcecopy $f [string map {test.db test.db2} $f]
           81  +      }
    75     82   
           83  +      sqlite3 db2 test.db2
           84  +      db2 eval {SELECT sum(b), md5sum(c) FROM t1}
           85  +    } $sum
           86  +    db2 close
           87  +  }
    76     88   }
    77     89       
    78     90   
    79     91   
    80     92   finish_test