2002-12-01 05:00:57 +03:00
|
|
|
# 2002 November 30
|
|
|
|
#
|
|
|
|
# The author disclaims copyright to this source code. In place of
|
|
|
|
# a legal notice, here is a blessing:
|
|
|
|
#
|
|
|
|
# May you do good and not evil.
|
|
|
|
# May you find forgiveness for yourself and forgive others.
|
|
|
|
# May you share freely, never taking more than you give.
|
|
|
|
#
|
|
|
|
#***********************************************************************
|
|
|
|
# This file implements regression tests for SQLite library. The
|
|
|
|
# focus of this script testing the ability of SQLite to handle database
|
|
|
|
# files larger than 4GB.
|
|
|
|
#
|
2009-03-05 07:27:08 +03:00
|
|
|
# $Id: bigfile.test,v 1.12 2009/03/05 04:27:08 shane Exp $
|
2002-12-01 05:00:57 +03:00
|
|
|
#
|
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
|
2010-06-22 17:46:43 +04:00
|
|
|
# Do not use a codec for this file, as the database is manipulated using
|
|
|
|
# external methods (the [fake_big_file] and [hexio_write] commands).
|
|
|
|
#
|
|
|
|
do_not_use_codec
|
|
|
|
|
2005-11-25 12:01:23 +03:00
|
|
|
# If SQLITE_DISABLE_LFS is defined, omit this file.
|
|
|
|
ifcapable !lfs {
|
|
|
|
finish_test
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2003-12-19 15:31:19 +03:00
|
|
|
# These tests only work for Tcl version 8.4 and later. Prior to 8.4,
|
|
|
|
# Tcl was unable to handle large files.
|
|
|
|
#
|
|
|
|
scan $::tcl_version %f vx
|
|
|
|
if {$vx<8.4} return
|
|
|
|
|
2004-06-30 15:28:13 +04:00
|
|
|
# Mac OS X does not handle large files efficiently. So skip this test
|
|
|
|
# on that platform.
|
|
|
|
if {$tcl_platform(os)=="Darwin"} return
|
|
|
|
|
2002-12-01 05:00:57 +03:00
|
|
|
# This is the md5 checksum of all the data in table t1 as created
|
|
|
|
# by the first test. We will use this number to make sure that data
|
|
|
|
# never changes.
|
|
|
|
#
|
|
|
|
set MAGIC_SUM {593f1efcfdbe698c28b4b1b693f7e4cf}
|
|
|
|
|
|
|
|
do_test bigfile-1.1 {
|
|
|
|
execsql {
|
|
|
|
BEGIN;
|
|
|
|
CREATE TABLE t1(x);
|
|
|
|
INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz');
|
|
|
|
INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
|
|
|
|
INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
|
|
|
|
INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
|
|
|
|
INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
|
|
|
|
INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
|
|
|
|
INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
|
|
|
|
INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;
|
|
|
|
COMMIT;
|
|
|
|
}
|
|
|
|
execsql {
|
|
|
|
SELECT md5sum(x) FROM t1;
|
|
|
|
}
|
|
|
|
} $::MAGIC_SUM
|
|
|
|
|
2002-12-17 17:13:48 +03:00
|
|
|
# Try to create a large file - a file that is larger than 2^32 bytes.
|
|
|
|
# If this fails, it means that the system being tested does not support
|
|
|
|
# large files. So skip all of the remaining tests in this file.
|
|
|
|
#
|
|
|
|
db close
|
2008-11-22 01:21:50 +03:00
|
|
|
if {[catch {fake_big_file 4096 [pwd]/test.db} msg]} {
|
2002-12-17 17:13:48 +03:00
|
|
|
puts "**** Unable to create a file larger than 4096 MB. *****"
|
|
|
|
finish_test
|
|
|
|
return
|
|
|
|
}
|
2010-04-01 20:15:56 +04:00
|
|
|
hexio_write test.db 28 00000000
|
2002-12-17 17:13:48 +03:00
|
|
|
|
2002-12-01 05:00:57 +03:00
|
|
|
do_test bigfile-1.2 {
|
2004-06-19 04:16:31 +04:00
|
|
|
sqlite3 db test.db
|
2002-12-01 05:00:57 +03:00
|
|
|
execsql {
|
|
|
|
SELECT md5sum(x) FROM t1;
|
|
|
|
}
|
|
|
|
} $::MAGIC_SUM
|
|
|
|
|
|
|
|
# The previous test may fail on some systems because they are unable
|
|
|
|
# to handle large files. If that is so, then skip all of the following
|
|
|
|
# tests. We will know the above test failed because the "db" command
|
|
|
|
# does not exist.
|
|
|
|
#
|
2009-03-05 07:27:08 +03:00
|
|
|
if {[llength [info command db]]<=0} {
|
|
|
|
puts "**** Large file support appears to be broken. *****"
|
|
|
|
finish_test
|
|
|
|
return
|
|
|
|
}
|
2002-12-01 05:00:57 +03:00
|
|
|
|
|
|
|
do_test bigfile-1.3 {
|
|
|
|
execsql {
|
|
|
|
CREATE TABLE t2 AS SELECT * FROM t1;
|
|
|
|
SELECT md5sum(x) FROM t2;
|
|
|
|
}
|
|
|
|
} $::MAGIC_SUM
|
|
|
|
do_test bigfile-1.4 {
|
|
|
|
db close
|
2004-06-19 04:16:31 +04:00
|
|
|
sqlite3 db test.db
|
2002-12-01 05:00:57 +03:00
|
|
|
execsql {
|
|
|
|
SELECT md5sum(x) FROM t1;
|
|
|
|
}
|
|
|
|
} $::MAGIC_SUM
|
2002-12-17 17:13:48 +03:00
|
|
|
|
|
|
|
db close
|
2008-11-22 01:21:50 +03:00
|
|
|
if {[catch {fake_big_file 8192 [pwd]/test.db}]} {
|
2002-12-17 17:13:48 +03:00
|
|
|
puts "**** Unable to create a file larger than 8192 MB. *****"
|
|
|
|
finish_test
|
|
|
|
return
|
|
|
|
}
|
2010-04-01 20:15:56 +04:00
|
|
|
hexio_write test.db 28 00000000
|
2002-12-17 17:13:48 +03:00
|
|
|
|
2009-03-05 07:27:08 +03:00
|
|
|
do_test bigfile-1.5 {
|
2004-06-19 04:16:31 +04:00
|
|
|
sqlite3 db test.db
|
2002-12-01 05:00:57 +03:00
|
|
|
execsql {
|
|
|
|
SELECT md5sum(x) FROM t1;
|
|
|
|
}
|
|
|
|
} $::MAGIC_SUM
|
2009-03-05 07:27:08 +03:00
|
|
|
do_test bigfile-1.6 {
|
|
|
|
sqlite3 db test.db
|
|
|
|
execsql {
|
|
|
|
SELECT md5sum(x) FROM t2;
|
|
|
|
}
|
|
|
|
} $::MAGIC_SUM
|
2002-12-01 05:00:57 +03:00
|
|
|
do_test bigfile-1.7 {
|
|
|
|
execsql {
|
|
|
|
CREATE TABLE t3 AS SELECT * FROM t1;
|
|
|
|
SELECT md5sum(x) FROM t3;
|
|
|
|
}
|
|
|
|
} $::MAGIC_SUM
|
|
|
|
do_test bigfile-1.8 {
|
|
|
|
db close
|
2004-06-19 04:16:31 +04:00
|
|
|
sqlite3 db test.db
|
2002-12-01 05:00:57 +03:00
|
|
|
execsql {
|
|
|
|
SELECT md5sum(x) FROM t1;
|
|
|
|
}
|
|
|
|
} $::MAGIC_SUM
|
|
|
|
do_test bigfile-1.9 {
|
|
|
|
execsql {
|
|
|
|
SELECT md5sum(x) FROM t2;
|
|
|
|
}
|
|
|
|
} $::MAGIC_SUM
|
2002-12-17 17:13:48 +03:00
|
|
|
|
|
|
|
db close
|
2008-11-22 01:21:50 +03:00
|
|
|
if {[catch {fake_big_file 16384 [pwd]/test.db}]} {
|
2002-12-17 17:13:48 +03:00
|
|
|
puts "**** Unable to create a file larger than 16384 MB. *****"
|
|
|
|
finish_test
|
|
|
|
return
|
|
|
|
}
|
2010-04-01 20:15:56 +04:00
|
|
|
hexio_write test.db 28 00000000
|
2002-12-17 17:13:48 +03:00
|
|
|
|
2009-03-05 07:27:08 +03:00
|
|
|
do_test bigfile-1.10 {
|
2004-06-19 04:16:31 +04:00
|
|
|
sqlite3 db test.db
|
2002-12-01 05:00:57 +03:00
|
|
|
execsql {
|
|
|
|
SELECT md5sum(x) FROM t1;
|
|
|
|
}
|
|
|
|
} $::MAGIC_SUM
|
2009-03-05 07:27:08 +03:00
|
|
|
do_test bigfile-1.11 {
|
|
|
|
sqlite3 db test.db
|
|
|
|
execsql {
|
|
|
|
SELECT md5sum(x) FROM t2;
|
|
|
|
}
|
|
|
|
} $::MAGIC_SUM
|
2002-12-01 05:00:57 +03:00
|
|
|
do_test bigfile-1.12 {
|
2009-03-05 07:27:08 +03:00
|
|
|
sqlite3 db test.db
|
2002-12-01 05:00:57 +03:00
|
|
|
execsql {
|
2009-03-05 07:27:08 +03:00
|
|
|
SELECT md5sum(x) FROM t3;
|
2002-12-01 05:00:57 +03:00
|
|
|
}
|
|
|
|
} $::MAGIC_SUM
|
|
|
|
do_test bigfile-1.13 {
|
|
|
|
execsql {
|
2009-03-05 07:27:08 +03:00
|
|
|
CREATE TABLE t4 AS SELECT * FROM t1;
|
|
|
|
SELECT md5sum(x) FROM t4;
|
2002-12-01 05:00:57 +03:00
|
|
|
}
|
|
|
|
} $::MAGIC_SUM
|
|
|
|
do_test bigfile-1.14 {
|
2009-03-05 07:27:08 +03:00
|
|
|
db close
|
|
|
|
sqlite3 db test.db
|
2002-12-01 05:00:57 +03:00
|
|
|
execsql {
|
2009-03-05 07:27:08 +03:00
|
|
|
SELECT md5sum(x) FROM t1;
|
2002-12-01 05:00:57 +03:00
|
|
|
}
|
|
|
|
} $::MAGIC_SUM
|
|
|
|
do_test bigfile-1.15 {
|
|
|
|
execsql {
|
2009-03-05 07:27:08 +03:00
|
|
|
SELECT md5sum(x) FROM t2;
|
2002-12-01 05:00:57 +03:00
|
|
|
}
|
|
|
|
} $::MAGIC_SUM
|
|
|
|
do_test bigfile-1.16 {
|
|
|
|
execsql {
|
|
|
|
SELECT md5sum(x) FROM t3;
|
|
|
|
}
|
|
|
|
} $::MAGIC_SUM
|
|
|
|
|
|
|
|
finish_test
|