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.5 2004/06/19 00:16:31 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 sqlite3 db test.db 65 execsql { 66 SELECT md5sum(x) FROM t1; 67 } 68} $::MAGIC_SUM 69 70 71# The previous test may fail on some systems because they are unable 72# to handle large files. If that is so, then skip all of the following 73# tests. We will know the above test failed because the "db" command 74# does not exist. 75# 76if {[llength [info command db]]>0} { 77 78do_test bigfile-1.3 { 79 execsql { 80 CREATE TABLE t2 AS SELECT * FROM t1; 81 SELECT md5sum(x) FROM t2; 82 } 83} $::MAGIC_SUM 84do_test bigfile-1.4 { 85 db close 86 sqlite3 db test.db 87 execsql { 88 SELECT md5sum(x) FROM t1; 89 } 90} $::MAGIC_SUM 91do_test bigfile-1.5 { 92 execsql { 93 SELECT md5sum(x) FROM t2; 94 } 95} $::MAGIC_SUM 96 97db close 98if {[catch {fake_big_file 8192 test.db}]} { 99 puts "**** Unable to create a file larger than 8192 MB. *****" 100 finish_test 101 return 102} 103 104do_test bigfile-1.6 { 105 sqlite3 db test.db 106 execsql { 107 SELECT md5sum(x) FROM t1; 108 } 109} $::MAGIC_SUM 110do_test bigfile-1.7 { 111 execsql { 112 CREATE TABLE t3 AS SELECT * FROM t1; 113 SELECT md5sum(x) FROM t3; 114 } 115} $::MAGIC_SUM 116do_test bigfile-1.8 { 117 db close 118 sqlite3 db test.db 119 execsql { 120 SELECT md5sum(x) FROM t1; 121 } 122} $::MAGIC_SUM 123do_test bigfile-1.9 { 124 execsql { 125 SELECT md5sum(x) FROM t2; 126 } 127} $::MAGIC_SUM 128do_test bigfile-1.10 { 129 execsql { 130 SELECT md5sum(x) FROM t3; 131 } 132} $::MAGIC_SUM 133 134db close 135if {[catch {fake_big_file 16384 test.db}]} { 136 puts "**** Unable to create a file larger than 16384 MB. *****" 137 finish_test 138 return 139} 140 141do_test bigfile-1.11 { 142 sqlite3 db test.db 143 execsql { 144 SELECT md5sum(x) FROM t1; 145 } 146} $::MAGIC_SUM 147do_test bigfile-1.12 { 148 execsql { 149 CREATE TABLE t4 AS SELECT * FROM t1; 150 SELECT md5sum(x) FROM t4; 151 } 152} $::MAGIC_SUM 153do_test bigfile-1.13 { 154 db close 155 sqlite3 db test.db 156 execsql { 157 SELECT md5sum(x) FROM t1; 158 } 159} $::MAGIC_SUM 160do_test bigfile-1.14 { 161 execsql { 162 SELECT md5sum(x) FROM t2; 163 } 164} $::MAGIC_SUM 165do_test bigfile-1.15 { 166 execsql { 167 SELECT md5sum(x) FROM t3; 168 } 169} $::MAGIC_SUM 170do_test bigfile-1.16 { 171 execsql { 172 SELECT md5sum(x) FROM t3; 173 } 174} $::MAGIC_SUM 175 176} ;# End of the "if( db command exists )" 177 178finish_test 179