From 06b2718a5f8898baa74b15761f84440d4a13a71c Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 26 Jun 2002 20:06:05 +0000 Subject: [PATCH] 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 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/tclsqlite.c | 18 ++++++++++-------- src/test1.c | 14 +++++++------- src/test3.c | 4 ++-- 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/manifest b/manifest index acba1d421e..dd1129e9f4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sdatatype\sof\sthe\si-th\scolumn\sin\sthe\sresult\sset\sis\sgiven\sby\sthe\nazColName(argc+1+i)\sparameter\sto\sthe\scallback.\s(CVS\s647) -D 2002-06-26T02:45:04 +C In\sthe\sTCL\sinterface,\sthe\s"sqlite"\scommand\snow\salways\sreturns\sthe\saddress\nof\sthe\s"sqlite*"\spointer\sthat\ssqlite_open()\sreturns.\s\sIt\sused\sto\sdo\sthis\nonly\swhen\scompiled\swith\sthe\sSQLITE_TEST\smacro\sdefined.\s(CVS\s648) +D 2002-06-26T20:06:06 F Makefile.in 6291a33b87d2a395aafd7646ee1ed562c6f2c28c F Makefile.template 4e11752e0b5c7a043ca50af4296ec562857ba495 F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0 @@ -43,10 +43,10 @@ F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e F src/sqlite.h.in 75c5bbb066d0faf34424b7d1babf8b44d5b31af2 F src/sqliteInt.h 3d1d86cb9ea4f06e49af855267478e3661abcd1b F src/table.c eed2098c9b577aa17f8abe89313a9c4413f57d63 -F src/tclsqlite.c 7bbdf1873d843cc8706826987268322798aaf6cd -F src/test1.c 5cc4f0bbf38237e04e1b2077e285b41bfb4c4cbf +F src/tclsqlite.c e932591c0bb522b0a35ea7dc861c623ccb2e3aa8 +F src/test1.c 29ed719d8ce890733fbeadb53cacc4e542d423ed F src/test2.c 669cc22781c6461a273416ec1a7414d25c081730 -F src/test3.c 4e52fff8b01f08bd202f7633feda5639b7ba2b5e +F src/test3.c 72ac6a9017a70e542954907a1dfd87ab6f7824e3 F src/threadtest.c 81f0598e0f031c1bd506af337fdc1b7e8dff263f F src/tokenize.c ac4c46f190346b87da54ec3e2605d160af80c619 F src/trigger.c d88ab4d68d68955c217b38fb6717e090fbbf54a4 @@ -137,7 +137,7 @@ F www/speed.tcl da8afcc1d3ccc5696cfb388a68982bc3d9f7f00f F www/sqlite.tcl ac64065d0c5e2de0f71238d55b2c14bb5c5c194c F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218 -P 332164d6455658ca633a1dc49811d9fb0fd4b01c -R 3d4733b97443e83d7b5e9cd5d5bb7f60 +P bdb006b809feb0f29342eb5138c0884d34e95599 +R e92040518419bf0a2b83e28d532bff32 U drh -Z 6ddcef67963fec9e5770a42b675dc0e1 +Z c4b8650cbf25de8c257848e151944d66 diff --git a/manifest.uuid b/manifest.uuid index c5df7d606a..8a6d3d1282 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bdb006b809feb0f29342eb5138c0884d34e95599 \ No newline at end of file +9ca6368525fe81fe9c78c6911f4d23009ce858d5 \ No newline at end of file diff --git a/src/tclsqlite.c b/src/tclsqlite.c index c613e8a602..8e6bc9717f 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -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 #include @@ -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; } diff --git a/src/test1.c b/src/test1.c index 1cdf653974..62c7bf5bcd 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.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; diff --git a/src/test3.c b/src/test3.c index 59f720901f..2fcd1cb025 100644 --- a/src/test3.c +++ b/src/test3.c @@ -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; }