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

Side by Side Diff: third_party/sqlite/src/test/filefmt.test

Issue 901033002: Import SQLite 3.8.7.4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chromium changes to support SQLite 3.8.7.4. Created 5 years, 10 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
OLDNEW
1 # 2007 April 6 1 # 2007 April 6
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 # This file implements regression tests for SQLite library. 11 # This file implements regression tests for SQLite library.
12 # 12 #
13 # This file implements tests to verify database file format. 13 # This file implements tests to verify database file format.
14 # 14 #
15 # $Id: filefmt.test,v 1.3 2009/06/18 11:34:43 drh Exp $ 15 # $Id: filefmt.test,v 1.3 2009/06/18 11:34:43 drh Exp $
16 16
17 set testdir [file dirname $argv0] 17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl 18 source $testdir/tester.tcl
19 19
20 # Do not use a codec for tests in this file, as the database file is 20 # Do not use a codec for tests in this file, as the database file is
21 # manipulated directly using tcl scripts (using the [hexio_write] command). 21 # manipulated directly using tcl scripts (using the [hexio_write] command).
22 # 22 #
23 do_not_use_codec 23 do_not_use_codec
24 24
25 db close 25 db close
26 file delete -force test.db test.db-journal 26 forcedelete test.db test.db-journal
27 27
28 # Database begins with valid 16-byte header string. 28 # Database begins with valid 16-byte header string.
29 # 29 #
30 do_test filefmt-1.1 { 30 do_test filefmt-1.1 {
31 sqlite3 db test.db 31 sqlite3 db test.db
32 db eval {CREATE TABLE t1(x)} 32 db eval {CREATE TABLE t1(x)}
33 db close 33 db close
34 hexio_read test.db 0 16 34 hexio_read test.db 0 16
35 } {53514C69746520666F726D6174203300} 35 } {53514C69746520666F726D6174203300}
36 36
(...skipping 19 matching lines...) Expand all
56 } {0 1} 56 } {0 1}
57 57
58 # The page-size is stored at offset 16 58 # The page-size is stored at offset 16
59 # 59 #
60 ifcapable pager_pragmas { 60 ifcapable pager_pragmas {
61 foreach pagesize {512 1024 2048 4096 8192 16384 32768} { 61 foreach pagesize {512 1024 2048 4096 8192 16384 32768} {
62 if {[info exists SQLITE_MAX_PAGE_SIZE] 62 if {[info exists SQLITE_MAX_PAGE_SIZE]
63 && $pagesize>$SQLITE_MAX_PAGE_SIZE} continue 63 && $pagesize>$SQLITE_MAX_PAGE_SIZE} continue
64 do_test filefmt-1.5.$pagesize.1 { 64 do_test filefmt-1.5.$pagesize.1 {
65 db close 65 db close
66 file delete -force test.db 66 forcedelete test.db
67 sqlite3 db test.db 67 sqlite3 db test.db
68 db eval "PRAGMA auto_vacuum=OFF" 68 db eval "PRAGMA auto_vacuum=OFF"
69 db eval "PRAGMA page_size=$pagesize" 69 db eval "PRAGMA page_size=$pagesize"
70 db eval {CREATE TABLE t1(x)} 70 db eval {CREATE TABLE t1(x)}
71 file size test.db 71 file size test.db
72 } [expr $pagesize*2] 72 } [expr $pagesize*2]
73 do_test filefmt-1.5.$pagesize.2 { 73 do_test filefmt-1.5.$pagesize.2 {
74 hexio_get_int [hexio_read test.db 16 2] 74 hexio_get_int [hexio_read test.db 16 2]
75 } $pagesize 75 } $pagesize
76 } 76 }
(...skipping 21 matching lines...) Expand all
98 SELECT count(*) FROM sqlite_master 98 SELECT count(*) FROM sqlite_master
99 } 99 }
100 } {1 {file is encrypted or is not a database}} 100 } {1 {file is encrypted or is not a database}}
101 101
102 # Usable space per page (page-size minus unused space per page) 102 # Usable space per page (page-size minus unused space per page)
103 # must be at least 480 bytes 103 # must be at least 480 bytes
104 # 104 #
105 ifcapable pager_pragmas { 105 ifcapable pager_pragmas {
106 do_test filefmt-1.8 { 106 do_test filefmt-1.8 {
107 db close 107 db close
108 file delete -force test.db 108 forcedelete test.db
109 sqlite3 db test.db 109 sqlite3 db test.db
110 db eval {PRAGMA page_size=512; CREATE TABLE t1(x)} 110 db eval {PRAGMA page_size=512; CREATE TABLE t1(x)}
111 db close 111 db close
112 hexio_write test.db 20 21 112 hexio_write test.db 20 21
113 sqlite3 db test.db 113 sqlite3 db test.db
114 catchsql { 114 catchsql {
115 SELECT count(*) FROM sqlite_master 115 SELECT count(*) FROM sqlite_master
116 } 116 }
117 } {1 {file is encrypted or is not a database}} 117 } {1 {file is encrypted or is not a database}}
118 } 118 }
119 119
120 #------------------------------------------------------------------------- 120 #-------------------------------------------------------------------------
121 # The following block of tests - filefmt-2.* - test that versions 3.7.0 121 # The following block of tests - filefmt-2.* - test that versions 3.7.0
122 # and later can read and write databases that have been modified or created 122 # and later can read and write databases that have been modified or created
123 # by 3.6.23.1 and earlier. The difference difference is that 3.7.0 stores 123 # by 3.6.23.1 and earlier. The difference difference is that 3.7.0 stores
124 # the size of the database in the database file header, whereas 3.6.23.1 124 # the size of the database in the database file header, whereas 3.6.23.1
125 # always derives this from the size of the file. 125 # always derives this from the size of the file.
126 # 126 #
127 db close 127 db close
128 file delete -force test.db 128 forcedelete test.db
129 129
130 set a_string_counter 1 130 set a_string_counter 1
131 proc a_string {n} { 131 proc a_string {n} {
132 incr ::a_string_counter 132 incr ::a_string_counter
133 string range [string repeat "${::a_string_counter}." $n] 1 $n 133 string range [string repeat "${::a_string_counter}." $n] 1 $n
134 } 134 }
135 sqlite3 db test.db 135 sqlite3 db test.db
136 db func a_string a_string 136 db func a_string a_string
137 137
138 do_execsql_test filefmt-2.1.1 { 138 do_execsql_test filefmt-2.1.1 {
(...skipping 11 matching lines...) Expand all
150 150
151 do_test filefmt-2.1.3 { 151 do_test filefmt-2.1.3 {
152 sql36231 { INSERT INTO t1 VALUES(a_string(3000)) } 152 sql36231 { INSERT INTO t1 VALUES(a_string(3000)) }
153 } {} 153 } {}
154 154
155 do_execsql_test filefmt-2.1.4 { INSERT INTO t2 VALUES(2) } {} 155 do_execsql_test filefmt-2.1.4 { INSERT INTO t2 VALUES(2) } {}
156 integrity_check filefmt-2.1.5 156 integrity_check filefmt-2.1.5
157 do_test filefmt-2.1.6 { hexio_read test.db 28 4 } {00000010} 157 do_test filefmt-2.1.6 { hexio_read test.db 28 4 } {00000010}
158 158
159 db close 159 db close
160 file delete -force test.db 160 forcedelete test.db
161 sqlite3 db test.db 161 sqlite3 db test.db
162 db func a_string a_string 162 db func a_string a_string
163 163
164 do_execsql_test filefmt-2.2.1 { 164 do_execsql_test filefmt-2.2.1 {
165 PRAGMA page_size = 1024; 165 PRAGMA page_size = 1024;
166 PRAGMA auto_vacuum = 0; 166 PRAGMA auto_vacuum = 0;
167 CREATE TABLE t1(a); 167 CREATE TABLE t1(a);
168 CREATE INDEX i1 ON t1(a); 168 CREATE INDEX i1 ON t1(a);
169 INSERT INTO t1 VALUES(a_string(3000)); 169 INSERT INTO t1 VALUES(a_string(3000));
170 CREATE TABLE t2(a); 170 CREATE TABLE t2(a);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 CREATE TABLE t1(a, b); 206 CREATE TABLE t1(a, b);
207 } {} 207 } {}
208 do_test filefmt-3.2 { 208 do_test filefmt-3.2 {
209 sql36231 { DROP TABLE t1 } 209 sql36231 { DROP TABLE t1 }
210 } {} 210 } {}
211 do_execsql_test filefmt-3.3 { 211 do_execsql_test filefmt-3.3 {
212 SELECT * FROM sqlite_master; 212 SELECT * FROM sqlite_master;
213 PRAGMA integrity_check; 213 PRAGMA integrity_check;
214 } {ok} 214 } {ok}
215 215
216 reset_db
217 do_execsql_test filefmt-4.1 {
218 PRAGMA auto_vacuum = 1;
219 CREATE TABLE t1(x, y);
220 CREATE TABLE t2(x, y);
221
222 INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
223 INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
224 INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
225 INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
226 INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
227 INSERT INTO t1 VALUES(randomblob(100), randomblob(100));
228
229 INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM t1;
230 INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM t1;
231 INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM t1;
232 INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM t1;
233 }
234
235 do_test filefmt-4.2 {
236 sql36231 { INSERT INTO t2 SELECT * FROM t1 }
237 } {}
238
239 do_test filefmt-4.3 {
240 forcedelete bak.db
241 db backup bak.db
242 } {}
243
244 do_test filefmt-4.4 {
245 sqlite3 db2 bak.db
246 db2 eval { PRAGMA integrity_check }
247 } {ok}
248 db2 close
249
216 finish_test 250 finish_test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698