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 if {[file exists skip-big-file]} return
19 if {$tcl_platform(os)=="Darwin"} return
21 set testdir [file dirname $argv0]
22 source $testdir/tester.tcl
24 # Do not use a codec for this file, as the database is manipulated using
25 # external methods (the [fake_big_file] and [hexio_write] commands).
29 # If SQLITE_DISABLE_LFS is defined, omit this file.
35 # These tests only work for Tcl version 8.4 and later. Prior to 8.4,
36 # Tcl was unable to handle large files.
38 scan $::tcl_version %f vx
41 # Mac OS X does not handle large files efficiently. So skip this test
43 if {$tcl_platform(os)=="Darwin"} return
45 # This is the md5 checksum of all the data in table t1 as created
46 # by the first test. We will use this number to make sure that data
49 set MAGIC_SUM {593f1efcfdbe698c28b4b1b693f7e4cf}
55 INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz');
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;
60 INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
61 INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
62 INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
66 SELECT md5sum(x) FROM t1;
70 # Try to create a large file - a file that is larger than 2^32 bytes.
71 # If this fails, it means that the system being tested does not support
72 # large files. So skip all of the remaining tests in this file.
75 if {[catch {fake_big_file 4096 [get_pwd]/test.db} msg]} {
76 puts "**** Unable to create a file larger than 4096 MB. *****"
80 hexio_write test.db 28 00000000
85 SELECT md5sum(x) FROM t1;
89 # The previous test may fail on some systems because they are unable
90 # to handle large files. If that is so, then skip all of the following
91 # tests. We will know the above test failed because the "db" command
94 if {[llength [info command db]]<=0} {
95 puts "**** Large file support appears to be broken. *****"
100 do_test bigfile-1.3 {
102 CREATE TABLE t2 AS SELECT * FROM t1;
103 SELECT md5sum(x) FROM t2;
106 do_test bigfile-1.4 {
110 SELECT md5sum(x) FROM t1;
115 if {[catch {fake_big_file 8192 [get_pwd]/test.db}]} {
116 puts "**** Unable to create a file larger than 8192 MB. *****"
120 hexio_write test.db 28 00000000
122 do_test bigfile-1.5 {
125 SELECT md5sum(x) FROM t1;
128 do_test bigfile-1.6 {
131 SELECT md5sum(x) FROM t2;
134 do_test bigfile-1.7 {
136 CREATE TABLE t3 AS SELECT * FROM t1;
137 SELECT md5sum(x) FROM t3;
140 do_test bigfile-1.8 {
144 SELECT md5sum(x) FROM t1;
147 do_test bigfile-1.9 {
149 SELECT md5sum(x) FROM t2;
154 if {[catch {fake_big_file 16384 [get_pwd]/test.db}]} {
155 puts "**** Unable to create a file larger than 16384 MB. *****"
159 hexio_write test.db 28 00000000
161 do_test bigfile-1.10 {
164 SELECT md5sum(x) FROM t1;
167 do_test bigfile-1.11 {
170 SELECT md5sum(x) FROM t2;
173 do_test bigfile-1.12 {
176 SELECT md5sum(x) FROM t3;
179 do_test bigfile-1.13 {
181 CREATE TABLE t4 AS SELECT * FROM t1;
182 SELECT md5sum(x) FROM t4;
185 do_test bigfile-1.14 {
189 SELECT md5sum(x) FROM t1;
192 do_test bigfile-1.15 {
194 SELECT md5sum(x) FROM t2;
197 do_test bigfile-1.16 {
199 SELECT md5sum(x) FROM t3;