1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

When opening a write-transaction on a database file that has been appended to or truncated by a pre-3.7.0 client, update the database-size field in the database header. Fix for [51ae9cad31].

FossilOrigin-Name: 65b8636ac6e5d3e4502d4f576ddf9350d5df3022
This commit is contained in:
dan
2010-08-04 11:34:31 +00:00
parent a3e414cd48
commit 59257dc615
6 changed files with 152 additions and 23 deletions

View File

@ -117,5 +117,80 @@ ifcapable pager_pragmas {
} {1 {file is encrypted or is not a database}}
}
#-------------------------------------------------------------------------
# The following block of tests - filefmt-2.* - test that versions 3.7.0
# and later can read and write databases that have been modified or created
# by 3.6.23.1 and earlier. The difference difference is that 3.7.0 stores
# the size of the database in the database file header, whereas 3.6.23.1
# always derives this from the size of the file.
#
db close
file delete -force test.db
set a_string_counter 1
proc a_string {n} {
incr ::a_string_counter
string range [string repeat "${::a_string_counter}." $n] 1 $n
}
sqlite3 db test.db
db func a_string a_string
do_execsql_test filefmt-2.1.1 {
PRAGMA page_size = 1024;
PRAGMA auto_vacuum = 0;
CREATE TABLE t1(a);
CREATE INDEX i1 ON t1(a);
INSERT INTO t1 VALUES(a_string(3000));
CREATE TABLE t2(a);
INSERT INTO t2 VALUES(1);
} {}
do_test filefmt-2.1.2 {
hexio_read test.db 28 4
} {00000009}
do_test filefmt-2.1.3 {
sql36231 { INSERT INTO t1 VALUES(a_string(3000)) }
} {}
do_execsql_test filefmt-2.1.4 { INSERT INTO t2 VALUES(2) } {}
integrity_check filefmt-2.1.5
do_test filefmt-2.1.6 { hexio_read test.db 28 4 } {00000010}
db close
file delete -force test.db
sqlite3 db test.db
db func a_string a_string
do_execsql_test filefmt-2.2.1 {
PRAGMA page_size = 1024;
PRAGMA auto_vacuum = 0;
CREATE TABLE t1(a);
CREATE INDEX i1 ON t1(a);
INSERT INTO t1 VALUES(a_string(3000));
CREATE TABLE t2(a);
INSERT INTO t2 VALUES(1);
} {}
do_test filefmt-2.2.2 {
hexio_read test.db 28 4
} {00000009}
do_test filefmt-2.2.3 {
sql36231 { INSERT INTO t1 VALUES(a_string(3000)) }
} {}
do_execsql_test filefmt-2.2.4 {
PRAGMA integrity_check;
BEGIN;
INSERT INTO t2 VALUES(2);
SAVEPOINT a;
INSERT INTO t2 VALUES(3);
ROLLBACK TO a;
} {ok}
integrity_check filefmt-2.2.5
do_execsql_test filefmt-2.2.6 { COMMIT } {}
db close
sqlite3 db test.db
integrity_check filefmt-2.2.7
finish_test