Ensure the database size field in the db header of a backup database is set correctly. Fix for [0cfd98ee201].

FossilOrigin-Name: ff6857b6ed6a46671006b75157d8cf853a816ef9
This commit is contained in:
dan 2012-12-21 16:15:35 +00:00
parent b2bb176b70
commit 5cc3bea44a
4 changed files with 55 additions and 12 deletions

View File

@ -1,5 +1,5 @@
C Add\sPRAGMA\sforeign_key_check.\s\sName\sthe\schild\sand\sparent\stables\sas\spart\sof\na\s"foreign\skey\smismatch"\serror.
D 2012-12-20T01:15:20.959
C Ensure\sthe\sdatabase\ssize\sfield\sin\sthe\sdb\sheader\sof\sa\sbackup\sdatabase\sis\sset\scorrectly.\sFix\sfor\s[0cfd98ee201].
D 2012-12-21T16:15:35.911
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 690d441a758cbffd13e814dc2724a721a6ebd400
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -118,7 +118,7 @@ F src/alter.c f8db986c03eb0bfb221523fc9bbb9d0b70de3168
F src/analyze.c 7553068d21e32a57fc33ab6b2393fc8c1ba41410
F src/attach.c ea5247f240e2c08afd608e9beb380814b86655e1
F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
F src/backup.c cab40f2c1fe79d6eb93d3b4086c78c41ad2fa5d0
F src/backup.c 32e35a3a4ea55b45c0e5f74eeb793aec71491517
F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1
F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
F src/btree.c 7a80e4a67f32a2494c383a28a495bf3bd71cc230
@ -407,7 +407,7 @@ F test/exists.test 8f7b27b61c2fbe5822f0a1f899c715d14e416e30
F test/expr.test 67c9fd6f8f829e239dc8b0f4a08a73c08b09196d
F test/fallocate.test b5d34437bd7ab01d41b1464b8117aefd4d32160e
F test/filectrl.test 14fa712e42c4cb791e09dfd58a6a03efb47ef13a
F test/filefmt.test ffa17b5aebc3eb4b1e3be1ccb5ee906ffbd97f6e
F test/filefmt.test dbee33e57818249cdffbbb7b13464635217beff1
F test/fkey1.test 01c7de578e11747e720c2d9aeef27f239853c4da
F test/fkey2.test 5aa44e7153928a1f002803f94aaab4c76a7ceac2
F test/fkey3.test 5ec899d12b13bcf1e9ef40eff7fb692fdb91392e
@ -1028,7 +1028,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
P b3c9e8f81275fe07272c01f66b16c16417f034af b5a8f3160b5dc1397312add3c5410e7e0a12b75e
R c25a7b70b2b47eedc79e89bea857f6d5
U drh
Z 54888f90388c5aea5593479ed7ab2502
P e408dc9080594dc464b8763dece6b365772c6105
R 029b6fc924e25c670b20c53f3ff270ca
U dan
Z feee379cb7d3362de52284de8aba8c99

View File

@ -1 +1 @@
e408dc9080594dc464b8763dece6b365772c6105
ff6857b6ed6a46671006b75157d8cf853a816ef9

View File

@ -212,7 +212,12 @@ static int isFatalError(int rc){
** page iSrcPg from the source database. Copy this data into the
** destination database.
*/
static int backupOnePage(sqlite3_backup *p, Pgno iSrcPg, const u8 *zSrcData){
static int backupOnePage(
sqlite3_backup *p, /* Backup handle */
Pgno iSrcPg, /* Source database page to backup */
const u8 *zSrcData, /* Source database page data */
int bUpdate /* True for an update, false otherwise */
){
Pager * const pDestPager = sqlite3BtreePager(p->pDest);
const int nSrcPgsz = sqlite3BtreeGetPageSize(p->pSrc);
int nDestPgsz = sqlite3BtreeGetPageSize(p->pDest);
@ -285,6 +290,9 @@ static int backupOnePage(sqlite3_backup *p, Pgno iSrcPg, const u8 *zSrcData){
*/
memcpy(zOut, zIn, nCopy);
((u8 *)sqlite3PagerGetExtra(pDestPg))[0] = 0;
if( iOff==0 && bUpdate==0 ){
sqlite3Put4byte(&zOut[28], sqlite3BtreeLastPage(p->pSrc));
}
}
sqlite3PagerUnref(pDestPg);
}
@ -391,7 +399,7 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){
DbPage *pSrcPg; /* Source page object */
rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg);
if( rc==SQLITE_OK ){
rc = backupOnePage(p, iSrcPg, sqlite3PagerGetData(pSrcPg));
rc = backupOnePage(p, iSrcPg, sqlite3PagerGetData(pSrcPg), 0);
sqlite3PagerUnref(pSrcPg);
}
}
@ -639,7 +647,7 @@ void sqlite3BackupUpdate(sqlite3_backup *pBackup, Pgno iPage, const u8 *aData){
int rc;
assert( p->pDestDb );
sqlite3_mutex_enter(p->pDestDb->mutex);
rc = backupOnePage(p, iPage, aData);
rc = backupOnePage(p, iPage, aData, 1);
sqlite3_mutex_leave(p->pDestDb->mutex);
assert( rc!=SQLITE_BUSY && rc!=SQLITE_LOCKED );
if( rc!=SQLITE_OK ){

View File

@ -213,4 +213,39 @@ do_execsql_test filefmt-3.3 {
PRAGMA integrity_check;
} {ok}
reset_db
do_execsql_test filefmt-4.1 {
PRAGMA auto_vacuum = 1;
CREATE TABLE t1(x, y);
CREATE TABLE t2(x, y);
INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM t1;
INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM t1;
INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM t1;
INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM t1;
}
do_test filefmt-4.2 {
sql36231 { INSERT INTO t2 SELECT * FROM t1 }
} {}
do_test filefmt-4.3 {
forcedelete bak.db
db backup bak.db
} {}
do_test filefmt-4.4 {
sqlite3 db2 bak.db
db2 eval { PRAGMA integrity_check }
} {ok}
db2 close
finish_test