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