diff options
author | drh <drh@noemail.net> | 2015-05-05 17:12:27 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2015-05-05 17:12:27 +0000 |
commit | d689fd3a92428042a0784f7d8eb0fecda8921af8 (patch) | |
tree | 4d08293a03c01784935430d2c1caed449ad48bb3 /src/tclsqlite.c | |
parent | b9db90995254891621c116039cef50b5c3606db1 (diff) | |
parent | 0a96931b76e9b68e73d312bcc479d54b818a26cb (diff) | |
download | sqlite-d689fd3a92428042a0784f7d8eb0fecda8921af8.tar.gz sqlite-d689fd3a92428042a0784f7d8eb0fecda8921af8.zip |
Merge all trunk enhancements and fixes into the sessions branch.
FossilOrigin-Name: de7083cfe2bb00b689bec6bcc75e994f564ceda6
Diffstat (limited to 'src/tclsqlite.c')
-rw-r--r-- | src/tclsqlite.c | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 671993547..5649b39f4 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -3850,7 +3850,44 @@ static int db_last_stmt_ptr( return TCL_OK; } -#endif +#endif /* SQLITE_TEST */ + +#if defined(SQLITE_TEST) || defined(SQLITE_ENABLE_DBSTAT_VTAB) +/* +** tclcmd: register_dbstat_vtab DB +** +** Cause the dbstat virtual table to be available on the connection DB +*/ +static int sqlite3RegisterDbstatCmd( + 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) ){ + int sqlite3_dbstat_register(sqlite3*); + sqlite3* db = ((struct SqliteDb*)cmdInfo.objClientData)->db; + sqlite3_dbstat_register(db); + } + return TCL_OK; +#endif /* SQLITE_OMIT_VIRTUALTABLE */ +} +#endif /* defined(SQLITE_TEST) || defined(SQLITE_ENABLE_DBSTAT_VTAB) */ /* ** Configure the interpreter passed as the first argument to have access @@ -3874,11 +3911,10 @@ static void init_all(Tcl_Interp *interp){ ** of virtual table dbstat (source file test_stat.c). This command is ** required for testfixture and sqlite3_analyzer, but not by the production ** Tcl extension. */ -#if defined(SQLITE_TEST) || TCLSH==2 - { - extern int SqlitetestStat_Init(Tcl_Interp*); - SqlitetestStat_Init(interp); - } +#if defined(SQLITE_TEST) || defined(SQLITE_ENABLE_DBSTAT_VTAB) + Tcl_CreateObjCommand( + interp, "register_dbstat_vtab", sqlite3RegisterDbstatCmd, 0, 0 + ); #endif #ifdef SQLITE_TEST |