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