Enhance the command-line completion extension to return the names of
[sqlite.git] / test / trans3.test
blobe82844241580d83369c210d104af4fa34a2cec55
1 # 2008 November 3
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
6 #    May you do good and not evil.
7 #    May you find forgiveness for yourself and forgive others.
8 #    May you share freely, never taking more than you give.
10 #***********************************************************************
12 # This file implements regression tests for SQLite library.  The
13 # focus of this script is the response of COMMIT and ROLLBACK when
14 # statements are still pending.
16 # $Id: trans3.test,v 1.2 2008/11/05 16:37:35 drh Exp $
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
20 unset -nocomplain ecode
22 do_test trans3-1.1 {
23   db eval {
24     CREATE TABLE t1(x);
25     INSERT INTO t1 VALUES(1);
26     INSERT INTO t1 VALUES(2);
27     INSERT INTO t1 VALUES(3);
28     SELECT * FROM t1;
29   }
30 } {1 2 3}
31 do_test trans3-1.2 {
32   db eval BEGIN
33   db eval {INSERT INTO t1 VALUES(4);}
34   set ::ecode {}
35   set x [catch {
36      db eval {SELECT * FROM t1 LIMIT 1} {
37         if {[catch {db eval COMMIT} errmsg]} {
38            set ::ecode [sqlite3_extended_errcode db]
39            error $errmsg
40         }
41      }
42   } errmsg]
43   lappend x $errmsg
44 } {0 {}}
45 do_test trans3-1.3 {
46   set ::ecode
47 } {}
48 do_test trans3-1.3.1 {
49   sqlite3_get_autocommit db
50 } 1
51 do_test trans3-1.4 {
52   db eval {SELECT * FROM t1}
53 } {1 2 3 4}
54 do_test trans3-1.5 {
55   db eval {BEGIN; CREATE TABLE xyzzy(abc);}
56   db eval {INSERT INTO t1 VALUES(5);}
57   set ::ecode {}
58   set x [catch {
59      db eval {SELECT * FROM t1} {
60         if {[catch {db eval ROLLBACK} errmsg]} {
61            set ::ecode [sqlite3_extended_errcode db]
62            error $errmsg
63         }
64      }
65   } errmsg]
66   lappend x $errmsg
67 } {1 {abort due to ROLLBACK}}
68 do_test trans3-1.6 {
69   set ::ecode
70 } {}
71 do_test trans3-1.7 {
72   db eval {SELECT * FROM t1}
73 } {1 2 3 4}
74 unset -nocomplain ecode
76 finish_test