aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifest28
-rw-r--r--manifest.uuid2
-rw-r--r--src/test_vfs.c19
-rw-r--r--test/pager1.test123
-rw-r--r--test/pager2.test4
5 files changed, 127 insertions, 49 deletions
diff --git a/manifest b/manifest
index 5b39f49e1..5a161b0e4 100644
--- a/manifest
+++ b/manifest
@@ -1,8 +1,5 @@
------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA1
-
-C Merge\sthe\sexperimental\sUNDELETABLE_WHEN_OPEN\soptimization\sinto\sthe\strunk.
-D 2010-06-21T12:47:41
+C Add\stest\scases\sto\spager1.test\sand\spager2.test.
+D 2010-06-21T18:29:41
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -212,7 +209,7 @@ F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0
F src/test_server.c bbba05c144b5fc4b52ff650a4328027b3fa5fcc6
F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa
F src/test_thread.c aa9919c885a1fe53eafc73492f0898ee6c0a0726
-F src/test_vfs.c 9ba0bb227f5fa08d7e3533ff21063c5acf13dabb
+F src/test_vfs.c f1b4398e7e2daf0f16ddff41f04135084fce9b2f
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
F src/tokenize.c 25ceb0f0a746ea1d0f9553787f3f0a56853cfaeb
F src/trigger.c 8927588cb9e6d47f933b53bfe74200fbb504100d
@@ -537,8 +534,8 @@ F test/notify2.test 195a467e021f74197be2c4fb02d6dee644b8d8db
F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347
F test/null.test a8b09b8ed87852742343b33441a9240022108993
F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec
-F test/pager1.test 86d034bf3ffe4e99648714443776440d0555f705
-F test/pager2.test ad062a51030dc1e2749f506528db4cc5bae6474c
+F test/pager1.test 07e839e5a712dbc4dcad99fdb4a05f32b5ce7146
+F test/pager2.test f5c757c271ce642d36a393ecbfb3aef1c240dcef
F test/pagerfault.test e67e9c18bf7b4bb8cc8d458d3a5ecc980f18a225
F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806
F test/pagesize.test 76aa9f23ecb0741a4ed9d2e16c5fa82671f28efb
@@ -828,14 +825,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 822a0283c6bc1c75001f3d1c528a4ff89c6b039c a64d96db09ef2b7651fa4e98d3c7bf3ae5d3fe96
-R aa81338105a8066f92038016780c9df7
-U drh
-Z e0549d09ee79c82d436d5aa9bbd618a3
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
-
-iD8DBQFMH19xoxKgR168RlERAt6AAJ96RqboVXAAENNG3NTV/9NSo4zbEgCghTxO
-GuKlnNnL+XTagpq68iLKUhk=
-=R4ik
------END PGP SIGNATURE-----
+P ee0acef1faffd480fd2136f81fb2b6f6a17b5388
+R 998ebf709f9a701de3ca0479eb0006bb
+U dan
+Z 7d285ff240ba302f82034a80af5fa58d
diff --git a/manifest.uuid b/manifest.uuid
index e41f233b0..6545457b1 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-ee0acef1faffd480fd2136f81fb2b6f6a17b5388 \ No newline at end of file
+cc9ddae6d72b214f52b8949e644b91f4ab340a28 \ No newline at end of file
diff --git a/src/test_vfs.c b/src/test_vfs.c
index 46f3a0630..7d37430a1 100644
--- a/src/test_vfs.c
+++ b/src/test_vfs.c
@@ -90,7 +90,7 @@ struct Testvfs {
#define TESTVFS_ALL_MASK 0x00003FFF
-#define TESTVFS_MAX_PAGES 256
+#define TESTVFS_MAX_PAGES 1024
/*
** A shared-memory buffer. There is one of these objects for each shared
@@ -907,20 +907,23 @@ static int testvfs_obj_cmd(
if( objc==4 ){
int n;
u8 *a = Tcl_GetByteArrayFromObj(objv[3], &n);
- assert( pBuffer->pgsz==0 || pBuffer->pgsz==32768 );
- for(i=0; i*32768<n; i++){
- int nByte = 32768;
- tvfsAllocPage(pBuffer, i, 32768);
- if( n-i*32768<32768 ){
+ int pgsz = pBuffer->pgsz;
+ if( pgsz==0 ) pgsz = 32768;
+ for(i=0; i*pgsz<n; i++){
+ int nByte = pgsz;
+ tvfsAllocPage(pBuffer, i, pgsz);
+ if( n-i*pgsz<pgsz ){
nByte = n;
}
- memcpy(pBuffer->aPage[i], &a[i*32768], nByte);
+ memcpy(pBuffer->aPage[i], &a[i*pgsz], nByte);
}
}
pObj = Tcl_NewObj();
for(i=0; pBuffer->aPage[i]; i++){
- Tcl_AppendObjToObj(pObj, Tcl_NewByteArrayObj(pBuffer->aPage[i], 32768));
+ int pgsz = pBuffer->pgsz;
+ if( pgsz==0 ) pgsz = 32768;
+ Tcl_AppendObjToObj(pObj, Tcl_NewByteArrayObj(pBuffer->aPage[i], pgsz));
}
Tcl_SetObjResult(interp, pObj);
break;
diff --git a/test/pager1.test b/test/pager1.test
index f7a821b6d..b733fc9b2 100644
--- a/test/pager1.test
+++ b/test/pager1.test
@@ -31,6 +31,8 @@ source $testdir/wal_common.tcl
#
# pager1-7.*: Cases specific to "PRAGMA journal_mode=TRUNCATE"
#
+# pager1-8.*: Cases using temporary and in-memory databases.
+#
set a_string_counter 1
proc a_string {n} {
@@ -179,7 +181,7 @@ do_multiclient_test tn {
#-------------------------------------------------------------------------
# Savepoint related test cases.
#
-do_test pager1-3.1 {
+do_test pager1-3.1.1 {
faultsim_delete_and_reopen
execsql {
CREATE TABLE t1(a PRIMARY KEY, b);
@@ -198,14 +200,14 @@ do_test pager1-3.1 {
execsql { SELECT * FROM counter }
} {0 0}
-do_execsql_test pager1-3.2 {
+do_execsql_test pager1-3.1.2 {
BEGIN;
INSERT INTO t1 VALUES(1, randomblob(1500));
INSERT INTO t1 VALUES(2, randomblob(1500));
INSERT INTO t1 VALUES(3, randomblob(1500));
SELECT * FROM counter;
} {3 0}
-do_catchsql_test pager1-3.3 {
+do_catchsql_test pager1-3.1.3 {
INSERT INTO t1 SELECT a+3, randomblob(1500) FROM t1
} {1 {constraint failed}}
do_execsql_test pager1-3.4 { SELECT * FROM counter } {3 0}
@@ -500,6 +502,75 @@ foreach {tn1 tcl} {
}
db close
tv delete
+file delete -force $dirname
+
+
+# Set up a VFS to make a copy of the file-system just before deleting a
+# journal file to commit a transaction. The transaction modifies exactly
+# two database pages (and page 1 - the change counter).
+#
+testvfs tv -default 1
+tv sectorsize 512
+tv script copy_on_journal_delete
+tv filter xDelete
+set ::mj_filename_length 0
+proc copy_on_journal_delete {method filename args} {
+ if {[string match *journal $filename]} faultsim_save
+ return SQLITE_OK
+}
+faultsim_delete_and_reopen
+do_execsql_test pager1.4.5.1 {
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ INSERT INTO t1 VALUES('I', 'II');
+ INSERT INTO t2 VALUES('III', 'IV');
+ BEGIN;
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t2 VALUES(3, 4);
+ COMMIT;
+} {}
+tv filter {}
+
+# Check the transaction was committed:
+#
+do_execsql_test pager1.4.5.2 {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+} {I II 1 2 III IV 3 4}
+
+# Now try three tests:
+#
+# pager1-4.5.3: Restore the file-system. Check that the whole transaction
+# is rolled back.
+#
+# pager1-4.5.4: Restore the file-system. Corrupt the first record in the
+# journal. Check the transaction is not rolled back.
+#
+# pager1-4.5.5: Restore the file-system. Corrupt the second record in the
+# journal. Check that the first record in the transaction is
+# played back, but not the second.
+#
+faultsim_restore_and_reopen
+do_execsql_test pager1.4.5.3 {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+} {I II III IV}
+faultsim_restore_and_reopen
+hexio_write test.db-journal [expr 512+4+1024 - 202] 0123456789ABCDEF
+do_execsql_test pager1.4.5.4 {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+} {I II 1 2 III IV 3 4}
+faultsim_restore_and_reopen
+hexio_write test.db-journal [expr 512+4+1024+4+4+1024 - 202] 0123456789ABCDEF
+do_execsql_test pager1.4.5.5 {
+ SELECT * FROM t1;
+ SELECT * FROM t2;
+} {I II III IV 3 4}
+
+db close
+tv delete
#-------------------------------------------------------------------------
# The following tests deal with multi-file commits.
@@ -724,23 +795,35 @@ foreach {tn sql res js ws} [subst {
do_test pager1-7.1.$tn.2 { list $J $W } [list $js $ws]
}
-do_test pager1-8.1 {
- faultsim_delete_and_reopen
- db close
- sqlite3 db :memory:
- execsql {
- CREATE TABLE x1(x);
- INSERT INTO x1 VALUES('Charles');
- INSERT INTO x1 VALUES('James');
- INSERT INTO x1 VALUES('Mary');
- SELECT * FROM x1;
- }
-} {Charles James Mary}
-do_test pager1-8.2 {
- db close
- sqlite3 db :memory:
- catchsql { SELECT * FROM x1 }
-} {1 {no such table: x1}}
+foreach {tn filename} {
+ 1 :memory:
+ 2 ""
+} {
+ do_test pager1-8.$tn.1 {
+ faultsim_delete_and_reopen
+ db close
+ sqlite3 db $filename
+ execsql {
+ CREATE TABLE x1(x);
+ INSERT INTO x1 VALUES('Charles');
+ INSERT INTO x1 VALUES('James');
+ INSERT INTO x1 VALUES('Mary');
+ SELECT * FROM x1;
+ }
+ } {Charles James Mary}
+
+ do_test pager1-8.$tn.2 {
+ sqlite3 db2 $filename
+ catchsql { SELECT * FROM x1 } db2
+ } {1 {no such table: x1}}
+
+ do_execsql_test pager1-8.$tn.3 {
+ BEGIN;
+ INSERT INTO x1 VALUES('William');
+ INSERT INTO x1 VALUES('Anne');
+ ROLLBACK;
+ } {}
+}
finish_test
diff --git a/test/pager2.test b/test/pager2.test
index 855850f05..977d45f91 100644
--- a/test/pager2.test
+++ b/test/pager2.test
@@ -37,6 +37,9 @@ foreach code [list {
set s 4096
set sql { PRAGMA journal_mode = WAL }
} {
+ set s 4096
+ set sql { PRAGMA auto_vacuum = 1 }
+} {
set s 8192
set sql { PRAGMA synchronous = off }
}] {
@@ -113,5 +116,4 @@ foreach code [list {
db close
tv delete
-
finish_test