diff options
author | drh <> | 2023-10-30 12:09:48 +0000 |
---|---|---|
committer | drh <> | 2023-10-30 12:09:48 +0000 |
commit | d2147bd32b0bb2e6cc4dc0306a834d7355932ba1 (patch) | |
tree | ab2ae973e64031800de4f832e1127feea69aa187 /src | |
parent | 7c2d3e8a06dcf9e1fc67a4049237cf77a26b1f34 (diff) | |
download | sqlite-d2147bd32b0bb2e6cc4dc0306a834d7355932ba1.tar.gz sqlite-d2147bd32b0bb2e6cc4dc0306a834d7355932ba1.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/pager.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/pager.c b/src/pager.c index 5c2d556b3..826e90f13 100644 --- a/src/pager.c +++ b/src/pager.c @@ -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); } |