Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/vacuummem.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / vacuummem.test` 74 lines ยท 1911 bytes Raw Blame History 1 # 2005 February 15 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 # This file implements regression tests for SQLite library. The 12 # focus of this file is testing that the VACUUM statement correctly 13 # frees any memory used for a temporary cache. 14 # 15 # TESTRUNNER: slow 16 17 set testdir [file dirname $argv0] 18 source $testdir/tester.tcl 19 set testprefix vacuummem 20 21 if {[permutation]=="memsubsys1"} { 22 finish_test 23 return 24 } 25 26 # If ENABLE_MEMORY_MANAGEMENT is defined, when VACUUM is run the temp db 27 # is able to borrow space from the main db (and it does, because the 28 # temp db is configure with a very small cache). When the VACUUM is 29 # finished and the temp db closed, all the page-cache memory currently 30 # assigned to the temp db is freed. If ENABLE_MEMORY_MANAGEMENT is defined 31 # this causes the total memory usage to drop much more than expected, 32 # causing tests in this file to fail. 33 # 34 ifcapable memorymanage { 35 finish_test 36 return 37 } 38 39 40 proc memory_used {} { 41 set stat [sqlite3_status SQLITE_STATUS_MEMORY_USED 1] 42 lindex $stat 1 43 } 44 45 do_execsql_test 1.0 { 46 PRAGMA cache_size = -2000; 47 CREATE TABLE t1(a, b, c); 48 49 WITH r(i) AS ( 50 SELECT 1 UNION ALL SELECT i+1 FROM r WHERE i<100000 51 ) 52 INSERT INTO t1 SELECT randomblob(100),randomblob(100),randomblob(100) FROM r; 53 54 CREATE INDEX t1a ON t1(a); 55 CREATE INDEX t1b ON t1(b); 56 CREATE INDEX t1c ON t1(c); 57 } 58 set ans "#/[memory_used]/" 59 60 do_test 1.1 { memory_used } $ans 61 62 do_execsql_test 1.2 VACUUM 63 64 do_test 1.3 { memory_used } $ans 65 66 do_execsql_test 1.4 { 67 SELECT count(*) FROM t1 WHERE +a IS NOT NULL 68 } {100000} 69 70 do_test 1.5 { memory_used } $ans 71 72 73 74 finish_test