3
# The author disclaims copyright to this source code. In place of
4
# a legal notice, here is a blessing:
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.
10
#***********************************************************************
12
# This file is focused on testing the pcache module.
14
# $Id: pcache2.test,v 1.5 2009/07/18 14:36:24 danielk1977 Exp $
16
set testdir [file dirname $argv0]
17
source $testdir/tester.tcl
20
# Set up a pcache memory pool so that we can easily track how many
21
# pages are being used for cache.
25
sqlite3_reset_auto_extension
27
sqlite3_config_pagecache 6000 100
29
autoinstall_test_functions
30
sqlite3_status SQLITE_STATUS_PAGECACHE_USED 1
31
sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0
34
# Open up two database connections to separate files.
37
file delete -force test.db test.db-journal
39
db eval {PRAGMA cache_size=10}
40
lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 1
43
file delete -force test2.db test2.db-journal
45
db2 eval {PRAGMA cache_size=50}
46
lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 1
50
# Make lots of changes on the first connection. Verify that the
51
# page cache usage does not grow to consume the page space set aside
52
# for the second connection.
58
INSERT INTO t1 VALUES(1, zeroblob(800));
59
INSERT INTO t1 VALUES(2, zeroblob(800));
60
INSERT INTO t2 SELECT * FROM t1;
61
INSERT INTO t1 SELECT x+2, y FROM t2;
62
INSERT INTO t2 SELECT a+10, b FROM t1;
63
INSERT INTO t1 SELECT x+10, y FROM t2;
64
INSERT INTO t2 SELECT a+100, b FROM t1;
65
INSERT INTO t1 SELECT x+100, y FROM t2;
66
INSERT INTO t2 SELECT a+1000, b FROM t1;
67
INSERT INTO t1 SELECT x+1000, y FROM t2;
69
sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0
74
sqlite3_reset_auto_extension
76
sqlite3_config_pagecache 0 0
78
autoinstall_test_functions