xref: /sqlite-3.40.0/test/bigfile.test (revision d0d006e2)
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.1 2002/12/01 02:00:58 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
46do_test bigfile-1.2 {
47  db close
48  fake_big_file 4096 test.db
49  sqlite db test.db
50  execsql {
51    SELECT md5sum(x) FROM t1;
52  }
53} $::MAGIC_SUM
54
55# The previous test may fail on some systems because they are unable
56# to handle large files.  If that is so, then skip all of the following
57# tests.  We will know the above test failed because the "db" command
58# does not exist.
59#
60if {[llength [info command db]]>0} {
61
62do_test bigfile-1.3 {
63  execsql {
64    CREATE TABLE t2 AS SELECT * FROM t1;
65    SELECT md5sum(x) FROM t2;
66  }
67} $::MAGIC_SUM
68do_test bigfile-1.4 {
69  db close
70  sqlite db test.db
71  execsql {
72    SELECT md5sum(x) FROM t1;
73  }
74} $::MAGIC_SUM
75do_test bigfile-1.5 {
76  execsql {
77    SELECT md5sum(x) FROM t2;
78  }
79} $::MAGIC_SUM
80do_test bigfile-1.6 {
81  db close
82  fake_big_file 8192 test.db
83  sqlite db test.db
84  execsql {
85    SELECT md5sum(x) FROM t1;
86  }
87} $::MAGIC_SUM
88do_test bigfile-1.7 {
89  execsql {
90    CREATE TABLE t3 AS SELECT * FROM t1;
91    SELECT md5sum(x) FROM t3;
92  }
93} $::MAGIC_SUM
94do_test bigfile-1.8 {
95  db close
96  sqlite db test.db
97  execsql {
98    SELECT md5sum(x) FROM t1;
99  }
100} $::MAGIC_SUM
101do_test bigfile-1.9 {
102  execsql {
103    SELECT md5sum(x) FROM t2;
104  }
105} $::MAGIC_SUM
106do_test bigfile-1.10 {
107  execsql {
108    SELECT md5sum(x) FROM t3;
109  }
110} $::MAGIC_SUM
111do_test bigfile-1.11 {
112  db close
113  fake_big_file 16384 test.db
114  sqlite db test.db
115  execsql {
116    SELECT md5sum(x) FROM t1;
117  }
118} $::MAGIC_SUM
119do_test bigfile-1.12 {
120  execsql {
121    CREATE TABLE t4 AS SELECT * FROM t1;
122    SELECT md5sum(x) FROM t4;
123  }
124} $::MAGIC_SUM
125do_test bigfile-1.13 {
126  db close
127  sqlite db test.db
128  execsql {
129    SELECT md5sum(x) FROM t1;
130  }
131} $::MAGIC_SUM
132do_test bigfile-1.14 {
133  execsql {
134    SELECT md5sum(x) FROM t2;
135  }
136} $::MAGIC_SUM
137do_test bigfile-1.15 {
138  execsql {
139    SELECT md5sum(x) FROM t3;
140  }
141} $::MAGIC_SUM
142do_test bigfile-1.16 {
143  execsql {
144    SELECT md5sum(x) FROM t3;
145  }
146} $::MAGIC_SUM
147
148} ;# End of the "if( db command exists )"
149
150finish_test
151