diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/wal.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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. */ |