- C Only\sopen\sa\sread-only\sconnection\sto\sshared-memory\sif\sthe\s"readonly_shm=1"\soption\sis\sspecified\sas\spart\sof\sthe\sdatabase\sfile\sURI\s(and\sif\sa\sread-write\sconnection\sfails).
- D 2011-05-11T14:57:33.029
-C Have\sflags\spassed\sto\ssqlite3_open_v2()\sapply\sto\sthe\smain\sand\sany\sattached\sdatabases.\sAnd\schange\sthings\sso\sthat\sany\s"mode=xxx"\sor\s"cache=xxx"\soptions\sspecified\sas\spart\sof\sa\sURI\sfor\sthe\smain\sdatabase\sdo\snot\salso\sapply\sto\sattached\sdatabases.
-D 2011-05-10T18:39:10.068
++C Merge\slatest\strunk\schanges.\sAdd\sa\scouple\sof\sreadonly\sshm\stests.
++D 2011-05-11T15:53:16.929
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85
- F src/main.c 167fb3285720917e4d1a5c633f558c81b751eca3
-F src/main.c e32d7a44c3307a4a33cfd1a2b06fb46f418ba7fc
++F src/main.c 951a1af49d13083da09be9d2464052e49fc25830
F src/malloc.c 591aedb20ae40813f1045f2ef253438a334775d9
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff
F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79
- F src/sqlite.h.in e7bbcb330ced6b5e25c9db8089c2c77aaefadf7d
-F src/sqlite.h.in 6e1af9733864bacbb4b5b821290f5395319f3259
++F src/sqlite.h.in 059514ec27c8f9e11c73695aa57e55d354973e1e
F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754
-F src/sqliteInt.h b34bd64a7ade4808fcc301e0bb67ef5051ea49c6
+F src/sqliteInt.h 798fb09648cefc159ac9b3ce5e00f5ada1377ed1
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
F src/status.c 7ac64842c86cec2fc1a1d0e5c16d3beb8ad332bf
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483
F test/walmode.test 22ddccd073c817ac9ead62b88ac446e8dedc7d2c
F test/walnoshm.test a074428046408f4eb5c6a00e09df8cc97ff93317
- F test/walro.test c204f62fb6a77839bc6ce5adbdcc9df2aac877ca
++F test/walro.test 1f15853383a976ff8bbec78dd44bc15c4e237392
F test/walshared.test 6dda2293880c300baf5d791c307f653094585761
F test/walslow.test d21625e2e99e11c032ce949e8a94661576548933
F test/walthread.test a25a393c068a2b42b44333fa3fdaae9072f1617c
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
- P bb59f9862da45d25fb51d7821130854828c91c98
- R 04ad06f1f1eb20213db6e513d8bb75aa
-P 5bde568028216f5bbf76fa0b61bf5b736699f4b1
-R 109bc7e0fff78b0c6554d3e5815c2cd8
++P 671ba5fc59f7a958e5a4138d2425b1173a442ad7 3e490915301216e242a5cdeb0febaff12ed53cb9
++R 1feba9025b47c541dc5cefaffc74e97e
U dan
- Z 112f0ce43ba9dc957c26d5146ee2fe50
-Z 5955a7caf010dc14908da2de85096565
++Z af31082504210cb42f7a67f58917a8ef
nocaseCollatingFunc, 0);
/* Parse the filename/URI argument. */
- rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);
+ db->openFlags = flags;
+ rc = sqlite3ParseUri(
+ zVfs, zFilename, &flags, &btflags, &db->pVfs, &zOpen, &zErrMsg);
if( rc!=SQLITE_OK ){
if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;
sqlite3Error(db, rc, zErrMsg ? "%s" : 0, zErrMsg);
}
/* Open the backend database driver */
- db->openFlags = flags;
- rc = sqlite3BtreeOpen(db->pVfs, zOpen, db, &db->aDb[0].pBt, 0,
+ rc = sqlite3BtreeOpen(db->pVfs, zOpen, db, &db->aDb[0].pBt, btflags,
flags | SQLITE_OPEN_MAIN_DB);
if( rc!=SQLITE_OK ){
if( rc==SQLITE_IOERR_NOMEM ){
--- /dev/null
+# 2011 May 09
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests for using WAL databases in read-only mode.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+set ::testprefix walro
+
+
+do_multiclient_test tn {
+ # These tests are only going to work on unix.
+ #
+ if {$tcl_platform(platform) != "unix"} continue
+
+ # Do not run tests with the connections in the same process.
+ #
+ if {$tn==2} continue
+
+ # Close all connections and delete the database.
+ #
+ code1 { db close }
+ code2 { db2 close }
+ code3 { db3 close }
+ forcedelete test.db
+ forcedelete walro
+
+ foreach c {code1 code2 code3} {
+ $c {
+ sqlite3_shutdown
+ sqlite3_config_uri 1
+ }
+ }
+
+ file mkdir walro
+
+ do_test 1.1.1 {
+ code2 { sqlite3 db2 test.db }
+ sql2 {
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(x, y);
+ INSERT INTO t1 VALUES('a', 'b');
+ }
+ file exists test.db-shm
+ } {1}
+
+ do_test 1.1.2 {
+ file attributes test.db-shm -permissions r--r--r--
+ code1 { sqlite3 db file:test.db?readonly_shm=1 }
+ } {}
+
+ do_test 1.1.3 { sql1 "SELECT * FROM t1" } {a b}
+ do_test 1.1.4 { sql2 "INSERT INTO t1 VALUES('c', 'd')" } {}
+ do_test 1.1.5 { sql1 "SELECT * FROM t1" } {a b c d}
+
+ # Check that the read-only connection cannot write or checkpoint the db.
+ #
+ do_test 1.1.6 {
+ csql1 "INSERT INTO t1 VALUES('e', 'f')"
+ } {1 {attempt to write a readonly database}}
+ do_test 1.1.7 {
+ csql1 "PRAGMA wal_checkpoint"
+ } {1 {attempt to write a readonly database}}
+
+ do_test 1.1.9 { sql2 "INSERT INTO t1 VALUES('e', 'f')" } {}
+ do_test 1.1.10 { sql1 "SELECT * FROM t1" } {a b c d e f}
+
+ do_test 1.1.11 {
+ sql2 {
+ INSERT INTO t1 VALUES('g', 'h');
+ PRAGMA wal_checkpoint;
+ }
+ set {} {}
+ } {}
+ do_test 1.1.12 { sql1 "SELECT * FROM t1" } {a b c d e f g h}
+ do_test 1.1.13 { sql2 "INSERT INTO t1 VALUES('i', 'j')" } {}
+
+ do_test 1.2.1 {
+ code2 { db2 close }
+ code1 { db close }
+ list [file exists test.db-wal] [file exists test.db-shm]
+ } {1 1}
+ do_test 1.2.2 {
+ code1 { sqlite3 db file:test.db?readonly_shm=1 }
+ sql1 { SELECT * FROM t1 }
+ } {a b c d e f g h i j}
+
+ do_test 1.2.3 {
+ code1 { db close }
+ file attributes test.db-shm -permissions rw-r--r--
+ hexio_write test.db-shm 0 01020304
+ file attributes test.db-shm -permissions r--r--r--
+ code1 { sqlite3 db file:test.db?readonly_shm=1 }
+ csql1 { SELECT * FROM t1 }
+ } {1 {attempt to write a readonly database}}
+ do_test 1.2.4 {
+ code1 { sqlite3_extended_errcode db }
+ } {SQLITE_READONLY_RECOVERY}
+
+ do_test 1.2.5 {
+ file attributes test.db-shm -permissions rw-r--r--
+ code2 { sqlite3 db2 test.db }
+ sql2 "SELECT * FROM t1"
+ } {a b c d e f g h i j}
+ file attributes test.db-shm -permissions r--r--r--
+ do_test 1.2.6 { sql1 "SELECT * FROM t1" } {a b c d e f g h i j}
+
+ do_test 1.2.7 {
+ sql2 {
+ PRAGMA wal_checkpoint;
+ INSERT INTO t1 VALUES('k', 'l');
+ }
+ set {} {}
+ } {}
+ do_test 1.2.8 { sql1 "SELECT * FROM t1" } {a b c d e f g h i j k l}
++
++ # Now check that if the readonly_shm option is not supplied, or if it
++ # is set to zero, it is not possible to connect to the database without
++ # read-write access to the shm.
++ do_test 1.3.1 {
++ code1 { db close }
++ code1 { sqlite3 db test.db }
++ csql1 { SELECT * FROM t1 }
++ } {1 {unable to open database file}}
++
++ # Also test that if the -shm file can be opened for read/write access,
++ # it is, even if readonly_shm=1 is present in the URI.
++ do_test 1.3.2.1 {
++ code1 { db close }
++ code2 { db2 close }
++ file exists test.db-shm
++ } {0}
++ do_test 1.3.2.2 {
++ code1 { sqlite3 db file:test.db?readonly_shm=1 }
++ sql1 { SELECT * FROM t1 }
++ } {a b c d e f g h i j k l}
++ do_test 1.3.2.3 {
++ code1 { db close }
++ close [open test.db-shm w]
++ file attributes test.db-shm -permissions r--r--r--
++ code1 { sqlite3 db file:test.db?readonly_shm=1 }
++ csql1 { SELECT * FROM t1 }
++ } {1 {attempt to write a readonly database}}
++ do_test 1.3.2.4 {
++ code1 { sqlite3_extended_errcode db }
++ } {SQLITE_READONLY_RECOVERY}
+}
+
+finish_test