Change pager_truncate() to a different method for extending files while
also ensuring that writes are page-size and page-aligned. FossilOrigin-Name: 874bc8844f6494cdbf700bd884dee67d40f11fc0
This commit is contained in:
parent
fb3828c25f
commit
bd1334dfd9
24
manifest
24
manifest
@ -1,5 +1,8 @@
|
||||
C When\sextending\sa\sdatabase\sfile,\sdo\sso\sby\swriting\sone\sor\smore\spage-size\schunks\sof\sdata\sto\sthe\sfile,\sinstead\sof\sjust\sa\ssingle\sbyte\sto\sthe\send.
|
||||
D 2011-01-28T15:07:56
|
||||
-----BEGIN PGP SIGNED MESSAGE-----
|
||||
Hash: SHA1
|
||||
|
||||
C Change\spager_truncate()\sto\sa\sdifferent\smethod\sfor\sextending\sfiles\swhile\nalso\sensuring\sthat\swrites\sare\spage-size\sand\spage-aligned.
|
||||
D 2011-01-28T15:46:14.305
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in de6498556d536ae60bb8bb10e8c1ba011448658c
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -162,7 +165,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f
|
||||
F src/os_os2.c 2e452c9f2ca507623ad351c33a8a8b27849b1863
|
||||
F src/os_unix.c 1be46a35bad4bec5171e4de88aaff817260eb378
|
||||
F src/os_win.c 9abdcdd925416d854eabb0996c96debd92abfef5
|
||||
F src/pager.c 3327c903932466adead8b4f4e9c6e5f958cae2a9
|
||||
F src/pager.c b0fcbe3038fd08b111e1cf1deddd5f42418004d8
|
||||
F src/pager.h 0ea59db2a33bc6c2c02cae34de33367e1effdf76
|
||||
F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58
|
||||
F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa
|
||||
@ -897,7 +900,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
P 35ac78f55159705af140b949ee33852aedd62816
|
||||
R 5a38d0e5da35229b881ee437e0399faf
|
||||
U dan
|
||||
Z ba9abebf804867e3ebdd758398513a6b
|
||||
P 58577135a81d3f19667b1de6167d2e3f1b74cd53
|
||||
R a0c65f35bd8df31841c75a033fdc54e1
|
||||
U drh
|
||||
Z afe8bfe1fbfd780cf630a681a38fd2a0
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1.4.6 (GNU/Linux)
|
||||
|
||||
iD8DBQFNQuTKoxKgR168RlERArXfAJ9CQ6LWQKMuWD1biGnn8WGHHeKjNwCdFcPT
|
||||
8yNpIIrDf9AAFFFQY8m1usg=
|
||||
=moCk
|
||||
-----END PGP SIGNATURE-----
|
||||
|
@ -1 +1 @@
|
||||
58577135a81d3f19667b1de6167d2e3f1b74cd53
|
||||
874bc8844f6494cdbf700bd884dee67d40f11fc0
|
13
src/pager.c
13
src/pager.c
@ -2477,20 +2477,21 @@ static int pager_truncate(Pager *pPager, Pgno nPage){
|
||||
&& (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN)
|
||||
){
|
||||
i64 currentSize, newSize;
|
||||
int szPage = pPager->pageSize;
|
||||
assert( pPager->eLock==EXCLUSIVE_LOCK );
|
||||
/* TODO: Is it safe to use Pager.dbFileSize here? */
|
||||
rc = sqlite3OsFileSize(pPager->fd, ¤tSize);
|
||||
newSize = pPager->pageSize*(i64)nPage;
|
||||
newSize = szPage*(i64)nPage;
|
||||
if( rc==SQLITE_OK && currentSize!=newSize ){
|
||||
if( currentSize>newSize ){
|
||||
rc = sqlite3OsTruncate(pPager->fd, newSize);
|
||||
}else{
|
||||
char *pTmp = pPager->pTmpSpace;
|
||||
memset(pTmp, 0, pPager->pageSize);
|
||||
while( currentSize<newSize ){
|
||||
rc = sqlite3OsWrite(pPager->fd, pTmp, pPager->pageSize, currentSize);
|
||||
currentSize += pPager->pageSize;
|
||||
}
|
||||
memset(pTmp, 0, szPage);
|
||||
testcase( (newSize-szPage) < currentSize );
|
||||
testcase( (newSize-szPage) == currentSize );
|
||||
testcase( (newSize-szPage) > currentSize );
|
||||
rc = sqlite3OsWrite(pPager->fd, pTmp, szPage, newSize-szPage);
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
pPager->dbFileSize = nPage;
|
||||
|
Loading…
Reference in New Issue
Block a user