Add testing for sqlite3_trace() and fix a bug. (CVS 1760)
FossilOrigin-Name: 7a15391079ae9ce5360fa13e8779c8872885e789
diff --git a/manifest b/manifest
index ee939a1..dc275b0 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Comment\sout\sunused\sroutine\sin\sos_unix.c.\s(CVS\s1759)
-D 2004-06-29T11:08:20
+C Add\stesting\sfor\ssqlite3_trace()\sand\sfix\sa\sbug.\s(CVS\s1760)
+D 2004-06-29T11:26:59
F Makefile.in cb7a9889c38723f72b2506c4236ff30a05ff172b
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -38,7 +38,7 @@
F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb
F src/insert.c d99ffe87e1e1397f4233afcd06841d52d6b17b18
F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f
-F src/main.c b6b9e0b4ac6b2f22bb61fe093eabc78de62e8a7a
+F src/main.c 9c01890c4e928d31b8c754d67820c645b7b99f4f
F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070
F src/os.h d1780e0db95cad01f213d48da22ab490eb4fd345
F src/os_common.h 1e745e582138c01d995f190d7544da3e826f6b2f
@@ -61,7 +61,7 @@
F src/sqlite.h.in b70fded2bdfeaddfb06adea3888118b722975136
F src/sqliteInt.h 4f8d44f04cc51cb421bf3c195247353a5be2e98f
F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2
-F src/tclsqlite.c 8d093146332b2f0cbf2a8ebe8597d481619308a3
+F src/tclsqlite.c a3b2acfe61677d9b49b199bfe043cc212d747412
F src/test1.c 0eca68f6e70069aad7ad0fd91fda886926646786
F src/test2.c dafd8bd314a554bf376c6d3a8c83fd69219f5a40
F src/test3.c bacc42bf41fa04d6faf7dd104b595b8bafb9aec9
@@ -164,6 +164,7 @@
F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35
F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b
F test/threadtest2.c 97a830d53c24c42290501fdfba4a6e5bdd34748b
+F test/trace.test 0c5da18f986bf2c83b2669f2691931264cdaab6d
F test/trans.test 29645b344d2b9b6792793562b12340177ddd8f96
F test/trigger1.test dc015c410161f1a6109fd52638dfac852e2a34de
F test/trigger2.test 0767ab30cb5a2c8402c8524f3d566b410b6f5263
@@ -231,7 +232,7 @@
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/version3.tcl 563ba3ac02f64da27ab17f3edbe8e56bfd0293fb
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P f46251ee0a654e9aa927df31968f7792f771caa9
-R d4d6b611d4afd22aee43dded3239ed4c
+P 20db8124ace5fbfa99035ae28e5c98f4c5fcde00
+R d22897a28d331f978222e91e9a697838
U drh
-Z 15420c5c1d1b1c4fee403f219d0530a7
+Z 73e3d176ba77297dc04534c51f5da9eb
diff --git a/manifest.uuid b/manifest.uuid
index bef9208..ee6616a 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-20db8124ace5fbfa99035ae28e5c98f4c5fcde00
\ No newline at end of file
+7a15391079ae9ce5360fa13e8779c8872885e789
\ No newline at end of file
diff --git a/src/main.c b/src/main.c
index e4c4006..0bb3496 100644
--- a/src/main.c
+++ b/src/main.c
@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
-** $Id: main.c,v 1.240 2004/06/29 10:53:55 drh Exp $
+** $Id: main.c,v 1.241 2004/06/29 11:26:59 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -981,7 +981,7 @@
char *tmpSql = sqliteStrNDup(zSql, sParse.zTail - zSql);
if( tmpSql ){
db->xTrace(db->pTraceArg, tmpSql);
- free(tmpSql);
+ sqliteFree(tmpSql);
}else{
/* If a memory error occurred during the copy,
** trace entire SQL string and fall through to the
diff --git a/src/tclsqlite.c b/src/tclsqlite.c
index 361aa59..ab08ad4 100644
--- a/src/tclsqlite.c
+++ b/src/tclsqlite.c
@@ -11,7 +11,7 @@
*************************************************************************
** A TCL Interface to SQLite
**
-** $Id: tclsqlite.c,v 1.90 2004/06/21 06:50:28 danielk1977 Exp $
+** $Id: tclsqlite.c,v 1.91 2004/06/29 11:26:59 drh Exp $
*/
#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */
@@ -858,6 +858,7 @@
case DB_TRACE: {
if( objc>3 ){
Tcl_WrongNumArgs(interp, 2, objv, "?CALLBACK?");
+ return TCL_ERROR;
}else if( objc==2 ){
if( pDb->zTrace ){
Tcl_AppendResult(interp, pDb->zTrace, 0);
diff --git a/test/trace.test b/test/trace.test
new file mode 100644
index 0000000..20fdbe4
--- /dev/null
+++ b/test/trace.test
@@ -0,0 +1,46 @@
+# 2004 Jun 29
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file implements tests for the "sqlite3_trace()" API.
+#
+# $Id: trace.test,v 1.1 2004/06/29 11:26:59 drh Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test trace-1.1 {
+ set rc [catch {db trace 1 2 3} msg]
+ lappend rc $msg
+} {1 {wrong # args: should be "db trace ?CALLBACK?"}}
+proc trace_proc cmd {
+ lappend ::stmtlist [string trim $cmd]
+}
+do_test trace-1.2 {
+ db trace trace_proc
+ db trace
+} {trace_proc}
+do_test trace-1.3 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ SELECT * FROM t1;
+ }
+} {1 2}
+do_test trace-1.4 {
+ set ::stmtlist
+} {{CREATE TABLE t1(a,b);} {INSERT INTO t1 VALUES(1,2);} {SELECT * FROM t1;} {}}
+do_test trace-1.5 {
+ db trace {}
+ db trace
+} {}
+
+finish_test