diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/os_unix.c | 2 | ||||
-rw-r--r-- | src/os_win.c | 2 | ||||
-rw-r--r-- | src/test1.c | 33 |
3 files changed, 35 insertions, 2 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 9f8204dfd..dbf3c1012 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3471,7 +3471,7 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ case SQLITE_FCNTL_PERSIST_WAL: { int bPersist = *(int*)pArg; if( bPersist<0 ){ - bPersist = (pFile->ctrlFlags & UNIXFILE_PERSIST_WAL)!=0; + *(int*)pArg = (pFile->ctrlFlags & UNIXFILE_PERSIST_WAL)!=0; }else if( bPersist==0 ){ pFile->ctrlFlags &= ~UNIXFILE_PERSIST_WAL; }else{ diff --git a/src/os_win.c b/src/os_win.c index 4c0fc8686..827091e84 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -1360,7 +1360,7 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){ case SQLITE_FCNTL_PERSIST_WAL: { int bPersist = *(int*)pArg; if( bPersist<0 ){ - bPersist = pFile->bPersistWal; + *(int*)pArg = pFile->bPersistWal; }else{ pFile->bPersistWal = bPersist!=0; } diff --git a/src/test1.c b/src/test1.c index 3301ab740..9a5a50103 100644 --- a/src/test1.c +++ b/src/test1.c @@ -5129,6 +5129,38 @@ static int file_control_win32_av_retry( return TCL_OK; } +/* +** tclcmd: file_control_persist_wal DB PERSIST-FLAG +** +** This TCL command runs the sqlite3_file_control interface with +** the SQLITE_FCNTL_PERSIST_WAL opcode. +*/ +static int file_control_persist_wal( + ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ + Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ + int objc, /* Number of arguments */ + Tcl_Obj *CONST objv[] /* Command arguments */ +){ + sqlite3 *db; + int rc; + int bPersist; + char z[100]; + + if( objc!=3 ){ + Tcl_AppendResult(interp, "wrong # args: should be \"", + Tcl_GetStringFromObj(objv[0], 0), " DB FLAG", 0); + return TCL_ERROR; + } + if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ + return TCL_ERROR; + } + if( Tcl_GetIntFromObj(interp, objv[2], &bPersist) ) return TCL_ERROR; + rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_PERSIST_WAL, (void*)&bPersist); + sqlite3_snprintf(sizeof(z), z, "%d %d", rc, bPersist); + Tcl_AppendResult(interp, z, (char*)0); + return TCL_OK; +} + /* ** tclcmd: sqlite3_vfs_list @@ -5928,6 +5960,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "file_control_chunksize_test", file_control_chunksize_test, 0 }, { "file_control_sizehint_test", file_control_sizehint_test, 0 }, { "file_control_win32_av_retry", file_control_win32_av_retry, 0 }, + { "file_control_persist_wal", file_control_persist_wal, 0 }, { "sqlite3_vfs_list", vfs_list, 0 }, { "sqlite3_create_function_v2", test_create_function_v2, 0 }, |