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