Make the pager less vulnerable to problems caused by shifting sector sizes

when rolling back a hot journal.

FossilOrigin-Name: 629108c8e5376f989cd66e11437949a54c33a5b8
This commit is contained in:
drh 2012-01-11 15:47:42 +00:00
parent 72cd90ac44
commit 935de7e81a
3 changed files with 11 additions and 11 deletions

View File

@ -1,5 +1,5 @@
C Fix\sthe\ssqlite3_quota_file()\sfunction\sin\stest_quota.c\sso\sthat\sit\sadds\sthe\ssecond\snul-terminator\sto\sall\sfile\snames\sthat\swill\sbe\spassed\sto\sa\sVFS\sxOpen\smethod.
D 2012-01-11T11:20:42.615
C Make\sthe\spager\sless\svulnerable\sto\sproblems\scaused\sby\sshifting\ssector\ssizes\nwhen\srolling\sback\sa\shot\sjournal.
D 2012-01-11T15:47:42.245
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5b4a3e12a850b021547e43daf886b25133b44c07
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -168,7 +168,7 @@ F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
F src/os_unix.c 657672fab2580a84116c140b36ee3d6b6fc75b4e
F src/os_win.c 5ac061ae1326a71500cee578ed0fd9113b4f6a37
F src/pager.c 99ee9e52e48bd42bd7523968017c057b93d75df9
F src/pager.c a3ef71cb0b8660d79bbc6a72c7e81ca36cc2bf6f
F src/pager.h 5cd760857707529b403837d813d86b68938d6183
F src/parse.y fabb2e7047417d840e6fdb3ef0988a86849a08ba
F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
@ -986,7 +986,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
P 93a65776dc8f496485e206a5eab11eeba579b5da
R 3805735c0ca2b6b98ec127d6abb27a40
U dan
Z 357b348e0dbbb80764282a97fc7e130f
P 3013f9a67cc6097c14e40a6155c1401f51f4da78
R d8b430b1632b38746b734caf871f0ff0
U drh
Z 899c0fed1d7782ced9fe8db2345743d3

View File

@ -1 +1 @@
3013f9a67cc6097c14e40a6155c1401f51f4da78
629108c8e5376f989cd66e11437949a54c33a5b8

View File

@ -2486,7 +2486,7 @@ static int pager_truncate(Pager *pPager, Pgno nPage){
if( rc==SQLITE_OK && currentSize!=newSize ){
if( currentSize>newSize ){
rc = sqlite3OsTruncate(pPager->fd, newSize);
}else{
}else if( (currentSize+szPage)<=newSize ){
char *pTmp = pPager->pTmpSpace;
memset(pTmp, 0, szPage);
testcase( (newSize-szPage) < currentSize );
@ -3088,7 +3088,7 @@ static int pagerPagecount(Pager *pPager, Pgno *pnPage){
return rc;
}
}
nPage = (Pgno)(n / pPager->pageSize);
nPage = (Pgno)((n+pPager->pageSize-1) / pPager->pageSize);
if( nPage==0 && n>0 ){
nPage = 1;
}
@ -3522,7 +3522,7 @@ int sqlite3PagerSetPagesize(Pager *pPager, u32 *pPageSize, int nReserve){
if( rc==SQLITE_OK ){
pager_reset(pPager);
pPager->dbSize = (Pgno)(nByte/pageSize);
pPager->dbSize = (Pgno)((nByte+pageSize-1)/pageSize);
pPager->pageSize = pageSize;
sqlite3PageFree(pPager->pTmpSpace);
pPager->pTmpSpace = pNew;