#
# This file contains test cases focused on the sqlite3_bcv_delete() API.
#
source [file join [file dirname [info script]] test_common.tcl]
set testprefix util_delete2.test
#-------------------------------------------------------------------------
# Test cases 1.* verify that deleting a database that shares blocks with
# another does not result in the blocks being made eligible for deletion.
#
bcv_create_container cont
bcv_upload_new_db cont test.db1 {
CREATE TABLE x1(a, b, PRIMARY KEY(a,b));
INSERT INTO x1 VALUES(randomblob(500), randomblob(500));
INSERT INTO x1 SELECT randomblob(500), randomblob(500) FROM x1; -- 2
INSERT INTO x1 SELECT randomblob(500), randomblob(500) FROM x1; -- 4
INSERT INTO x1 SELECT randomblob(500), randomblob(500) FROM x1; -- 8
INSERT INTO x1 SELECT randomblob(500), randomblob(500) FROM x1; -- 16
INSERT INTO x1 SELECT randomblob(500), randomblob(500) FROM x1; -- 32
INSERT INTO x1 SELECT randomblob(500), randomblob(500) FROM x1; -- 64
INSERT INTO x1 SELECT randomblob(500), randomblob(500) FROM x1; -- 128
}
bcv_upload_empty_database cont test.db2
bcv_upload_empty_database cont test.db3
bcv_upload_empty_database cont test.db4
proc xPuts {args} { puts $args }
do_test 1.1.1 {
set ::bcv [bcv_open cont]
$::bcv cleanup 0
$::bcv copy test.db1 test.db5
} 0
do_test 1.1.2 {
$::bcv delete test.db5
} 0
do_test 1.1.3 {
# $::bcv config log xPuts
$::bcv cleanup 0
} 0
do_test 1.1.3 {
$::bcv close
} {}
bcv_mkdir testdir
set cmd [bcvfs_create testdir bcvfs]
bcvfs_attach $cmd cont
sqlite3 db /cont/test.db1 -vfs bcvfs
do_execsql_test 1.2 {
PRAGMA integrity_check
} ok
db close
$cmd destroy
finish_test