blob: c43b7e25033b691c05eaa5638d81e3745ef60c2e [file] [log] [blame]
danbd0e9072010-07-07 09:48:44 +00001# 2010 July 07
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 in WAL mode.
14#
15
16
17set testdir [file dirname $argv0]
18source $testdir/tester.tcl
19
dan52091322011-09-24 05:55:36 +000020ifcapable !wal {
21 finish_test
22 return
23}
24
danbd0e9072010-07-07 09:48:44 +000025# Do not use a codec for this file, as the database is manipulated using
26# external methods (the [fake_big_file] and [hexio_write] commands).
27#
28do_not_use_codec
29
30# If SQLITE_DISABLE_LFS is defined, omit this file.
31ifcapable !lfs {
32 finish_test
33 return
34}
35
36set a_string_counter 1
37proc a_string {n} {
38 incr ::a_string_counter
39 string range [string repeat "${::a_string_counter}." $n] 1 $n
40}
41db func a_string a_string
42
43do_test walbig-1.0 {
44 execsql {
45 PRAGMA journal_mode = WAL;
46 CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
47 INSERT INTO t1 VALUES(a_string(300), a_string(500));
48 INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1;
49 INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1;
50 INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1;
51 }
52} {wal}
53
54db close
mistachkinf8a78462012-03-08 20:00:36 +000055if {[catch {fake_big_file 5000 [get_pwd]/test.db}]} {
danbd0e9072010-07-07 09:48:44 +000056 puts "**** Unable to create a file larger than 5000 MB. *****"
57 finish_test
58 return
59}
60hexio_write test.db 28 00000000
61
62sqlite3 db test.db
63db func a_string a_string
64do_test walbig-1.1 {
65 execsql { INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1 }
66} {}
67db close
68
69sqlite3 db test.db
70do_test walbig-1.2 {
71 execsql { SELECT a FROM t1 ORDER BY a }
72} [lsort [execsql { SELECT a FROM t1 ORDER BY rowid }]]
73
74do_test walbig-1.3 {
75 execsql { SELECT b FROM t1 ORDER BY b }
76} [lsort [execsql { SELECT b FROM t1 ORDER BY rowid }]]
77
78finish_test