diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/os_unix.c | 13 | ||||
-rw-r--r-- | src/pager.c | 2 |
2 files changed, 14 insertions, 1 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; } } diff --git a/src/pager.c b/src/pager.c index 9686eb904..1c8fd8314 100644 --- a/src/pager.c +++ b/src/pager.c @@ -4446,7 +4446,7 @@ static int pager_incr_changecounter(Pager *pPager, int isDirectMode){ #endif assert( pPager->state>=PAGER_RESERVED ); - if( !pPager->changeCountDone && ALWAYS(pPager->dbSize>0) ){ + if( !pPager->changeCountDone && pPager->dbSize>0 ){ PgHdr *pPgHdr; /* Reference to page 1 */ u32 change_counter; /* Initial value of change-counter field */ |