Fix a bug in transaction rollback during backup when the CODEC is enabled
that can result in a corrupt backup file. This is only a problem when SQLITE_HAS_CODEC is defined. FossilOrigin-Name: f3398fc4db765e2c63d425d570c4469a84b3328c
This commit is contained in:
parent
8c30f72deb
commit
bfcb4adaf8
18
manifest
18
manifest
@ -1,8 +1,8 @@
|
||||
-----BEGIN PGP SIGNED MESSAGE-----
|
||||
Hash: SHA1
|
||||
|
||||
C When\smoving\spages\sas\spart\sof\sautovacuum\son\san\sin-memory\sdatabase,\smake\ssure\nthat\sthe\ssource\slocation\sis\sjournalled\sso\sthat\sa\sROLLBACK\scan\soccur.\nPart\sof\sthe\sfix\sfor\sticket\s[564d412f15a00]
|
||||
D 2009-11-20T18:48:36
|
||||
C Fix\sa\sbug\sin\stransaction\srollback\sduring\sbackup\swhen\sthe\sCODEC\sis\senabled\nthat\scan\sresult\sin\sa\scorrupt\sbackup\sfile.\s\sThis\sis\sonly\sa\sproblem\swhen\nSQLITE_HAS_CODEC\sis\sdefined.
|
||||
D 2009-11-21T01:33:51
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in 7f6c6aa7feeeb5e26e01b344161d9aa1b5d64177
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -153,7 +153,7 @@ F src/os_common.h 240c88b163b02c21a9f21f87d49678a0aa21ff30
|
||||
F src/os_os2.c 75a8c7b9a00a2cf1a65f9fa4afbc27d46634bb2f
|
||||
F src/os_unix.c bdd6ca0932dcb51c344081aff430bcc71c14db7f
|
||||
F src/os_win.c 5ffab20249a61e0625f869efe157fa009747039b
|
||||
F src/pager.c 3c408c646d2a4adba5aedde9862ef69a27be68d8
|
||||
F src/pager.c a5c0fa9bc0dd6d04b304a35aeedee9ebd0dc2948
|
||||
F src/pager.h 1b32faf2e578ac3e7bcf9c9d11217128261c5c54
|
||||
F src/parse.y f785d814562a14dc19202f61abb4372845f64752
|
||||
F src/pcache.c 3b079306376e0e04c0d3df40c0a4b750a1839310
|
||||
@ -775,14 +775,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
P cae949ce971ca216e0f8880b2f93866619fa05be
|
||||
R 2694b0c14575364b4e238f551e9978fe
|
||||
P 2f42f91fe65b0b21671936013df08037091f0cc6
|
||||
R f31a7b27b605d7a26aa89eb1b256db48
|
||||
U drh
|
||||
Z 282c516102a118903c65953429c1dd9e
|
||||
Z 06dbdf8ffebc750a1009c3d1910ae035
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1.4.6 (GNU/Linux)
|
||||
|
||||
iD8DBQFLBuSLoxKgR168RlERAuGTAJ9fd56Dwjiro+x2qI/XWq9kCYvkpgCeNshK
|
||||
ifMBSSRy91DoqTPyE1WJ+1s=
|
||||
=D02H
|
||||
iD8DBQFLB0OCoxKgR168RlERAkJZAJ9mG+901dHWGrJ3Ve4ChzrzuDAunwCfSxd3
|
||||
dv/JktoI/j9ez9dQLHX5Ffs=
|
||||
=dGQd
|
||||
-----END PGP SIGNATURE-----
|
||||
|
@ -1 +1 @@
|
||||
2f42f91fe65b0b21671936013df08037091f0cc6
|
||||
f3398fc4db765e2c63d425d570c4469a84b3328c
|
20
src/pager.c
20
src/pager.c
@ -1421,7 +1421,7 @@ static int pager_playback_one_page(
|
||||
PgHdr *pPg; /* An existing page in the cache */
|
||||
Pgno pgno; /* The page number of a page in journal */
|
||||
u32 cksum; /* Checksum used for sanity checking */
|
||||
u8 *aData; /* Temporary storage for the page */
|
||||
char *aData; /* Temporary storage for the page */
|
||||
sqlite3_file *jfd; /* The file descriptor for the journal file */
|
||||
|
||||
assert( (isMainJrnl&~1)==0 ); /* isMainJrnl is 0 or 1 */
|
||||
@ -1429,7 +1429,7 @@ static int pager_playback_one_page(
|
||||
assert( isMainJrnl || pDone ); /* pDone always used on sub-journals */
|
||||
assert( isSavepnt || pDone==0 ); /* pDone never used on non-savepoint */
|
||||
|
||||
aData = (u8*)pPager->pTmpSpace;
|
||||
aData = pPager->pTmpSpace;
|
||||
assert( aData ); /* Temp storage must have already been allocated */
|
||||
|
||||
/* Read the page number and page data from the journal or sub-journal
|
||||
@ -1438,7 +1438,7 @@ static int pager_playback_one_page(
|
||||
jfd = isMainJrnl ? pPager->jfd : pPager->sjfd;
|
||||
rc = read32bits(jfd, *pOffset, &pgno);
|
||||
if( rc!=SQLITE_OK ) return rc;
|
||||
rc = sqlite3OsRead(jfd, aData, pPager->pageSize, (*pOffset)+4);
|
||||
rc = sqlite3OsRead(jfd, (u8*)aData, pPager->pageSize, (*pOffset)+4);
|
||||
if( rc!=SQLITE_OK ) return rc;
|
||||
*pOffset += pPager->pageSize + 4 + isMainJrnl*4;
|
||||
|
||||
@ -1457,7 +1457,7 @@ static int pager_playback_one_page(
|
||||
if( isMainJrnl ){
|
||||
rc = read32bits(jfd, (*pOffset)-4, &cksum);
|
||||
if( rc ) return rc;
|
||||
if( !isSavepnt && pager_cksum(pPager, aData)!=cksum ){
|
||||
if( !isSavepnt && pager_cksum(pPager, (u8*)aData)!=cksum ){
|
||||
return SQLITE_DONE;
|
||||
}
|
||||
}
|
||||
@ -1503,8 +1503,8 @@ static int pager_playback_one_page(
|
||||
pPg = pager_lookup(pPager, pgno);
|
||||
assert( pPg || !MEMDB );
|
||||
PAGERTRACE(("PLAYBACK %d page %d hash(%08x) %s\n",
|
||||
PAGERID(pPager), pgno, pager_datahash(pPager->pageSize, aData),
|
||||
(isMainJrnl?"main-journal":"sub-journal")
|
||||
PAGERID(pPager), pgno, pager_datahash(pPager->pageSize, (u8*)aData),
|
||||
(isMainJrnl?"main-journal":"sub-journal")
|
||||
));
|
||||
if( (pPager->state>=PAGER_EXCLUSIVE)
|
||||
&& (pPg==0 || 0==(pPg->flags&PGHDR_NEED_SYNC))
|
||||
@ -1512,14 +1512,14 @@ static int pager_playback_one_page(
|
||||
&& !isUnsync
|
||||
){
|
||||
i64 ofst = (pgno-1)*(i64)pPager->pageSize;
|
||||
rc = sqlite3OsWrite(pPager->fd, aData, pPager->pageSize, ofst);
|
||||
rc = sqlite3OsWrite(pPager->fd, (u8*)aData, pPager->pageSize, ofst);
|
||||
if( pgno>pPager->dbFileSize ){
|
||||
pPager->dbFileSize = pgno;
|
||||
}
|
||||
if( pPager->pBackup ){
|
||||
CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM);
|
||||
sqlite3BackupUpdate(pPager->pBackup, pgno, aData);
|
||||
CODEC1(pPager, aData, pgno, 0, rc=SQLITE_NOMEM);
|
||||
sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)aData);
|
||||
CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM, aData);
|
||||
}
|
||||
}else if( !isMainJrnl && pPg==0 ){
|
||||
/* If this is a rollback of a savepoint and data was not written to
|
||||
@ -1554,7 +1554,7 @@ static int pager_playback_one_page(
|
||||
*/
|
||||
void *pData;
|
||||
pData = pPg->pData;
|
||||
memcpy(pData, aData, pPager->pageSize);
|
||||
memcpy(pData, (u8*)aData, pPager->pageSize);
|
||||
pPager->xReiniter(pPg);
|
||||
if( isMainJrnl && (!isSavepnt || *pOffset<=pPager->journalHdr) ){
|
||||
/* If the contents of this page were just restored from the main
|
||||
|
Loading…
Reference in New Issue
Block a user