1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Use the read and write version fields of the database header to mark a database as operating in wal-mode.

FossilOrigin-Name: 96bef18c1411c3e0348295886f105e1646c46320
This commit is contained in:
dan
2010-04-20 18:53:15 +00:00
parent 8d22a17411
commit e04dc88be5
10 changed files with 327 additions and 128 deletions

View File

@ -31,6 +31,7 @@ proc blob {nByte} {
proc sqlite3_wal {args} {
eval sqlite3 $args
[lindex $args 0] eval { PRAGMA page_size = 1024 }
[lindex $args 0] eval { PRAGMA journal_mode = wal }
[lindex $args 0] eval { PRAGMA synchronous = normal }
[lindex $args 0] function blob blob
@ -60,14 +61,19 @@ do_test wal-0.1 {
execsql { PRAGMA synchronous = normal }
execsql { PRAGMA journal_mode = wal }
} {wal}
do_test wal-0.2 {
file size test.db
} {1024}
do_test wal-1.0 {
execsql {
BEGIN;
CREATE TABLE t1(a, b);
}
list [file exists test.db-journal] [file exists test.db-wal]
} {0 1}
list [file exists test.db-journal] \
[file exists test.db-wal] \
[file size test.db]
} {0 1 1024}
do_test wal-1.1 {
execsql COMMIT
list [file exists test.db-journal] [file exists test.db-wal]
@ -197,9 +203,10 @@ foreach sector {512 4096} {
foreach pgsz {512 1024 2048 4096} {
file delete -force test.db test.db-wal
do_test wal-6.$sector.$pgsz.1 {
sqlite3_wal db test.db -vfs devsym
sqlite3 db test.db -vfs devsym
execsql "
PRAGMA page_size = $pgsz ;
PRAGMA page_size = $pgsz;
PRAGMA journal_mode = wal;
"
execsql "
CREATE TABLE t1(a, b);
@ -224,7 +231,7 @@ do_test wal-7.1 {
INSERT INTO t1 VALUES(1, 2);
}
list [file size test.db] [file size test.db-wal]
} [list 0 [log_file_size 3 1024]]
} [list 1024 [log_file_size 3 1024]]
do_test wal-7.2 {
execsql { PRAGMA checkpoint }
list [file size test.db] [file size test.db-wal]
@ -235,11 +242,17 @@ do_test wal-7.2 {
#
do_test wal-8.1 {
reopen_db
catch { db close }
file delete -force test.db test.db-wal
sqlite3 db test.db
db function blob blob
execsql {
PRAGMA auto_vacuum = 1;
PRAGMA journal_mode = wal;
PRAGMA auto_vacuum;
}
} {1}
} {wal 1}
do_test wal-8.2 {
execsql {
PRAGMA page_size = 1024;
@ -269,7 +282,6 @@ do_test wal-8.3 {
do_test wal-9.1 {
reopen_db
execsql {
PRAGMA page_size = 1024;
CREATE TABLE t1(x PRIMARY KEY);
INSERT INTO t1 VALUES(blob(900));
INSERT INTO t1 VALUES(blob(900));
@ -282,7 +294,7 @@ do_test wal-9.1 {
INSERT INTO t1 SELECT blob(900) FROM t1; /* 256 */
}
file size test.db
} 0
} 1024
do_test wal-9.2 {
sqlite3_wal db2 test.db
execsql {PRAGMA integrity_check } db2
@ -560,7 +572,7 @@ do_test wal-11.1 {
CREATE TABLE t1(x PRIMARY KEY);
}
list [expr [file size test.db]/1024] [expr [file size test.db-wal]/1044]
} {0 3}
} {1 3}
do_test wal-11.2 {
execsql { PRAGMA checkpoint }
list [expr [file size test.db]/1024] [file size test.db-wal]
@ -613,7 +625,7 @@ do_test wal-11.10 {
SELECT count(*) FROM t1;
}
list [expr [file size test.db]/1024] [file size test.db-wal]
} [list 37 [log_file_size 35 1024]]
} [list 37 [log_file_size 37 1024]]
do_test wal-11.11 {
execsql {
SELECT count(*) FROM t1;
@ -623,7 +635,7 @@ do_test wal-11.11 {
} {32 16}
do_test wal-11.12 {
list [expr [file size test.db]/1024] [file size test.db-wal]
} [list 37 [log_file_size 35 1024]]
} [list 37 [log_file_size 37 1024]]
do_test wal-11.13 {
execsql {
INSERT INTO t1 VALUES( blob(900) );
@ -633,7 +645,7 @@ do_test wal-11.13 {
} {17 ok}
do_test wal-11.14 {
list [expr [file size test.db]/1024] [file size test.db-wal]
} [list 37 [log_file_size 35 1024]]
} [list 37 [log_file_size 37 1024]]
#-------------------------------------------------------------------------
@ -650,11 +662,12 @@ do_test wal-12.1 {
INSERT INTO t1 VALUES('A', 1);
}
list [expr [file size test.db]/1024] [file size test.db-wal]
} [list 0 [log_file_size 5 1024]]
} [list 1 [log_file_size 5 1024]]
do_test wal-12.2 {
db close
sqlite3_wal db test.db
sqlite3 db test.db
execsql {
PRAGMA synchronous = normal;
UPDATE t1 SET y = 0 WHERE x = 'A';
}
list [expr [file size test.db]/1024] [expr [file size test.db-wal]/1044]
@ -668,7 +681,6 @@ do_test wal-12.4 {
file copy -force test.db test2.db
file copy -force test.db-wal test2.db-wal
sqlite3_wal db2 test2.db
breakpoint
execsql { SELECT * FROM t2 } db2
} {B 1}
db2 close
@ -695,6 +707,5 @@ do_test wal-12.4 {
} {B 2}
db2 close
finish_test