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

@ -1,5 +1,8 @@
C Merged\saccidental\sfork.
D 2009-11-06T03:33:02
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
C Fix\sthe\sbackup\sAPI\sso\sthat\sa\sbackup\sfrom\san\sempty\sdatabase\sto\sa\snon-empty\ndatabase\sworks.\s\sTicket\s[0bf974bdf9].\s\sThe\sonly\schanges\sare\sin\sassert()\nstatements.
D 2009-11-06T04:13:18
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in a77dfde96ad86aafd3f71651a4333a104debe86a
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -146,9 +149,9 @@ F src/os.c 8d62d8d98ad7909cb0dd294c1e5f3835c887ccb6
F src/os.h 00a1334a4eecee7f7bef79ac606b88d325119f21
F src/os_common.h 8c61457df58f1a4bd5f5adc3e90e01b37bf7afbc
F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5
F src/os_unix.c a4b4ea928ce31ed34cb8f90ed36a35df19312fad
F src/os_unix.c bdd6ca0932dcb51c344081aff430bcc71c14db7f
F src/os_win.c 5ffab20249a61e0625f869efe157fa009747039b
F src/pager.c 36e29a1056457305d3afc5a8f81f7d9bf27dd70d
F src/pager.c 5b5a980aec52a3864bba8600c003b6ad6f4112c2
F src/pager.h 11852d044c86cf5a9d6e34171fb0c4fcf1f6265f
F src/parse.y 0204f0dfe8974dc2a0d46eb9ab98a433a1f963d6
F src/pcache.c c92ffd4f3e1279b3766854c6d18b5bf4aac0d1fa
@ -762,7 +765,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 38eaf1ab6e05161e6dc7cd69e942aeca16548c45 6bf43338049f956b447139c90df472682e28222a
R 04091970e2e76e3a20b2d6d4a8f9a97a
U shaneh
Z 124f978c5a8d21bfc62ab6af1f53f175
P d410cd4e42ecf50a849f49cf3395ec169350e7cf
R b6fd4922d8c93defdc16b7c4fc43d34c
U drh
Z c58c667f47a419949ef32e3c3c6a33b9
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFK86JioxKgR168RlERArjsAJ4iUjlJBvgOkG5Q0ykoZ9HOp9lYXwCfXOv9
56uC4JRhdJF56nAXOwquqLE=
=qYH+
-----END PGP SIGNATURE-----

View File

@ -1 +1 @@
d410cd4e42ecf50a849f49cf3395ec169350e7cf
ddb71cd9ed395804a13dc136bb7688a7627c798f

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

View File

@ -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 */