1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Fix for ticket #110: return an error if trying to start a transaction within a

transaction or when attempting to commit or rollback outside of a transaction. (CVS 721)

FossilOrigin-Name: df51cb166bf7c5b8b0530cc86df8d2d68de81a40
This commit is contained in:
drh
2002-08-18 20:28:06 +00:00
parent d8acdb3c36
commit 6b8b8749d4
7 changed files with 46 additions and 32 deletions

View File

@ -13,7 +13,7 @@
# This file implements tests for the conflict resolution extension
# to SQLite.
#
# $Id: conflict.test,v 1.13 2002/06/28 12:18:48 drh Exp $
# $Id: conflict.test,v 1.14 2002/08/18 20:28:07 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -67,7 +67,7 @@ foreach {i conf cmd t0 t1 t2} {
INSERT INTO t2 VALUES(1);
$cmd INTO t1 VALUES(1,2,4);
}]} r1]
execsql {COMMIT}
catch {execsql {COMMIT}}
if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
set r2 [execsql {SELECT x FROM t2}]
list $r0 $r1 $r2
@ -125,7 +125,7 @@ foreach {i conf cmd t0 t1 t2} {
INSERT INTO t2 VALUES(1);
$cmd INTO t1 VALUES(1,2,4);
}]} r1]
execsql {COMMIT}
catch {execsql {COMMIT}}
if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
set r2 [execsql {SELECT x FROM t2}]
list $r0 $r1 $r2
@ -183,7 +183,7 @@ foreach {i conf cmd t0 t1 t2} {
INSERT INTO t2 VALUES(1);
$cmd INTO t1 VALUES(1,2,4);
}]} r1]
execsql {COMMIT}
catch {execsql {COMMIT}}
if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
set r2 [execsql {SELECT x FROM t2}]
list $r0 $r1 $r2
@ -238,7 +238,7 @@ foreach {i conf1 conf2 cmd t0 t1 t2} {
INSERT INTO t2 VALUES(1);
$cmd INTO t1 VALUES(1,2,4);
}]} r1]
execsql {COMMIT}
catch {execsql {COMMIT}}
if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}
set r2 [execsql {SELECT x FROM t2}]
list $r0 $r1 $r2
@ -300,7 +300,7 @@ foreach {i conf1 conf2 cmd t0 t1 t2} {
INSERT INTO t2 VALUES(1);
$cmd INTO t1 VALUES(1,2,NULL);
}]} r1]
execsql {COMMIT}
catch {execsql {COMMIT}}
if {!$r0} {set r1 [execsql {SELECT c FROM t1}]}
set r2 [execsql {SELECT x FROM t2}]
list $r0 $r1 $r2
@ -370,7 +370,7 @@ foreach {i conf1 conf2 cmd t0 t1 t2} {
$cmd t1 SET b=b*2;
$cmd t1 SET a=c+5;
}]} r1]
execsql {COMMIT}
catch {execsql {COMMIT}}
if {!$r0} {set r1 [execsql {SELECT a FROM t1 ORDER BY b}]}
set r2 [execsql {SELECT x FROM t3}]
list $r0 $r1 $r2
@ -620,7 +620,7 @@ do_test conflict-9.19 {
}
} {1 {constraint failed}}
do_test conflict-9.20 {
execsql {COMMIT}
catch {execsql {COMMIT}}
execsql {SELECT * FROM t3}
} {5}
do_test conflict-9.21 {
@ -632,7 +632,7 @@ do_test conflict-9.21 {
}
} {1 {constraint failed}}
do_test conflict-9.22 {
execsql {COMMIT}
catch {execsql {COMMIT}}
execsql {SELECT * FROM t3}
} {5}
do_test conflict-9.23 {
@ -656,7 +656,7 @@ do_test conflict-9.25 {
}
} {0 {3 3 1 3 3}}
do_test conflict-9.26 {
execsql {COMMIT}
catch {execsql {COMMIT}}
execsql {SELECT * FROM t3}
} {6}

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script is database locks.
#
# $Id: lock.test,v 1.15 2002/06/25 13:16:04 drh Exp $
# $Id: lock.test,v 1.16 2002/08/18 20:28:07 drh Exp $
set testdir [file dirname $argv0]
@ -241,7 +241,7 @@ do_test lock-3.1 {
set r [catch {execsql {BEGIN TRANSACTION}} msg]
execsql {ROLLBACK}
lappend r $msg
} {0 {}}
} {1 {cannot start a transaction within a transaction}}
integrity_check lock-3.2
do_test lock-999.1 {

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script is database locks.
#
# $Id: trans.test,v 1.15 2002/08/13 00:01:18 drh Exp $
# $Id: trans.test,v 1.16 2002/08/18 20:28:07 drh Exp $
set testdir [file dirname $argv0]
@ -173,13 +173,13 @@ do_test trans-4.1 {
COMMIT;
} db} msg]
lappend v $msg
} {0 {}}
} {1 {cannot commit - no transaction is active}}
do_test trans-4.2 {
set v [catch {execsql {
ROLLBACK;
} db} msg]
lappend v $msg
} {0 {}}
} {1 {cannot rollback - no transaction is active}}
do_test trans-4.3 {
set v [catch {execsql {
BEGIN TRANSACTION;
@ -205,7 +205,7 @@ do_test trans-4.6 {
SELECT a FROM one ORDER BY a;
} db} msg]
lappend v $msg
} {0 {1 2 3 4}}
} {1 {cannot start a transaction within a transaction}}
do_test trans-4.7 {
set v [catch {execsql {
SELECT a FROM two ORDER BY a;

View File

@ -69,7 +69,6 @@ do_test trig-raise-3.1 {
do_test trig-raise-3.2 {
execsql {
SELECT * FROM tbl;
ROLLBACK;
}
} {}
# IGNORE