diff options
author | drh <drh@noemail.net> | 2006-01-03 00:33:50 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2006-01-03 00:33:50 +0000 |
commit | dddca28608a7affaa923cd7032ae42ed937e444c (patch) | |
tree | 6268513e43553f7921bf62169f0328cf3889c57c /src/test1.c | |
parent | 88f474a9380d3a890d484497bc8a8beaf5877a93 (diff) | |
download | sqlite-dddca28608a7affaa923cd7032ae42ed937e444c.tar.gz sqlite-dddca28608a7affaa923cd7032ae42ed937e444c.zip |
The sqlite TCL command no longer returns the hex address of the sqlite3*
structure. Instead there is a new command in testfixture to find that
information. (CVS 2852)
FossilOrigin-Name: 70b228575e045bc56013aab945334203ceb31d8b
Diffstat (limited to 'src/test1.c')
-rw-r--r-- | src/test1.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/src/test1.c b/src/test1.c index af05a2f35..263666ca9 100644 --- a/src/test1.c +++ b/src/test1.c @@ -13,7 +13,7 @@ ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test1.c,v 1.178 2005/12/30 16:28:02 danielk1977 Exp $ +** $Id: test1.c,v 1.179 2006/01/03 00:33:50 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -21,6 +21,48 @@ #include <stdlib.h> #include <string.h> +/* +** This is a copy of the first part of the SqliteDb structure in +** tclsqlite.c. We need it here so that the get_sqlite_pointer routine +** can extract the sqlite3* pointer from an existing Tcl SQLite +** connection. +*/ +struct SqliteDb { + sqlite3 *db; +}; + +/* +** A TCL command that returns the address of the sqlite* pointer +** for an sqlite connection instance. Bad things happen if the +** input is not an sqlite connection. +*/ +static int get_sqlite_pointer( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + struct SqliteDb *p; + Tcl_CmdInfo cmdInfo; + char zBuf[100]; + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 1, objv, "SQLITE-CONNECTION"); + return TCL_ERROR; + } + if( !Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &cmdInfo) ){ + Tcl_AppendResult(interp, "command not found: ", + Tcl_GetString(objv[1]), (char*)0); + return TCL_ERROR; + } + p = (struct SqliteDb*)cmdInfo.objClientData; + sprintf(zBuf, "%p", p->db); + if( strncmp(zBuf,"0x",2) ){ + sprintf(zBuf, "0x%p", p->db); + } + Tcl_AppendResult(interp, zBuf, 0); + return TCL_OK; +} + const char *sqlite3TestErrorName(int rc){ const char *zName = 0; switch( rc ){ @@ -3219,6 +3261,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ Tcl_ObjCmdProc *xProc; void *clientData; } aObjCmd[] = { + { "sqlite3_connection_pointer", get_sqlite_pointer, 0 }, { "sqlite3_bind_int", test_bind_int, 0 }, { "sqlite3_bind_int64", test_bind_int64, 0 }, { "sqlite3_bind_double", test_bind_double, 0 }, |