sl@0: # 2002 November 30 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # This file implements regression tests for SQLite library. The sl@0: # focus of this script testing the ability of SQLite to handle database sl@0: # files larger than 4GB. sl@0: # sl@0: # $Id: bigfile.test,v 1.10 2007/08/18 10:59:21 danielk1977 Exp $ sl@0: # sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: sl@0: # If SQLITE_DISABLE_LFS is defined, omit this file. sl@0: ifcapable !lfs { sl@0: finish_test sl@0: return sl@0: } sl@0: sl@0: # These tests only work for Tcl version 8.4 and later. Prior to 8.4, sl@0: # Tcl was unable to handle large files. sl@0: # sl@0: scan $::tcl_version %f vx sl@0: if {$vx<8.4} return sl@0: sl@0: # Mac OS X does not handle large files efficiently. So skip this test sl@0: # on that platform. sl@0: if {$tcl_platform(os)=="Darwin"} return sl@0: sl@0: # This is the md5 checksum of all the data in table t1 as created sl@0: # by the first test. We will use this number to make sure that data sl@0: # never changes. sl@0: # sl@0: set MAGIC_SUM {593f1efcfdbe698c28b4b1b693f7e4cf} sl@0: sl@0: do_test bigfile-1.1 { sl@0: execsql { sl@0: BEGIN; sl@0: CREATE TABLE t1(x); sl@0: INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz'); sl@0: INSERT INTO t1 SELECT rowid || ' ' || x FROM t1; sl@0: INSERT INTO t1 SELECT rowid || ' ' || x FROM t1; sl@0: INSERT INTO t1 SELECT rowid || ' ' || x FROM t1; sl@0: INSERT INTO t1 SELECT rowid || ' ' || x FROM t1; sl@0: INSERT INTO t1 SELECT rowid || ' ' || x FROM t1; sl@0: INSERT INTO t1 SELECT rowid || ' ' || x FROM t1; sl@0: INSERT INTO t1 SELECT rowid || ' ' || x FROM t1; sl@0: COMMIT; sl@0: } sl@0: execsql { sl@0: SELECT md5sum(x) FROM t1; sl@0: } sl@0: } $::MAGIC_SUM sl@0: sl@0: # Try to create a large file - a file that is larger than 2^32 bytes. sl@0: # If this fails, it means that the system being tested does not support sl@0: # large files. So skip all of the remaining tests in this file. sl@0: # sl@0: db close sl@0: if {[catch {fake_big_file 4096 test.db} msg]} { sl@0: puts "**** Unable to create a file larger than 4096 MB. *****" sl@0: puts "$msg" sl@0: finish_test sl@0: return sl@0: } sl@0: sl@0: do_test bigfile-1.2 { sl@0: sqlite3 db test.db sl@0: execsql { sl@0: SELECT md5sum(x) FROM t1; sl@0: } sl@0: } $::MAGIC_SUM sl@0: sl@0: # The previous test may fail on some systems because they are unable sl@0: # to handle large files. If that is so, then skip all of the following sl@0: # tests. We will know the above test failed because the "db" command sl@0: # does not exist. sl@0: # sl@0: if {[llength [info command db]]>0} { sl@0: sl@0: do_test bigfile-1.3 { sl@0: execsql { sl@0: CREATE TABLE t2 AS SELECT * FROM t1; sl@0: SELECT md5sum(x) FROM t2; sl@0: } sl@0: } $::MAGIC_SUM sl@0: do_test bigfile-1.4 { sl@0: db close sl@0: sqlite3 db test.db sl@0: execsql { sl@0: SELECT md5sum(x) FROM t1; sl@0: } sl@0: } $::MAGIC_SUM sl@0: do_test bigfile-1.5 { sl@0: execsql { sl@0: SELECT md5sum(x) FROM t2; sl@0: } sl@0: } $::MAGIC_SUM sl@0: sl@0: db close sl@0: if {[catch {fake_big_file 8192 test.db}]} { sl@0: puts "**** Unable to create a file larger than 8192 MB. *****" sl@0: finish_test sl@0: return sl@0: } sl@0: sl@0: do_test bigfile-1.6 { sl@0: sqlite3 db test.db sl@0: execsql { sl@0: SELECT md5sum(x) FROM t1; sl@0: } sl@0: } $::MAGIC_SUM sl@0: do_test bigfile-1.7 { sl@0: execsql { sl@0: CREATE TABLE t3 AS SELECT * FROM t1; sl@0: SELECT md5sum(x) FROM t3; sl@0: } sl@0: } $::MAGIC_SUM sl@0: do_test bigfile-1.8 { sl@0: db close sl@0: sqlite3 db test.db sl@0: execsql { sl@0: SELECT md5sum(x) FROM t1; sl@0: } sl@0: } $::MAGIC_SUM sl@0: do_test bigfile-1.9 { sl@0: execsql { sl@0: SELECT md5sum(x) FROM t2; sl@0: } sl@0: } $::MAGIC_SUM sl@0: do_test bigfile-1.10 { sl@0: execsql { sl@0: SELECT md5sum(x) FROM t3; sl@0: } sl@0: } $::MAGIC_SUM sl@0: sl@0: db close sl@0: if {[catch {fake_big_file 16384 test.db}]} { sl@0: puts "**** Unable to create a file larger than 16384 MB. *****" sl@0: finish_test sl@0: return sl@0: } sl@0: sl@0: do_test bigfile-1.11 { sl@0: sqlite3 db test.db sl@0: execsql { sl@0: SELECT md5sum(x) FROM t1; sl@0: } sl@0: } $::MAGIC_SUM sl@0: do_test bigfile-1.12 { sl@0: execsql { sl@0: CREATE TABLE t4 AS SELECT * FROM t1; sl@0: SELECT md5sum(x) FROM t4; sl@0: } sl@0: } $::MAGIC_SUM sl@0: do_test bigfile-1.13 { sl@0: db close sl@0: sqlite3 db test.db sl@0: execsql { sl@0: SELECT md5sum(x) FROM t1; sl@0: } sl@0: } $::MAGIC_SUM sl@0: do_test bigfile-1.14 { sl@0: execsql { sl@0: SELECT md5sum(x) FROM t2; sl@0: } sl@0: } $::MAGIC_SUM sl@0: do_test bigfile-1.15 { sl@0: execsql { sl@0: SELECT md5sum(x) FROM t3; sl@0: } sl@0: } $::MAGIC_SUM sl@0: do_test bigfile-1.16 { sl@0: execsql { sl@0: SELECT md5sum(x) FROM t3; sl@0: } sl@0: } $::MAGIC_SUM sl@0: do_test bigfile-1.17 { sl@0: execsql { sl@0: SELECT md5sum(x) FROM t4; sl@0: } sl@0: } $::MAGIC_SUM sl@0: sl@0: } ;# End of the "if( db command exists )" sl@0: sl@0: finish_test