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