diff options
author | danielk1977 <danielk1977@noemail.net> | 2008-05-06 18:13:26 +0000 |
---|---|---|
committer | danielk1977 <danielk1977@noemail.net> | 2008-05-06 18:13:26 +0000 |
commit | 06e11af9b75ab463ed8a3845d5771e17cfd6d2f8 (patch) | |
tree | 622568bb778726d659201d1bec1546bd0188a40e /src | |
parent | 10b6c9ab3776f0850ebc89e27210b799951bd8c9 (diff) | |
download | sqlite-06e11af9b75ab463ed8a3845d5771e17cfd6d2f8.tar.gz sqlite-06e11af9b75ab463ed8a3845d5771e17cfd6d2f8.zip |
Fix a bug whereby the database file was not always being extended to its original size when rolling back an incremental-vacuum operation. (CVS 5089)
FossilOrigin-Name: 4a1ae9d0320de1013a3b5f24ebdd25fe9fdab424
Diffstat (limited to 'src')
-rw-r--r-- | src/pager.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/pager.c b/src/pager.c index fca3d3bc9..dd691c2ee 100644 --- a/src/pager.c +++ b/src/pager.c @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.439 2008/05/05 16:23:55 danielk1977 Exp $ +** @(#) $Id: pager.c,v 1.440 2008/05/06 18:13:26 danielk1977 Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" @@ -1695,7 +1695,8 @@ static void pager_truncate_cache(Pager *pPager); ** in cache, then an INSERT or UPDATE does a statement rollback. Some ** operating system implementations can get confused if you try to ** truncate a file to some size that is larger than it currently is, -** so detect this case and do not do the truncation. +** so detect this case and write a single zero byte to the end of the new +** file instead. */ static int pager_truncate(Pager *pPager, int nPage){ int rc = SQLITE_OK; @@ -1703,8 +1704,12 @@ static int pager_truncate(Pager *pPager, int nPage){ i64 currentSize, newSize; rc = sqlite3OsFileSize(pPager->fd, ¤tSize); newSize = pPager->pageSize*(i64)nPage; - if( rc==SQLITE_OK && currentSize>newSize ){ - rc = sqlite3OsTruncate(pPager->fd, newSize); + if( rc==SQLITE_OK && currentSize!=newSize ){ + if( currentSize>newSize ){ + rc = sqlite3OsTruncate(pPager->fd, newSize); + }else{ + rc = sqlite3OsWrite(pPager->fd, "", 1, newSize-1); + } } } if( rc==SQLITE_OK ){ |