xref: /sqlite-3.40.0/test/walbig.test (revision f8a78464)
1bd0e9070Sdan# 2010 July 07
2bd0e9070Sdan#
3bd0e9070Sdan# The author disclaims copyright to this source code.  In place of
4bd0e9070Sdan# a legal notice, here is a blessing:
5bd0e9070Sdan#
6bd0e9070Sdan#    May you do good and not evil.
7bd0e9070Sdan#    May you find forgiveness for yourself and forgive others.
8bd0e9070Sdan#    May you share freely, never taking more than you give.
9bd0e9070Sdan#
10bd0e9070Sdan#***********************************************************************
11bd0e9070Sdan# This file implements regression tests for SQLite library.  The
12bd0e9070Sdan# focus of this script testing the ability of SQLite to handle database
13bd0e9070Sdan# files larger than 4GB in WAL mode.
14bd0e9070Sdan#
15bd0e9070Sdan
16bd0e9070Sdan
17bd0e9070Sdanset testdir [file dirname $argv0]
18bd0e9070Sdansource $testdir/tester.tcl
19bd0e9070Sdan
205209132aSdanifcapable !wal {
215209132aSdan  finish_test
225209132aSdan  return
235209132aSdan}
245209132aSdan
25bd0e9070Sdan# Do not use a codec for this file, as the database is manipulated using
26bd0e9070Sdan# external methods (the [fake_big_file] and [hexio_write] commands).
27bd0e9070Sdan#
28bd0e9070Sdando_not_use_codec
29bd0e9070Sdan
30bd0e9070Sdan# If SQLITE_DISABLE_LFS is defined, omit this file.
31bd0e9070Sdanifcapable !lfs {
32bd0e9070Sdan  finish_test
33bd0e9070Sdan  return
34bd0e9070Sdan}
35bd0e9070Sdan
36bd0e9070Sdanset a_string_counter 1
37bd0e9070Sdanproc a_string {n} {
38bd0e9070Sdan  incr ::a_string_counter
39bd0e9070Sdan  string range [string repeat "${::a_string_counter}." $n] 1 $n
40bd0e9070Sdan}
41bd0e9070Sdandb func a_string a_string
42bd0e9070Sdan
43bd0e9070Sdando_test walbig-1.0 {
44bd0e9070Sdan  execsql {
45bd0e9070Sdan    PRAGMA journal_mode = WAL;
46bd0e9070Sdan    CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
47bd0e9070Sdan    INSERT INTO t1 VALUES(a_string(300), a_string(500));
48bd0e9070Sdan    INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1;
49bd0e9070Sdan    INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1;
50bd0e9070Sdan    INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1;
51bd0e9070Sdan  }
52bd0e9070Sdan} {wal}
53bd0e9070Sdan
54bd0e9070Sdandb close
55*f8a78464Smistachkinif {[catch {fake_big_file 5000 [get_pwd]/test.db}]} {
56bd0e9070Sdan  puts "**** Unable to create a file larger than 5000 MB. *****"
57bd0e9070Sdan  finish_test
58bd0e9070Sdan  return
59bd0e9070Sdan}
60bd0e9070Sdanhexio_write test.db 28 00000000
61bd0e9070Sdan
62bd0e9070Sdansqlite3 db test.db
63bd0e9070Sdandb func a_string a_string
64bd0e9070Sdando_test walbig-1.1 {
65bd0e9070Sdan  execsql { INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1 }
66bd0e9070Sdan} {}
67bd0e9070Sdandb close
68bd0e9070Sdan
69bd0e9070Sdansqlite3 db test.db
70bd0e9070Sdando_test walbig-1.2 {
71bd0e9070Sdan  execsql { SELECT a FROM t1 ORDER BY a }
72bd0e9070Sdan} [lsort [execsql { SELECT a FROM t1 ORDER BY rowid }]]
73bd0e9070Sdan
74bd0e9070Sdando_test walbig-1.3 {
75bd0e9070Sdan  execsql { SELECT b FROM t1 ORDER BY b }
76bd0e9070Sdan} [lsort [execsql { SELECT b FROM t1 ORDER BY rowid }]]
77bd0e9070Sdan
78bd0e9070Sdanfinish_test
79