/ Check-in [cedfa214]
Login

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

Overview
Comment:Test cases to verify that COMMIT and ROLLBACK return SQLITE_BUSY when there are active statements. (CVS 5858)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:cedfa214e4e979ab04a30f558f767d46862151de
User & Date: drh 2008-11-03 21:40:00
Context
2008-11-04
13:46
Add the sqlite3_db_mutex() interface. No test cases yet. (CVS 5859) check-in: d95de32e user: drh tags: trunk
2008-11-03
21:40
Test cases to verify that COMMIT and ROLLBACK return SQLITE_BUSY when there are active statements. (CVS 5858) check-in: cedfa214 user: drh tags: trunk
20:55
Change the name of the Cursor object to VdbeCursor. (CVS 5857) check-in: fdb98fd8 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added test/trans3.test.

            1  +# 2008 November 3
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            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.
            9  +#
           10  +#***********************************************************************
           11  +#
           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.
           15  +#
           16  +# $Id: trans3.test,v 1.1 2008/11/03 21:40:00 drh Exp $
           17  +#
           18  +set testdir [file dirname $argv0]
           19  +source $testdir/tester.tcl
           20  +unset -nocomplain ecode
           21  +
           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} {
           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  +} {1 {cannot commit transaction - SQL statements in progress}}
           45  +do_test trans3-1.3 {
           46  +  set ::ecode
           47  +} {SQLITE_BUSY}
           48  +do_test trans3-1.4 {
           49  +  db eval COMMIT
           50  +  db eval {SELECT * FROM t1}
           51  +} {1 2 3 4}
           52  +do_test trans3-1.5 {
           53  +  db eval BEGIN
           54  +  db eval {INSERT INTO t1 VALUES(5);}
           55  +  set ::ecode {}
           56  +  set x [catch {
           57  +     db eval {SELECT * FROM t1} {
           58  +        if {[catch {db eval ROLLBACK} errmsg]} {
           59  +           set ::ecode [sqlite3_extended_errcode db]
           60  +           error $errmsg
           61  +        }
           62  +     }
           63  +  } errmsg]
           64  +  lappend x $errmsg
           65  +} {1 {cannot rollback transaction - SQL statements in progress}}
           66  +do_test trans3-1.6 {
           67  +  set ::ecode
           68  +} {SQLITE_BUSY}
           69  +do_test trans3-1.7 {
           70  +  db eval COMMIT
           71  +  db eval {SELECT * FROM t1}
           72  +} {1 2 3 4 5}
           73  +unset -nocomplain ecode
           74  +
           75  +finish_test