Test cases for the cache_spill pragma.

FossilOrigin-Name: b85c9ec5e02c1b92faa8eeb9e56e02a576a43a96
This commit is contained in:
drh 2013-08-17 00:25:07 +00:00
parent 40c3941cfa
commit d4b5c60eca
3 changed files with 57 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C Add\sthe\scache_spill\spragma.
D 2013-08-16T20:42:20.550
C Test\scases\sfor\sthe\scache_spill\spragma.
D 2013-08-17T00:25:07.417
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -716,7 +716,7 @@ F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025
F test/percentile.test b98fc868d71eb5619d42a1702e9ab91718cbed54
F test/permutations.test 461ef4ea10db02cd421dfe5f988eac3e99b5cd9a
F test/pragma.test 5e7de6c32a5d764f09437d2025f07e4917b9e178
F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947
F test/pragma2.test 5bc62f356ad2ea64ec2b931fd4189485c9518d58
F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552
F test/progress.test 552dc1edc37333a8d3098b8c26a2b7f06f5799d7
F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc
@ -1105,10 +1105,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
P f2d175f975cd0be63425424ec322a98fb650019e
R 51784bade3c91fc13297b6a9e11bfbe0
T *branch * cache_spill
T *sym-cache_spill *
T -sym-trunk *
P cdb181c04fa99c6c29f23eb68ccb5475e7f6bf9c
R 4fb024de498b67ffd161eb735de52cba
U drh
Z 6759e9990b6aac3480039cd24c99d255
Z e0fbe7fca060e30f944a0c3b1b2c8e44

View File

@ -1 +1 @@
cdb181c04fa99c6c29f23eb68ccb5475e7f6bf9c
b85c9ec5e02c1b92faa8eeb9e56e02a576a43a96

View File

@ -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,53 @@ ifcapable attach {
} {9 9}
}
# Default setting of PRAGMA cache_spill is always ON
#
db close
delete_file test.db test.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;
PRAGMA cache_spill=ON;
} {}
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
finish_test