Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: third_party/sqlite/test/vacuum2.test

Issue 3108030: Move bundled copy of sqlite one level deeper to better separate it... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/sqlite/test/vacuum.test ('k') | third_party/sqlite/test/vacuum3.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # 2005 February 15
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 VACUUM statement.
13 #
14 # $Id: vacuum2.test,v 1.10 2009/02/18 20:31:18 drh Exp $
15
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
18
19 # If the VACUUM statement is disabled in the current build, skip all
20 # the tests in this file.
21 #
22 ifcapable {!vacuum||!autoinc} {
23 finish_test
24 return
25 }
26 if $AUTOVACUUM {
27 finish_test
28 return
29 }
30
31 # Ticket #1121 - make sure vacuum works if all autoincrement tables
32 # have been deleted.
33 #
34 do_test vacuum2-1.1 {
35 execsql {
36 CREATE TABLE t1(x INTEGER PRIMARY KEY AUTOINCREMENT, y);
37 DROP TABLE t1;
38 VACUUM;
39 }
40 } {}
41
42 # Ticket #2518. Make sure vacuum increments the change counter
43 # in the database header.
44 #
45 do_test vacuum2-2.1 {
46 execsql {
47 CREATE TABLE t1(x);
48 CREATE TABLE t2(y);
49 INSERT INTO t1 VALUES(1);
50 }
51 hexio_get_int [hexio_read test.db 24 4]
52 } [expr {[hexio_get_int [hexio_read test.db 24 4]]+3}]
53 do_test vacuum2-2.1 {
54 execsql {
55 VACUUM
56 }
57 hexio_get_int [hexio_read test.db 24 4]
58 } [expr {[hexio_get_int [hexio_read test.db 24 4]]+1}]
59
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.
65 #
66 sqlite3 db2 test.db
67 set pageSize [db eval {pragma page_size}]
68
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.
71 #
72 do_test vacuum2-3.1 {
73 execsql {
74 INSERT INTO t1 VALUES('hello');
75 INSERT INTO t2 VALUES('out there');
76 }
77 expr {[file size test.db]/$pageSize}
78 } {3}
79 set cksum [cksum]
80 do_test vacuum2-3.2 {
81 cksum db2
82 } $cksum
83
84 # Convert the database to an autovacuumed database.
85 ifcapable autovacuum {
86 do_test vacuum2-3.3 {
87 execsql {
88 PRAGMA auto_vacuum=FULL;
89 VACUUM;
90 }
91 expr {[file size test.db]/$pageSize}
92 } {4}
93 }
94 do_test vacuum2-3.4 {
95 cksum db2
96 } $cksum
97 do_test vacuum2-3.5 {
98 cksum
99 } $cksum
100 do_test vacuum2-3.6 {
101 execsql {PRAGMA integrity_check} db2
102 } {ok}
103 do_test vacuum2-3.7 {
104 execsql {PRAGMA integrity_check} db
105 } {ok}
106
107 # Convert the database back to a non-autovacuumed database.
108 do_test vacuum2-3.13 {
109 execsql {
110 PRAGMA auto_vacuum=NONE;
111 VACUUM;
112 }
113 expr {[file size test.db]/$pageSize}
114 } {3}
115 do_test vacuum2-3.14 {
116 cksum db2
117 } $cksum
118 do_test vacuum2-3.15 {
119 cksum
120 } $cksum
121 do_test vacuum2-3.16 {
122 execsql {PRAGMA integrity_check} db2
123 } {ok}
124 do_test vacuum2-3.17 {
125 execsql {PRAGMA integrity_check} db
126 } {ok}
127
128 db2 close
129
130 ifcapable autovacuum {
131 do_test vacuum2-4.1 {
132 db close
133 file delete -force test.db
134 sqlite3 db test.db
135 execsql {
136 pragma auto_vacuum=1;
137 create table t(a, b);
138 insert into t values(1, 2);
139 insert into t values(1, 2);
140 pragma auto_vacuum=0;
141 vacuum;
142 pragma auto_vacuum;
143 }
144 } {0}
145 do_test vacuum2-4.2 {
146 execsql {
147 pragma auto_vacuum=1;
148 vacuum;
149 pragma auto_vacuum;
150 }
151 } {1}
152 do_test vacuum2-4.3 {
153 execsql {
154 pragma integrity_check
155 }
156 } {ok}
157 do_test vacuum2-4.4 {
158 db close
159 sqlite3 db test.db
160 execsql {
161 pragma auto_vacuum;
162 }
163 } {1}
164 do_test vacuum2-4.5 { # Ticket #3663
165 execsql {
166 pragma auto_vacuum=2;
167 vacuum;
168 pragma auto_vacuum;
169 }
170 } {2}
171 do_test vacuum2-4.6 {
172 execsql {
173 pragma integrity_check
174 }
175 } {ok}
176 do_test vacuum2-4.7 {
177 db close
178 sqlite3 db test.db
179 execsql {
180 pragma auto_vacuum;
181 }
182 } {2}
183 }
184
185 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/test/vacuum.test ('k') | third_party/sqlite/test/vacuum3.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698