diff options
author | dan <dan@noemail.net> | 2011-10-07 16:57:59 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2011-10-07 16:57:59 +0000 |
commit | c5f20a00616ca2d0d18cbacff234715b7682b0fb (patch) | |
tree | 854117c384ac3773ad2c52b88298a5405079e269 /src/backup.c | |
parent | f3259997c017d9660587ffd61a5ca3d3a7db973e (diff) | |
download | sqlite-c5f20a00616ca2d0d18cbacff234715b7682b0fb.tar.gz sqlite-c5f20a00616ca2d0d18cbacff234715b7682b0fb.zip |
Add the SQLITE_FCNTL_OVERWRITE file-control. Used by SQLite to indicate to the OS layer that the current transaction will overwrite the entire file.
FossilOrigin-Name: 1da87fcdacfa7d277c3ee98e410a9ea8b529c368
Diffstat (limited to 'src/backup.c')
-rw-r--r-- | src/backup.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/backup.c b/src/backup.c index 70a782665..411a9b8d6 100644 --- a/src/backup.c +++ b/src/backup.c @@ -669,10 +669,18 @@ void sqlite3BackupRestart(sqlite3_backup *pBackup){ */ int sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){ int rc; + sqlite3_file *pFd; /* File descriptor for database pTo */ sqlite3_backup b; sqlite3BtreeEnter(pTo); sqlite3BtreeEnter(pFrom); + assert( sqlite3BtreeIsInTrans(pTo) ); + pFd = sqlite3PagerFile(sqlite3BtreePager(pTo)); + if( pFd->pMethods ){ + i64 nByte = sqlite3BtreeGetPageSize(pFrom)*(i64)sqlite3BtreeLastPage(pFrom); + sqlite3OsFileControl(pFd, SQLITE_FCNTL_OVERWRITE, &nByte); + } + /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set ** to 0. This is used by the implementations of sqlite3_backup_step() ** and sqlite3_backup_finish() to detect that they are being called @@ -698,6 +706,7 @@ int sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){ pTo->pBt->pageSizeFixed = 0; } + assert( sqlite3BtreeIsInTrans(pTo)==0 ); sqlite3BtreeLeave(pFrom); sqlite3BtreeLeave(pTo); return rc; |