| Index: third_party/sqlite/src/src/test6.c
|
| diff --git a/third_party/sqlite/src/src/test6.c b/third_party/sqlite/src/src/test6.c
|
| index 306482dcd30964268958e854eae4fb87bda06ad0..5304bcc31f20b012501aa544ffe6a618a1c12671 100644
|
| --- a/third_party/sqlite/src/src/test6.c
|
| +++ b/third_party/sqlite/src/src/test6.c
|
| @@ -16,7 +16,11 @@
|
| */
|
| #if SQLITE_TEST /* This file is used for testing only */
|
| #include "sqliteInt.h"
|
| -#include "tcl.h"
|
| +#if defined(INCLUDE_SQLITE_TCL_H)
|
| +# include "sqlite_tcl.h"
|
| +#else
|
| +# include "tcl.h"
|
| +#endif
|
|
|
| #ifndef SQLITE_OMIT_DISKIO /* This file is a no-op if disk I/O is disabled */
|
|
|
| @@ -215,7 +219,9 @@ static int writeListSync(CrashFile *pFile, int isCrash){
|
| }
|
|
|
| #ifdef TRACE_CRASHTEST
|
| - printf("Sync %s (is %s crash)\n", pFile->zName, (isCrash?"a":"not a"));
|
| + if( pFile ){
|
| + printf("Sync %s (is %s crash)\n", pFile->zName, (isCrash?"a":"not a"));
|
| + }
|
| #endif
|
|
|
| ppPtr = &g.pWriteList;
|
| @@ -701,6 +707,10 @@ static int cfCurrentTime(sqlite3_vfs *pCfVfs, double *pTimeOut){
|
| sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;
|
| return pVfs->xCurrentTime(pVfs, pTimeOut);
|
| }
|
| +static int cfGetLastError(sqlite3_vfs *pCfVfs, int n, char *z){
|
| + sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;
|
| + return pVfs->xGetLastError(pVfs, n, z);
|
| +}
|
|
|
| static int processDevSymArgs(
|
| Tcl_Interp *interp,
|
| @@ -796,12 +806,33 @@ static int processDevSymArgs(
|
| }
|
|
|
| /*
|
| +** tclcmd: sqlite3_crash_now
|
| +**
|
| +** Simulate a crash immediately. This function does not return
|
| +** (writeListSync() calls exit(-1)).
|
| +*/
|
| +static int SQLITE_TCLAPI crashNowCmd(
|
| + void * clientData,
|
| + Tcl_Interp *interp,
|
| + int objc,
|
| + Tcl_Obj *CONST objv[]
|
| +){
|
| + if( objc!=1 ){
|
| + Tcl_WrongNumArgs(interp, 1, objv, "");
|
| + return TCL_ERROR;
|
| + }
|
| + writeListSync(0, 1);
|
| + assert( 0 );
|
| + return TCL_OK;
|
| +}
|
| +
|
| +/*
|
| ** tclcmd: sqlite_crash_enable ENABLE
|
| **
|
| ** Parameter ENABLE must be a boolean value. If true, then the "crash"
|
| ** vfs is added to the system. If false, it is removed.
|
| */
|
| -static int crashEnableCmd(
|
| +static int SQLITE_TCLAPI crashEnableCmd(
|
| void * clientData,
|
| Tcl_Interp *interp,
|
| int objc,
|
| @@ -827,7 +858,7 @@ static int crashEnableCmd(
|
| cfRandomness, /* xRandomness */
|
| cfSleep, /* xSleep */
|
| cfCurrentTime, /* xCurrentTime */
|
| - 0, /* xGetlastError */
|
| + cfGetLastError, /* xGetLastError */
|
| 0, /* xCurrentTimeInt64 */
|
| };
|
|
|
| @@ -876,7 +907,7 @@ static int crashEnableCmd(
|
| ** sqlite_crashparams -sect 1024 -char {atomic sequential} ./test.db 1
|
| **
|
| */
|
| -static int crashParamsObjCmd(
|
| +static int SQLITE_TCLAPI crashParamsObjCmd(
|
| void * clientData,
|
| Tcl_Interp *interp,
|
| int objc,
|
| @@ -923,7 +954,7 @@ error:
|
| return TCL_ERROR;
|
| }
|
|
|
| -static int devSymObjCmd(
|
| +static int SQLITE_TCLAPI devSymObjCmd(
|
| void * clientData,
|
| Tcl_Interp *interp,
|
| int objc,
|
| @@ -940,12 +971,33 @@ static int devSymObjCmd(
|
| devsym_register(iDc, iSectorSize);
|
|
|
| return TCL_OK;
|
| +
|
| +}
|
| +
|
| +/*
|
| +** tclcmd: unregister_devsim
|
| +*/
|
| +static int SQLITE_TCLAPI dsUnregisterObjCmd(
|
| + void * clientData,
|
| + Tcl_Interp *interp,
|
| + int objc,
|
| + Tcl_Obj *CONST objv[]
|
| +){
|
| + void devsym_unregister(void);
|
| +
|
| + if( objc!=1 ){
|
| + Tcl_WrongNumArgs(interp, 1, objv, "");
|
| + return TCL_ERROR;
|
| + }
|
| +
|
| + devsym_unregister();
|
| + return TCL_OK;
|
| }
|
|
|
| /*
|
| ** tclcmd: register_jt_vfs ?-default? PARENT-VFS
|
| */
|
| -static int jtObjCmd(
|
| +static int SQLITE_TCLAPI jtObjCmd(
|
| void * clientData,
|
| Tcl_Interp *interp,
|
| int objc,
|
| @@ -983,7 +1035,7 @@ static int jtObjCmd(
|
| /*
|
| ** tclcmd: unregister_jt_vfs
|
| */
|
| -static int jtUnregisterObjCmd(
|
| +static int SQLITE_TCLAPI jtUnregisterObjCmd(
|
| void * clientData,
|
| Tcl_Interp *interp,
|
| int objc,
|
| @@ -1009,7 +1061,9 @@ int Sqlitetest6_Init(Tcl_Interp *interp){
|
| #ifndef SQLITE_OMIT_DISKIO
|
| Tcl_CreateObjCommand(interp, "sqlite3_crash_enable", crashEnableCmd, 0, 0);
|
| Tcl_CreateObjCommand(interp, "sqlite3_crashparams", crashParamsObjCmd, 0, 0);
|
| + Tcl_CreateObjCommand(interp, "sqlite3_crash_now", crashNowCmd, 0, 0);
|
| Tcl_CreateObjCommand(interp, "sqlite3_simulate_device", devSymObjCmd, 0, 0);
|
| + Tcl_CreateObjCommand(interp, "unregister_devsim", dsUnregisterObjCmd, 0, 0);
|
| Tcl_CreateObjCommand(interp, "register_jt_vfs", jtObjCmd, 0, 0);
|
| Tcl_CreateObjCommand(interp, "unregister_jt_vfs", jtUnregisterObjCmd, 0, 0);
|
| #endif
|
|
|