dan | 27d47fb | 2011-12-21 17:00:16 +0000 | [diff] [blame] | 1 | # 2011 December 20 |
| 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 | |
drh | ee3a77d | 2012-03-01 22:33:41 +0000 | [diff] [blame] | 16 | if {[file exists skip-big-file]} return |
drh | befda46 | 2012-09-29 15:45:12 +0000 | [diff] [blame] | 17 | if {$tcl_platform(os)=="Darwin"} return |
drh | ee3a77d | 2012-03-01 22:33:41 +0000 | [diff] [blame] | 18 | |
dan | 27d47fb | 2011-12-21 17:00:16 +0000 | [diff] [blame] | 19 | set testdir [file dirname $argv0] |
| 20 | source $testdir/tester.tcl |
| 21 | set testprefix bigfile2 |
| 22 | |
| 23 | # Create a small database. |
| 24 | # |
| 25 | do_execsql_test 1.1 { |
| 26 | CREATE TABLE t1(a, b); |
| 27 | INSERT INTO t1 VALUES(1, 2); |
| 28 | } |
| 29 | |
| 30 | # Pad the file out to 4GB in size. Then clear the file-size field in the |
| 31 | # db header. This will cause SQLite to assume that the first 4GB of pages |
| 32 | # are actually in use and new pages will be appended to the file. |
| 33 | # |
| 34 | db close |
mistachkin | f8a7846 | 2012-03-08 20:00:36 +0000 | [diff] [blame] | 35 | if {[catch {fake_big_file 4096 [get_pwd]/test.db} msg]} { |
dan | 27d47fb | 2011-12-21 17:00:16 +0000 | [diff] [blame] | 36 | puts "**** Unable to create a file larger than 4096 MB. *****" |
| 37 | finish_test |
| 38 | return |
| 39 | } |
| 40 | hexio_write test.db 28 00000000 |
| 41 | |
| 42 | do_test 1.2 { |
| 43 | file size test.db |
| 44 | } [expr 14 + 4096 * (1<<20)] |
| 45 | |
| 46 | # Now insert a large row. The overflow pages will be located past the 4GB |
| 47 | # boundary. Then, after opening and closing the database, test that the row |
| 48 | # can be read back in. |
| 49 | # |
| 50 | set str [string repeat k 30000] |
| 51 | do_test 1.3 { |
| 52 | sqlite3 db test.db |
| 53 | execsql { INSERT INTO t1 VALUES(3, $str) } |
| 54 | db close |
| 55 | sqlite3 db test.db |
| 56 | db one { SELECT b FROM t1 WHERE a = 3 } |
| 57 | } $str |
| 58 | |
| 59 | db close |
mistachkin | 9ac9931 | 2013-09-13 23:26:47 +0000 | [diff] [blame] | 60 | delete_file test.db |
dan | 27d47fb | 2011-12-21 17:00:16 +0000 | [diff] [blame] | 61 | |
| 62 | finish_test |