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

With SQLITE_ENABLE_BLOCK_ATOMIC_WRITE enabled, if a transaction is committing

and there is a new freelist page at the end of the database file which would
cause the database file size to grow, ensure that page is written and the
file size grows before the block-atomic-write commits.  Fix for the
problem identified by [forum:/forumpost/3bd8d497b2|forum post 3bd8d497b2]

FossilOrigin-Name: c9fdd6805df04f05ef347e5a43506fd37a729c5924abb6e1103e871c4ac2d6dc
This commit is contained in:
drh
2023-10-30 12:09:48 +00:00
parent 7c2d3e8a06
commit d2147bd32b
3 changed files with 15 additions and 8 deletions

View File

@@ -6588,6 +6588,13 @@ int sqlite3PagerCommitPhaseOne(
rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, 0);
if( rc==SQLITE_OK ){
rc = pager_write_pagelist(pPager, pList);
if( rc==SQLITE_OK && pPager->dbSize>pPager->dbFileSize ){
char *pTmp = pPager->pTmpSpace;
int szPage = (int)pPager->pageSize;
memset(pTmp, 0, szPage);
rc = sqlite3OsWrite(pPager->fd, pTmp, szPage,
(pPager->dbSize*pPager->pageSize)-szPage);
}
if( rc==SQLITE_OK ){
rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, 0);
}