/ Check-in [68dd0ed5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Tests and bug fixes on the new transaction method in the TCL interface. (CVS 2574)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 68dd0ed5e312ecd5e98ee0fa1c21b70ff330f711
User & Date: drh 2005-08-02 17:15:15
Context
2005-08-02
17:38
Update the documentation for the new transaction method on the TCL interface. (CVS 2575) check-in: 3dc823a0 user: drh tags: trunk
17:15
Tests and bug fixes on the new transaction method in the TCL interface. (CVS 2574) check-in: 68dd0ed5 user: drh tags: trunk
17:13
Fix a bug in the btree balancer. ticket #1346. (CVS 2573) check-in: 3af69a49 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/tclsqlite.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** A TCL Interface to SQLite
    13     13   **
    14         -** $Id: tclsqlite.c,v 1.129 2005/08/02 12:21:09 drh Exp $
           14  +** $Id: tclsqlite.c,v 1.130 2005/08/02 17:15:15 drh Exp $
    15     15   */
    16     16   #ifndef NO_TCL     /* Omit this whole file if TCL is unavailable */
    17     17   
    18     18   #include "sqliteInt.h"
    19     19   #include "hash.h"
    20     20   #include "tcl.h"
    21     21   #include <stdlib.h>
................................................................................
  1514   1514         static const char *TTYPE_strs[] = {
  1515   1515           "deferred",   "exclusive",  "immediate"
  1516   1516         };
  1517   1517         enum TTYPE_enum {
  1518   1518           TTYPE_DEFERRED, TTYPE_EXCLUSIVE, TTYPE_IMMEDIATE
  1519   1519         };
  1520   1520         int ttype;
  1521         -      if( Tcl_GetIndexFromObj(interp, objv[2], TTYPE_strs, "transaction_type",
         1521  +      if( Tcl_GetIndexFromObj(interp, objv[2], TTYPE_strs, "transaction type",
  1522   1522                                 0, &ttype) ){
  1523   1523           return TCL_ERROR;
  1524   1524         }
  1525   1525         switch( (enum TTYPE_enum)ttype ){
  1526   1526           case TTYPE_DEFERRED:    /* no-op */;                 break;
  1527   1527           case TTYPE_EXCLUSIVE:   zBegin = "BEGIN EXCLUSIVE";  break;
  1528   1528           case TTYPE_IMMEDIATE:   zBegin = "BEGIN IMMEDIATE";  break;

Changes to test/tclsqlite.test.

    11     11   # This file implements regression tests for TCL interface to the
    12     12   # SQLite library. 
    13     13   #
    14     14   # Actually, all tests are based on the TCL interface, so the main
    15     15   # interface is pretty well tested.  This file contains some addition
    16     16   # tests for fringe issues that the main test suite does not cover.
    17     17   #
    18         -# $Id: tclsqlite.test,v 1.42 2005/08/02 12:21:10 drh Exp $
           18  +# $Id: tclsqlite.test,v 1.43 2005/08/02 17:15:16 drh Exp $
    19     19   
    20     20   set testdir [file dirname $argv0]
    21     21   source $testdir/tester.tcl
    22     22   
    23     23   # Check the error messages generated by tclsqlite
    24     24   #
    25     25   if {[sqlite3 -has-codec]} {
................................................................................
   344    344     db function r1 userfunc_r1
   345    345     execsql {SELECT r1(10)}
   346    346   } {55}
   347    347   do_test tcl-9.11 {
   348    348     execsql {SELECT r1(100)}
   349    349   } {5050}
   350    350   
          351  +# Tests for the new transaction method
          352  +#
          353  +do_test tcl-10.1 {
          354  +  db transaction {}
          355  +} {}
          356  +do_test tcl-10.2 {
          357  +  db transaction deferred {}
          358  +} {}
          359  +do_test tcl-10.3 {
          360  +  db transaction immediate {}
          361  +} {}
          362  +do_test tcl-10.4 {
          363  +  db transaction exclusive {}
          364  +} {}
          365  +do_test tcl-10.5 {
          366  +  set rc [catch {db transaction xyzzy {}} msg]
          367  +  lappend rc $msg
          368  +} {1 {bad transaction type "xyzzy": must be deferred, exclusive, or immediate}}
          369  +do_test tcl-10.6 {
          370  +  set rc [catch {db transaction {error test-error}} msg]
          371  +  lappend rc $msg
          372  +} {1 test-error}
          373  +do_test tcl-10.7 {
          374  +  db transaction {
          375  +    db eval {CREATE TABLE t4(x)}
          376  +    db transaction {
          377  +      db eval {INSERT INTO t4 VALUES(1)}
          378  +    }
          379  +  }
          380  +  db eval {SELECT * FROM t4}
          381  +} 1
          382  +do_test tcl-10.8 {
          383  +  catch {
          384  +    db transaction {
          385  +      db eval {INSERT INTO t4 VALUES(2)}
          386  +      db eval {INSERT INTO t4 VALUES(3)}
          387  +      db eval {INSERT INTO t4 VALUES(4)}
          388  +      error test-error
          389  +    }
          390  +  }
          391  +  db eval {SELECT * FROM t4}
          392  +} 1
          393  +do_test tcl-10.9 {
          394  +  db transaction {
          395  +    db eval {INSERT INTO t4 VALUES(2)}
          396  +    catch {
          397  +      db transaction {
          398  +        db eval {INSERT INTO t4 VALUES(3)}
          399  +        db eval {INSERT INTO t4 VALUES(4)}
          400  +        error test-error
          401  +      }
          402  +    }
          403  +  }
          404  +  db eval {SELECT * FROM t4}
          405  +} {1 2 3 4}
          406  +do_test tcl-10.10 {
          407  +  for {set i 0} {$i<1} {incr i} {
          408  +    db transaction {
          409  +      db eval {INSERT INTO t4 VALUES(5)}
          410  +      continue
          411  +    }
          412  +  }
          413  +  db eval {SELECT * FROM t4}
          414  +} {1 2 3 4 5}
          415  +do_test tcl-10.11 {
          416  +  for {set i 0} {$i<10} {incr i} {
          417  +    db transaction {
          418  +      db eval {INSERT INTO t4 VALUES(6)}
          419  +      break
          420  +    }
          421  +  }
          422  +  db eval {SELECT * FROM t4}
          423  +} {1 2 3 4 5 6}
          424  +do_test tcl-10.12 {
          425  +  set rc [catch {
          426  +    for {set i 0} {$i<10} {incr i} {
          427  +      db transaction {
          428  +        db eval {INSERT INTO t4 VALUES(7)}
          429  +        return
          430  +      }
          431  +    }
          432  +  }]
          433  +} {2}
          434  +do_test tcl-10.13 {
          435  +  db eval {SELECT * FROM t4}
          436  +} {1 2 3 4 5 6 7}
   351    437   
   352    438   finish_test