Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: third_party/sqlite/test/pcache.test

Issue 3108030: Move bundled copy of sqlite one level deeper to better separate it... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/sqlite/test/pagesize.test ('k') | third_party/sqlite/test/pcache2.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # 2008 August 29
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 # This file is focused on testing the pcache module.
13 #
14 # $Id: pcache.test,v 1.5 2009/05/08 06:52:48 danielk1977 Exp $
15
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
18
19
20 # The pcache module limits the number of pages available to purgeable
21 # caches to the sum of the 'cache_size' values for the set of open
22 # caches. This block of tests, pcache-1.*, test that the library behaves
23 # corrctly when it is forced to exceed this limit.
24 #
25 do_test pcache-1.1 {
26 db close
27 pcache_stats
28 } {current 0 max 0 min 0 recyclable 0}
29
30 do_test pcache-1.2 {
31 sqlite3 db test.db
32 execsql {
33 PRAGMA cache_size=12;
34 PRAGMA auto_vacuum=0;
35 }
36 pcache_stats
37 } {current 1 max 12 min 10 recyclable 1}
38
39 do_test pcache-1.3 {
40 execsql {
41 BEGIN;
42 CREATE TABLE t1(a, b, c);
43 CREATE TABLE t2(a, b, c);
44 CREATE TABLE t3(a, b, c);
45 CREATE TABLE t4(a, b, c);
46 CREATE TABLE t5(a, b, c);
47 }
48 pcache_stats
49 } {current 6 max 12 min 10 recyclable 0}
50
51 do_test pcache-1.4 {
52 execsql {
53 CREATE TABLE t6(a, b, c);
54 CREATE TABLE t7(a, b, c);
55 CREATE TABLE t8(a, b, c);
56 CREATE TABLE t9(a, b, c);
57 }
58 pcache_stats
59 } {current 10 max 12 min 10 recyclable 0}
60
61 do_test pcache-1.5 {
62 sqlite3 db2 test.db
63 execsql "PRAGMA cache_size=10" db2
64 pcache_stats
65 } {current 11 max 22 min 20 recyclable 1}
66
67 do_test pcache-1.6.1 {
68 execsql {
69 BEGIN;
70 SELECT * FROM sqlite_master;
71 } db2
72 pcache_stats
73 } {current 11 max 22 min 20 recyclable 0}
74
75 # At this point connection db2 has a read lock on the database file and a
76 # single pinned page in its cache. Connection [db] is holding 10 dirty
77 # pages. It cannot recycle them because of the read lock held by db2.
78 #
79 do_test pcache-1.6.2 {
80 execsql {
81 CREATE INDEX i1 ON t1(a, b);
82 CREATE INDEX i2 ON t2(a, b);
83 CREATE INDEX i3 ON t3(a, b);
84 CREATE INDEX i4 ON t4(a, b);
85 CREATE INDEX i5 ON t5(a, b);
86 CREATE INDEX i6 ON t6(a, b);
87 CREATE INDEX i7 ON t7(a, b);
88 CREATE INDEX i8 ON t8(a, b);
89 CREATE INDEX i9 ON t9(a, b);
90 CREATE INDEX i10 ON t9(a, b);
91 CREATE INDEX i11 ON t9(a, b);
92 }
93 pcache_stats
94 } {current 23 max 22 min 20 recyclable 0}
95
96 do_test pcache-1.7 {
97 execsql {
98 CREATE TABLE t10(a, b, c);
99 }
100 pcache_stats
101 } {current 24 max 22 min 20 recyclable 0}
102
103 # Rolling back the transaction held by db2 at this point releases a pinned
104 # page. Because the number of allocated pages is greater than the
105 # configured maximum, this page should be freed immediately instead of
106 # recycled.
107 #
108 do_test pcache-1.8 {
109 execsql {ROLLBACK} db2
110 pcache_stats
111 } {current 23 max 22 min 20 recyclable 0}
112
113 do_test pcache-1.9 {
114 execsql COMMIT
115 pcache_stats
116 } {current 22 max 22 min 20 recyclable 22}
117
118 do_test pcache-1.10 {
119 db2 close
120 pcache_stats
121 } {current 12 max 12 min 10 recyclable 12}
122
123 do_test pcache-1.11 {
124 execsql { PRAGMA cache_size = 20 }
125 pcache_stats
126 } {current 12 max 20 min 10 recyclable 12}
127
128 do_test pcache-1.12 {
129 execsql {
130 SELECT * FROM t1 ORDER BY a; SELECT * FROM t1;
131 SELECT * FROM t2 ORDER BY a; SELECT * FROM t2;
132 SELECT * FROM t3 ORDER BY a; SELECT * FROM t3;
133 SELECT * FROM t4 ORDER BY a; SELECT * FROM t4;
134 SELECT * FROM t5 ORDER BY a; SELECT * FROM t5;
135 SELECT * FROM t6 ORDER BY a; SELECT * FROM t6;
136 SELECT * FROM t7 ORDER BY a; SELECT * FROM t7;
137 SELECT * FROM t8 ORDER BY a; SELECT * FROM t8;
138 SELECT * FROM t9 ORDER BY a; SELECT * FROM t9;
139 }
140 pcache_stats
141 } {current 19 max 20 min 10 recyclable 19}
142
143 do_test pcache-1.13 {
144 execsql { PRAGMA cache_size = 15 }
145 pcache_stats
146 } {current 15 max 15 min 10 recyclable 15}
147
148 do_test pcache-1.14 {
149 hexio_write test.db 24 [hexio_render_int32 1000]
150 execsql { SELECT * FROM sqlite_master }
151 pcache_stats
152 } {current 2 max 15 min 10 recyclable 2}
153
154 do_test pcache-1.15 {
155 execsql {
156 SELECT * FROM t1 ORDER BY a; SELECT * FROM t1;
157 SELECT * FROM t2 ORDER BY a; SELECT * FROM t2;
158 SELECT * FROM t3 ORDER BY a; SELECT * FROM t3;
159 SELECT * FROM t4 ORDER BY a; SELECT * FROM t4;
160 SELECT * FROM t5 ORDER BY a; SELECT * FROM t5;
161 SELECT * FROM t6 ORDER BY a; SELECT * FROM t6;
162 SELECT * FROM t7 ORDER BY a; SELECT * FROM t7;
163 SELECT * FROM t8 ORDER BY a; SELECT * FROM t8;
164 SELECT * FROM t9 ORDER BY a; SELECT * FROM t9;
165 }
166 pcache_stats
167 } {current 14 max 15 min 10 recyclable 14}
168
169 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/test/pagesize.test ('k') | third_party/sqlite/test/pcache2.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698