1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

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
This commit is contained in:
dan
2010-07-15 18:20:53 +00:00
parent 7d4514a4e1
commit 1e5de5a13d
4 changed files with 15 additions and 10 deletions

View File

@@ -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.
*/