aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2015-05-11 11:59:15 +0000
committerdrh <drh@noemail.net>2015-05-11 11:59:15 +0000
commit3e0327d5deadbfbf8550456b338d128f35c48bca (patch)
tree180e1df39c5a4f6238daadaa53542779a63b0a8f /src
parent1fef289133ffd341e01da9e037faace4fef488b7 (diff)
downloadsqlite-3e0327d5deadbfbf8550456b338d128f35c48bca.tar.gz
sqlite-3e0327d5deadbfbf8550456b338d128f35c48bca.zip
Revamp the way the DBSTAT virtual table is registered.
FossilOrigin-Name: 4e6520159e729b6ea96ccdb14f0ecb00a0ff7cbd
Diffstat (limited to 'src')
-rw-r--r--src/dbstat.c2
-rw-r--r--src/main.c3
-rw-r--r--src/sqliteInt.h4
-rw-r--r--src/tclsqlite.c47
-rw-r--r--src/test1.c36
5 files changed, 41 insertions, 51 deletions
diff --git a/src/dbstat.c b/src/dbstat.c
index 64cd5d812..e0ab0cea6 100644
--- a/src/dbstat.c
+++ b/src/dbstat.c
@@ -621,7 +621,7 @@ static int statRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){
/*
** Invoke this routine to register the "dbstat" virtual table module
*/
-int sqlite3_dbstat_register(sqlite3 *db){
+int sqlite3DbstatRegister(sqlite3 *db){
static sqlite3_module dbstat_module = {
0, /* iVersion */
statConnect, /* xCreate */
diff --git a/src/main.c b/src/main.c
index cc819c3fa..83d0b9913 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2878,8 +2878,7 @@ static int openDatabase(
#ifdef SQLITE_ENABLE_DBSTAT_VTAB
if( !db->mallocFailed && rc==SQLITE_OK){
- int sqlite3_dbstat_register(sqlite3*);
- rc = sqlite3_dbstat_register(db);
+ rc = sqlite3DbstatRegister(db);
}
#endif
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index 7b9542a96..d809245a6 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -3867,4 +3867,8 @@ int sqlite3ThreadCreate(SQLiteThread**,void*(*)(void*),void*);
int sqlite3ThreadJoin(SQLiteThread*, void**);
#endif
+#if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)
+int sqlite3DbstatRegister(sqlite3*);
+#endif
+
#endif /* _SQLITEINT_H_ */
diff --git a/src/tclsqlite.c b/src/tclsqlite.c
index 3e9c98664..b44f5b8fa 100644
--- a/src/tclsqlite.c
+++ b/src/tclsqlite.c
@@ -3706,43 +3706,6 @@ static int db_last_stmt_ptr(
}
#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
** to the commands and linked variables that make up:
@@ -3761,16 +3724,6 @@ static void init_all(Tcl_Interp *interp){
Md5_Init(interp);
#endif
- /* Install the [register_dbstat_vtab] command to access the implementation
- ** 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) || defined(SQLITE_ENABLE_DBSTAT_VTAB)
- Tcl_CreateObjCommand(
- interp, "register_dbstat_vtab", sqlite3RegisterDbstatCmd, 0, 0
- );
-#endif
-
#ifdef SQLITE_TEST
{
extern int Sqliteconfig_Init(Tcl_Interp*);
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 },