|
1 # 2002 November 30 |
|
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 script testing the ability of SQLite to handle database |
|
13 # files larger than 4GB. |
|
14 # |
|
15 # $Id: bigfile.test,v 1.10 2007/08/18 10:59:21 danielk1977 Exp $ |
|
16 # |
|
17 |
|
18 set testdir [file dirname $argv0] |
|
19 source $testdir/tester.tcl |
|
20 |
|
21 # If SQLITE_DISABLE_LFS is defined, omit this file. |
|
22 ifcapable !lfs { |
|
23 finish_test |
|
24 return |
|
25 } |
|
26 |
|
27 # These tests only work for Tcl version 8.4 and later. Prior to 8.4, |
|
28 # Tcl was unable to handle large files. |
|
29 # |
|
30 scan $::tcl_version %f vx |
|
31 if {$vx<8.4} return |
|
32 |
|
33 # Mac OS X does not handle large files efficiently. So skip this test |
|
34 # on that platform. |
|
35 if {$tcl_platform(os)=="Darwin"} return |
|
36 |
|
37 # This is the md5 checksum of all the data in table t1 as created |
|
38 # by the first test. We will use this number to make sure that data |
|
39 # never changes. |
|
40 # |
|
41 set MAGIC_SUM {593f1efcfdbe698c28b4b1b693f7e4cf} |
|
42 |
|
43 do_test bigfile-1.1 { |
|
44 execsql { |
|
45 BEGIN; |
|
46 CREATE TABLE t1(x); |
|
47 INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz'); |
|
48 INSERT INTO t1 SELECT rowid || ' ' || x FROM t1; |
|
49 INSERT INTO t1 SELECT rowid || ' ' || x FROM t1; |
|
50 INSERT INTO t1 SELECT rowid || ' ' || x FROM t1; |
|
51 INSERT INTO t1 SELECT rowid || ' ' || x FROM t1; |
|
52 INSERT INTO t1 SELECT rowid || ' ' || x FROM t1; |
|
53 INSERT INTO t1 SELECT rowid || ' ' || x FROM t1; |
|
54 INSERT INTO t1 SELECT rowid || ' ' || x FROM t1; |
|
55 COMMIT; |
|
56 } |
|
57 execsql { |
|
58 SELECT md5sum(x) FROM t1; |
|
59 } |
|
60 } $::MAGIC_SUM |
|
61 |
|
62 # Try to create a large file - a file that is larger than 2^32 bytes. |
|
63 # If this fails, it means that the system being tested does not support |
|
64 # large files. So skip all of the remaining tests in this file. |
|
65 # |
|
66 db close |
|
67 if {[catch {fake_big_file 4096 test.db} msg]} { |
|
68 puts "**** Unable to create a file larger than 4096 MB. *****" |
|
69 puts "$msg" |
|
70 finish_test |
|
71 return |
|
72 } |
|
73 |
|
74 do_test bigfile-1.2 { |
|
75 sqlite3 db test.db |
|
76 execsql { |
|
77 SELECT md5sum(x) FROM t1; |
|
78 } |
|
79 } $::MAGIC_SUM |
|
80 |
|
81 # The previous test may fail on some systems because they are unable |
|
82 # to handle large files. If that is so, then skip all of the following |
|
83 # tests. We will know the above test failed because the "db" command |
|
84 # does not exist. |
|
85 # |
|
86 if {[llength [info command db]]>0} { |
|
87 |
|
88 do_test bigfile-1.3 { |
|
89 execsql { |
|
90 CREATE TABLE t2 AS SELECT * FROM t1; |
|
91 SELECT md5sum(x) FROM t2; |
|
92 } |
|
93 } $::MAGIC_SUM |
|
94 do_test bigfile-1.4 { |
|
95 db close |
|
96 sqlite3 db test.db |
|
97 execsql { |
|
98 SELECT md5sum(x) FROM t1; |
|
99 } |
|
100 } $::MAGIC_SUM |
|
101 do_test bigfile-1.5 { |
|
102 execsql { |
|
103 SELECT md5sum(x) FROM t2; |
|
104 } |
|
105 } $::MAGIC_SUM |
|
106 |
|
107 db close |
|
108 if {[catch {fake_big_file 8192 test.db}]} { |
|
109 puts "**** Unable to create a file larger than 8192 MB. *****" |
|
110 finish_test |
|
111 return |
|
112 } |
|
113 |
|
114 do_test bigfile-1.6 { |
|
115 sqlite3 db test.db |
|
116 execsql { |
|
117 SELECT md5sum(x) FROM t1; |
|
118 } |
|
119 } $::MAGIC_SUM |
|
120 do_test bigfile-1.7 { |
|
121 execsql { |
|
122 CREATE TABLE t3 AS SELECT * FROM t1; |
|
123 SELECT md5sum(x) FROM t3; |
|
124 } |
|
125 } $::MAGIC_SUM |
|
126 do_test bigfile-1.8 { |
|
127 db close |
|
128 sqlite3 db test.db |
|
129 execsql { |
|
130 SELECT md5sum(x) FROM t1; |
|
131 } |
|
132 } $::MAGIC_SUM |
|
133 do_test bigfile-1.9 { |
|
134 execsql { |
|
135 SELECT md5sum(x) FROM t2; |
|
136 } |
|
137 } $::MAGIC_SUM |
|
138 do_test bigfile-1.10 { |
|
139 execsql { |
|
140 SELECT md5sum(x) FROM t3; |
|
141 } |
|
142 } $::MAGIC_SUM |
|
143 |
|
144 db close |
|
145 if {[catch {fake_big_file 16384 test.db}]} { |
|
146 puts "**** Unable to create a file larger than 16384 MB. *****" |
|
147 finish_test |
|
148 return |
|
149 } |
|
150 |
|
151 do_test bigfile-1.11 { |
|
152 sqlite3 db test.db |
|
153 execsql { |
|
154 SELECT md5sum(x) FROM t1; |
|
155 } |
|
156 } $::MAGIC_SUM |
|
157 do_test bigfile-1.12 { |
|
158 execsql { |
|
159 CREATE TABLE t4 AS SELECT * FROM t1; |
|
160 SELECT md5sum(x) FROM t4; |
|
161 } |
|
162 } $::MAGIC_SUM |
|
163 do_test bigfile-1.13 { |
|
164 db close |
|
165 sqlite3 db test.db |
|
166 execsql { |
|
167 SELECT md5sum(x) FROM t1; |
|
168 } |
|
169 } $::MAGIC_SUM |
|
170 do_test bigfile-1.14 { |
|
171 execsql { |
|
172 SELECT md5sum(x) FROM t2; |
|
173 } |
|
174 } $::MAGIC_SUM |
|
175 do_test bigfile-1.15 { |
|
176 execsql { |
|
177 SELECT md5sum(x) FROM t3; |
|
178 } |
|
179 } $::MAGIC_SUM |
|
180 do_test bigfile-1.16 { |
|
181 execsql { |
|
182 SELECT md5sum(x) FROM t3; |
|
183 } |
|
184 } $::MAGIC_SUM |
|
185 do_test bigfile-1.17 { |
|
186 execsql { |
|
187 SELECT md5sum(x) FROM t4; |
|
188 } |
|
189 } $::MAGIC_SUM |
|
190 |
|
191 } ;# End of the "if( db command exists )" |
|
192 |
|
193 finish_test |