Invoke sqlite3_log() whenever one or more frames are recovered from a WAL file.

FossilOrigin-Name: e05089aaefe02ec59a1923812349471a78075d29
This commit is contained in:
dan
2010-08-17 14:52:22 +00:00
parent fc6a621a96
commit eb8763d7b3
5 changed files with 105 additions and 12 deletions
+42
View File
@@ -4949,6 +4949,47 @@ static int test_wal_checkpoint(
return TCL_OK;
}
/*
** tclcmd: test_sqlite3_log ?SCRIPT?
*/
static struct LogCallback {
Tcl_Interp *pInterp;
Tcl_Obj *pObj;
} logcallback = {0, 0};
static void xLogcallback(void *unused, int err, char *zMsg){
Tcl_Obj *pNew = Tcl_DuplicateObj(logcallback.pObj);
Tcl_IncrRefCount(pNew);
Tcl_ListObjAppendElement(
0, pNew, Tcl_NewStringObj(sqlite3TestErrorName(err), -1)
);
Tcl_ListObjAppendElement(0, pNew, Tcl_NewStringObj(zMsg, -1));
Tcl_EvalObjEx(logcallback.pInterp, pNew, TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT);
Tcl_DecrRefCount(pNew);
}
static int test_sqlite3_log(
ClientData clientData,
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
int objc, /* Number of arguments */
Tcl_Obj *CONST objv[] /* Command arguments */
){
if( objc>2 ){
Tcl_WrongNumArgs(interp, 1, objv, "SCRIPT");
return TCL_ERROR;
}
if( logcallback.pObj ){
Tcl_DecrRefCount(logcallback.pObj);
logcallback.pObj = 0;
logcallback.pInterp = 0;
sqlite3_config(SQLITE_CONFIG_LOG, 0, 0);
}
if( objc>1 ){
logcallback.pObj = objv[1];
Tcl_IncrRefCount(logcallback.pObj);
logcallback.pInterp = interp;
sqlite3_config(SQLITE_CONFIG_LOG, xLogcallback, 0);
}
return TCL_OK;
}
/*
** tcl_objproc COMMANDNAME ARGS...
@@ -5172,6 +5213,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "sqlite3_unlock_notify", test_unlock_notify, 0 },
#endif
{ "sqlite3_wal_checkpoint", test_wal_checkpoint, 0 },
{ "test_sqlite3_log", test_sqlite3_log, 0 },
};
static int bitmask_size = sizeof(Bitmask)*8;
int i;