Add support for SQLITE_OPEN_FULLMUTEX. (CVS 5669)

FossilOrigin-Name: f2f361a5e2fb81fb0f99e83ecf8bae9a750723b1
This commit is contained in:
drh 2008-09-03 00:43:15 +00:00
parent a9625eaeb9
commit 039963ad33
6 changed files with 59 additions and 21 deletions

View File

@ -1,5 +1,5 @@
C If\sa\srollback\sfails,\smark\sthe\sdatabase\sas\scorrupt.\s(CVS\s5668)
D 2008-09-03T00:08:29
C Add\ssupport\sfor\sSQLITE_OPEN_FULLMUTEX.\s(CVS\s5669)
D 2008-09-03T00:43:15
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 689e14735f862a5553bceef206d8c13e29504e44
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -116,7 +116,7 @@ F src/insert.c 110cca7845ed5a66c08fdd413b02e706ae34455f
F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
F src/legacy.c aac57bd984e666059011ea01ec4383892a253be3
F src/loadext.c 6581a5bbc4d74fcd46dbbcfd695a6a5417f778a2
F src/main.c a679dd3e0f040d13d72b9800840e07bedd6aa2d4
F src/main.c 088b513b16b480e96cbabab883107e0e74646a2e
F src/malloc.c 9aa2ef805287017ed16a9e3809d275b8af26b762
F src/mem1.c 5a529ff121c55ab067be14de00f86f6dcc4f4fb9
F src/mem2.c f87e681d0d1ed8436870d089332ed0d27d885b5c
@ -153,7 +153,7 @@ F src/sqliteInt.h 4e81ab61bc9a942f0dafdb8c2cec7825f6eba2f5
F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76
F src/table.c 22744786199c9195720c15a7a42cb97b2e2728d8
F src/tclsqlite.c 01312c2af41189ff20335d6ac64e3dbda57e627b
F src/tclsqlite.c f431fe065a024e80b32a4691bab73beaccda024e
F src/test1.c 349606445a5a938e9fa9b5e410413632c6c25f87
F src/test2.c eaa77124786649eedf47d3c5e94d8070c0da228f
F src/test3.c e85b7ce5c28c3ce7fbdbf7f98e1467b19786c62b
@ -448,7 +448,7 @@ F test/pager3.test 2323bf27fd5bd887b580247e5bce500ceee994b4
F test/pageropt.test 3ee6578891baaca967f0bd349e4abfa736229e1a
F test/pagesize.test 0d9ff3fedfce6e5ffe8fa7aca9b6d3433a2e843b
F test/pcache.test a0fc9e965d039c4de24f9af929f9a25eb8be8539
F test/permutations.test e4509095a9870ae13b6184b3b957f78675716e6f
F test/permutations.test b3dc25ef805a940e23b7e1a8189cc8a06f21ca0a
F test/pragma.test 4461cb1004084b907dd28f9d517af7bcf8f5b35f
F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47
F test/printf.test 262a5acd3158f788e9bdf7f18d718f3af32ff6ef
@ -501,7 +501,7 @@ F test/substr.test 4be572ac017143e59b4058dc75c91a0d0dc6d4e0
F test/sync.test ded6b39d8d8ca3c0c5518516c6371b3316d3e3a3
F test/table.test 13b1c2e2fb4727b35ee1fb7641fc469214fd2455
F test/tableapi.test 505031f15b18a750184d967d2c896cf88fcc969c
F test/tclsqlite.test 401358dc4669fa4993cc129510edcd206289e029
F test/tclsqlite.test 9689ded2f8909362e869eb8bd8c2f5219f4f12af
F test/tempdb.test b88ac8a19823cf771d742bf61eef93ef337c06b1
F test/temptable.test 19b851b9e3e64d91e9867619b2a3f5fffee6e125
F test/tester.tcl 12fd8394caeb71f7d961707da8668756389bc9d3
@ -630,7 +630,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P fa237c14c8551315ea8f239e89a81b7725675c81
R bef98882f050cbe8a7e09b4a627b9eac
P c8b24bd1be94b6d385e759a2f9e202be066578a0
R 40631eb64a3c216515d7d10a0d831308
U drh
Z b8216416ceb392107a1119cd9017e017
Z 44c1ecf2f51b2cc145c32f8106994277

View File

@ -1 +1 @@
c8b24bd1be94b6d385e759a2f9e202be066578a0
f2f361a5e2fb81fb0f99e83ecf8bae9a750723b1

View File

@ -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.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 <ctype.h>
@ -1426,15 +1426,21 @@ static int openDatabase(
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 */
@ -1446,13 +1452,14 @@ static int openDatabase(
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);

View File

@ -12,7 +12,7 @@
** 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 <errno.h>
@ -2374,9 +2374,19 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
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;
}else{
flags &= ~SQLITE_OPEN_FULLMUTEX;
}
}else{
Tcl_AppendResult(interp, "unknown option: ", zArg, (char*)0);
return TCL_ERROR;
@ -2385,7 +2395,7 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
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

View File

@ -9,7 +9,7 @@
#
#***********************************************************************
#
# $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
@ -266,7 +266,7 @@ run_tests "singlethread" -description {
}
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} {
@ -306,6 +306,27 @@ run_tests "multithread" -description {
} 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 {

View File

@ -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.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
@ -25,7 +25,7 @@ source $testdir/tester.tcl
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]