Index: third_party/sqlite/src/test/backup.test |
diff --git a/third_party/sqlite/src/test/backup.test b/third_party/sqlite/src/test/backup.test |
index ae1559593f95d0af23859dcd99f1c2bf3489015b..0e2c26f33b8f84b4e0928f48902f61e7da33b2b6 100644 |
--- a/third_party/sqlite/src/test/backup.test |
+++ b/third_party/sqlite/src/test/backup.test |
@@ -16,6 +16,8 @@ |
set testdir [file dirname $argv0] |
source $testdir/tester.tcl |
+do_not_use_codec |
+ |
#--------------------------------------------------------------------- |
# Test organization: |
# |
@@ -38,6 +40,8 @@ source $testdir/tester.tcl |
# |
# backup-9.*: Test that passing a negative argument to backup_step() is |
# interpreted as "copy the whole file". |
+# |
+# backup-10.*: Test writing the source database mid backup. |
# |
proc data_checksum {db file} { $db one "SELECT md5sum(a, b) FROM ${file}.t1" } |
@@ -173,7 +177,7 @@ foreach nPagePerStep {1 200} { |
# page size is the same as the source page size (in this case 1024 bytes). |
# |
set isMemDest [expr { |
- $zDestFile eq ":memory:" || $file_dest eq "temp" && $TEMP_STORE==3 |
+ $zDestFile eq ":memory:" || $file_dest eq "temp" && $TEMP_STORE>=2 |
}] |
if { $isMemDest==0 || $pgsz_dest == 1024 } { |
@@ -487,6 +491,7 @@ db2 close |
# 3) Backing up memory-to-file. |
# |
set iTest 0 |
+file delete -force bak.db-wal |
foreach {writer file} {db test.db db3 test.db db :memory:} { |
incr iTest |
catch { file delete bak.db } |
@@ -904,4 +909,64 @@ 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.$tn.6 { |
+ B finish |
+ } {SQLITE_OK} |
+ |
+ db2 close |
+} |
+ |
finish_test |