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 script testing the ability of SQLite to handle database
13 # files larger than 4GB.
15 # $Id: bigfile.test,v 1.12 2009/03/05 04:27:08 shane Exp $
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
21 # Do not use a codec for this file, as the database is manipulated using
22 # external methods (the [fake_big_file] and [hexio_write] commands).
26 # If SQLITE_DISABLE_LFS is defined, omit this file.
32 # These tests only work for Tcl version 8.4 and later. Prior to 8.4,
33 # Tcl was unable to handle large files.
35 scan $::tcl_version %f vx
38 # Mac OS X does not handle large files efficiently. So skip this test
40 if {$tcl_platform(os)=="Darwin"} return
42 # This is the md5 checksum of all the data in table t1 as created
43 # by the first test. We will use this number to make sure that data
46 set MAGIC_SUM {593f1efcfdbe698c28b4b1b693f7e4cf}
52 INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz');
53 INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
54 INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
55 INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
56 INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
57 INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
58 INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
59 INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
63 SELECT md5sum(x) FROM t1;
67 # Try to create a large file - a file that is larger than 2^32 bytes.
68 # If this fails, it means that the system being tested does not support
69 # large files. So skip all of the remaining tests in this file.
72 if {[catch {fake_big_file 4096 [pwd]/test.db} msg]} {
73 puts "**** Unable to create a file larger than 4096 MB. *****"
77 hexio_write test.db 28 00000000
82 SELECT md5sum(x) FROM t1;
86 # The previous test may fail on some systems because they are unable
87 # to handle large files. If that is so, then skip all of the following
88 # tests. We will know the above test failed because the "db" command
91 if {[llength [info command db]]<=0} {
92 puts "**** Large file support appears to be broken. *****"
99 CREATE TABLE t2 AS SELECT * FROM t1;
100 SELECT md5sum(x) FROM t2;
103 do_test bigfile-1.4 {
107 SELECT md5sum(x) FROM t1;
112 if {[catch {fake_big_file 8192 [pwd]/test.db}]} {
113 puts "**** Unable to create a file larger than 8192 MB. *****"
117 hexio_write test.db 28 00000000
119 do_test bigfile-1.5 {
122 SELECT md5sum(x) FROM t1;
125 do_test bigfile-1.6 {
128 SELECT md5sum(x) FROM t2;
131 do_test bigfile-1.7 {
133 CREATE TABLE t3 AS SELECT * FROM t1;
134 SELECT md5sum(x) FROM t3;
137 do_test bigfile-1.8 {
141 SELECT md5sum(x) FROM t1;
144 do_test bigfile-1.9 {
146 SELECT md5sum(x) FROM t2;
151 if {[catch {fake_big_file 16384 [pwd]/test.db}]} {
152 puts "**** Unable to create a file larger than 16384 MB. *****"
156 hexio_write test.db 28 00000000
158 do_test bigfile-1.10 {
161 SELECT md5sum(x) FROM t1;
164 do_test bigfile-1.11 {
167 SELECT md5sum(x) FROM t2;
170 do_test bigfile-1.12 {
173 SELECT md5sum(x) FROM t3;
176 do_test bigfile-1.13 {
178 CREATE TABLE t4 AS SELECT * FROM t1;
179 SELECT md5sum(x) FROM t4;
182 do_test bigfile-1.14 {
186 SELECT md5sum(x) FROM t1;
189 do_test bigfile-1.15 {
191 SELECT md5sum(x) FROM t2;
194 do_test bigfile-1.16 {
196 SELECT md5sum(x) FROM t3;