aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authormistachkin <mistachkin@noemail.net>2011-07-28 20:48:38 +0000
committermistachkin <mistachkin@noemail.net>2011-07-28 20:48:38 +0000
commit5b7f786e7eb46e461c0a0bd3f8e58422ddacd94d (patch)
treecf3be75b123af30b06d897befe7b7365fcba9607 /src/os_unix.c
parent4e6b49b4098bf4795bb877b79d80133e4ab58685 (diff)
parent253cea5c6f34b1be77e9cc9c9c5ad35587ec5b25 (diff)
downloadsqlite-5b7f786e7eb46e461c0a0bd3f8e58422ddacd94d.tar.gz
sqlite-5b7f786e7eb46e461c0a0bd3f8e58422ddacd94d.zip
Merge changes for the new sqlite3_file_control() that will cause the -wal and -shm files to persist after the last database connection closes.
FossilOrigin-Name: 1b56677bdfb102d070a2057a65ba424fec81131d
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 7f0013e82..9e7b45821 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 ){
+ *(int*)pArg = (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