1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

When extending a database file, do so by writing one or more page-size chunks of data to the file, instead of just a single byte to the end.

FossilOrigin-Name: 58577135a81d3f19667b1de6167d2e3f1b74cd53
This commit is contained in:
dan
2011-01-28 15:07:55 +00:00
parent 10431c306b
commit fb3828c25f
3 changed files with 14 additions and 19 deletions

View File

@@ -2485,7 +2485,12 @@ static int pager_truncate(Pager *pPager, Pgno nPage){
if( currentSize>newSize ){
rc = sqlite3OsTruncate(pPager->fd, newSize);
}else{
rc = sqlite3OsWrite(pPager->fd, "", 1, newSize-1);
char *pTmp = pPager->pTmpSpace;
memset(pTmp, 0, pPager->pageSize);
while( currentSize<newSize ){
rc = sqlite3OsWrite(pPager->fd, pTmp, pPager->pageSize, currentSize);
currentSize += pPager->pageSize;
}
}
if( rc==SQLITE_OK ){
pPager->dbFileSize = nPage;