-C Fix\sproblems\scaused\sby\sover-agressive\soptimization\sof\sORDER\sBY\sin\sjoins.\nLots\smore\stesting\sneeded.\s(CVS\s2571)
-D 2005-07-29T19:43:58
+C Add\sthe\s"transaction"\scoommand\sto\sthe\sTCL\sinterface.\s\sUntested.\s(CVS\s2572)
+D 2005-08-02T12:21:09
F Makefile.in 22ea9c0fe748f591712d8fe3c6d972c6c173a165
F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/sqlite.h.in 7ccf2f61de2a0dca515e73708e561362e6c3d1e3
F src/sqliteInt.h 4cacefaca973cbf8e6a82910c704bf9b4a32fdf1
F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9
-F src/tclsqlite.c ef3276d0967cc0042bedcc1a7f09e0eb95cd3a8c
+F src/tclsqlite.c b24407b7363d6535e9ccf5e5bc8c68e3c879c340
F src/test1.c 4268e81180a7f9b396a4cf2aa7f268d828cfdf74
F src/test2.c 716c1809dba8e5be6093703e9cada99d627542dc
F src/test3.c 683e1e3819152ffd35da2f201e507228921148d0
F test/subselect.test 3f3f7a940dc3195c3139f4d530385cb54665d614
F test/table.test e87fb2211b97c6a3a367fbc116e8572091b53160
F test/tableapi.test 6a66d58b37d46dc0f2b3c7d4bd2617d209399bd1
-F test/tclsqlite.test faa15080060c39c9d6caa7e067c35e0ab3d4e793
+F test/tclsqlite.test 2679b0fa8397717c0a57609011a0727cb0c6510c
F test/temptable.test c71eeffe8af807f76eafdc5a39824639a1e301df
F test/tester.tcl 98ecdc5723b3b2be5a8a5c3a7f38fa53031466ee
F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 528299b8316726dbcc5548e9aa0648c8b1bd055b
-P cc7ae73ed01f0b89e31dd8de48b913bbd83887b8
-R f7ec03dd4f33cee2f3fa1b70964a7b5e
+P 1a4e526d46280970b43505a5c8a4090767c63043
+R 78b1c899f4b5fe928acfe9e6cfb5036e
U drh
-Z d383af4bb27f70288e32f2b965c3944b
+Z 52f52fd4f5ae893bb4b1cf865ecc97b9
-1a4e526d46280970b43505a5c8a4090767c63043
\ No newline at end of file
+a5ce6c58c3bfc0e1c9953fe4ad4991ac56a4fb87
\ No newline at end of file
*************************************************************************
** A TCL Interface to SQLite
**
-** $Id: tclsqlite.c,v 1.128 2005/07/23 02:17:03 drh Exp $
+** $Id: tclsqlite.c,v 1.129 2005/08/02 12:21:09 drh Exp $
*/
#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */
"function", "last_insert_rowid", "nullvalue",
"onecolumn", "progress", "rekey",
"timeout", "total_changes", "trace",
- "version",
- 0
+ "transaction", "version", 0
};
enum DB_enum {
DB_AUTHORIZER, DB_BUSY, DB_CACHE,
DB_FUNCTION, DB_LAST_INSERT_ROWID,DB_NULLVALUE,
DB_ONECOLUMN, DB_PROGRESS, DB_REKEY,
DB_TIMEOUT, DB_TOTAL_CHANGES, DB_TRACE,
- DB_VERSION
+ DB_TRANSACTION, DB_VERSION,
};
/* don't leave trailing commas on DB_enum, it confuses the AIX xlc compiler */
break;
}
+ /* $db transaction [-deferred|-immediate|-exclusive] SCRIPT
+ **
+ ** Start a new transaction (if we are not already in the midst of a
+ ** transaction) and execute the TCL script SCRIPT. After SCRIPT
+ ** completes, either commit the transaction or roll it back if SCRIPT
+ ** throws an exception. Or if no new transation was started, do nothing.
+ ** pass the exception on up the stack.
+ **
+ ** This command was inspired by Dave Thomas's talk on Ruby at the
+ ** 2005 O'Reilly Open Source Convention (OSCON).
+ */
+ case DB_TRANSACTION: {
+ int inTrans;
+ Tcl_Obj *pScript;
+ const char *zBegin = "BEGIN";
+ if( objc!=3 && objc!=4 ){
+ Tcl_WrongNumArgs(interp, 2, objv, "[TYPE] SCRIPT");
+ return TCL_ERROR;
+ }
+ if( objc==3 ){
+ pScript = objv[2];
+ } else {
+ static const char *TTYPE_strs[] = {
+ "deferred", "exclusive", "immediate"
+ };
+ enum TTYPE_enum {
+ TTYPE_DEFERRED, TTYPE_EXCLUSIVE, TTYPE_IMMEDIATE
+ };
+ int ttype;
+ if( Tcl_GetIndexFromObj(interp, objv[2], TTYPE_strs, "transaction_type",
+ 0, &ttype) ){
+ return TCL_ERROR;
+ }
+ switch( (enum TTYPE_enum)ttype ){
+ case TTYPE_DEFERRED: /* no-op */; break;
+ case TTYPE_EXCLUSIVE: zBegin = "BEGIN EXCLUSIVE"; break;
+ case TTYPE_IMMEDIATE: zBegin = "BEGIN IMMEDIATE"; break;
+ }
+ pScript = objv[3];
+ }
+ inTrans = !sqlite3_get_autocommit(pDb->db);
+ if( !inTrans ){
+ sqlite3_exec(pDb->db, zBegin, 0, 0, 0);
+ }
+ rc = Tcl_EvalObjEx(interp, pScript, 0);
+ if( !inTrans ){
+ const char *zEnd;
+ if( rc==TCL_ERROR ){
+ zEnd = "ROLLBACK";
+ } else {
+ zEnd = "COMMIT";
+ }
+ sqlite3_exec(pDb->db, zEnd, 0, 0, 0);
+ }
+ break;
+ }
+
/* $db copy conflict-algorithm table filename ?SEPARATOR? ?NULLINDICATOR?
**
** Copy data into table from filename, optionally using SEPARATOR
# interface is pretty well tested. This file contains some addition
# tests for fringe issues that the main test suite does not cover.
#
-# $Id: tclsqlite.test,v 1.41 2005/06/26 17:55:34 drh Exp $
+# $Id: tclsqlite.test,v 1.42 2005/08/02 12:21:10 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
do_test tcl-1.2 {
set v [catch {db bogus} msg]
lappend v $msg
-} {1 {bad option "bogus": must be authorizer, busy, cache, changes, close, collate, collation_needed, commit_hook, complete, copy, errorcode, eval, function, last_insert_rowid, nullvalue, onecolumn, progress, rekey, timeout, total_changes, trace, or version}}
+} {1 {bad option "bogus": must be authorizer, busy, cache, changes, close, collate, collation_needed, commit_hook, complete, copy, errorcode, eval, function, last_insert_rowid, nullvalue, onecolumn, progress, rekey, timeout, total_changes, trace, transaction, or version}}
do_test tcl-1.3 {
execsql {CREATE TABLE t1(a int, b int)}
execsql {INSERT INTO t1 VALUES(10,20)}