aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan <dan@noemail.net>2010-07-15 18:20:53 +0000
committerdan <dan@noemail.net>2010-07-15 18:20:53 +0000
commit1e5de5a13d6fe2fd2c690126f375124d617215bf (patch)
treea27e279b409fa87994312982a2eb82c50f09e556 /src
parent7d4514a4e16322182a06b2e4e24fc6cd639cff79 (diff)
downloadsqlite-1e5de5a13d6fe2fd2c690126f375124d617215bf.tar.gz
sqlite-1e5de5a13d6fe2fd2c690126f375124d617215bf.zip
Changes to wal.c so that SQLite can read even if the WAL file is opened read-only, provided the wal-index (shm file) is opened read/write.
FossilOrigin-Name: 932d19da73c9673cdd4cc01289b17761c23d23cb
Diffstat (limited to 'src')
-rw-r--r--src/wal.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/wal.c b/src/wal.c
index 261bed196..54274640e 100644
--- 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.
*/