interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / test / mmapwarm.test

81 lines · 1640 bytes Raw Blame History
1# 20 September 18
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#
12
13set testdir [file dirname $argv0]
14source $testdir/tester.tcl
15
16
17if 0 {
18 db close
19 sqlite3_shutdown
20 proc msg {args} { puts $args }
21 test_sqlite3_log msg
22 sqlite3 db test.db
23}
24
25set testprefix mmapwarm
26
27
28do_execsql_test 1.0 {
29 PRAGMA auto_vacuum = 0;
30 CREATE TABLE t1(x, y);
31 WITH s(i) AS (
32 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<500
33 )
34 INSERT INTO t1 SELECT randomblob(400), randomblob(500) FROM s;
35 PRAGMA page_count;
36} {507}
37db close
38
39do_test 1.1 {
40 sqlite3 db test.db
41 db eval {PRAGMA mmap_size = 1000000}
42 sqlite3_mmap_warm db
43} {SQLITE_OK}
44
45do_test 1.2 {
46 db close
47 sqlite3 db test.db
48 db eval {PRAGMA mmap_size = 1000000}
49 sqlite3_mmap_warm db "main"
50} {SQLITE_OK}
51
52do_test 1.3 {
53 sqlite3 db test.db
54 sqlite3_mmap_warm db
55} {SQLITE_OK}
56
57do_test 1.4 {
58 db close
59 sqlite3 db test.db
60 sqlite3_mmap_warm db "main"
61} {SQLITE_OK}
62
63do_test 2.0 {
64 db close
65 sqlite3 db test.db
66 db eval BEGIN
67 sqlite3_mmap_warm db "main"
68} {SQLITE_MISUSE}
69
70do_faultsim_test 3 -faults oom* -prep {
71 sqlite3 db test.db
72 sqlite3_db_config_lookaside db 0 0 0
73 db eval { PRAGMA mmap_size = 1000000 }
74 db eval { SELECT * FROM sqlite_master }
75} -body {
76 sqlite3_mmap_warm db "main"
77} -test {
78 faultsim_test_result {0 SQLITE_OK} {0 SQLITE_NOMEM}
79}
80
81finish_test