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 #***********************************************************************
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
16 file_control_chunksize_test db main [expr 1024*1024]
18 do_test fallocate-1.1 {
20 PRAGMA page_size = 1024;
21 PRAGMA auto_vacuum = 1;
22 CREATE TABLE t1(a, b);
27 do_test fallocate-1.2 {
28 execsql { INSERT INTO t1 VALUES(1, zeroblob(1024*900)) }
32 do_test fallocate-1.3 {
33 execsql { INSERT INTO t1 VALUES(2, zeroblob(1024*900)) }
37 do_test fallocate-1.4 {
38 execsql { DELETE FROM t1 WHERE a = 1 }
42 do_test fallocate-1.5 {
43 execsql { DELETE FROM t1 WHERE a = 2 }
47 do_test fallocate-1.6 {
48 execsql { PRAGMA freelist_count }
51 # Start a write-transaction and read the "database file size" field from
52 # the journal file. This field should be set to the number of pages in
53 # the database file based on the size of the file on disk, not the actual
54 # logical size of the database within the file.
56 # We need to check this to verify that if in the unlikely event a rollback
57 # causes a database file to grow, the database grows to its previous size
58 # on disk, not to the minimum size required to hold the database image.
60 do_test fallocate-1.7 {
61 execsql { BEGIN; INSERT INTO t1 VALUES(1, 2); }
62 if {[permutation] != "inmemory_journal"
63 && [permutation] != "atomic-batch-write"
64 && [atomic_batch_write test.db]==0
66 hexio_get_int [hexio_read test.db-journal 16 4]
71 do_test fallocate-1.8 { execsql { COMMIT } } {}
74 #-------------------------------------------------------------------------
75 # The following tests - fallocate-2.* - test that things work in WAL
78 set skipwaltests [expr {
79 [permutation]=="journaltest" || [permutation]=="inmemory_journal"
81 ifcapable !wal { set skipwaltests 1 }
87 file_control_chunksize_test db main [expr 32*1024]
89 do_test fallocate-2.1 {
91 PRAGMA page_size = 1024;
92 PRAGMA journal_mode = WAL;
93 CREATE TABLE t1(a, b);
98 do_test fallocate-2.2 {
99 execsql { INSERT INTO t1 VALUES(1, zeroblob(35*1024)) }
100 execsql { PRAGMA wal_checkpoint }
104 do_test fallocate-2.3 {
105 execsql { DELETE FROM t1 }
110 do_test fallocate-2.4 {
111 execsql { PRAGMA wal_checkpoint }
115 do_test fallocate-2.5 {
117 INSERT INTO t1 VALUES(2, randomblob(35*1024));
118 PRAGMA wal_checkpoint;
119 INSERT INTO t1 VALUES(3, randomblob(128));
120 DELETE FROM t1 WHERE a = 2;
126 do_test fallocate-2.6 {
128 execsql { BEGIN ; SELECT count(a) FROM t1 } db2
130 INSERT INTO t1 VALUES(4, randomblob(128));
131 PRAGMA wal_checkpoint;
136 do_test fallocate-2.7 {
137 execsql { SELECT count(b) FROM t1 } db2
140 do_test fallocate-2.8 {
141 execsql { COMMIT } db2
142 execsql { PRAGMA wal_checkpoint }