aboutsummaryrefslogtreecommitdiff
path: root/src/test6.c
diff options
context:
space:
mode:
authordan <dan@noemail.net>2017-03-02 14:51:47 +0000
committerdan <dan@noemail.net>2017-03-02 14:51:47 +0000
commitcb1b0a693ac7aef2f05c65dba4d4bf5d78d4cf3b (patch)
tree65b4b1409dea7d5209e56c7dfba5a3bb0caac643 /src/test6.c
parent76adb239805a543742232090cd4399db3f8f46f6 (diff)
downloadsqlite-cb1b0a693ac7aef2f05c65dba4d4bf5d78d4cf3b.tar.gz
sqlite-cb1b0a693ac7aef2f05c65dba4d4bf5d78d4cf3b.zip
When saving the state of an RBU update in the incremental-checkpoint phase,
sync the database file. Otherwise, if a power failure occurs and the RBU update resumed following system recovery, the database may become corrupt. FossilOrigin-Name: edee6a80e1cc7e6a2b8c3c7f76dd794fc8ab9a72
Diffstat (limited to 'src/test6.c')
-rw-r--r--src/test6.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/test6.c b/src/test6.c
index a103b9619..849cdeb3b 100644
--- a/src/test6.c
+++ b/src/test6.c
@@ -315,8 +315,9 @@ static int writeListSync(CrashFile *pFile, int isCrash){
assert(pWrite->zBuf);
#ifdef TRACE_CRASHTEST
- printf("Trashing %d sectors @ %lld (sector %d) (%s)\n",
- 1+iLast-iFirst, pWrite->iOffset, iFirst, pWrite->pFile->zName
+ printf("Trashing %d sectors (%d bytes) @ %lld (sector %d) (%s)\n",
+ 1+iLast-iFirst, (1+iLast-iFirst)*g.iSectorSize,
+ pWrite->iOffset, iFirst, pWrite->pFile->zName
);
#endif
@@ -827,7 +828,7 @@ static int SQLITE_TCLAPI crashNowCmd(
}
/*
-** tclcmd: sqlite_crash_enable ENABLE
+** tclcmd: sqlite_crash_enable ENABLE ?DEFAULT?
**
** Parameter ENABLE must be a boolean value. If true, then the "crash"
** vfs is added to the system. If false, it is removed.
@@ -839,6 +840,7 @@ static int SQLITE_TCLAPI crashEnableCmd(
Tcl_Obj *CONST objv[]
){
int isEnable;
+ int isDefault = 0;
static sqlite3_vfs crashVfs = {
2, /* iVersion */
0, /* szOsFile */
@@ -862,14 +864,17 @@ static int SQLITE_TCLAPI crashEnableCmd(
0, /* xCurrentTimeInt64 */
};
- if( objc!=2 ){
- Tcl_WrongNumArgs(interp, 1, objv, "ENABLE");
+ if( objc!=2 && objc!=3 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "ENABLE ?DEFAULT?");
return TCL_ERROR;
}
if( Tcl_GetBooleanFromObj(interp, objv[1], &isEnable) ){
return TCL_ERROR;
}
+ if( objc==3 && Tcl_GetBooleanFromObj(interp, objv[2], &isDefault) ){
+ return TCL_ERROR;
+ }
if( (isEnable && crashVfs.pAppData) || (!isEnable && !crashVfs.pAppData) ){
return TCL_OK;
@@ -880,7 +885,7 @@ static int SQLITE_TCLAPI crashEnableCmd(
crashVfs.mxPathname = pOriginalVfs->mxPathname;
crashVfs.pAppData = (void *)pOriginalVfs;
crashVfs.szOsFile = sizeof(CrashFile) + pOriginalVfs->szOsFile;
- sqlite3_vfs_register(&crashVfs, 0);
+ sqlite3_vfs_register(&crashVfs, isDefault);
}else{
crashVfs.pAppData = 0;
sqlite3_vfs_unregister(&crashVfs);