]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Changes to wal.c so that SQLite can read even if the WAL file is opened read-only...
authordan <dan@noemail.net>
Thu, 15 Jul 2010 18:20:53 +0000 (18:20 +0000)
committerdan <dan@noemail.net>
Thu, 15 Jul 2010 18:20:53 +0000 (18:20 +0000)
FossilOrigin-Name: 932d19da73c9673cdd4cc01289b17761c23d23cb

manifest
manifest.uuid
src/wal.c
test/wal2.test

index 59bd74df4c95a6d701fea8b6204eef0c1a69f8f4..813f6951320b1dfb059979431921afee59aae470 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Handle\sthe\scase\swhere\sxShmMap\sreturns\sSQLITE_BUSY.
-D 2010-07-15T17:54:15
+C Changes\sto\swal.c\sso\sthat\sSQLite\scan\sread\seven\sif\sthe\sWAL\sfile\sis\sopened\sread-only,\sprovided\sthe\swal-index\s(shm\sfile)\sis\sopened\sread/write.
+D 2010-07-15T18:20:54
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -227,7 +227,7 @@ F src/vdbeblob.c 258a6010ba7a82b72b327fb24c55790655689256
 F src/vdbemem.c 5e579abf6532001dfbee0e640dc34eae897a9807
 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2
 F src/vtab.c a0f8a40274e4261696ef57aa806de2776ab72cda
-F src/wal.c 66e9034aa9076ce2dbf9ac1ba9fbb9d52ef77c52
+F src/wal.c 0925601f3299c2941a67c9cfff41ee710f70ca82
 F src/wal.h 906c85760598b18584921fe08008435aa4eeeeb2
 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
 F src/where.c 903a7828a0a7de03b5d0f1b5eff222d8d5b138f1
@@ -778,7 +778,7 @@ F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
 F test/vtab_shared.test 0eff9ce4f19facbe0a3e693f6c14b80711a4222d
 F test/wal.test 1891e6f72dd437a1c2a48091aa9182ba17a8f780
-F test/wal2.test 7c50a38aa9f0b7c7144d5556d7f30b61febfc929
+F test/wal2.test fa6dc4457b46988f46cf6c68ea51ebe341765f4a
 F test/wal3.test d2ae7e66f973bd6b58ce49e546b2c00f44fe0485
 F test/wal4.test 640be93f5422df37203aa5e7c06b24fb5e4a2439
 F test/wal_common.tcl 895d76138043b86bdccf36494054bdabcf65837b
@@ -836,7 +836,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P a121cd80c5ac94e5977bc3164d2500e0ea132fed
-R b291f8d91c6eb25a36e00bd7f65fa871
+P 75f5354876c4300a8e53fe551dc837dd383d1e38
+R 5fdef461b56aef5e86f35d4620ab20d6
 U dan
-Z 6941f09d52700154471a2c362441f818
+Z 679f6331e7be3f40e18fcb4456a4e594
index 773df511729a4e819b3b1237f1e8c4108bfa6a77..14909f0e44b6bb995d3c80d12340d36d4b2ae367 100644 (file)
@@ -1 +1 @@
-75f5354876c4300a8e53fe551dc837dd383d1e38
\ No newline at end of file
+932d19da73c9673cdd4cc01289b17761c23d23cb
\ No newline at end of file
index 261bed196320d037e148a1c2709f5343b64f2adf..54274640ed6f4092481c92fe77d17fc33227606b 100644 (file)
--- a/src/wal.c
+++ b/src/wal.c
@@ -415,6 +415,7 @@ struct Wal {
   u8 exclusiveMode;          /* Non-zero if connection is in exclusive mode */
   u8 writeLock;              /* True if in a write transaction */
   u8 ckptLock;               /* True if holding a checkpoint lock */
+  u8 readOnly;               /* True if the WAL file is open read-only */
   WalIndexHdr hdr;           /* Wal-index header for current transaction */
   const char *zWalName;      /* Name of WAL file */
   u32 nCkpt;                 /* Checkpoint sequence counter in the wal-header */
@@ -1227,7 +1228,7 @@ int sqlite3WalOpen(
   flags = (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_WAL);
   rc = sqlite3OsOpen(pVfs, zWalName, pRet->pWalFd, flags, &flags);
   if( rc==SQLITE_OK && flags&SQLITE_OPEN_READONLY ){
-    rc = SQLITE_CANTOPEN;
+    pRet->readOnly = 1;
   }
 
   if( rc!=SQLITE_OK ){
@@ -2180,6 +2181,10 @@ int sqlite3WalBeginWriteTransaction(Wal *pWal){
   ** transaction. */
   assert( pWal->readLock>=0 );
 
+  if( pWal->readOnly ){
+    return SQLITE_READONLY;
+  }
+
   /* Only one writer allowed at a time.  Get the write lock.  Return
   ** SQLITE_BUSY if unable.
   */
index 630abeeaee0856a7515eb05be874c65a68d2f360..c4d7fa7bc510a7f9acc7c8eacdb1e9018ac66b41 100644 (file)
@@ -1088,7 +1088,7 @@ if {$::tcl_platform(platform) == "unix"} {
 
   foreach {tn db_perm wal_perm shm_perm can_open can_read can_write} {
     2   00644   00644   00644   1   1   1
-    3   00644   00400   00644   1   0   0
+    3   00644   00400   00644   1   1   0
     4   00644   00644   00400   1   0   0
     5   00400   00644   00644   1   1   0