mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
In the TCL interface, the "sqlite" command now always returns the address
of the "sqlite*" pointer that sqlite_open() returns. It used to do this only when compiled with the SQLITE_TEST macro defined. (CVS 648) FossilOrigin-Name: 9ca6368525fe81fe9c78c6911f4d23009ce858d5
This commit is contained in:
@ -11,11 +11,11 @@
|
||||
*************************************************************************
|
||||
** A TCL Interface to SQLite
|
||||
**
|
||||
** $Id: tclsqlite.c,v 1.33 2002/06/25 19:31:18 drh Exp $
|
||||
** $Id: tclsqlite.c,v 1.34 2002/06/26 20:06:06 drh Exp $
|
||||
*/
|
||||
#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */
|
||||
|
||||
#include "sqlite.h"
|
||||
#include "sqliteInt.h"
|
||||
#include "tcl.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -543,6 +543,7 @@ static int DbMain(void *cd, Tcl_Interp *interp, int argc, char **argv){
|
||||
int mode;
|
||||
SqliteDb *p;
|
||||
char *zErrMsg;
|
||||
char zBuf[80];
|
||||
if( argc==2 ){
|
||||
if( strcmp(argv[1],"-encoding")==0 ){
|
||||
Tcl_AppendResult(interp,sqlite_encoding,0);
|
||||
@ -583,18 +584,19 @@ static int DbMain(void *cd, Tcl_Interp *interp, int argc, char **argv){
|
||||
}
|
||||
Tcl_CreateObjCommand(interp, argv[1], DbObjCmd, (char*)p, DbDeleteCmd);
|
||||
|
||||
/* The return value is the value of the sqlite* pointer
|
||||
*/
|
||||
sprintf(zBuf, "%p", p->db);
|
||||
Tcl_AppendResult(interp, zBuf, 0);
|
||||
|
||||
/* If compiled with SQLITE_TEST turned on, then register the "md5sum"
|
||||
** SQL function and return an integer which is the memory address of
|
||||
** the underlying sqlite* pointer.
|
||||
** SQL function.
|
||||
*/
|
||||
#ifdef SQLITE_TEST
|
||||
{
|
||||
char zBuf[40];
|
||||
extern void Md5_Register(sqlite*);
|
||||
Md5_Register(p->db);
|
||||
sprintf(zBuf, "%d", (int)p->db);
|
||||
Tcl_AppendResult(interp, zBuf, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return TCL_OK;
|
||||
}
|
||||
|
14
src/test1.c
14
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.9 2002/06/16 04:54:29 chw Exp $
|
||||
** $Id: test1.c,v 1.10 2002/06/26 20:06:06 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "tcl.h"
|
||||
@ -91,7 +91,7 @@ static int test_exec_printf(
|
||||
" DB FORMAT STRING", 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
db = (sqlite*)atoi(argv[1]);
|
||||
db = (sqlite*)strtol(argv[1], 0, 0);
|
||||
Tcl_DStringInit(&str);
|
||||
rc = sqlite_exec_printf(db, argv[2], exec_printf_cb, &str, &zErr, argv[3]);
|
||||
sprintf(zBuf, "%d", rc);
|
||||
@ -128,7 +128,7 @@ static int test_get_table_printf(
|
||||
" DB FORMAT STRING", 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
db = (sqlite*)atoi(argv[1]);
|
||||
db = (sqlite*)strtol(argv[1], 0, 0);
|
||||
Tcl_DStringInit(&str);
|
||||
rc = sqlite_get_table_printf(db, argv[2], &aResult, &nRow, &nCol,
|
||||
&zErr, argv[3]);
|
||||
@ -169,7 +169,7 @@ static int test_last_rowid(
|
||||
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " DB\"", 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
db = (sqlite*)atoi(argv[1]);
|
||||
db = (sqlite*)strtol(argv[1], 0, 0);
|
||||
sprintf(zBuf, "%d", sqlite_last_insert_rowid(db));
|
||||
Tcl_AppendResult(interp, zBuf, 0);
|
||||
return SQLITE_OK;
|
||||
@ -192,7 +192,7 @@ static int sqlite_test_close(
|
||||
" FILENAME\"", 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
db = (sqlite*)atoi(argv[1]);
|
||||
db = (sqlite*)strtol(argv[1], 0, 0);
|
||||
sqlite_close(db);
|
||||
return TCL_OK;
|
||||
}
|
||||
@ -251,7 +251,7 @@ static int sqlite_test_create_function(
|
||||
" FILENAME\"", 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
db = (sqlite*)atoi(argv[1]);
|
||||
db = (sqlite*)strtol(argv[1], 0, 0);
|
||||
sqlite_create_function(db, "x_coalesce", -1, ifnullFunc, 0);
|
||||
sqlite_create_function(db, "x_sqlite_exec", 1, sqliteExecFunc, db);
|
||||
return TCL_OK;
|
||||
@ -300,7 +300,7 @@ static int sqlite_test_create_aggregate(
|
||||
" FILENAME\"", 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
db = (sqlite*)atoi(argv[1]);
|
||||
db = (sqlite*)strtol(argv[1], 0, 0);
|
||||
sqlite_create_aggregate(db, "x_count", 0, countStep, countFinalize, 0);
|
||||
sqlite_create_aggregate(db, "x_count", 1, countStep, countFinalize, 0);
|
||||
return TCL_OK;
|
||||
|
@ -13,7 +13,7 @@
|
||||
** is not included in the SQLite library. It is used for automated
|
||||
** testing of the SQLite library.
|
||||
**
|
||||
** $Id: test3.c,v 1.14 2002/02/19 13:39:23 drh Exp $
|
||||
** $Id: test3.c,v 1.15 2002/06/26 20:06:06 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "pager.h"
|
||||
@ -72,7 +72,7 @@ static int btree_open(
|
||||
Tcl_AppendResult(interp, errorName(rc), 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
sprintf(zBuf,"0x%x",(int)pBt);
|
||||
sprintf(zBuf,"%p", pBt);
|
||||
Tcl_AppendResult(interp, zBuf, 0);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
Reference in New Issue
Block a user