From: dan Date: Wed, 13 Jan 2010 14:08:01 +0000 (+0000) Subject: Add tests to backup.test to verify that SQLite behaves as expected when the source... X-Git-Tag: version-3.7.2~642 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=33d58bcee9fd4bd25d624122554b7d9e52b25903;p=thirdparty%2Fsqlite.git Add tests to backup.test to verify that SQLite behaves as expected when the source database is modified mid-backup. FossilOrigin-Name: 985d3bec07430536485056bcd2ae0471791601ed --- diff --git a/manifest b/manifest index 8194b0fe4f..44ef4c0b67 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Comment\sout\sunused\scode\swhen\sSQLITE_OMIT_FLOATING_POINT\sis\sselected.\nAdded\stestcase()\smacros\sto\sboundary\sconditions\sin\sutil.c\sroutines. -D 2010-01-13T04:22:21 +C Add\stests\sto\sbackup.test\sto\sverify\sthat\sSQLite\sbehaves\sas\sexpected\swhen\sthe\ssource\sdatabase\sis\smodified\smid-backup. +D 2010-01-13T14:08:01 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -250,7 +247,7 @@ F test/autoinc.test 85ef3180a737e6580086a018c09c6f1a52759b46 F test/autovacuum.test 25f891bc343a8bf5d9229e2e9ddab9f31a9ab5ec F test/autovacuum_ioerr2.test 598b0663074d3673a9c1bc9a16e80971313bafe6 F test/avtrans.test 1e901d8102706b63534dbd2bdd4d8f16c4082650 -F test/backup.test 9b184cc3cccb153e73387a88c6e6d23210212f86 +F test/backup.test 8962568895a1178041544ca014b940086f0178f5 F test/backup2.test 159419073d9769fdb1780ed7e5b391a046f898d5 F test/backup_ioerr.test 1f012e692f42c0442ae652443258f70e9f20fa38 F test/backup_malloc.test 1e063c6d75143d0d6e0ae77971dd690070369387 @@ -788,14 +785,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 61df5986600b6c9e6d5c42efc0067a27fe54251f -R ed1297a5ea74ad9a93623001b89f8fe6 -U drh -Z 6850a89c31f37b37c7103946a0617fb2 ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFLTUqAoxKgR168RlERArrjAJ4+fjS5/JTEovzvoqB7ZbKz9iMf2wCeITA6 -uHjhIi3LJdPEe5X1lDBaOhI= -=jnHU ------END PGP SIGNATURE----- +P dfc6595d347ea87923a857778b68751103f535d2 +R af14a12e0fb93ccaa943052917036ca2 +U dan +Z 2a08504403cd615454c575ebb53e6c12 diff --git a/manifest.uuid b/manifest.uuid index 42fa9a8cbb..80af0a0ba9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -dfc6595d347ea87923a857778b68751103f535d2 \ No newline at end of file +985d3bec07430536485056bcd2ae0471791601ed \ No newline at end of file diff --git a/test/backup.test b/test/backup.test index ae1559593f..817aac6b19 100644 --- a/test/backup.test +++ b/test/backup.test @@ -904,4 +904,62 @@ ifcapable memorymanage { db3 close } + +# Test that if the database is written to via the same database handle being +# used as the source by a backup operation: +# +# 10.1.*: If the db is in-memory, the backup is restarted. +# 10.2.*: If the db is a file, the backup is not restarted. +# +db close +file delete -force test.db test.db-journal +foreach {tn file rc} { + 1 test.db SQLITE_DONE + 2 :memory: SQLITE_OK +} { + do_test backup-10.$tn.1 { + sqlite3 db $file + execsql { + CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB); + BEGIN; + INSERT INTO t1 VALUES(NULL, randomblob(200)); + INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1; + INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1; + INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1; + INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1; + INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1; + INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1; + INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1; + INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1; + COMMIT; + SELECT count(*) FROM t1; + } + } {256} + + do_test backup-10.$tn.2 { + set pgs [execsql {pragma page_count}] + expr {$pgs > 50 && $pgs < 75} + } {1} + + do_test backup-10.$tn.3 { + file delete -force bak.db bak.db-journal + sqlite3 db2 bak.db + sqlite3_backup B db2 main db main + B step 50 + } {SQLITE_OK} + + do_test backup-10.$tn.4 { + execsql { UPDATE t1 SET b = randomblob(200) WHERE a IN (1, 250) } + } {} + + do_test backup-10.$tn.5 { + B step 50 + } $rc + + do_test backup-10.6 { + B finish + } {SQLITE_OK} +} + +db2 close finish_test