aboutsummaryrefslogtreecommitdiff
path: root/src/test1.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test1.c')
-rw-r--r--src/test1.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/test1.c b/src/test1.c
index a87fcd859..732ad9e04 100644
--- a/src/test1.c
+++ b/src/test1.c
@@ -6680,7 +6680,40 @@ static int test_bad_behavior(
}
return TCL_OK;
}
-
+
+/*
+** tclcmd: register_dbstat_vtab DB
+**
+** Cause the dbstat virtual table to be available on the connection DB
+*/
+static int test_register_dbstat_vtab(
+ void *clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+#ifdef SQLITE_OMIT_VIRTUALTABLE
+ Tcl_AppendResult(interp, "dbstat not available because of "
+ "SQLITE_OMIT_VIRTUALTABLE", (void*)0);
+ return TCL_ERROR;
+#else
+ struct SqliteDb { sqlite3 *db; };
+ char *zDb;
+ Tcl_CmdInfo cmdInfo;
+
+ if( objc!=2 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "DB");
+ return TCL_ERROR;
+ }
+
+ zDb = Tcl_GetString(objv[1]);
+ if( Tcl_GetCommandInfo(interp, zDb, &cmdInfo) ){
+ sqlite3* db = ((struct SqliteDb*)cmdInfo.objClientData)->db;
+ sqlite3DbstatRegister(db);
+ }
+ return TCL_OK;
+#endif /* SQLITE_OMIT_VIRTUALTABLE */
+}
/*
** Register commands with the TCL interpreter.
@@ -6752,6 +6785,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
void *clientData;
} aObjCmd[] = {
{ "bad_behavior", test_bad_behavior, (void*)&iZero },
+ { "register_dbstat_vtab", test_register_dbstat_vtab },
{ "sqlite3_connection_pointer", get_sqlite_pointer, 0 },
{ "sqlite3_bind_int", test_bind_int, 0 },
{ "sqlite3_bind_zeroblob", test_bind_zeroblob, 0 },