Index: src/test_thread.c ================================================================== --- src/test_thread.c +++ src/test_thread.c @@ -280,10 +280,25 @@ UNUSED_PARAMETER(clientData); UNUSED_PARAMETER(objc); zFilename = Tcl_GetString(objv[2]); rc = sqlite3_open(zFilename, &db); +#ifdef SQLITE_HAS_CODEC + if( db && objc>=4 ){ + const char *zKey; + int nKey; + zKey = Tcl_GetStringFromObj(objv[3], &nKey); + rc = sqlite3_key(db, zKey, nKey); + if( rc!=SQLITE_OK ){ + char *zErrMsg = sqlite3_mprintf("error %d: %s", rc, sqlite3_errmsg(db)); + sqlite3_close(db); + Tcl_AppendResult(interp, zErrMsg, (char*)0); + sqlite3_free(zErrMsg); + return TCL_ERROR; + } + } +#endif Md5_Register(db); sqlite3_busy_handler(db, xBusy, 0); if( sqlite3TestMakePointerStr(interp, zBuf, db) ) return TCL_ERROR; Tcl_AppendResult(interp, zBuf, 0); @@ -347,11 +362,11 @@ interp, objv[1], aSub, sizeof(aSub[0]), "sub-command", 0, &iIndex ); if( rc!=TCL_OK ) return rc; pSub = &aSub[iIndex]; - if( objc!=(pSub->nArg+2) ){ + if( objc<(pSub->nArg+2) ){ Tcl_WrongNumArgs(interp, 2, objv, pSub->zUsage); return TCL_ERROR; } return pSub->xProc(clientData, interp, objc, objv); Index: test/thread001.test ================================================================== --- test/thread001.test +++ test/thread001.test @@ -40,11 +40,11 @@ do_test thread001.$tn.0 { db close sqlite3_enable_shared_cache $shared_cache sqlite3_enable_shared_cache $shared_cache } $shared_cache - sqlite3 db test.db -fullmutex 1 + sqlite3 db test.db -fullmutex 1 -key xyzzy set dbconfig "" if {$same_db} { set dbconfig [list set ::DB [sqlite3_connection_pointer db]] } @@ -75,11 +75,11 @@ set thread_program { #sqlthread parent {puts STARTING..} set needToClose 0 if {![info exists ::DB]} { - set ::DB [sqlthread open test.db] + set ::DB [sqlthread open test.db xyzzy] #sqlthread parent "puts \"OPEN $::DB\"" set needToClose 1 } for {set i 0} {$i < 100} {incr i} { Index: test/thread002.test ================================================================== --- test/thread002.test +++ test/thread002.test @@ -14,12 +14,14 @@ # # $Id: thread002.test,v 1.9 2009/03/26 14:48:07 danielk1977 Exp $ set testdir [file dirname $argv0] +set do_not_use_codec 1 source $testdir/tester.tcl if {[run_thread_tests]==0} { finish_test ; return } + db close set ::enable_shared_cache [sqlite3_enable_shared_cache 1] set ::NTHREAD 10 Index: test/thread003.test ================================================================== --- test/thread003.test +++ test/thread003.test @@ -78,11 +78,11 @@ puts "Starting thread003.2 (should run for ~$nSecond seconds)" do_test thread003.2 { foreach zFile {test.db test2.db} { set SCRIPT [format { set iEnd [expr {[clock_seconds] + %d}] - set ::DB [sqlthread open %s] + set ::DB [sqlthread open %s xyzzy] # Set the cache size to 15 pages per cache. 30 available globally. execsql { PRAGMA cache_size = 15 } while {[clock_seconds] < $iEnd} { @@ -115,11 +115,11 @@ do_test thread003.3 { foreach zFile {test.db test2.db} { set SCRIPT [format { set iStart [clock_seconds] set iEnd [expr {[clock_seconds] + %d}] - set ::DB [sqlthread open %s] + set ::DB [sqlthread open %s xyzzy] # Set the cache size to 15 pages per cache. 30 available globally. execsql { PRAGMA cache_size = 15 } while {[clock_seconds] < $iEnd} { @@ -154,11 +154,11 @@ unset -nocomplain finished(1) unset -nocomplain finished(2) do_test thread003.4 { thread_spawn finished(1) $thread_procs [format { set iEnd [expr {[clock_seconds] + %d}] - set ::DB [sqlthread open test.db] + set ::DB [sqlthread open test.db xyzzy] # Set the cache size to 15 pages per cache. 30 available globally. execsql { PRAGMA cache_size = 15 } while {[clock_seconds] < $iEnd} {