Annotation of embedaddon/sqlite3/test/trans3.test, revision 1.1
1.1 ! misho 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.2 2008/11/05 16:37:35 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 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
! 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 {cannot rollback transaction - SQL statements in progress}}
! 68: do_test trans3-1.6 {
! 69: set ::ecode
! 70: } {SQLITE_BUSY}
! 71: do_test trans3-1.7 {
! 72: db eval COMMIT
! 73: db eval {SELECT * FROM t1}
! 74: } {1 2 3 4 5}
! 75: unset -nocomplain ecode
! 76:
! 77: finish_test
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>