drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 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 | # |
shane | 3c9cfa9 | 2009-03-05 04:27:08 +0000 | [diff] [blame] | 15 | # $Id: bigfile.test,v 1.12 2009/03/05 04:27:08 shane Exp $ |
drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 16 | # |
| 17 | |
| 18 | set testdir [file dirname $argv0] |
| 19 | source $testdir/tester.tcl |
| 20 | |
dan | 68928b6 | 2010-06-22 13:46:43 +0000 | [diff] [blame] | 21 | # Do not use a codec for this file, as the database is manipulated using |
| 22 | # external methods (the [fake_big_file] and [hexio_write] commands). |
| 23 | # |
| 24 | do_not_use_codec |
| 25 | |
danielk1977 | 26c5d79 | 2005-11-25 09:01:23 +0000 | [diff] [blame] | 26 | # If SQLITE_DISABLE_LFS is defined, omit this file. |
| 27 | ifcapable !lfs { |
| 28 | finish_test |
| 29 | return |
| 30 | } |
| 31 | |
drh | 5202560 | 2003-12-19 12:31:19 +0000 | [diff] [blame] | 32 | # These tests only work for Tcl version 8.4 and later. Prior to 8.4, |
| 33 | # Tcl was unable to handle large files. |
| 34 | # |
| 35 | scan $::tcl_version %f vx |
| 36 | if {$vx<8.4} return |
| 37 | |
drh | 3ea6440 | 2004-06-30 11:28:13 +0000 | [diff] [blame] | 38 | # Mac OS X does not handle large files efficiently. So skip this test |
| 39 | # on that platform. |
| 40 | if {$tcl_platform(os)=="Darwin"} return |
| 41 | |
drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 42 | # This is the md5 checksum of all the data in table t1 as created |
| 43 | # by the first test. We will use this number to make sure that data |
| 44 | # never changes. |
| 45 | # |
| 46 | set MAGIC_SUM {593f1efcfdbe698c28b4b1b693f7e4cf} |
| 47 | |
| 48 | do_test bigfile-1.1 { |
| 49 | execsql { |
| 50 | BEGIN; |
| 51 | CREATE TABLE t1(x); |
| 52 | INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz'); |
| 53 | INSERT INTO t1 SELECT rowid || ' ' || x FROM t1; |
| 54 | INSERT INTO t1 SELECT rowid || ' ' || x FROM t1; |
| 55 | INSERT INTO t1 SELECT rowid || ' ' || x FROM t1; |
| 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 | COMMIT; |
| 61 | } |
| 62 | execsql { |
| 63 | SELECT md5sum(x) FROM t1; |
| 64 | } |
| 65 | } $::MAGIC_SUM |
| 66 | |
drh | f33cb42 | 2002-12-17 14:13:48 +0000 | [diff] [blame] | 67 | # Try to create a large file - a file that is larger than 2^32 bytes. |
| 68 | # If this fails, it means that the system being tested does not support |
| 69 | # large files. So skip all of the remaining tests in this file. |
| 70 | # |
| 71 | db close |
drh | 107886a | 2008-11-21 22:21:50 +0000 | [diff] [blame] | 72 | if {[catch {fake_big_file 4096 [pwd]/test.db} msg]} { |
drh | f33cb42 | 2002-12-17 14:13:48 +0000 | [diff] [blame] | 73 | puts "**** Unable to create a file larger than 4096 MB. *****" |
| 74 | finish_test |
| 75 | return |
| 76 | } |
drh | 43377f5 | 2010-04-01 16:15:56 +0000 | [diff] [blame] | 77 | hexio_write test.db 28 00000000 |
drh | f33cb42 | 2002-12-17 14:13:48 +0000 | [diff] [blame] | 78 | |
drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 79 | do_test bigfile-1.2 { |
drh | ef4ac8f | 2004-06-19 00:16:31 +0000 | [diff] [blame] | 80 | sqlite3 db test.db |
drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 81 | execsql { |
| 82 | SELECT md5sum(x) FROM t1; |
| 83 | } |
| 84 | } $::MAGIC_SUM |
| 85 | |
| 86 | # The previous test may fail on some systems because they are unable |
| 87 | # to handle large files. If that is so, then skip all of the following |
| 88 | # tests. We will know the above test failed because the "db" command |
| 89 | # does not exist. |
| 90 | # |
shane | 3c9cfa9 | 2009-03-05 04:27:08 +0000 | [diff] [blame] | 91 | if {[llength [info command db]]<=0} { |
| 92 | puts "**** Large file support appears to be broken. *****" |
| 93 | finish_test |
| 94 | return |
| 95 | } |
drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 96 | |
| 97 | do_test bigfile-1.3 { |
| 98 | execsql { |
| 99 | CREATE TABLE t2 AS SELECT * FROM t1; |
| 100 | SELECT md5sum(x) FROM t2; |
| 101 | } |
| 102 | } $::MAGIC_SUM |
| 103 | do_test bigfile-1.4 { |
| 104 | db close |
drh | ef4ac8f | 2004-06-19 00:16:31 +0000 | [diff] [blame] | 105 | sqlite3 db test.db |
drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 106 | execsql { |
| 107 | SELECT md5sum(x) FROM t1; |
| 108 | } |
| 109 | } $::MAGIC_SUM |
drh | f33cb42 | 2002-12-17 14:13:48 +0000 | [diff] [blame] | 110 | |
| 111 | db close |
drh | 107886a | 2008-11-21 22:21:50 +0000 | [diff] [blame] | 112 | if {[catch {fake_big_file 8192 [pwd]/test.db}]} { |
drh | f33cb42 | 2002-12-17 14:13:48 +0000 | [diff] [blame] | 113 | puts "**** Unable to create a file larger than 8192 MB. *****" |
| 114 | finish_test |
| 115 | return |
| 116 | } |
drh | 43377f5 | 2010-04-01 16:15:56 +0000 | [diff] [blame] | 117 | hexio_write test.db 28 00000000 |
drh | f33cb42 | 2002-12-17 14:13:48 +0000 | [diff] [blame] | 118 | |
shane | 3c9cfa9 | 2009-03-05 04:27:08 +0000 | [diff] [blame] | 119 | do_test bigfile-1.5 { |
drh | ef4ac8f | 2004-06-19 00:16:31 +0000 | [diff] [blame] | 120 | sqlite3 db test.db |
drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 121 | execsql { |
| 122 | SELECT md5sum(x) FROM t1; |
| 123 | } |
| 124 | } $::MAGIC_SUM |
shane | 3c9cfa9 | 2009-03-05 04:27:08 +0000 | [diff] [blame] | 125 | do_test bigfile-1.6 { |
| 126 | sqlite3 db test.db |
| 127 | execsql { |
| 128 | SELECT md5sum(x) FROM t2; |
| 129 | } |
| 130 | } $::MAGIC_SUM |
drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 131 | do_test bigfile-1.7 { |
| 132 | execsql { |
| 133 | CREATE TABLE t3 AS SELECT * FROM t1; |
| 134 | SELECT md5sum(x) FROM t3; |
| 135 | } |
| 136 | } $::MAGIC_SUM |
| 137 | do_test bigfile-1.8 { |
| 138 | db close |
drh | ef4ac8f | 2004-06-19 00:16:31 +0000 | [diff] [blame] | 139 | sqlite3 db test.db |
drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 140 | execsql { |
| 141 | SELECT md5sum(x) FROM t1; |
| 142 | } |
| 143 | } $::MAGIC_SUM |
| 144 | do_test bigfile-1.9 { |
| 145 | execsql { |
| 146 | SELECT md5sum(x) FROM t2; |
| 147 | } |
| 148 | } $::MAGIC_SUM |
drh | f33cb42 | 2002-12-17 14:13:48 +0000 | [diff] [blame] | 149 | |
| 150 | db close |
drh | 107886a | 2008-11-21 22:21:50 +0000 | [diff] [blame] | 151 | if {[catch {fake_big_file 16384 [pwd]/test.db}]} { |
drh | f33cb42 | 2002-12-17 14:13:48 +0000 | [diff] [blame] | 152 | puts "**** Unable to create a file larger than 16384 MB. *****" |
| 153 | finish_test |
| 154 | return |
| 155 | } |
drh | 43377f5 | 2010-04-01 16:15:56 +0000 | [diff] [blame] | 156 | hexio_write test.db 28 00000000 |
drh | f33cb42 | 2002-12-17 14:13:48 +0000 | [diff] [blame] | 157 | |
shane | 3c9cfa9 | 2009-03-05 04:27:08 +0000 | [diff] [blame] | 158 | do_test bigfile-1.10 { |
drh | ef4ac8f | 2004-06-19 00:16:31 +0000 | [diff] [blame] | 159 | sqlite3 db test.db |
drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 160 | execsql { |
| 161 | SELECT md5sum(x) FROM t1; |
| 162 | } |
| 163 | } $::MAGIC_SUM |
shane | 3c9cfa9 | 2009-03-05 04:27:08 +0000 | [diff] [blame] | 164 | do_test bigfile-1.11 { |
| 165 | sqlite3 db test.db |
| 166 | execsql { |
| 167 | SELECT md5sum(x) FROM t2; |
| 168 | } |
| 169 | } $::MAGIC_SUM |
drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 170 | do_test bigfile-1.12 { |
shane | 3c9cfa9 | 2009-03-05 04:27:08 +0000 | [diff] [blame] | 171 | sqlite3 db test.db |
| 172 | execsql { |
| 173 | SELECT md5sum(x) FROM t3; |
| 174 | } |
| 175 | } $::MAGIC_SUM |
| 176 | do_test bigfile-1.13 { |
drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 177 | execsql { |
| 178 | CREATE TABLE t4 AS SELECT * FROM t1; |
| 179 | SELECT md5sum(x) FROM t4; |
| 180 | } |
| 181 | } $::MAGIC_SUM |
shane | 3c9cfa9 | 2009-03-05 04:27:08 +0000 | [diff] [blame] | 182 | do_test bigfile-1.14 { |
drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 183 | db close |
drh | ef4ac8f | 2004-06-19 00:16:31 +0000 | [diff] [blame] | 184 | sqlite3 db test.db |
drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 185 | execsql { |
| 186 | SELECT md5sum(x) FROM t1; |
| 187 | } |
| 188 | } $::MAGIC_SUM |
drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 189 | do_test bigfile-1.15 { |
| 190 | execsql { |
shane | 3c9cfa9 | 2009-03-05 04:27:08 +0000 | [diff] [blame] | 191 | SELECT md5sum(x) FROM t2; |
drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 192 | } |
| 193 | } $::MAGIC_SUM |
| 194 | do_test bigfile-1.16 { |
| 195 | execsql { |
| 196 | SELECT md5sum(x) FROM t3; |
| 197 | } |
| 198 | } $::MAGIC_SUM |
drh | d0d006e | 2002-12-01 02:00:57 +0000 | [diff] [blame] | 199 | |
| 200 | finish_test |