From 89441bf185b7d6ee79164bcc4198eaff0e98fe2e Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 21 Jul 2016 16:43:54 +0000 Subject: [PATCH] Add new test file vacuummem.test. To test that any temporary memory used by VACUUM is freed as soon as the VACUUM has finished (not, for example, when sqlite3_close() is finally called). FossilOrigin-Name: 1b1ad0b28c392ade4321734e9b022a545b845b04 --- manifest | 11 ++++----- manifest.uuid | 2 +- test/vacuummem.test | 54 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 test/vacuummem.test diff --git a/manifest b/manifest index 9a69ac1bf0..d47aa8101b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\slargely\suntested\sSQLITE_FTS5_NO_WITHOUT_ROWID\scompile\stime\soption\sto\sfts5.\sFor\sbuilding\sa\sdynamically\sloadable\sextension\sthat\sdoes\snot\suse\sWITHOUT\sROWID. -D 2016-07-15T19:17:19.168 +C Add\snew\stest\sfile\svacuummem.test.\sTo\stest\sthat\sany\stemporary\smemory\sused\sby\sVACUUM\sis\sfreed\sas\ssoon\sas\sthe\sVACUUM\shas\sfinished\s(not,\sfor\sexample,\swhen\ssqlite3_close()\sis\sfinally\scalled). +D 2016-07-21T16:43:54.563 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc d66d0395c38571aab3804f8db0fa20707ae4609a @@ -1323,6 +1323,7 @@ F test/vacuum.test ce91c39f7f91a4273bf620efad21086b5aa6ef1d F test/vacuum2.test aa048abee196c16c9ba308465494009057b79f9b F test/vacuum3.test 77ecdd54592b45a0bcb133339f99f1ae0ae94d0d F test/vacuum4.test d3f8ecff345f166911568f397d2432c16d2867d9 +F test/vacuummem.test 09c8b72a12405649ed84564367dad729bff88760 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661 F test/view.test 765802c7a66d37fabd5ac8e2f2dbe572b43eb9ab @@ -1505,7 +1506,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ec7180892ac737f0731cf61f2d095a5c1d18ad93 -R e7e67692a9bf28fabbef5b90b609823b +P d0a1cf1c56c237617fb73cb31f4950365b1f3e9b +R c861801c1aa1bd5e3e0533101c0a9583 U dan -Z 6e92686cc60df8d9ecf6a38e315fe4e5 +Z 9b35e9b2fd0052d524acf36a9f5b4f2b diff --git a/manifest.uuid b/manifest.uuid index 6d86586167..9af2c82fe3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d0a1cf1c56c237617fb73cb31f4950365b1f3e9b \ No newline at end of file +1b1ad0b28c392ade4321734e9b022a545b845b04 \ No newline at end of file diff --git a/test/vacuummem.test b/test/vacuummem.test new file mode 100644 index 0000000000..967e28cec7 --- /dev/null +++ b/test/vacuummem.test @@ -0,0 +1,54 @@ +# 2005 February 15 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus of this file is testing that the VACUUM statement correctly +# frees any memory used for a temporary cache. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix vacuummem + +proc memory_used {} { + set stat [sqlite3_status SQLITE_STATUS_MEMORY_USED 1] + lindex $stat 1 +} + +do_execsql_test 1.0 { + PRAGMA cache_size = -2000; + CREATE TABLE t1(a, b, c); + + WITH r(i) AS ( + SELECT 1 UNION ALL SELECT i+1 FROM r WHERE i<100000 + ) + INSERT INTO t1 SELECT randomblob(100),randomblob(100),randomblob(100) FROM r; + + CREATE INDEX t1a ON t1(a); + CREATE INDEX t1b ON t1(b); + CREATE INDEX t1c ON t1(c); +} + +do_test 1.1 { memory_used } {#/2300000/} + +do_execsql_test 1.2 VACUUM + +do_test 1.3 { memory_used } {#/2300000/} + +do_execsql_test 1.4 { + SELECT count(*) FROM t1 WHERE +a IS NOT NULL +} {100000} + +do_test 1.5 { memory_used } {#/2300000/} + + + +finish_test +