| 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 87c3c5d04e6926410558bf4892c71c187ed1000a..0dbc9777d261ffe8d7d770f3bf395fc1df9cd150 100644
|
| --- a/third_party/sqlite/src/test/pragma2.test
|
| +++ b/third_party/sqlite/src/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 {
|
| @@ -33,8 +34,8 @@ ifcapable !pragma||!schema_pragmas {
|
| # that the "all.test" script does.
|
| #
|
| db close
|
| -file delete test.db test.db-journal
|
| -file delete test3.db test3.db-journal
|
| +delete_file test.db test.db-journal
|
| +delete_file test3.db test3.db-journal
|
| sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
|
| db eval {PRAGMA auto_vacuum=0}
|
|
|
| @@ -61,8 +62,8 @@ do_test pragma2-1.4 {
|
| }
|
| } {1}
|
|
|
| -file delete -force test2.db
|
| -file delete -force test2.db-journal
|
| +forcedelete test2.db
|
| +forcedelete test2.db-journal
|
|
|
| ifcapable attach {
|
| do_test pragma2-2.1 {
|
| @@ -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
|
|
|