3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
12 # The tests in this file verify that if an empty database (zero bytes in
13 # size) is used as the source of a backup operation, the final destination
14 # database is one page in size.
16 # The destination must consist of at least one page as truncating a
17 # database file to zero bytes is equivalent to resetting the database
18 # schema cookie and change counter. Doing that could cause other clients
19 # to become confused and continue using out-of-date cache data.
22 set testdir [file dirname $argv0]
23 source $testdir/tester.tcl
24 set testprefix backup4
26 # The codec logic does not work for zero-length database files. A database
27 # file must contain at least one page in order to be recognized as an
31 #-------------------------------------------------------------------------
32 # At one point this test was failing because [db] was using an out of
33 # date schema in test case 1.2.
36 CREATE TABLE t1(x, y, UNIQUE(x, y));
37 INSERT INTO t1 VALUES('one', 'two');
38 SELECT * FROM t1 WHERE x='one';
39 PRAGMA integrity_check;
47 CREATE TABLE t1(x, y);
48 INSERT INTO t1 VALUES('one', 'two');
54 SELECT * FROM t1 WHERE x='one';
55 PRAGMA integrity_check;
63 #-------------------------------------------------------------------------
64 # Test that if the source is zero bytes, the destination database
65 # consists of a single page only.
68 CREATE TABLE t1(a, b);
69 CREATE INDEX i1 ON t1(a, b);
71 do_test 2.2 { file size test.db } [expr $AUTOVACUUM ? 4096 : 3072]
80 do_test 2.4 { file size test.db2 } 0
87 #-------------------------------------------------------------------------
88 # Test that if the destination has a page-size larger than the implicit
89 # page-size of the source, the final destination database still consists
93 PRAGMA page_size = 4096;
94 CREATE TABLE t1(a, b);
95 CREATE INDEX i1 ON t1(a, b);
97 do_test 3.2 { file size test.db } [expr $AUTOVACUUM ? 16384 : 12288]
106 do_test 3.4 { file size test.db2 } 0