Defer computing the number of bytes of free space on a btree page until that

value is actually needed.

FossilOrigin-Name: 177f5f40eabfcfd229ac7f291dfed9e9ee35762e86923a0f356915f389da177d
This commit is contained in:
drh
2019-02-12 01:04:49 +00:00
7 changed files with 177 additions and 105 deletions
+8 -10
View File
@@ -95,11 +95,11 @@ do_test corrupt2-1.4 {
close $f
sqlite3 db2 corrupt.db
catchsql "
$::presql
SELECT * FROM sqlite_master;
" db2
} {1 {database disk image is malformed}}
# Note: This test is no longer meaningful due to the deferred computation
# of MemPage.nFree
catchsql {PRAGMA quick_check} db2
} {0 {{*** in database main ***
Page 1: free space corruption}}}
do_test corrupt2-1.5 {
db2 close
@@ -118,11 +118,9 @@ do_test corrupt2-1.5 {
close $f
sqlite3 db2 corrupt.db
catchsql "
$::presql
SELECT * FROM sqlite_master;
" db2
} {1 {database disk image is malformed}}
catchsql {PRAGMA quick_check} db2
} {0 {{*** in database main ***
Page 1: free space corruption}}}
db2 close
# Corrupt a database by having 2 indices of the same name:
+3 -2
View File
@@ -111,8 +111,9 @@ proc restore_file {} {
do_test corruptD-1.1.1 {
incr_change_counter
hexio_write test.db [expr 1024+1] FFFF
catchsql { SELECT * FROM t1 ORDER BY rowid }
} {1 {database disk image is malformed}}
catchsql { PRAGMA quick_check }
} {0 {{*** in database main ***
Page 2: free space corruption}}}
do_test corruptD-1.1.2 {
incr_change_counter
hexio_write test.db [expr 1024+1] [hexio_render_int32 1021]
+6
View File
@@ -68,9 +68,15 @@ do_test 1.2 {
do_execsql_test 1.3 {
INSERT INTO t1 VALUES(randomblob(20));
}
# This test no longer functions due to the deferred computation of
# MemPage.nFree.
#
if 0 {
do_catchsql_test 1.4 {
INSERT INTO t1 VALUES(randomblob(90));
} {1 {database disk image is malformed}}
}
#-------------------------------------------------------------------------
reset_db