aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2011-07-26 16:03:07 +0000
committerdrh <drh@noemail.net>2011-07-26 16:03:07 +0000
commitf0b190d94c1d80b7c20d1a4d52aef9187142c864 (patch)
tree9063398c8b2640744172f2ff219cd7c08e61f426 /src/os_unix.c
parent7d2dc7156ce267ca844793c20cd0c510a698de4b (diff)
downloadsqlite-f0b190d94c1d80b7c20d1a4d52aef9187142c864.tar.gz
sqlite-f0b190d94c1d80b7c20d1a4d52aef9187142c864.zip
Prototype change for a new sqlite3_file_control() that will cause the
-wal and -shm files to persist after the last database connection closes. FossilOrigin-Name: e34c553bf04761e86f3bd72f91439c05886caa5c
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index dce13e536..9f8204dfd 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -250,8 +250,9 @@ struct unixFile {
/*
** Allowed values for the unixFile.ctrlFlags bitmask:
*/
-#define UNIXFILE_EXCL 0x01 /* Connections from one process only */
-#define UNIXFILE_RDONLY 0x02 /* Connection is read only */
+#define UNIXFILE_EXCL 0x01 /* Connections from one process only */
+#define UNIXFILE_RDONLY 0x02 /* Connection is read only */
+#define UNIXFILE_PERSIST_WAL 0x04 /* Persistent WAL mode */
/*
** Include code that is common to all os_*.c files
@@ -3450,21 +3451,33 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
** Information and control of an open file handle.
*/
static int unixFileControl(sqlite3_file *id, int op, void *pArg){
+ unixFile *pFile = (unixFile*)id;
switch( op ){
case SQLITE_FCNTL_LOCKSTATE: {
- *(int*)pArg = ((unixFile*)id)->eFileLock;
+ *(int*)pArg = pFile->eFileLock;
return SQLITE_OK;
}
case SQLITE_LAST_ERRNO: {
- *(int*)pArg = ((unixFile*)id)->lastErrno;
+ *(int*)pArg = pFile->lastErrno;
return SQLITE_OK;
}
case SQLITE_FCNTL_CHUNK_SIZE: {
- ((unixFile*)id)->szChunk = *(int *)pArg;
+ pFile->szChunk = *(int *)pArg;
return SQLITE_OK;
}
case SQLITE_FCNTL_SIZE_HINT: {
- return fcntlSizeHint((unixFile *)id, *(i64 *)pArg);
+ return fcntlSizeHint(pFile, *(i64 *)pArg);
+ }
+ case SQLITE_FCNTL_PERSIST_WAL: {
+ int bPersist = *(int*)pArg;
+ if( bPersist<0 ){
+ bPersist = (pFile->ctrlFlags & UNIXFILE_PERSIST_WAL)!=0;
+ }else if( bPersist==0 ){
+ pFile->ctrlFlags &= ~UNIXFILE_PERSIST_WAL;
+ }else{
+ pFile->ctrlFlags |= UNIXFILE_PERSIST_WAL;
+ }
+ return SQLITE_OK;
}
#ifndef NDEBUG
/* The pager calls this method to signal that it has done