mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Changes to the backup API: (1) if a negative number is passed as the second argument to backup_step(), this is interpreted as "copy all remaining pages" and (2) if backup_finish() is called after backup_step() fails with a BUSY or LOCKED error, then this error is also returned by backup_finish() (same handling as for other errors encountered by backup_step()). (CVS 6266)
FossilOrigin-Name: 9b8c8b18cf6b7d44d5fd64760537bc030097756b
This commit is contained in:
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the sqlite3_backup_XXX API.
|
||||
#
|
||||
# $Id: backup.test,v 1.3 2009/02/04 22:46:47 drh Exp $
|
||||
# $Id: backup.test,v 1.4 2009/02/06 05:59:45 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -36,6 +36,9 @@ source $testdir/tester.tcl
|
||||
#
|
||||
# backup-8.*: Test multiple simultaneous backup operations.
|
||||
#
|
||||
# backup-9.*: Test that passing a negative argument to backup_step() is
|
||||
# interpreted as "copy the whole file".
|
||||
#
|
||||
|
||||
proc data_checksum {db file} { $db one "SELECT md5sum(a, b) FROM ${file}.t1" }
|
||||
proc test_contents {name db1 file1 db2 file2} {
|
||||
@ -763,5 +766,42 @@ do_test backup-8.10 {
|
||||
catch { db2 close }
|
||||
catch { db3 close }
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# The following tests, backup-9.*, test that:
|
||||
#
|
||||
# * Passing 0 as an argument to sqlite3_backup_step() means no pages
|
||||
# are backed up (backup-9.1.*), and
|
||||
# * Passing a negative value as an argument to sqlite3_backup_step() means
|
||||
# all pages are backed up (backup-9.2.*).
|
||||
#
|
||||
# These tests reuse the database "test.db" left over from backup-7.*.
|
||||
#
|
||||
do_test backup-9.1.1 {
|
||||
sqlite3 db2 test2.db
|
||||
sqlite3_backup B db2 main db main
|
||||
B step 1
|
||||
} {SQLITE_OK}
|
||||
do_test backup-9.1.2 {
|
||||
set nRemaining [B remaining]
|
||||
expr {$nRemaining>100}
|
||||
} {1}
|
||||
do_test backup-9.1.3 {
|
||||
B step 0
|
||||
} {SQLITE_OK}
|
||||
do_test backup-9.1.4 {
|
||||
B remaining
|
||||
} $nRemaining
|
||||
|
||||
do_test backup-9.2.1 {
|
||||
B step -1
|
||||
} {SQLITE_DONE}
|
||||
do_test backup-9.2.2 {
|
||||
B remaining
|
||||
} {0}
|
||||
do_test backup-9.2.3 {
|
||||
B finish
|
||||
} {SQLITE_OK}
|
||||
catch {db2 close}
|
||||
|
||||
finish_test
|
||||
|
||||
|
Reference in New Issue
Block a user