github.com/jdgcs/sqlite3@v1.12.1-0.20210908114423-bc5f96e4dd51/testdata/tcl/cachespill.test (about) 1 # 2017 April 26 2 # 3 # The author disclaims copyright to this source code. In place of 4 # a legal notice, here is a blessing: 5 # 6 # May you do good and not evil. 7 # May you find forgiveness for yourself and forgive others. 8 # May you share freely, never taking more than you give. 9 # 10 #*********************************************************************** 11 # 12 13 set testdir [file dirname $argv0] 14 source $testdir/tester.tcl 15 set testprefix cachespill 16 17 ifcapable !pager_pragmas { 18 finish_test 19 return 20 } 21 22 #------------------------------------------------------------------------- 23 # Test that "PRAGMA cache_spill = 0" completely disables cache spilling. 24 # 25 do_execsql_test 1.1 { 26 PRAGMA auto_vacuum = 0; 27 PRAGMA page_size = 1024; 28 PRAGMA cache_size = 100; 29 CREATE TABLE t1(a); 30 } 31 32 do_test 1.2 { 33 file size test.db 34 } {2048} 35 36 do_test 1.3 { 37 execsql { 38 BEGIN; 39 WITH s(i) AS ( 40 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<200 41 ) INSERT INTO t1 SELECT randomblob(900) FROM s; 42 } 43 expr {[file size test.db] > 50000} 44 } {1} 45 46 do_test 1.4 { 47 execsql ROLLBACK 48 file size test.db 49 } {2048} 50 51 do_test 1.5 { 52 execsql { 53 PRAGMA cache_spill = 0; 54 BEGIN; 55 WITH s(i) AS ( 56 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<200 57 ) INSERT INTO t1 SELECT randomblob(900) FROM s; 58 } 59 file size test.db 60 } {2048} 61 62 do_test 1.5 { 63 execsql { 64 ROLLBACK; 65 PRAGMA cache_spill = 1; 66 BEGIN; 67 WITH s(i) AS ( 68 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<200 69 ) INSERT INTO t1 SELECT randomblob(900) FROM s; 70 } 71 expr {[file size test.db] > 50000} 72 } {1} 73 74 do_execsql_test 1.6 { ROLLBACK } 75 76 77 finish_test