aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/sqlite/unix/sqlite-3.5.1/test/incrvacuum2.test
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/test/incrvacuum2.test')
-rw-r--r--libraries/sqlite/unix/sqlite-3.5.1/test/incrvacuum2.test125
1 files changed, 125 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/test/incrvacuum2.test b/libraries/sqlite/unix/sqlite-3.5.1/test/incrvacuum2.test
new file mode 100644
index 0000000..50da7a2
--- /dev/null
+++ b/libraries/sqlite/unix/sqlite-3.5.1/test/incrvacuum2.test
@@ -0,0 +1,125 @@
1# 2007 May 04
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
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.
9#
10#***********************************************************************
11# This file implements regression tests for SQLite library. The
12# focus of this file is testing the incremental vacuum feature.
13#
14# $Id: incrvacuum2.test,v 1.3 2007/05/17 06:44:28 danielk1977 Exp $
15
16set testdir [file dirname $argv0]
17source $testdir/tester.tcl
18
19# If this build of the library does not support auto-vacuum, omit this
20# whole file.
21ifcapable {!autovacuum || !pragma} {
22 finish_test
23 return
24}
25
26# If the OMIT_INCRBLOB symbol was defined at compile time, there
27# is no zeroblob() function available. So create a similar
28# function here using Tcl. It doesn't return a blob, but it returns
29# data of the required length, which is good enough for this
30# test file.
31ifcapable !incrblob {
32 proc zeroblob {n} { string repeat 0 $n }
33 db function zeroblob zeroblob
34}
35
36# Create a database in incremental vacuum mode that has many
37# pages on the freelist.
38#
39do_test incrvacuum2-1.1 {
40 execsql {
41 PRAGMA page_size=1024;
42 PRAGMA auto_vacuum=incremental;
43 CREATE TABLE t1(x);
44 INSERT INTO t1 VALUES(zeroblob(30000));
45 DELETE FROM t1;
46 }
47 file size test.db
48} {32768}
49
50# Vacuum off a single page.
51#
52do_test incrvacuum2-1.2 {
53 execsql {
54 PRAGMA incremental_vacuum(1);
55 }
56 file size test.db
57} {31744}
58
59# Vacuum off five pages
60#
61do_test incrvacuum2-1.3 {
62 execsql {
63 PRAGMA incremental_vacuum(5);
64 }
65 file size test.db
66} {26624}
67
68# Vacuum off all the rest
69#
70do_test incrvacuum2-1.4 {
71 execsql {
72 PRAGMA incremental_vacuum(1000);
73 }
74 file size test.db
75} {3072}
76
77# Make sure incremental vacuum works on attached databases.
78#
79do_test incrvacuum2-2.1 {
80 file delete -force test2.db test2.db-journal
81 execsql {
82 ATTACH DATABASE 'test2.db' AS aux;
83 PRAGMA aux.auto_vacuum=incremental;
84 CREATE TABLE aux.t2(x);
85 INSERT INTO t2 VALUES(zeroblob(30000));
86 INSERT INTO t1 SELECT * FROM t2;
87 DELETE FROM t2;
88 DELETE FROM t1;
89 }
90 list [file size test.db] [file size test2.db]
91} {32768 32768}
92do_test incrvacuum2-2.2 {
93 execsql {
94 PRAGMA aux.incremental_vacuum(1)
95 }
96 list [file size test.db] [file size test2.db]
97} {32768 31744}
98do_test incrvacuum2-2.3 {
99 execsql {
100 PRAGMA aux.incremental_vacuum(5)
101 }
102 list [file size test.db] [file size test2.db]
103} {32768 26624}
104do_test incrvacuum2-2.4 {
105 execsql {
106 PRAGMA main.incremental_vacuum(5)
107 }
108 list [file size test.db] [file size test2.db]
109} {27648 26624}
110do_test incrvacuum2-2.5 {
111 execsql {
112 PRAGMA aux.incremental_vacuum
113 }
114 list [file size test.db] [file size test2.db]
115} {27648 3072}
116do_test incrvacuum2-2.6 {
117 execsql {
118 PRAGMA incremental_vacuum(1)
119 }
120 list [file size test.db] [file size test2.db]
121} {26624 3072}
122
123
124
125finish_test