Index: src/wal.c ================================================================== --- src/wal.c +++ src/wal.c @@ -3547,26 +3547,26 @@ if( pWal->iReCksum==1 ){ iCksumOff = 24; }else{ iCksumOff = walFrameOffset(pWal->iReCksum-1, szPage) + 16; } - rc = sqlite3OsRead(pWal->apWalFd[0], aBuf, sizeof(u32)*2, iCksumOff); + rc = sqlite3OsRead(pWalFd, aBuf, sizeof(u32)*2, iCksumOff); pWal->hdr.aFrameCksum[0] = sqlite3Get4byte(aBuf); pWal->hdr.aFrameCksum[1] = sqlite3Get4byte(&aBuf[sizeof(u32)]); iRead = pWal->iReCksum; pWal->iReCksum = 0; for(; rc==SQLITE_OK && iRead<=iLast; iRead++){ i64 iOff = walFrameOffset(iRead, szPage); - rc = sqlite3OsRead(pWal->apWalFd[0], aBuf, szPage+WAL_FRAME_HDRSIZE, iOff); + rc = sqlite3OsRead(pWalFd, aBuf, szPage+WAL_FRAME_HDRSIZE, iOff); if( rc==SQLITE_OK ){ u32 iPgno, nDbSize; iPgno = sqlite3Get4byte(aBuf); nDbSize = sqlite3Get4byte(&aBuf[4]); walEncodeFrame(pWal, iPgno, nDbSize, &aBuf[WAL_FRAME_HDRSIZE], aFrame); - rc = sqlite3OsWrite(pWal->apWalFd[0], aFrame, sizeof(aFrame), iOff); + rc = sqlite3OsWrite(pWalFd, aFrame, sizeof(aFrame), iOff); } } sqlite3_free(aBuf); return rc; Index: test/wal2rewrite.test ================================================================== --- test/wal2rewrite.test +++ test/wal2rewrite.test @@ -69,12 +69,24 @@ } execsql COMMIT do_test $tn.$i.3 { expr [filesize test.db-wal] < 100000 } 1 do_test $tn.$i.4 { expr [filesize test.db-wal2] < 100000 } 1 - } + + set sum [db eval {SELECT sum(b), md5sum(c) FROM t1}] + + do_test $tn.$i.5 { + foreach f [glob -nocomplain test.db2*] {forcedelete $f} + foreach f [glob -nocomplain test.db*] { + forcecopy $f [string map {test.db test.db2} $f] + } + sqlite3 db2 test.db2 + db2 eval {SELECT sum(b), md5sum(c) FROM t1} + } $sum + db2 close + } } finish_test