xref: /onnv-gate/usr/src/lib/libsqlite/test/bigfile.test (revision 4520:7dbeadedd7fe)
1*4520Snw141292
2*4520Snw141292#pragma ident	"%Z%%M%	%I%	%E% SMI"
3*4520Snw141292
4*4520Snw141292# 2002 November 30
5*4520Snw141292#
6*4520Snw141292# The author disclaims copyright to this source code.  In place of
7*4520Snw141292# a legal notice, here is a blessing:
8*4520Snw141292#
9*4520Snw141292#    May you do good and not evil.
10*4520Snw141292#    May you find forgiveness for yourself and forgive others.
11*4520Snw141292#    May you share freely, never taking more than you give.
12*4520Snw141292#
13*4520Snw141292#***********************************************************************
14*4520Snw141292# This file implements regression tests for SQLite library.  The
15*4520Snw141292# focus of this script testing the ability of SQLite to handle database
16*4520Snw141292# files larger than 4GB.
17*4520Snw141292#
18*4520Snw141292# $Id: bigfile.test,v 1.3 2003/12/19 12:31:22 drh Exp $
19*4520Snw141292#
20*4520Snw141292
21*4520Snw141292set testdir [file dirname $argv0]
22*4520Snw141292source $testdir/tester.tcl
23*4520Snw141292
24*4520Snw141292# These tests only work for Tcl version 8.4 and later.  Prior to 8.4,
25*4520Snw141292# Tcl was unable to handle large files.
26*4520Snw141292#
27*4520Snw141292scan $::tcl_version %f vx
28*4520Snw141292if {$vx<8.4} return
29*4520Snw141292
30*4520Snw141292# This is the md5 checksum of all the data in table t1 as created
31*4520Snw141292# by the first test.  We will use this number to make sure that data
32*4520Snw141292# never changes.
33*4520Snw141292#
34*4520Snw141292set MAGIC_SUM {593f1efcfdbe698c28b4b1b693f7e4cf}
35*4520Snw141292
36*4520Snw141292do_test bigfile-1.1 {
37*4520Snw141292  execsql {
38*4520Snw141292    BEGIN;
39*4520Snw141292    CREATE TABLE t1(x);
40*4520Snw141292    INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz');
41*4520Snw141292    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
42*4520Snw141292    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
43*4520Snw141292    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
44*4520Snw141292    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
45*4520Snw141292    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
46*4520Snw141292    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
47*4520Snw141292    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
48*4520Snw141292    COMMIT;
49*4520Snw141292  }
50*4520Snw141292  execsql {
51*4520Snw141292    SELECT md5sum(x) FROM t1;
52*4520Snw141292  }
53*4520Snw141292} $::MAGIC_SUM
54*4520Snw141292
55*4520Snw141292# Try to create a large file - a file that is larger than 2^32 bytes.
56*4520Snw141292# If this fails, it means that the system being tested does not support
57*4520Snw141292# large files.  So skip all of the remaining tests in this file.
58*4520Snw141292#
59*4520Snw141292db close
60*4520Snw141292if {[catch {fake_big_file 4096 test.db}]} {
61*4520Snw141292  puts "**** Unable to create a file larger than 4096 MB. *****"
62*4520Snw141292  finish_test
63*4520Snw141292  return
64*4520Snw141292}
65*4520Snw141292
66*4520Snw141292do_test bigfile-1.2 {
67*4520Snw141292  sqlite db test.db
68*4520Snw141292  execsql {
69*4520Snw141292    SELECT md5sum(x) FROM t1;
70*4520Snw141292  }
71*4520Snw141292} $::MAGIC_SUM
72*4520Snw141292
73*4520Snw141292# The previous test may fail on some systems because they are unable
74*4520Snw141292# to handle large files.  If that is so, then skip all of the following
75*4520Snw141292# tests.  We will know the above test failed because the "db" command
76*4520Snw141292# does not exist.
77*4520Snw141292#
78*4520Snw141292if {[llength [info command db]]>0} {
79*4520Snw141292
80*4520Snw141292do_test bigfile-1.3 {
81*4520Snw141292  execsql {
82*4520Snw141292    CREATE TABLE t2 AS SELECT * FROM t1;
83*4520Snw141292    SELECT md5sum(x) FROM t2;
84*4520Snw141292  }
85*4520Snw141292} $::MAGIC_SUM
86*4520Snw141292do_test bigfile-1.4 {
87*4520Snw141292  db close
88*4520Snw141292  sqlite db test.db
89*4520Snw141292  execsql {
90*4520Snw141292    SELECT md5sum(x) FROM t1;
91*4520Snw141292  }
92*4520Snw141292} $::MAGIC_SUM
93*4520Snw141292do_test bigfile-1.5 {
94*4520Snw141292  execsql {
95*4520Snw141292    SELECT md5sum(x) FROM t2;
96*4520Snw141292  }
97*4520Snw141292} $::MAGIC_SUM
98*4520Snw141292
99*4520Snw141292db close
100*4520Snw141292if {[catch {fake_big_file 8192 test.db}]} {
101*4520Snw141292  puts "**** Unable to create a file larger than 8192 MB. *****"
102*4520Snw141292  finish_test
103*4520Snw141292  return
104*4520Snw141292}
105*4520Snw141292
106*4520Snw141292do_test bigfile-1.6 {
107*4520Snw141292  sqlite db test.db
108*4520Snw141292  execsql {
109*4520Snw141292    SELECT md5sum(x) FROM t1;
110*4520Snw141292  }
111*4520Snw141292} $::MAGIC_SUM
112*4520Snw141292do_test bigfile-1.7 {
113*4520Snw141292  execsql {
114*4520Snw141292    CREATE TABLE t3 AS SELECT * FROM t1;
115*4520Snw141292    SELECT md5sum(x) FROM t3;
116*4520Snw141292  }
117*4520Snw141292} $::MAGIC_SUM
118*4520Snw141292do_test bigfile-1.8 {
119*4520Snw141292  db close
120*4520Snw141292  sqlite db test.db
121*4520Snw141292  execsql {
122*4520Snw141292    SELECT md5sum(x) FROM t1;
123*4520Snw141292  }
124*4520Snw141292} $::MAGIC_SUM
125*4520Snw141292do_test bigfile-1.9 {
126*4520Snw141292  execsql {
127*4520Snw141292    SELECT md5sum(x) FROM t2;
128*4520Snw141292  }
129*4520Snw141292} $::MAGIC_SUM
130*4520Snw141292do_test bigfile-1.10 {
131*4520Snw141292  execsql {
132*4520Snw141292    SELECT md5sum(x) FROM t3;
133*4520Snw141292  }
134*4520Snw141292} $::MAGIC_SUM
135*4520Snw141292
136*4520Snw141292db close
137*4520Snw141292if {[catch {fake_big_file 16384 test.db}]} {
138*4520Snw141292  puts "**** Unable to create a file larger than 16384 MB. *****"
139*4520Snw141292  finish_test
140*4520Snw141292  return
141*4520Snw141292}
142*4520Snw141292
143*4520Snw141292do_test bigfile-1.11 {
144*4520Snw141292  sqlite db test.db
145*4520Snw141292  execsql {
146*4520Snw141292    SELECT md5sum(x) FROM t1;
147*4520Snw141292  }
148*4520Snw141292} $::MAGIC_SUM
149*4520Snw141292do_test bigfile-1.12 {
150*4520Snw141292  execsql {
151*4520Snw141292    CREATE TABLE t4 AS SELECT * FROM t1;
152*4520Snw141292    SELECT md5sum(x) FROM t4;
153*4520Snw141292  }
154*4520Snw141292} $::MAGIC_SUM
155*4520Snw141292do_test bigfile-1.13 {
156*4520Snw141292  db close
157*4520Snw141292  sqlite db test.db
158*4520Snw141292  execsql {
159*4520Snw141292    SELECT md5sum(x) FROM t1;
160*4520Snw141292  }
161*4520Snw141292} $::MAGIC_SUM
162*4520Snw141292do_test bigfile-1.14 {
163*4520Snw141292  execsql {
164*4520Snw141292    SELECT md5sum(x) FROM t2;
165*4520Snw141292  }
166*4520Snw141292} $::MAGIC_SUM
167*4520Snw141292do_test bigfile-1.15 {
168*4520Snw141292  execsql {
169*4520Snw141292    SELECT md5sum(x) FROM t3;
170*4520Snw141292  }
171*4520Snw141292} $::MAGIC_SUM
172*4520Snw141292do_test bigfile-1.16 {
173*4520Snw141292  execsql {
174*4520Snw141292    SELECT md5sum(x) FROM t3;
175*4520Snw141292  }
176*4520Snw141292} $::MAGIC_SUM
177*4520Snw141292
178*4520Snw141292} ;# End of the "if( db command exists )"
179*4520Snw141292
180*4520Snw141292finish_test
181