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