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

Unified Diff: third_party/sqlite/src/test/cache.test

Issue 6990047: Import SQLite 3.7.6.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/test/boundary4.test ('k') | third_party/sqlite/src/test/capi2.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/test/cache.test
diff --git a/third_party/sqlite/src/test/cache.test b/third_party/sqlite/src/test/cache.test
index dd51c7cd1f1482f422960970bb0d4e8e344f4c88..8d801f05998775228d2c95acc8ba8bcc0ab14196 100644
--- a/third_party/sqlite/src/test/cache.test
+++ b/third_party/sqlite/src/test/cache.test
@@ -28,9 +28,9 @@ proc pager_cache_size {db} {
return $stats(page)
}
-do_test cache-1.1 {
- pager_cache_size db
-} {0}
+if {[permutation] == ""} {
+ do_test cache-1.1 { pager_cache_size db } {0}
+}
do_test cache-1.2 {
execsql {
@@ -51,13 +51,90 @@ do_test cache-1.2 {
#
set cache_size [pager_cache_size db]
for {set ii 0} {$ii < 10} {incr ii} {
-
do_test cache-1.3.$ii {
execsql {SELECT * FROM abc}
pager_cache_size db
} $::cache_size
+}
+
+#-------------------------------------------------------------------------
+# This block of tests checks that it is possible to set the cache_size of a
+# database to a small (< 10) value. More specifically:
+#
+# cache-2.1.*: Test that "PRAGMA cache_size" appears to work with small
+# values.
+# cache-2.2.*: Test that "PRAGMA main.cache_size" appears to work with
+# small values.
+# cache-2.3.*: Test cache_size=1 correctly spills/flushes the cache.
+# cache-2.4.*: Test cache_size=0 correctly spills/flushes the cache.
+#
+#
+db_delete_and_reopen
+do_execsql_test cache-2.0 {
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA journal_mode=DELETE;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(c, d);
+ INSERT INTO t1 VALUES('x', 'y');
+ INSERT INTO t2 VALUES('i', 'j');
+} {delete}
+for {set i 0} {$i < 20} {incr i} {
+ do_execsql_test cache-2.1.$i.1 "PRAGMA cache_size = $i"
+ do_execsql_test cache-2.1.$i.2 "PRAGMA cache_size" $i
+ do_execsql_test cache-2.1.$i.3 "SELECT * FROM t1" {x y}
+ do_execsql_test cache-2.1.$i.4 "PRAGMA cache_size" $i
}
-sqlite3_soft_heap_limit $soft_limit
+for {set i 0} {$i < 20} {incr i} {
+ do_execsql_test cache-2.2.$i.1 "PRAGMA main.cache_size = $i"
+ do_execsql_test cache-2.2.$i.2 "PRAGMA main.cache_size" $i
+ do_execsql_test cache-2.2.$i.3 "SELECT * FROM t1" {x y}
+ do_execsql_test cache-2.2.$i.4 "PRAGMA main.cache_size" $i
+}
+
+# Tests for cache_size = 1.
+#
+do_execsql_test cache-2.3.1 {
+ PRAGMA cache_size = 1;
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ PRAGMA lock_status;
+} {main reserved temp closed}
+do_test cache-2.3.2 { pager_cache_size db } 2
+do_execsql_test cache-2.3.3 {
+ INSERT INTO t2 VALUES(1, 2);
+ PRAGMA lock_status;
+} {main exclusive temp closed}
+do_test cache-2.3.4 { pager_cache_size db } 2
+do_execsql_test cache-2.3.5 COMMIT
+do_test cache-2.3.6 { pager_cache_size db } 1
+
+do_execsql_test cache-2.3.7 {
+ SELECT * FROM t1 UNION SELECT * FROM t2;
+} {1 2 i j x y}
+do_test cache-2.3.8 { pager_cache_size db } 1
+
+# Tests for cache_size = 0.
+#
+do_execsql_test cache-2.4.1 {
+ PRAGMA cache_size = 0;
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ PRAGMA lock_status;
+} {main reserved temp closed}
+do_test cache-2.4.2 { pager_cache_size db } 2
+do_execsql_test cache-2.4.3 {
+ INSERT INTO t2 VALUES(1, 2);
+ PRAGMA lock_status;
+} {main exclusive temp closed}
+do_test cache-2.4.4 { pager_cache_size db } 2
+do_execsql_test cache-2.4.5 COMMIT
+
+do_test cache-2.4.6 { pager_cache_size db } 0
+do_execsql_test cache-2.4.7 {
+ SELECT * FROM t1 UNION SELECT * FROM t2;
+} {1 2 i j x y}
+do_test cache-2.4.8 { pager_cache_size db } 0
+sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
finish_test
« no previous file with comments | « third_party/sqlite/src/test/boundary4.test ('k') | third_party/sqlite/src/test/capi2.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698