diff --git a/manifest b/manifest index 4f21e27075..7afc30ed3a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Tests\sto\simprove\scoverage\sof\svdbeaux.c.\s(CVS\s2201) -D 2005-01-12T09:10:40 +C Tests\sto\simprove\scoverage\sof\smain.c.\s(CVS\s2202) +D 2005-01-12T12:44:04 F Makefile.in ecf441ac5ca1ccfc8748a8a9537706e69893dfa4 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1 @@ -41,7 +41,7 @@ F src/hash.c a97721a55440b7bea31ffe471bb2f6b4123cddd5 F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84 F src/insert.c f6b69e40e8938f63a2368cbcb5087a56098cf632 F src/legacy.c d58ea507bce885298a2c8c3cbb0f4bff5d47830b -F src/main.c a05e1e50406d2776272c1470077136f63866bbe2 +F src/main.c 977c401767bce91952cd3c86f28c35efc1b50e75 F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070 F src/os.h c92a675533c75fea0f53559f34c7b91c5afe1a9d F src/os_common.h 0e7f428ba0a6c40a61bc56c4e96f493231301b73 @@ -64,8 +64,8 @@ F src/shell.c e8f4f486cbf6e60d81173146ac8a6522c930fa51 F src/sqlite.h.in 0d5e48e506845b74a845c9470e01d3f472b59611 F src/sqliteInt.h 087d21946d79c6eec1b84a32122def5fd99ee03b F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9 -F src/tclsqlite.c 75a8dc9cd7ac0f41482bd7b96b99d54e62b6e98f -F src/test1.c 30584dd0b7eb501534c5f4b2292b13a32ef58651 +F src/tclsqlite.c 8419f424ebcc6ae0d391f21a991638cb20c2ffc6 +F src/test1.c 540e1f51cf37d5a05871562e87d976909ab517a1 F src/test2.c b11fa244fff02190707dd0879987c37c75e61fc8 F src/test3.c a72f20066cccd5a7b9f20b7b78fa9b05b47b3020 F src/test4.c 7c6b9fc33dd1f3f93c7f1ee6e5e6d016afa6c1df @@ -105,7 +105,7 @@ F test/btree4.test 3797b4305694c7af6828675b0f4b1424b8ca30e4 F test/btree5.test 8e5ff32c02e685d36516c6499add9375fe1377f2 F test/btree6.test a5ede6bfbbb2ec8b27e62813612c0f28e8f3e027 F test/btree7.test a6d3b842db22af97dd14b989e90a2fd96066b72f -F test/capi2.test 8279d1d5ca1f9b518d78fefd01fd58958c7240d6 +F test/capi2.test 325e8d68fe7b3c518f73a37f039c52278be8f101 F test/capi3.test 3b33bf7c8836028835354c055989314e9c969c5c F test/capi3b.test 5b6a66f9f295f79f443b5d3f33187fa5ef6cf336 F test/collate1.test f79736d2ebf5492167ee4d1f4ab4c09dda776b03 @@ -146,11 +146,11 @@ F test/join4.test 8dec387d06b3a4685e1104048065cf5236b99b93 F test/lastinsert.test b6a1db3e1ce2d3f0d6afe99d445084f543b6feaa F test/laststmtchanges.test 07cbdabc52407c29e40abc25050f2434f044a6b1 F test/limit.test 0225cadf96f199566b6d1ae7b5642492878ec45a -F test/lock.test 32fe28e5030f25f23bcf6beef440675b0d848413 +F test/lock.test a19aab9a963273fe61c1058e3d1b648d6a0a2425 F test/lock2.test 59c3dd7d9b24d1bf7ec91b2d1541c37e97939d5f F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9 F test/main.test a60a1d234b5f5784097973bd395514ca56003ef1 -F test/malloc.test c3985c0a5a2f28dbfdb68a4e07886f9090feeda1 +F test/malloc.test 5a18f953212cc14ec999b5abf9d2a781a18d7a1e F test/memdb.test 532aac7128a3da494cddc4461d76c6e3988f771b F test/memleak.test f1fa233f8295dd1d955a00d5e5ee857850f27f29 F test/minmax.test e7048476940df0af11d0f2cf687572f557cd0b29 @@ -185,7 +185,7 @@ F test/sort.test 87882e6c72a75d45e98a1c802c1ded0eac557d85 F test/subselect.test ff3850d0aab1443dafa4ecbdab1d01e58e7b366d F test/table.test b8b0bee2ac2f3d36a674bc68344c1bdd80e99a18 F test/tableapi.test b21ab097e87a5484bb61029e69e1a4e5c5e65ede -F test/tclsqlite.test 8b9dae3b68a899e5cbaebe6bb51cfc27f2503c6d +F test/tclsqlite.test f467d9062e17c1ace54467e6fba5ce3ca176c0fe F test/temptable.test 63a16e3ad19adf073cfbcdf7624c92ac5236522c F test/tester.tcl 071ad70ee2c1d3393e20baabaac03f07e7925cfe F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35 @@ -268,7 +268,7 @@ F www/tclsqlite.tcl e73f8f8e5f20e8277619433f7970060ab01088fc F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/whentouse.tcl c3b50d3ac31c54be2a1af9b488a89d22f1e6e746 -P 319bb4a9064deb062a888fdc31067619c9b749bb -R eca04ac646dc0adf8b62dade6edd7859 +P 2b3e21ce2e8126ec2851751546094c3a2c831942 +R 5afae1e8307f40841f1da323337aa8a5 U danielk1977 -Z bac0bd5515f392b48e8053527f28ff2a +Z 16673a65fc0ffd926dfd73f55b52e6d7 diff --git a/manifest.uuid b/manifest.uuid index e9bbbfea7e..0425010029 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2b3e21ce2e8126ec2851751546094c3a2c831942 \ No newline at end of file +4e28c82adabb58ad9f79ed829734a2ff569a7c05 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 386dcbaf90..75d93956d8 100644 --- a/src/main.c +++ b/src/main.c @@ -14,7 +14,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: main.c,v 1.269 2005/01/08 18:42:28 drh Exp $ +** $Id: main.c,v 1.270 2005/01/12 12:44:04 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -1160,14 +1160,8 @@ static int openDatabase( ** is accessed. */ sqlite3RegisterBuiltinFunctions(db); - if( rc==SQLITE_OK ){ - sqlite3Error(db, SQLITE_OK, 0); - db->magic = SQLITE_MAGIC_OPEN; - }else{ - sqlite3Error(db, rc, "%s", zErrMsg, 0); - if( zErrMsg ) sqliteFree(zErrMsg); - db->magic = SQLITE_MAGIC_CLOSED; - } + sqlite3Error(db, SQLITE_OK, 0); + db->magic = SQLITE_MAGIC_OPEN; opendb_out: if( sqlite3_errcode(db)==SQLITE_OK && sqlite3_malloc_failed ){ diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 7561fdc639..00dee1837f 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -11,7 +11,7 @@ ************************************************************************* ** A TCL Interface to SQLite ** -** $Id: tclsqlite.c,v 1.113 2005/01/12 00:08:25 drh Exp $ +** $Id: tclsqlite.c,v 1.114 2005/01/12 12:44:04 danielk1977 Exp $ */ #ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ @@ -406,7 +406,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ "errorcode", "eval", "function", "last_insert_rowid", "onecolumn", "progress", "rekey", "timeout", "total_changes", - "trace", + "trace", "version", 0 }; enum DB_enum { @@ -416,7 +416,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ DB_ERRORCODE, DB_EVAL, DB_FUNCTION, DB_LAST_INSERT_ROWID, DB_ONECOLUMN, DB_PROGRESS, DB_REKEY, DB_TIMEOUT, DB_TOTAL_CHANGES, - DB_TRACE + DB_TRACE, DB_VERSION }; /* don't leave trailing commas on DB_enum, it confuses the AIX xlc compiler */ @@ -1279,6 +1279,15 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ break; } + /* $db version + ** + ** Return the version string for this database. + */ + case DB_VERSION: { + Tcl_SetResult(interp, (char *)sqlite3_libversion(), TCL_STATIC); + break; + } + } /* End of the SWITCH statement */ return rc; diff --git a/src/test1.c b/src/test1.c index 152765306b..7db3615ab6 100644 --- a/src/test1.c +++ b/src/test1.c @@ -13,7 +13,7 @@ ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test1.c,v 1.120 2005/01/12 07:15:05 danielk1977 Exp $ +** $Id: test1.c,v 1.121 2005/01/12 12:44:04 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -483,7 +483,7 @@ static int test_create_function( if( argc!=2 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " FILENAME\"", 0); + " DB\"", 0); return TCL_ERROR; } if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; @@ -504,6 +504,7 @@ static int test_create_function( #endif if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; + Tcl_SetResult(interp, (char *)errorName(rc), 0); return TCL_OK; } @@ -907,10 +908,12 @@ static int test_finalize( if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; - db = StmtToDb(pStmt); + if( pStmt ){ + db = StmtToDb(pStmt); + } rc = sqlite3_finalize(pStmt); Tcl_SetResult(interp, (char *)errorName(rc), TCL_STATIC); - if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; + if( db && sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; return TCL_OK; } @@ -937,7 +940,9 @@ static int test_reset( if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR; rc = sqlite3_reset(pStmt); - if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; + if( pStmt && + sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; + Tcl_SetResult(interp, (char *)errorName(rc), TCL_STATIC); if( rc ){ return TCL_ERROR; } diff --git a/test/capi2.test b/test/capi2.test index 08e95e5cef..1dfdd3c4fd 100644 --- a/test/capi2.test +++ b/test/capi2.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script testing the callback-free C/C++ API. # -# $Id: capi2.test,v 1.22 2004/11/22 10:02:22 danielk1977 Exp $ +# $Id: capi2.test,v 1.23 2005/01/12 12:44:04 danielk1977 Exp $ # set testdir [file dirname $argv0] @@ -618,6 +618,13 @@ do_test capi2-9.1 { sqlite3_finalize $VM1 } {SQLITE_OK} +do_test capi2-10.1 { + sqlite3_finalize 0 +} {SQLITE_OK} +do_test capi2-10.2 { + sqlite3_reset 0 +} {SQLITE_OK} + db2 close finish_test diff --git a/test/lock.test b/test/lock.test index 053d7183c1..d56a05c4fc 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.29 2004/11/22 10:02:23 danielk1977 Exp $ +# $Id: lock.test,v 1.30 2005/01/12 12:44:04 danielk1977 Exp $ set testdir [file dirname $argv0] @@ -212,8 +212,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 + catchsql {BEGIN EXCLUSIVE;} db2 } {1 {database is locked}} do_test lock-2.9 { db2 timeout 0 diff --git a/test/malloc.test b/test/malloc.test index 9b117b68e9..ad501d42de 100644 --- a/test/malloc.test +++ b/test/malloc.test @@ -14,7 +14,7 @@ # special feature is used to see what happens in the library if a malloc # were to really fail due to an out-of-memory situation. # -# $Id: malloc.test,v 1.15 2005/01/12 09:10:41 danielk1977 Exp $ +# $Id: malloc.test,v 1.16 2005/01/12 12:44:04 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -27,6 +27,66 @@ if {[info command sqlite_malloc_stat]==""} { return } +# Usage: do_malloc_test +# +# The first argument, , is an integer used to name the +# tests executed by this proc. Options are as follows: +# +# -tclprep TCL script to run to prepare test. +# -sqlprep SQL script to run to prepare test. +# -tclbody TCL script to run with IO error simulation. +# -sqlbody TCL script to run with IO error simulation. +# +proc do_malloc_test {tn args} { + array set ::mallocopts $args + + set ::go 1 + for {set ::n 1} {$::go} {incr ::n} { + + do_test malloc-$tn.$::n { + + sqlite_malloc_fail 0 + catch {db close} + catch {file delete -force test.db} + catch {file delete -force test.db-journal} + catch {file delete -force test2.db} + catch {file delete -force test2.db-journal} + set ::DB [sqlite3 db test.db] + + if {[info exists ::mallocopts(-tclprep)]} { + eval $::mallocopts(-tclprep) + } + if {[info exists ::mallocopts(-sqlprep)]} { + execsql $::mallocopts(-sqlprep) + } + + sqlite_malloc_fail $::n + set ::mallocbody {} + if {[info exists ::mallocopts(-tclbody)]} { + append ::mallocbody "$::mallocopts(-tclbody)\n" + } + if {[info exists ::mallocopts(-sqlbody)]} { + append ::mallocbody "db eval {$::mallocopts(-sqlbody)}" + } + + set v [catch $::mallocbody msg] + + set leftover [lindex [sqlite_malloc_stat] 2] + if {$leftover>0} { + if {$leftover>1} {puts "\nLeftover: $leftover\nReturn=$v Message=$msg"} + set ::go 0 + set v {1 1} + } else { + set v2 [expr {$msg=="" || $msg=="out of memory"}] + if {!$v2} {puts "\nError message returned: $msg"} + lappend v $v2 + } + } {1 1} + } +} + +if 0 { + for {set go 1; set i 1} {$go} {incr i} { do_test malloc-1.$i { sqlite_malloc_fail 0 @@ -386,45 +446,47 @@ for {set go 1; set i 1} {$go && $::sqlite_options(utf16)} {incr i} { } {0} } + # This block tests that malloc() failures that occur whilst commiting # a multi-file transaction are handled correctly. # -for {set go 1; set i 1} {$go} {incr i} { - do_test malloc-9.$i { - sqlite_malloc_fail 0 - catch {db close} - catch {file delete -force test.db} - catch {file delete -force test.db-journal} - catch {file delete -force test2.db} - catch {file delete -force test2.db-journal} - - sqlite3 db test.db - execsql { - ATTACH 'test2.db' as test2; - CREATE TABLE abc1(a, b, c); - CREATE TABLE test2.abc2(a, b, c); - } - - sqlite_malloc_fail $i - set v [catch {execsql { - BEGIN; - INSERT INTO abc1 VALUES(1, 2, 3); - INSERT INTO abc2 VALUES(1, 2, 3); - COMMIT; - }} msg] - set leftover [lindex [sqlite_malloc_stat] 2] - if {$leftover>0} { - if {$leftover>1} {puts "\nLeftover: $leftover\nReturn=$v Message=$msg"} - set ::go 0 - set v {1 1} - } else { - set v2 [expr {$msg=="" || $msg=="out of memory"}] - if {!$v2} {puts "\nError message returned: $msg"} - lappend v $v2 - } - } {1 1} +do_malloc_test 9 -sqlprep { + ATTACH 'test2.db' as test2; + CREATE TABLE abc1(a, b, c); + CREATE TABLE test2.abc2(a, b, c); +} -sqlbody { + BEGIN; + INSERT INTO abc1 VALUES(1, 2, 3); + INSERT INTO abc2 VALUES(1, 2, 3); + COMMIT; } +} + +# This block tests malloc() failures that occur while opening a +# connection to a database. +do_malloc_test 10 -sqlprep { + CREATE TABLE abc(a, b, c); +} -tclbody { + set ::DB [sqlite3 db2 test.db] + db2 eval {SELECT * FROM sqlite_master} + db2 close +} + +# This block tests malloc() failures that occur within calls to +# sqlite3_create_function(). +do_malloc_test 11 -tclbody { + if {[string match [sqlite3_create_function $::DB] SQLITE_NOMEM]==0} { + error "out of memory" + } +} + +do_malloc_test 12 -tclbody { + set sql16 [encoding convertto unicode "SELECT * FROM sqlite_master"] + append sql16 "\00\00" + set ::STMT [sqlite3_prepare16 $::DB $sql16 -1 DUMMY] + sqlite3_finalize $::STMT +} # Ensure that no file descriptors were leaked. do_test malloc-99.X { diff --git a/test/tclsqlite.test b/test/tclsqlite.test index ec4e4220de..b949b5ad8f 100644 --- a/test/tclsqlite.test +++ b/test/tclsqlite.test @@ -15,7 +15,7 @@ # interface is pretty well tested. This file contains some addition # tests for fringe issues that the main test suite does not cover. # -# $Id: tclsqlite.test,v 1.35 2004/12/17 15:41:13 tpoindex Exp $ +# $Id: tclsqlite.test,v 1.36 2005/01/12 12:44:04 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -34,7 +34,7 @@ do_test tcl-1.1 { do_test tcl-1.2 { set v [catch {db bogus} msg] lappend v $msg -} {1 {bad option "bogus": must be authorizer, busy, changes, close, collate, collation_needed, commit_hook, complete, copy, errorcode, eval, function, last_insert_rowid, onecolumn, progress, rekey, timeout, total_changes, or trace}} +} {1 {bad option "bogus": must be authorizer, busy, changes, close, collate, collation_needed, commit_hook, complete, copy, errorcode, eval, function, last_insert_rowid, onecolumn, progress, rekey, timeout, total_changes, trace, or version}} do_test tcl-1.3 { execsql {CREATE TABLE t1(a int, b int)} execsql {INSERT INTO t1 VALUES(10,20)} @@ -295,4 +295,9 @@ do_test tcl-6.7 { return_test 0 } {} +do_test tcl-7.1 { + db version + expr 0 +} {0} + finish_test