mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Fix some tests in malloc5.test to account for the sqlite3_release_memory()
change in the previous commit. FossilOrigin-Name: d336858dfcfb9539c43582b1443911df825f9af7146957734bc6f01c8f4d98e3
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Fix\sthe\ssqlite3_release_memory()\sinterface\sso\sthat\sit\sworks\seven\sif\nSQLITE_DEFAULT_PCACHE_INITSZ\sis\snon-zero.
|
C Fix\ssome\stests\sin\smalloc5.test\sto\saccount\sfor\sthe\ssqlite3_release_memory()\nchange\sin\sthe\sprevious\scommit.
|
||||||
D 2017-03-29T15:18:40.905
|
D 2017-03-29T16:55:23.235
|
||||||
F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb
|
F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb
|
||||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||||
F Makefile.msc 1faf9f06aadc9284c212dea7bbc7c0dea7e8337f0287c81001eff500912c790a
|
F Makefile.msc 1faf9f06aadc9284c212dea7bbc7c0dea7e8337f0287c81001eff500912c790a
|
||||||
@@ -939,7 +939,7 @@ F test/make-where7.tcl 05c16b5d4f5d6512881dfec560cb793915932ef9
|
|||||||
F test/malloc.test 21c213365f2cca95ab2d7dc078dc8525f96065f8
|
F test/malloc.test 21c213365f2cca95ab2d7dc078dc8525f96065f8
|
||||||
F test/malloc3.test e3b32c724b5a124b57cb0ed177f675249ad0c66a
|
F test/malloc3.test e3b32c724b5a124b57cb0ed177f675249ad0c66a
|
||||||
F test/malloc4.test 957337613002b7058a85116493a262f679f3a261
|
F test/malloc4.test 957337613002b7058a85116493a262f679f3a261
|
||||||
F test/malloc5.test 192d0b5ee1d023a07d5164c34cf47d010da73da1
|
F test/malloc5.test a591be066ebc6ad34adaa4b38939a037a59ebd80ad681e79dedac7b4a9e7bc09
|
||||||
F test/malloc6.test 2f039d9821927eacae43e1831f815e157659a151
|
F test/malloc6.test 2f039d9821927eacae43e1831f815e157659a151
|
||||||
F test/malloc7.test 7c68a32942858bc715284856c5507446bba88c3a
|
F test/malloc7.test 7c68a32942858bc715284856c5507446bba88c3a
|
||||||
F test/malloc8.test 9b7a3f8cb9cf0b12fff566e80a980b1767bd961d
|
F test/malloc8.test 9b7a3f8cb9cf0b12fff566e80a980b1767bd961d
|
||||||
@@ -1569,7 +1569,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 8469fc0d48d6af0accef9b8a84e08ad2ca32351907510d177b4ca4815c1ea7cb
|
P 5d902b7fea3144bf57f02aca87b9795fdcec4774310ade6ef01f37d206c3d74f
|
||||||
R 723c73ce75ba5d602a30ca6a02a92d57
|
R b34a64973f50dfefc35323bb58d30845
|
||||||
U drh
|
U dan
|
||||||
Z 0cd616785f0e67ca6b1ab11d9b71f146
|
Z 6677e2c642118fa2c5f8a791ca8e31e4
|
||||||
|
@@ -1 +1 @@
|
|||||||
5d902b7fea3144bf57f02aca87b9795fdcec4774310ade6ef01f37d206c3d74f
|
d336858dfcfb9539c43582b1443911df825f9af7146957734bc6f01c8f4d98e3
|
@@ -39,11 +39,27 @@ ifcapable !memorymanage {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# The sizes of memory allocations from system malloc() might vary,
|
||||||
|
# depending on the memory allocator algorithms used. The following
|
||||||
|
# routine is designed to support answers that fall within a range
|
||||||
|
# of values while also supplying easy-to-understand "expected" values
|
||||||
|
# when errors occur.
|
||||||
|
#
|
||||||
|
proc value_in_range {target x args} {
|
||||||
|
set v [lindex $args 0]
|
||||||
|
if {$v!=""} {
|
||||||
|
if {$v<$target*$x} {return $v}
|
||||||
|
if {$v>$target/$x} {return $v}
|
||||||
|
}
|
||||||
|
return "number between [expr {int($target*$x)}] and [expr {int($target/$x)}]"
|
||||||
|
}
|
||||||
|
set mrange 0.98 ;# plus or minus 2%
|
||||||
|
|
||||||
test_set_config_pagecache 0 100
|
test_set_config_pagecache 0 100
|
||||||
|
|
||||||
sqlite3_soft_heap_limit 0
|
sqlite3_soft_heap_limit 0
|
||||||
sqlite3 db test.db
|
sqlite3 db test.db
|
||||||
db eval {PRAGMA cache_size=1}
|
# db eval {PRAGMA cache_size=1}
|
||||||
|
|
||||||
do_test malloc5-1.1 {
|
do_test malloc5-1.1 {
|
||||||
# Simplest possible test. Call sqlite3_release_memory when there is exactly
|
# Simplest possible test. Call sqlite3_release_memory when there is exactly
|
||||||
@@ -71,24 +87,8 @@ do_test malloc5-1.3 {
|
|||||||
# in the cache belonging to db2.
|
# in the cache belonging to db2.
|
||||||
#
|
#
|
||||||
set ::pgalloc [sqlite3_release_memory]
|
set ::pgalloc [sqlite3_release_memory]
|
||||||
} {0}
|
value_in_range 1288 0.75
|
||||||
|
} [value_in_range 1288 0.75]
|
||||||
# The sizes of memory allocations from system malloc() might vary,
|
|
||||||
# depending on the memory allocator algorithms used. The following
|
|
||||||
# routine is designed to support answers that fall within a range
|
|
||||||
# of values while also supplying easy-to-understand "expected" values
|
|
||||||
# when errors occur.
|
|
||||||
#
|
|
||||||
proc value_in_range {target x args} {
|
|
||||||
set v [lindex $args 0]
|
|
||||||
if {$v!=""} {
|
|
||||||
if {$v<$target*$x} {return $v}
|
|
||||||
if {$v>$target/$x} {return $v}
|
|
||||||
}
|
|
||||||
return "number between [expr {int($target*$x)}] and [expr {int($target/$x)}]"
|
|
||||||
}
|
|
||||||
set mrange 0.98 ;# plus or minus 2%
|
|
||||||
|
|
||||||
|
|
||||||
do_test malloc5-1.4 {
|
do_test malloc5-1.4 {
|
||||||
# Commit the transaction and open a new one. Read 1 page into the cache.
|
# Commit the transaction and open a new one. Read 1 page into the cache.
|
||||||
@@ -117,12 +117,12 @@ do_test malloc5-1.6 {
|
|||||||
db2 close
|
db2 close
|
||||||
execsql {
|
execsql {
|
||||||
BEGIN;
|
BEGIN;
|
||||||
SELECT * FROM abc;
|
|
||||||
CREATE TABLE def(d, e, f);
|
CREATE TABLE def(d, e, f);
|
||||||
|
SELECT * FROM abc;
|
||||||
}
|
}
|
||||||
|
breakpoint
|
||||||
value_in_range $::pgalloc $::mrange [sqlite3_release_memory 500]
|
value_in_range $::pgalloc $::mrange [sqlite3_release_memory 500]
|
||||||
} [value_in_range $::pgalloc $::mrange]
|
} [value_in_range $::pgalloc $::mrange]
|
||||||
|
|
||||||
do_test malloc5-1.7 {
|
do_test malloc5-1.7 {
|
||||||
# Database should not be locked this time.
|
# Database should not be locked this time.
|
||||||
sqlite3 db2 test.db
|
sqlite3 db2 test.db
|
||||||
@@ -346,7 +346,7 @@ do_test malloc5-6.2.2 {
|
|||||||
# If we now try to reclaim some memory, it should come from the db2 cache.
|
# If we now try to reclaim some memory, it should come from the db2 cache.
|
||||||
sqlite3_release_memory 3000
|
sqlite3_release_memory 3000
|
||||||
expr [nPage db] + [nPage db2]
|
expr [nPage db] + [nPage db2]
|
||||||
} {4}
|
} {1}
|
||||||
do_test malloc5-6.2.3 {
|
do_test malloc5-6.2.3 {
|
||||||
# Access the db2 cache again, so that all the db2 pages have been used
|
# Access the db2 cache again, so that all the db2 pages have been used
|
||||||
# more recently than all the db pages. Then try to reclaim 3000 bytes.
|
# more recently than all the db pages. Then try to reclaim 3000 bytes.
|
||||||
@@ -354,7 +354,7 @@ do_test malloc5-6.2.3 {
|
|||||||
execsql { SELECT * FROM abc } db2
|
execsql { SELECT * FROM abc } db2
|
||||||
sqlite3_release_memory 3000
|
sqlite3_release_memory 3000
|
||||||
expr [nPage db] + [nPage db2]
|
expr [nPage db] + [nPage db2]
|
||||||
} {4}
|
} {0}
|
||||||
|
|
||||||
do_test malloc5-6.3.1 {
|
do_test malloc5-6.3.1 {
|
||||||
# Now open a transaction and update 2 pages in the db2 cache. Then
|
# Now open a transaction and update 2 pages in the db2 cache. Then
|
||||||
@@ -364,6 +364,8 @@ do_test malloc5-6.3.1 {
|
|||||||
# sync() to free up the dirty db2 pages. The only page that cannot be
|
# sync() to free up the dirty db2 pages. The only page that cannot be
|
||||||
# freed is page1 of db2. Because there is an open transaction, the
|
# freed is page1 of db2. Because there is an open transaction, the
|
||||||
# btree layer holds a reference to page 1 in the db2 cache.
|
# btree layer holds a reference to page 1 in the db2 cache.
|
||||||
|
#
|
||||||
|
# UPDATE: No longer. As release_memory() does not cause a sync()
|
||||||
execsql {
|
execsql {
|
||||||
BEGIN;
|
BEGIN;
|
||||||
UPDATE abc SET c = randstr(100,100)
|
UPDATE abc SET c = randstr(100,100)
|
||||||
@@ -377,13 +379,13 @@ do_test malloc5-6.3.2 {
|
|||||||
# non-dirty pages held by db2.
|
# non-dirty pages held by db2.
|
||||||
sqlite3_release_memory [expr 7*1132]
|
sqlite3_release_memory [expr 7*1132]
|
||||||
list [nPage db] [nPage db2]
|
list [nPage db] [nPage db2]
|
||||||
} {1 3}
|
} {0 3}
|
||||||
do_test malloc5-6.3.3 {
|
do_test malloc5-6.3.3 {
|
||||||
# Try to release another 1000 bytes. This should come fromt the db
|
# Try to release another 1000 bytes. This should come fromt the db
|
||||||
# cache, since all three pages held by db2 are either in-use or diry.
|
# cache, since all three pages held by db2 are either in-use or diry.
|
||||||
sqlite3_release_memory 1000
|
sqlite3_release_memory 1000
|
||||||
list [nPage db] [nPage db2]
|
list [nPage db] [nPage db2]
|
||||||
} {1 3}
|
} {0 3}
|
||||||
do_test malloc5-6.3.4 {
|
do_test malloc5-6.3.4 {
|
||||||
# Now release 9900 more (about 9 pages worth). This should expunge
|
# Now release 9900 more (about 9 pages worth). This should expunge
|
||||||
# the rest of the db cache. But the db2 cache remains intact, because
|
# the rest of the db cache. But the db2 cache remains intact, because
|
||||||
@@ -394,20 +396,20 @@ do_test malloc5-6.3.4 {
|
|||||||
sqlite3_release_memory 9900
|
sqlite3_release_memory 9900
|
||||||
}
|
}
|
||||||
list [nPage db] [nPage db2]
|
list [nPage db] [nPage db2]
|
||||||
} {1 3}
|
} {0 3}
|
||||||
do_test malloc5-6.3.5 {
|
do_test malloc5-6.3.5 {
|
||||||
# But if we are really insistent, SQLite will consent to call sync()
|
# But if we are really insistent, SQLite will consent to call sync()
|
||||||
# if there is no other option. UPDATE: As of 3.6.2, SQLite will not
|
# if there is no other option. UPDATE: As of 3.6.2, SQLite will not
|
||||||
# call sync() in this scenario. So no further memory can be reclaimed.
|
# call sync() in this scenario. So no further memory can be reclaimed.
|
||||||
sqlite3_release_memory 1000
|
sqlite3_release_memory 1000
|
||||||
list [nPage db] [nPage db2]
|
list [nPage db] [nPage db2]
|
||||||
} {1 3}
|
} {0 3}
|
||||||
do_test malloc5-6.3.6 {
|
do_test malloc5-6.3.6 {
|
||||||
# The referenced page (page 1 of the db2 cache) will not be freed no
|
# The referenced page (page 1 of the db2 cache) will not be freed no
|
||||||
# matter how much memory we ask for:
|
# matter how much memory we ask for:
|
||||||
sqlite3_release_memory 31459
|
sqlite3_release_memory 31459
|
||||||
list [nPage db] [nPage db2]
|
list [nPage db] [nPage db2]
|
||||||
} {1 3}
|
} {0 3}
|
||||||
|
|
||||||
db2 close
|
db2 close
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user