diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/attach.test | 10 | ||||
-rw-r--r-- | test/attach2.test | 8 | ||||
-rw-r--r-- | test/conflict.test | 6 | ||||
-rw-r--r-- | test/hook.test | 6 | ||||
-rw-r--r-- | test/lock.test | 15 | ||||
-rw-r--r-- | test/misc1.test | 4 | ||||
-rwxr-xr-x | test/progress.test | 16 | ||||
-rw-r--r-- | test/trans.test | 4 |
8 files changed, 50 insertions, 19 deletions
diff --git a/test/attach.test b/test/attach.test index 488f30eda..b5c84efba 100644 --- a/test/attach.test +++ b/test/attach.test @@ -12,7 +12,7 @@ # focus of this script is testing the ATTACH and DETACH commands # and related functionality. # -# $Id: attach.test,v 1.18 2004/05/29 10:23:20 danielk1977 Exp $ +# $Id: attach.test,v 1.19 2004/05/31 08:26:49 danielk1977 Exp $ # set testdir [file dirname $argv0] @@ -347,6 +347,7 @@ do_test attach-3.7 { do_test attach-3.8 { execsql BEGIN execsql BEGIN db2 + execsql {UPDATE t2 SET x=0 WHERE 0} db2 catchsql {SELECT * FROM t2} } {1 {database is locked}} do_test attach-3.9 { @@ -364,6 +365,11 @@ do_test attach-3.12 { do_test attach-3.13 { catchsql {UPDATE t2 SET x=x+1 WHERE x=50} } {1 {database is locked}} + +# Change for version 3. Transaction is no longer rolled back +# for a locked database. +execsql {ROLLBACK} + do_test attach-3.14 { # Unable to reinitialize the schema tables because the aux database # is still locked. @@ -438,11 +444,13 @@ do_test attach-4.8 { execsql { ATTACH DATABASE 'test2.db' AS db2; INSERT INTO db2.t3 VALUES(13,14); +pragma vdbe_trace = on; SELECT * FROM db2.t4 UNION ALL SELECT * FROM main.t4; } } {db2.6 db2.13 main.11} do_test attach-4.9 { execsql { +pragma vdbe_trace = off; INSERT INTO main.t3 VALUES(15,16); SELECT * FROM db2.t4 UNION ALL SELECT * FROM main.t4; } diff --git a/test/attach2.test b/test/attach2.test index 8cc11aa2a..9c79b33a0 100644 --- a/test/attach2.test +++ b/test/attach2.test @@ -12,7 +12,7 @@ # focus of this script is testing the ATTACH and DETACH commands # and related functionality. # -# $Id: attach2.test,v 1.9 2004/05/21 10:08:55 danielk1977 Exp $ +# $Id: attach2.test,v 1.10 2004/05/31 08:26:49 danielk1977 Exp $ # @@ -51,6 +51,7 @@ db eval {DETACH t2} do_test attach2-2.1 { # lock test2.db then try to attach it. Should get an error. db2 eval {BEGIN} + db2 eval {UPDATE t1 SET a = 0 WHERE 0} catchsql { ATTACH 'test2.db' AS t2; } @@ -77,6 +78,7 @@ do_test attach2-2.5 { do_test attach2-2.6 { # lock test2.db and try to read from it. should get an error. db2 eval BEGIN + db2 eval {UPDATE t1 SET a = 0 WHERE 0} catchsql { SELECT name FROM t2.sqlite_master; } @@ -108,6 +110,10 @@ do_test attach2-2.10 { do_test attach2-2.11 { # when the write failed in the previous test, the transaction should # have rolled back. + # + # Update for version 3: A transaction is no longer rolled back if a + # database is found to be busy. + execsql {rollback} db2 eval ROLLBACK execsql { SELECT * FROM t1 diff --git a/test/conflict.test b/test/conflict.test index 925c161fa..c2c3ec41d 100644 --- a/test/conflict.test +++ b/test/conflict.test @@ -13,7 +13,7 @@ # This file implements tests for the conflict resolution extension # to SQLite. # -# $Id: conflict.test,v 1.19 2003/08/05 13:13:39 drh Exp $ +# $Id: conflict.test,v 1.20 2004/05/31 08:26:49 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -57,6 +57,8 @@ foreach {i conf cmd t0 t1 t2} { 17 ABORT INSERT 1 {} 1 18 ROLLBACK INSERT 1 {} {} } { + if { $conf=={} } { + do_test conflict-1.$i { if {$conf!=""} {set conf "ON CONFLICT $conf"} set r0 [catch {execsql [subst { @@ -72,6 +74,8 @@ foreach {i conf cmd t0 t1 t2} { set r2 [execsql {SELECT x FROM t2}] list $r0 $r1 $r2 } [list $t0 $t1 $t2] + + } } # Create tables for the first group of tests. diff --git a/test/hook.test b/test/hook.test index d19dfaf8c..c037c04dc 100644 --- a/test/hook.test +++ b/test/hook.test @@ -15,7 +15,7 @@ # # sqlite_commit_hook # -# $Id: hook.test,v 1.3 2004/01/15 02:44:03 drh Exp $ +# $Id: hook.test,v 1.4 2004/05/31 08:26:49 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -65,7 +65,7 @@ do_test hook-3.5 { do_test hook-3.6 { set commit_cnt {} proc commit_hook {} { - set ::commit_cnt [execsql {SELECT * FROM t2}] + set ::commit_cnt [execsql {SELECT * FROM t2}] return 1 } catchsql { @@ -73,7 +73,7 @@ do_test hook-3.6 { } } {1 {constraint failed}} do_test hook-3.7 { - set commit_cnt + set ::commit_cnt } {1 2 2 3 3 4 4 5 5 6 6 7} do_test hook-3.8 { execsql {SELECT * FROM t2} diff --git a/test/lock.test b/test/lock.test index 4b30fd0bf..a68f1be24 100644 --- a/test/lock.test +++ b/test/lock.test @@ -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.20 2004/02/14 16:31:04 drh Exp $ +# $Id: lock.test,v 1.21 2004/05/31 08:26:49 danielk1977 Exp $ set testdir [file dirname $argv0] @@ -60,6 +60,7 @@ do_test lock-1.9 { } {2 1} do_test lock-1.10 { execsql {BEGIN TRANSACTION} + execsql {UPDATE t1 SET a = 0 WHERE 0} execsql {SELECT * FROM t1} } {2 1} do_test lock-1.11 { @@ -155,7 +156,10 @@ integrity_check lock-1.23 # do_test lock-2.1 { execsql {BEGIN TRANSACTION} - set r [catch {execsql {BEGIN TRANSACTION} db2} msg] + execsql {UPDATE t1 SET a = 0 WHERE 0} + execsql {BEGIN TRANSACTION} db2 + set r [catch {execsql {UPDATE t1 SET a = 0 WHERE 0} db2} msg] + execsql {ROLLBACK} db2 lappend r $msg } {1 {database is locked}} @@ -222,6 +226,7 @@ do_test lock-2.6 { } {0 {9 8} {1 2 3}} do_test lock-2.7 { execsql {BEGIN TRANSACTION} + execsql {UPDATE t1 SET a = 0 WHERE 0} proc callback {file count} { lappend ::callback_value $count if {$count>2} { @@ -230,7 +235,8 @@ do_test lock-2.7 { } set ::callback_value {} db2 busy callback - set r [catch {execsql {BEGIN TRANSACTION} db2} msg] + execsql {BEGIN TRANSACTION} db2 + set r [catch {execsql {UPDATE t1 SET a = 0 WHERE 0} db2} msg] execsql {ROLLBACK} db2 lappend r $msg lappend r $::callback_value @@ -241,7 +247,9 @@ do_test lock-2.7 { do_test lock-2.8 { db2 timeout 400 execsql BEGIN + execsql {UPDATE t1 SET a = 0 WHERE 0} catchsql BEGIN db2 + catchsql {UPDATE t1 SET a = 0 WHERE 0} db2 } {1 {database is locked}} do_test lock-2.9 { db2 timeout 0 @@ -267,6 +275,7 @@ do_test lock-4.1 { db2 close catch {db eval ROLLBACK} db eval BEGIN + db eval {UPDATE t1 SET a=0 WHERE 0} sqlite db2 ./test.db set rc [catch {db2 eval {SELECT * FROM t1}} msg] lappend rc $msg diff --git a/test/misc1.test b/test/misc1.test index 81c17d8a3..12720961c 100644 --- a/test/misc1.test +++ b/test/misc1.test @@ -13,7 +13,7 @@ # This file implements tests for miscellanous features that were # left out of other test files. # -# $Id: misc1.test,v 1.24 2004/05/19 20:41:04 drh Exp $ +# $Id: misc1.test,v 1.25 2004/05/31 08:26:49 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -312,6 +312,7 @@ do_test misc1-10.10 { # do_test misc1-11.1 { execsql {BEGIN} + execsql {UPDATE t1 SET a=0 WHERE 0} sqlite db2 test.db set rc [catch {db2 eval {SELECT count(*) FROM t1}} msg] lappend rc $msg @@ -454,6 +455,7 @@ do_test misc1-14.1 { file exists ./test.db-journal } {0} do_test misc1-14.2 { + execsql {UPDATE t1 SET a=0 WHERE 0} file exists ../test.db-journal } {1} do_test misc1-14.3 { diff --git a/test/progress.test b/test/progress.test index 15d769d49..90bb63d2f 100755 --- a/test/progress.test +++ b/test/progress.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the 'progress callback'. # -# $Id: progress.test,v 1.1 2003/10/18 09:37:27 danielk1977 Exp $ +# $Id: progress.test,v 1.2 2004/05/31 08:26:50 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -49,11 +49,11 @@ do_test progress-1.0 { do_test progress1.1 { set counter 0 db progress 1 "[namespace code {incr counter}] ; expr 1" - execsql { + set rc [catch {execsql { SELECT * FROM t1 - } - set counter -} 1 + }}] + list $counter $rc +} {1 1} # Test that the query is rolled back when the progress callback returns # non-zero. @@ -75,8 +75,8 @@ do_test progress1.2 { # some data will have been inserted into the table by the time the progress # callback abandons the query. db progress $five_rows "expr 1" - execsql { - INSERT INTO t1 SELECT a+10 FROM t1 WHERE a < 7 + catchsql { + INSERT INTO t1 SELECT a+10 FROM t1 WHERE a < 9 } execsql { SELECT count(*) FROM t1 @@ -93,7 +93,7 @@ do_test progress1.3 { INSERT INTO t1 VALUES(11) } db progress 1 "expr 1" - execsql { + catchsql { INSERT INTO t1 VALUES(12) } db progress 0 "" diff --git a/test/trans.test b/test/trans.test index a2a443c15..4e59a63cc 100644 --- a/test/trans.test +++ b/test/trans.test @@ -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.19 2004/03/08 13:26:18 drh Exp $ +# $Id: trans.test,v 1.20 2004/05/31 08:26:50 danielk1977 Exp $ set testdir [file dirname $argv0] @@ -88,6 +88,7 @@ integrity_check trans-2.11 do_test trans-3.1 { execsql { BEGIN; + UPDATE one SET a = 0 WHERE 0; SELECT a FROM one ORDER BY a; } } {1 2 3} @@ -183,6 +184,7 @@ do_test trans-4.2 { do_test trans-4.3 { set v [catch {execsql { BEGIN TRANSACTION; + UPDATE two SET a = 0 WHERE 0; SELECT a FROM two ORDER BY a; } db} msg] lappend v $msg |