summaryrefslogtreecommitdiff
path: root/test/pragma2.test
diff options
context:
space:
mode:
Diffstat (limited to 'test/pragma2.test')
-rw-r--r--test/pragma2.test89
1 files changed, 89 insertions, 0 deletions
diff --git a/test/pragma2.test b/test/pragma2.test
index 1111a98..0dbc977 100644
--- a/test/pragma2.test
+++ b/test/pragma2.test
@@ -22,6 +22,7 @@ source $testdir/tester.tcl
# pragma2-1.*: Test freelist_count pragma on the main database.
# pragma2-2.*: Test freelist_count pragma on an attached database.
# pragma2-3.*: Test trying to write to the freelist_count is a no-op.
+# pragma2-4.*: Tests for PRAGMA cache_spill
#
ifcapable !pragma||!schema_pragmas {
@@ -116,4 +117,92 @@ ifcapable attach {
} {9 9}
}
+# Default setting of PRAGMA cache_spill is always ON
+#
+# EVIDENCE-OF: R-51036-62828 PRAGMA cache_spill; PRAGMA
+# cache_spill=boolean;
+#
+# EVIDENCE-OF: R-23955-02765 Cache_spill is enabled by default
+#
+db close
+delete_file test.db test.db-journal
+delete_file test2.db test2.db-journal
+sqlite3 db test.db
+do_execsql_test pragma2-4.1 {
+ PRAGMA cache_spill;
+ PRAGMA main.cache_spill;
+ PRAGMA temp.cache_spill;
+} {1 1 1}
+do_execsql_test pragma2-4.2 {
+ PRAGMA cache_spill=OFF;
+ PRAGMA cache_spill;
+ PRAGMA main.cache_spill;
+ PRAGMA temp.cache_spill;
+} {0 0 0}
+do_execsql_test pragma2-4.3 {
+ PRAGMA page_size=1024;
+ PRAGMA cache_size=50;
+ BEGIN;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d);
+ INSERT INTO t1 VALUES(1, randomblob(400), 1, randomblob(400));
+ INSERT INTO t1 SELECT a+1, randomblob(400), a+1, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+2, randomblob(400), a+2, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+4, randomblob(400), a+4, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+8, randomblob(400), a+8, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+16, randomblob(400), a+16, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+32, randomblob(400), a+32, randomblob(400) FROM t1;
+ INSERT INTO t1 SELECT a+64, randomblob(400), a+64, randomblob(400) FROM t1;
+ COMMIT;
+ ATTACH 'test2.db' AS aux1;
+ CREATE TABLE aux1.t2(a INTEGER PRIMARY KEY, b, c, d);
+ INSERT INTO t2 SELECT * FROM t1;
+ DETACH aux1;
+ PRAGMA cache_spill=ON;
+} {}
+sqlite3_release_memory
+#
+# EVIDENCE-OF: R-07634-40532 The cache_spill pragma enables or disables
+# the ability of the pager to spill dirty cache pages to the database
+# file in the middle of a transaction.
+#
+do_test pragma2-4.4 {
+ db eval {
+ BEGIN;
+ UPDATE t1 SET c=c+1;
+ PRAGMA lock_status;
+ }
+} {main exclusive temp unknown} ;# EXCLUSIVE lock due to cache spill
+do_test pragma2-4.5 {
+ db eval {
+ COMMIT;
+ PRAGMA cache_spill=OFF;
+ BEGIN;
+ UPDATE t1 SET c=c-1;
+ PRAGMA lock_status;
+ }
+} {main reserved temp unknown} ;# No cache spill, so no exclusive lock
+
+# Verify that newly attached databases inherit the cache_spill=OFF
+# setting.
+#
+do_execsql_test pragma2-4.6 {
+ COMMIT;
+ ATTACH 'test2.db' AS aux1;
+ PRAGMA aux1.cache_size=50;
+ BEGIN;
+ UPDATE t2 SET c=c+1;
+ PRAGMA lock_status;
+} {main unlocked temp unknown aux1 reserved}
+do_execsql_test pragma2-4.7 {
+ COMMIT;
+}
+sqlite3_release_memory
+do_execsql_test pragma2-4.8 {
+ PRAGMA cache_spill=ON; -- Applies to all databases
+ BEGIN;
+ UPDATE t2 SET c=c-1;
+ PRAGMA lock_status;
+} {main unlocked temp unknown aux1 exclusive}
+
+
finish_test