CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
bigfile.test204 linesDownload Raw Back to test
1# 2002 November 302#3# The author disclaims copyright to this source code.  In place of4# 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.  The12# focus of this script testing the ability of SQLite to handle database13# files larger than 4GB.14#15# $Id: bigfile.test,v 1.12 2009/03/05 04:27:08 shane Exp $16#17 18if {[file exists skip-big-file]} return19if {$tcl_platform(os)=="Darwin"} return20 21set testdir [file dirname $argv0]22source $testdir/tester.tcl23 24# Do not use a codec for this file, as the database is manipulated using25# external methods (the [fake_big_file] and [hexio_write] commands).26#27do_not_use_codec28 29# If SQLITE_DISABLE_LFS is defined, omit this file.30ifcapable !lfs {31  finish_test32  return33}34 35# These tests only work for Tcl version 8.4 and later.  Prior to 8.4,36# Tcl was unable to handle large files.37#38scan $::tcl_version %f vx39if {$vx<8.4} return40 41# Mac OS X does not handle large files efficiently.  So skip this test42# on that platform.43if {$tcl_platform(os)=="Darwin"} return44 45# This is the md5 checksum of all the data in table t1 as created46# by the first test.  We will use this number to make sure that data47# never changes.48#49set MAGIC_SUM {593f1efcfdbe698c28b4b1b693f7e4cf}50 51do_test bigfile-1.1 {52  execsql {53    BEGIN;54    CREATE TABLE t1(x);55    INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz');56    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;57    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;58    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;59    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;60    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;61    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;62    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;63    COMMIT;64  }65  execsql {66    SELECT md5sum(x) FROM t1;67  }68} $::MAGIC_SUM69 70# Try to create a large file - a file that is larger than 2^32 bytes.71# If this fails, it means that the system being tested does not support72# large files.  So skip all of the remaining tests in this file.73#74db close75if {[catch {fake_big_file 4096 [get_pwd]/test.db} msg]} {76  puts "**** Unable to create a file larger than 4096 MB. *****"77  finish_test78  return79}80hexio_write test.db 28 0000000081 82do_test bigfile-1.2 {83  sqlite3 db test.db84  execsql {85    SELECT md5sum(x) FROM t1;86  }87} $::MAGIC_SUM88 89# The previous test may fail on some systems because they are unable90# to handle large files.  If that is so, then skip all of the following91# tests.  We will know the above test failed because the "db" command92# does not exist.93#94if {[llength [info command db]]<=0} {95  puts "**** Large file support appears to be broken. *****"96  finish_test97  return98}99 100do_test bigfile-1.3 {101  execsql {102    CREATE TABLE t2 AS SELECT * FROM t1;103    SELECT md5sum(x) FROM t2;104  }105} $::MAGIC_SUM106do_test bigfile-1.4 {107  db close108  sqlite3 db test.db109  execsql {110    SELECT md5sum(x) FROM t1;111  }112} $::MAGIC_SUM113 114db close115if {[catch {fake_big_file 8192 [get_pwd]/test.db}]} {116  puts "**** Unable to create a file larger than 8192 MB. *****"117  finish_test118  return119}120hexio_write test.db 28 00000000121 122do_test bigfile-1.5 {123  sqlite3 db test.db124  execsql {125    SELECT md5sum(x) FROM t1;126  }127} $::MAGIC_SUM128do_test bigfile-1.6 {129  sqlite3 db test.db130  execsql {131    SELECT md5sum(x) FROM t2;132  }133} $::MAGIC_SUM134do_test bigfile-1.7 {135  execsql {136    CREATE TABLE t3 AS SELECT * FROM t1;137    SELECT md5sum(x) FROM t3;138  }139} $::MAGIC_SUM140do_test bigfile-1.8 {141  db close142  sqlite3 db test.db143  execsql {144    SELECT md5sum(x) FROM t1;145  }146} $::MAGIC_SUM147do_test bigfile-1.9 {148  execsql {149    SELECT md5sum(x) FROM t2;150  }151} $::MAGIC_SUM152 153db close154if {[catch {fake_big_file 16384 [get_pwd]/test.db}]} {155  puts "**** Unable to create a file larger than 16384 MB. *****"156  finish_test157  return158}159hexio_write test.db 28 00000000160 161do_test bigfile-1.10 {162  sqlite3 db test.db163  execsql {164    SELECT md5sum(x) FROM t1;165  }166} $::MAGIC_SUM167do_test bigfile-1.11 {168  sqlite3 db test.db169  execsql {170    SELECT md5sum(x) FROM t2;171  }172} $::MAGIC_SUM173do_test bigfile-1.12 {174  sqlite3 db test.db175  execsql {176    SELECT md5sum(x) FROM t3;177  }178} $::MAGIC_SUM179do_test bigfile-1.13 {180  execsql {181    CREATE TABLE t4 AS SELECT * FROM t1;182    SELECT md5sum(x) FROM t4;183  }184} $::MAGIC_SUM185do_test bigfile-1.14 {186  db close187  sqlite3 db test.db188  execsql {189    SELECT md5sum(x) FROM t1;190  }191} $::MAGIC_SUM192do_test bigfile-1.15 {193  execsql {194    SELECT md5sum(x) FROM t2;195  }196} $::MAGIC_SUM197do_test bigfile-1.16 {198  execsql {199    SELECT md5sum(x) FROM t3;200  }201} $::MAGIC_SUM202 203finish_test204