1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

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
This commit is contained in:
drh
2009-11-06 04:13:18 +00:00
parent 6278666fe3
commit 3313b14f46
4 changed files with 33 additions and 10 deletions

View File

@@ -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;
}
}