Update contrib.
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 #***********************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this file is testing the VACUUM statement.
14 # $Id: vacuum2.test,v 1.8 2008/08/23 16:17:56 danielk1977 Exp $
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
19 # If the VACUUM statement is disabled in the current build, skip all
20 # the tests in this file.
22 ifcapable {!vacuum||!autoinc} {
31 # Ticket #1121 - make sure vacuum works if all autoincrement tables
36 CREATE TABLE t1(x INTEGER PRIMARY KEY AUTOINCREMENT, y);
42 # Ticket #2518. Make sure vacuum increments the change counter
43 # in the database header.
49 INSERT INTO t1 VALUES(1);
51 hexio_get_int [hexio_read test.db 24 4]
52 } [expr {[hexio_get_int [hexio_read test.db 24 4]]+3}]
57 hexio_get_int [hexio_read test.db 24 4]
58 } [expr {[hexio_get_int [hexio_read test.db 24 4]]+1}]
60 ############################################################################
61 # Verify that we can use the auto_vacuum pragma to request a new
62 # autovacuum setting, do a VACUUM, and the new setting takes effect.
63 # Make sure this happens correctly even if there are multiple open
64 # connections to the same database file.
67 set pageSize [db eval {pragma page_size}]
69 # We are currently not autovacuuming so the database should be 3 pages
70 # in size. 1 page for each of sqlite_master, t1, and t2.
74 INSERT INTO t1 VALUES('hello');
75 INSERT INTO t2 VALUES('out there');
77 expr {[file size test.db]/$pageSize}
84 # Convert the database to an autovacuumed database.
87 PRAGMA auto_vacuum=FULL;
90 expr {[file size test.db]/$pageSize}
99 execsql {PRAGMA integrity_check} db2
101 do_test vacuum2-3.7 {
102 execsql {PRAGMA integrity_check} db
105 # Convert the database back to a non-autovacuumed database.
106 do_test vacuum2-3.13 {
108 PRAGMA auto_vacuum=NONE;
111 expr {[file size test.db]/$pageSize}
113 do_test vacuum2-3.14 {
116 do_test vacuum2-3.15 {
119 do_test vacuum2-3.16 {
120 execsql {PRAGMA integrity_check} db2
122 do_test vacuum2-3.17 {
123 execsql {PRAGMA integrity_check} db
128 ifcapable autovacuum {
129 do_test vacuum2-4.1 {
131 file delete -force test.db
134 pragma auto_vacuum=1;
135 create table t(a, b);
136 insert into t values(1, 2);
137 insert into t values(1, 2);
138 pragma auto_vacuum=0;
143 do_test vacuum2-4.2 {
145 pragma auto_vacuum=1;
150 do_test vacuum2-4.3 {
152 pragma integrity_check
155 do_test vacuum2-4.4 {