Skip to content

Commit

Permalink
Refactoring the VFS-SHM methods used by WAL. This version compiles and
Browse files Browse the repository at this point in the history
runs non-WAL test cases but crashes and burns on wal.test.
  • Loading branch information
D. Richard Hipp committed May 12, 2010
1 parent cdac03a commit 3fba4d0
Show file tree
Hide file tree
Showing 14 changed files with 1,940 additions and 1,928 deletions.
18 changes: 14 additions & 4 deletions doc/vfs-shm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,24 @@ during testing using an instrumented lock manager.

(5) No part of the wal-index will be read without holding either some
kind of SHM lock or an EXCLUSIVE lock on the original database.
The original database is the file named in the 2nd parameter to
the xShmOpen method.

(6) A holder of a READ_FULL will never read any page of the database
file that is contained anywhere in the wal-index.

(7) No part of the wal-index other than the header will be written nor
will the size of the wal-index grow without holding a WRITE.
will the size of the wal-index grow without holding a WRITE or
an EXCLUSIVE on the original database file.

(8) The wal-index header will not be written without holding one of
WRITE, CHECKPOINT, or RECOVER.
(9) A CHECKPOINT or RECOVER must be held in order to reset the last valid
frame counter in the header of the wal-index back to zero.
WRITE, CHECKPOINT, or RECOVER on the wal-index or an EXCLUSIVE on
the original database files.

(9) A CHECKPOINT or RECOVER must be held on the wal-index, or an
EXCLUSIVE on the original database file, in order to reset the
last valid frame counter in the header of the wal-index back to zero.

(10) A WRITE can only increase the last valid frame pointer in the header.

The SQLite core will only ever send requests for UNLOCK, READ, WRITE,
Expand Down
18 changes: 18 additions & 0 deletions src/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@ int sqlite3OsSectorSize(sqlite3_file *id){
int sqlite3OsDeviceCharacteristics(sqlite3_file *id){
return id->pMethods->xDeviceCharacteristics(id);
}
int sqlite3OsShmOpen(sqlite3_file *id){
return id->pMethods->xShmOpen(id);
}
int sqlite3OsShmSize(sqlite3_file *id, int reqSize, int *pNewSize){
return id->pMethods->xShmSize(id, reqSize, pNewSize);
}
int sqlite3OsShmGet(sqlite3_file *id, int reqSize, int *pSize, void **pp){
return id->pMethods->xShmGet(id, reqSize, pSize, pp);
}
int sqlite3OsShmRelease(sqlite3_file *id){
return id->pMethods->xShmRelease(id);
}
int sqlite3OsShmLock(sqlite3_file *id, int desiredLock, int *pGotLock){
return id->pMethods->xShmLock(id, desiredLock, pGotLock);
}
int sqlite3OsShmClose(sqlite3_file *id, int deleteFlag){
return id->pMethods->xShmClose(id, deleteFlag);
}

/*
** The next group of routines are convenience wrappers around the
Expand Down
6 changes: 6 additions & 0 deletions src/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ int sqlite3OsFileControl(sqlite3_file*,int,void*);
#define SQLITE_FCNTL_DB_UNCHANGED 0xca093fa0
int sqlite3OsSectorSize(sqlite3_file *id);
int sqlite3OsDeviceCharacteristics(sqlite3_file *id);
int sqlite3OsShmOpen(sqlite3_file *id);
int sqlite3OsShmSize(sqlite3_file *id, int, int*);
int sqlite3OsShmGet(sqlite3_file *id, int, int*, void**);
int sqlite3OsShmRelease(sqlite3_file *id);
int sqlite3OsShmLock(sqlite3_file *id, int, int*);
int sqlite3OsShmClose(sqlite3_file *id, int);

/*
** Functions for accessing sqlite3_vfs methods
Expand Down
Loading

0 comments on commit 3fba4d0

Please sign in to comment.