Index: third_party/sqlite/src/test/pragma2.test |
diff --git a/third_party/sqlite/src/test/pragma2.test b/third_party/sqlite/src/test/pragma2.test |
index 0dbc9777d261ffe8d7d770f3bf395fc1df9cd150..a4fb2ce657a187153ad3e7cda72466df8e627507 100644 |
--- a/third_party/sqlite/src/test/pragma2.test |
+++ b/third_party/sqlite/src/test/pragma2.test |
@@ -30,6 +30,8 @@ ifcapable !pragma||!schema_pragmas { |
return |
} |
+test_set_config_pagecache 0 0 |
+ |
# Delete the preexisting database to avoid the special setup |
# that the "all.test" script does. |
# |
@@ -39,6 +41,10 @@ delete_file test3.db test3.db-journal |
sqlite3 db test.db; set DB [sqlite3_connection_pointer db] |
db eval {PRAGMA auto_vacuum=0} |
+ |
+# EVIDENCE-OF: R-11211-21323 PRAGMA schema.freelist_count; Return the |
+# number of unused pages in the database file. |
+# |
do_test pragma2-1.1 { |
execsql { |
PRAGMA freelist_count; |
@@ -119,8 +125,8 @@ ifcapable attach { |
# Default setting of PRAGMA cache_spill is always ON |
# |
-# EVIDENCE-OF: R-51036-62828 PRAGMA cache_spill; PRAGMA |
-# cache_spill=boolean; |
+# EVIDENCE-OF: R-63549-59887 PRAGMA cache_spill; PRAGMA |
+# cache_spill=boolean; PRAGMA schema.cache_spill=N; |
# |
# EVIDENCE-OF: R-23955-02765 Cache_spill is enabled by default |
# |
@@ -129,10 +135,12 @@ 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 main.cache_size=2000; |
+ PRAGMA temp.cache_size=2000; |
PRAGMA cache_spill; |
PRAGMA main.cache_spill; |
PRAGMA temp.cache_spill; |
-} {1 1 1} |
+} {2000 2000 2000} |
do_execsql_test pragma2-4.2 { |
PRAGMA cache_spill=OFF; |
PRAGMA cache_spill; |
@@ -172,21 +180,61 @@ do_test pragma2-4.4 { |
PRAGMA lock_status; |
} |
} {main exclusive temp unknown} ;# EXCLUSIVE lock due to cache spill |
-do_test pragma2-4.5 { |
+do_test pragma2-4.5.1 { |
db eval { |
- COMMIT; |
+ ROLLBACK; |
PRAGMA cache_spill=OFF; |
+ PRAGMA Cache_Spill; |
BEGIN; |
- UPDATE t1 SET c=c-1; |
+ UPDATE t1 SET c=c+1; |
PRAGMA lock_status; |
} |
-} {main reserved temp unknown} ;# No cache spill, so no exclusive lock |
+} {0 main reserved temp unknown} ;# No cache spill, so no exclusive lock |
+ |
+ |
+# EVIDENCE-OF: R-34657-61226 The "PRAGMA cache_spill=N" form of this |
+# pragma sets a minimum cache size threshold required for spilling to |
+# occur. |
+do_test pragma2-4.5.2 { |
+ db eval { |
+ ROLLBACK; |
+ PRAGMA cache_spill=100000; |
+ PRAGMA cache_spill; |
+ BEGIN; |
+ UPDATE t1 SET c=c+1; |
+ PRAGMA lock_status; |
+ } |
+} {100000 main reserved temp unknown} ;# Big spill threshold -> no excl lock |
+ifcapable !memorymanage { |
+ do_test pragma2-4.5.3 { |
+ db eval { |
+ ROLLBACK; |
+ PRAGMA cache_spill=25; |
+ PRAGMA main.cache_spill; |
+ BEGIN; |
+ UPDATE t1 SET c=c+1; |
+ PRAGMA lock_status; |
+ } |
+ } {50 main exclusive temp unknown} ;# Small cache spill -> exclusive lock |
+ do_test pragma2-4.5.4 { |
+ db eval { |
+ ROLLBACK; |
+ PRAGMA cache_spill(-25); |
+ PRAGMA main.cache_spill; |
+ BEGIN; |
+ UPDATE t1 SET c=c+1; |
+ PRAGMA lock_status; |
+ } |
+ } {50 main exclusive temp unknown} ;# Small cache spill -> exclusive lock |
+} |
+ |
# Verify that newly attached databases inherit the cache_spill=OFF |
# setting. |
# |
do_execsql_test pragma2-4.6 { |
- COMMIT; |
+ ROLLBACK; |
+ PRAGMA cache_spill=OFF; |
ATTACH 'test2.db' AS aux1; |
PRAGMA aux1.cache_size=50; |
BEGIN; |
@@ -203,6 +251,26 @@ do_execsql_test pragma2-4.8 { |
UPDATE t2 SET c=c-1; |
PRAGMA lock_status; |
} {main unlocked temp unknown aux1 exclusive} |
- |
+db close |
+forcedelete test.db |
+sqlite3 db test.db |
+breakpoint |
+do_execsql_test pragma2-5.1 { |
+ PRAGMA page_size=16384; |
+ CREATE TABLE t1(x); |
+ PRAGMA cache_size=2; |
+ PRAGMA cache_spill=YES; |
+ PRAGMA cache_spill; |
+} {2} |
+do_execsql_test pragma2-5.2 { |
+ PRAGMA cache_spill=NO; |
+ PRAGMA cache_spill; |
+} {0} |
+do_execsql_test pragma2-5.3 { |
+ PRAGMA cache_spill(-51); |
+ PRAGMA cache_spill; |
+} {3} |
+ |
+test_restore_config_pagecache |
finish_test |