Index: src/main.c ================================================================== --- src/main.c +++ src/main.c @@ -12,11 +12,11 @@ ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: main.c,v 1.498 2008/09/02 16:22:29 danielk1977 Exp $ +** $Id: main.c,v 1.499 2008/09/03 00:43:15 drh Exp $ */ #include "sqliteInt.h" #include #ifdef SQLITE_ENABLE_FTS3 @@ -1424,19 +1424,25 @@ const char *zVfs /* Name of the VFS to use */ ){ sqlite3 *db; int rc; CollSeq *pColl; - int isThreadsafe = 1; + int isThreadsafe; #ifndef SQLITE_OMIT_AUTOINIT rc = sqlite3_initialize(); if( rc ) return rc; #endif - if( flags&SQLITE_OPEN_NOMUTEX ){ + if( sqlite3GlobalConfig.bCoreMutex==0 ){ + isThreadsafe = 0; + }else if( flags & SQLITE_OPEN_NOMUTEX ){ isThreadsafe = 0; + }else if( flags & SQLITE_OPEN_FULLMUTEX ){ + isThreadsafe = 1; + }else{ + isThreadsafe = sqlite3GlobalConfig.bFullMutex; } /* Remove harmful bits from the flags parameter */ flags &= ~( SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_MAIN_DB | @@ -1444,17 +1450,18 @@ SQLITE_OPEN_TRANSIENT_DB | SQLITE_OPEN_MAIN_JOURNAL | SQLITE_OPEN_TEMP_JOURNAL | SQLITE_OPEN_SUBJOURNAL | SQLITE_OPEN_MASTER_JOURNAL | - SQLITE_OPEN_NOMUTEX + SQLITE_OPEN_NOMUTEX | + SQLITE_OPEN_FULLMUTEX ); /* Allocate the sqlite data structure */ db = sqlite3MallocZero( sizeof(sqlite3) ); if( db==0 ) goto opendb_out; - if( sqlite3GlobalConfig.bFullMutex && isThreadsafe ){ + if( isThreadsafe ){ db->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE); if( db->mutex==0 ){ sqlite3_free(db); db = 0; goto opendb_out; Index: src/tclsqlite.c ================================================================== --- src/tclsqlite.c +++ src/tclsqlite.c @@ -10,11 +10,11 @@ ** ************************************************************************* ** A TCL Interface to SQLite. Append this file to sqlite3.c and ** compile the whole thing to build a TCL-enabled version of SQLite. ** -** $Id: tclsqlite.c,v 1.221 2008/09/01 20:38:12 shane Exp $ +** $Id: tclsqlite.c,v 1.222 2008/09/03 00:43:15 drh Exp $ */ #include "tcl.h" #include /* @@ -2372,7 +2372,15 @@ }else if( strcmp(zArg, "-nomutex")==0 ){ int b; if( Tcl_GetBooleanFromObj(interp, objv[i+1], &b) ) return TCL_ERROR; if( b ){ flags |= SQLITE_OPEN_NOMUTEX; + flags &= ~SQLITE_OPEN_FULLMUTEX; }else{ flags &= ~SQLITE_OPEN_NOMUTEX; + } + }else if( strcmp(zArg, "-fullmutex")==0 ){ + int b; + if( Tcl_GetBooleanFromObj(interp, objv[i+1], &b) ) return TCL_ERROR; + if( b ){ + flags |= SQLITE_OPEN_FULLMUTEX; + flags &= ~SQLITE_OPEN_NOMUTEX; @@ -2379,15 +2387,17 @@ + }else{ + flags &= ~SQLITE_OPEN_FULLMUTEX; } }else{ Tcl_AppendResult(interp, "unknown option: ", zArg, (char*)0); return TCL_ERROR; } } if( objc<3 || (objc&1)!=1 ){ Tcl_WrongNumArgs(interp, 1, objv, "HANDLE FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN?" - " ?-nomutex BOOLEAN?" + " ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN?" #ifdef SQLITE_HAS_CODEC " ?-key CODECKEY?" #endif ); return TCL_ERROR; Index: test/permutations.test ================================================================== --- test/permutations.test +++ test/permutations.test @@ -7,11 +7,11 @@ # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # -# $Id: permutations.test,v 1.27 2008/08/30 16:07:04 drh Exp $ +# $Id: permutations.test,v 1.28 2008/09/03 00:43:15 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Argument processing. @@ -264,11 +264,11 @@ sqlite3_config serialized } SQLITE_OK } run_tests "nomutex" -description { - Tests run with the SQLITE_OPEN_SINGLETHREADED flag passed to sqlite3_open(). + Tests run with the SQLITE_OPEN_MULTITHREADED flag passed to sqlite3_open(). } -initialize { rename sqlite3 sqlite3_nomutex proc sqlite3 {args} { if {[string range [lindex $args 0] 0 0] ne "-"} { lappend args -nomutex 1 @@ -303,10 +303,31 @@ catch {db close} sqlite3_shutdown sqlite3_config serialized } SQLITE_OK } + +# Run some tests in SQLITE_OPEN_FULLMUTEX mode. +# +run_tests "fullmutex" -description { + Tests run in SQLITE_OPEN_FULLMUTEX mode +} -initialize { + rename sqlite3 sqlite3_fullmutex + proc sqlite3 {args} { + if {[string range [lindex $args 0] 0 0] ne "-"} { + lappend args -fullmutex 1 + } + uplevel [concat sqlite3_fullmutex $args] + } +} -include { + delete.test delete2.test insert.test rollback.test select1.test + select2.test trans.test update.test vacuum.test types.test + types2.test types3.test +} -shutdown { + rename sqlite3 {} + rename sqlite3_fullmutex sqlite3 +} # Run some tests using the "onefile" demo. # run_tests "onefile" -description { Run some tests using the "test_onefile.c" demo Index: test/tclsqlite.test ================================================================== --- test/tclsqlite.test +++ test/tclsqlite.test @@ -13,21 +13,21 @@ # # Actually, all tests are based on the TCL interface, so the main # 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.67 2008/08/29 15:54:57 danielk1977 Exp $ +# $Id: tclsqlite.test,v 1.68 2008/09/03 00:43:15 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Check the error messages generated by tclsqlite # if {[sqlite3 -has-codec]} { set r "sqlite_orig HANDLE FILENAME ?-key CODEC-KEY?" } else { - set r "sqlite3 HANDLE FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN? ?-nomutex BOOLEAN?" + set r "sqlite3 HANDLE FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN? ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN?" } do_test tcl-1.1 { set v [catch {sqlite3 bogus} msg] regsub {really_sqlite3} $msg {sqlite3} msg lappend v $msg