From: drh Date: Sat, 17 Dec 2011 13:45:28 +0000 (+0000) Subject: Merge in changes that cause the first sector of the WAL file to be synced X-Git-Tag: version-3.7.10~19^2~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fe6163d7cfbf5d61ca90611bcafada91fe5372ea;p=thirdparty%2Fsqlite.git Merge in changes that cause the first sector of the WAL file to be synced when the WAL restarts. This is a fix for the power-loss corruption problem described in ticket [ff5be73dee086] FossilOrigin-Name: 44ca4d123385d759c11919865525c998c2e35bdb --- fe6163d7cfbf5d61ca90611bcafada91fe5372ea diff --cc manifest index 6676da8ac4,bc2dd4cdea..f48b9a0540 --- a/manifest +++ b/manifest @@@ -1,5 -1,5 +1,5 @@@ - C Add\stests\sto\swalcrash3.test. - D 2011-12-17T08:10:34.481 -C Enhance\sthe\sWAL\sheader\ssync\sso\sthat\sit\shonors\sthe\svarious\ssynchronous\npragmas,\ssettings,\sand\sdevice\scharacteristics. -D 2011-12-16T21:26:26.087 ++C Merge\sin\schanges\sthat\scause\sthe\sfirst\ssector\sof\sthe\sWAL\sfile\sto\sbe\ssynced\nwhen\sthe\sWAL\srestarts.\s\sThis\sis\sa\sfix\sfor\sthe\spower-loss\scorruption\nproblem\sdescribed\sin\sticket\s[ff5be73dee086] ++D 2011-12-17T13:45:28.989 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5b4a3e12a850b021547e43daf886b25133b44c07 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@@ -250,8 -250,8 +250,8 @@@ F src/vdbemem.c 2fc78b3e0fabcc1eaa23cd7 F src/vdbesort.c 468d43c057063e54da4f1988b38b4f46d60e7790 F src/vdbetrace.c d6e50e04e1ec498150e519058f617d91b8f5c843 F src/vtab.c e9318d88feac85be8e27ee783ac8f5397933fc8a - F src/wal.c 8f6fd4900934124f6c2701448c13038cbc02a4f4 - F src/wal.h 66b40bd91bc29a5be1c88ddd1f5ade8f3f48728a -F src/wal.c 20022b733ce06f77cc1d7f154da32987b57532ae ++F src/wal.c 89a60a8bf8daa805b819f97b2049a62ae5618707 + F src/wal.h 42f8313f7aaf8913e2d1fdf7b47025c23491ea1d F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f F src/where.c af623942514571895818b9b7ae11db95ae3b3d88 F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823 @@@ -984,7 -984,7 +984,7 @@@ F tool/tostr.awk e75472c2f98dd76e06b8c9 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 - P 7b63b11b93396079131686abb36c4221354fa50e - R 177c457106f4a322f13cf8ef2b836d21 - U dan - Z c66e15671707eedc5457d2cd5fb751c5 -P 91d0437c0702904d27f0ef7b1b52d0797efe1826 -R 5f78dbf89e78a567743daf43caa5df96 ++P d76880428013ae2c5be00d87bb3e1695af6f706f 9799241f7de952c4d1ea8bf6508b577d2b57a370 ++R a66c21780a9737a3739ef721dbd80b71 + U drh -Z da5e946383fd5dfe4d9a2957cf126f26 ++Z 8683a36598a7c916281a4627e543388f diff --cc manifest.uuid index 47932d748d,433b9f5a98..9c694594ad --- a/manifest.uuid +++ b/manifest.uuid @@@ -1,1 -1,1 +1,1 @@@ - d76880428013ae2c5be00d87bb3e1695af6f706f -9799241f7de952c4d1ea8bf6508b577d2b57a370 ++44ca4d123385d759c11919865525c998c2e35bdb diff --cc src/wal.c index 047368406f,34ddb1b1e2..03c482554e --- a/src/wal.c +++ b/src/wal.c @@@ -1094,6 -1097,6 +1097,7 @@@ static int walIndexRecover(Wal *pWal) int szPage; /* Page size according to the log */ u32 magic; /* Magic value read from WAL header */ u32 version; /* Magic value read from WAL header */ ++ int isValid; /* True if this frame is valid */ /* Read in the WAL header. */ rc = sqlite3OsRead(pWal->pWalFd, aBuf, WAL_HDRSIZE, 0); @@@ -1149,17 -1152,17 +1153,25 @@@ /* Read all frames from the log file. */ iFrame = 0; ++ isValid = 1; for(iOffset=WAL_HDRSIZE; (iOffset+szFrame)<=nSize; iOffset+=szFrame){ u32 pgno; /* Database page number for frame */ u32 nTruncate; /* dbsize field from frame header */ -- int isValid; /* True if this frame is valid */ /* Read and decode the next log frame. */ ++ iFrame++; rc = sqlite3OsRead(pWal->pWalFd, aFrame, szFrame, iOffset); if( rc!=SQLITE_OK ) break; ++ if( sqlite3Get4byte(&aFrame[8]) == ++ 1+sqlite3Get4byte((u8*)&pWal->hdr.aSalt[0]) ){ ++ pWal->hdr.mxFrame = 0; ++ pWal->hdr.nPage = 0; ++ break; ++ } ++ if( !isValid ) continue; isValid = walDecodeFrame(pWal, &pgno, &nTruncate, aData, aFrame); -- if( !isValid ) break; -- rc = walIndexAppend(pWal, ++iFrame, pgno); ++ if( !isValid ) continue; ++ rc = walIndexAppend(pWal, iFrame, pgno); if( rc!=SQLITE_OK ) break; /* If nTruncate is non-zero, this is a commit record. */