aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2009-11-06 04:13:18 +0000
committerdrh <drh@noemail.net>2009-11-06 04:13:18 +0000
commit3313b14f46bb3eb5bc7fab5571ec44ed2d25d3c1 (patch)
tree075cf063811184a05518f04d1124c115e5499656 /src/os_unix.c
parent6278666fe346998f630933c690fe2f357d1f2da8 (diff)
downloadsqlite-3313b14f46bb3eb5bc7fab5571ec44ed2d25d3c1.tar.gz
sqlite-3313b14f46bb3eb5bc7fab5571ec44ed2d25d3c1.zip
Fix the backup API so that a backup from an empty database to a non-empty
database works. Ticket [0bf974bdf9]. The only changes are in assert() statements. FossilOrigin-Name: ddb71cd9ed395804a13dc136bb7688a7627c798f
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index b31fbab21..0a866f155 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -3113,6 +3113,19 @@ static int unixTruncate(sqlite3_file *id, i64 nByte){
((unixFile*)id)->lastErrno = errno;
return SQLITE_IOERR_TRUNCATE;
}else{
+#ifndef NDEBUG
+ /* If we are doing a normal write to a database file (as opposed to
+ ** doing a hot-journal rollback or a write to some file other than a
+ ** normal database file) and we truncate the file to zero length,
+ ** that effectively updates the change counter. This might happen
+ ** when restoring a database using the backup API from a zero-length
+ ** source.
+ */
+ if( ((unixFile*)id)->inNormalWrite && nByte==0 ){
+ ((unixFile*)id)->transCntrChng = 1;
+ }
+#endif
+
return SQLITE_OK;
}
}