mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-10 01:02:56 +03:00
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
This commit is contained in:
13
src/pager.c
13
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 ){
|
||||
|
Reference in New Issue
Block a user