-C Make\ssure\saggregate\sfunctions\scan\stake\sany\snumber\sof\sarguments\sup\sto\sthe\nlimit\simposed\sby\sSQLITE_LIMIT_FUNCTION_ARGS.\s\sTicket\s#3179.\s\sModify\nthe\sgroup_concat()\sfunction\sto\stake\san\sunlimited\snumber\sof\sarguments\sin\norder\sto\sfacilitate\stesting\sthis\sbehavior.\s(CVS\s5233)
-D 2008-06-18T15:34:10
+C Implement\sthe\s'CONFIG_SINGLETHREAD'\sand\s'CONFIG_MULTITHREAD'\sconfiguration\smodes.\s(CVS\s5234)
+D 2008-06-18T17:09:10
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in dc5608df93faf4406cfd7a1c8ed9ab93d8bfbfd5
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
F src/bitvec.c ab50c4b8c6a899dae499f5a805eebe4223c78269
F src/btmutex.c 483ced3c52205b04b97df69161fadbf87f4f1ea2
-F src/btree.c a7b1ffdde06b8e854076789e393b315ee7856ae5
+F src/btree.c bae7f135dad8fd72ac41ce3c13b7b7ba9fe4d056
F src/btree.h b1bd7e0b8c2e33658aaf447cb0d1d94f74664b6b
F src/btreeInt.h 02325f04758dba0fcd0c08ac55cd9b189dad61a5
F src/build.c 88cc5501a87f72d0538b040001d88d31f994edea
F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
-F src/date.c bbc4114d1b946d6a94d060bc5b9edce7142c6086
+F src/date.c e841168e5520bbbb2a1cbcdce7531d8b23017b4d
F src/delete.c d3fc5987f2eb88f7b9549d58a5dfea079a83fe8b
F src/expr.c ecb3b23d3543427cba3e2ac12a6c6ae4bb20d39b
F src/fault.c 1f6177188edb00641673e462f3fab8cba9f7422b
F src/insert.c c2ead6c36566de8e3f130e7ab1431723a269d5d7
F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
F src/legacy.c 3626c71fb70912abec9a4312beba753a9ce800df
-F src/loadext.c f99a75534a53e281fa2461239ee4a4b4bf6ad564
-F src/main.c 34c9d9f99e0c6df25ac9d6e1a9c0964d8170cbe2
-F src/malloc.c 7b622d22f29e3be56d271a5a921f3b5788330189
+F src/loadext.c 2ac671f42a8ce15e2a58155b9d7f6c61eb7e127e
+F src/main.c 619caedf25329b55fe138e581497ec5052bb7e34
+F src/malloc.c 6f84f295db49a79c1e2fc07a63311f5685d47274
F src/md5.c 008216bbb5d34c6fbab5357aa68575ad8a31516a
F src/mem1.c 159f10e280f2d9aea597cf938851e61652dd5c3d
-F src/mem2.c 594270b8f0ed6c09ae5fb729eca2864139f9e293
-F src/mem3.c 617c2e2a72a10ecc5c01af14efc8c2596d2c2e87
-F src/mem4.c 45c328ec6dcb7e8d319cb383615b5fe547ca5409
-F src/mem5.c 3d2ff00c6e3bc37f5d82cd82e1a123b246fb7b39
-F src/mutex.c 890b83ccf19de17e88b612b2b3f18009a9f1bfa1
+F src/mem2.c 468a7fd5e0ce1909cfb554d7589af1d4a61f14bb
+F src/mem3.c 28b4812b87470a00b11821fb5850e7cabcce06c6
+F src/mem4.c 6703adb1717b26d9d70a1c2586b4b7b7ffee7909
+F src/mem5.c ad31a0a481b86b86f4ac0b6d952e69727d4e113a
+F src/mutex.c bcd07a29039b192c59117a5eb08fce208fe7d5aa
F src/mutex.h b9b9baf7050f3bb1c723e1d22088a704783a2927
F src/mutex_os2.c b8c1231319e966875f251a7ec137bea353546b87
F src/mutex_unix.c 469a35c105435794375d683f75cad9e848817d19
F src/mutex_w32.c e03baa369c5e8e7ea4dd2e5b3d098e047f7a2f06
-F src/os.c cf7e09d4215f35fc8269f0fa99f03fd2c2978658
+F src/os.c e9f37351dc4aacc4861f0adbe463f21c8f5969fa
F src/os.h c9a7f94e80193fd4cf27f5c5698eb56753f1b05a
F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
F src/os_os2.c 9f74147f1899793a106827f6bc770363ec377912
-F src/os_unix.c dd4a7b19ec00869764c389560c3faf566cf98a71
+F src/os_unix.c b8c07b0cd85c9909000740dc3f29ce938091b00c
F src/os_win.c 0b90d9a1ce18bfd2a5f3c4a6bdb13ec369c805a9
-F src/pager.c 124b3eaed1bcf9d19b183b5796fa94e292f8cdb8
+F src/pager.c 2f5f55a9405a17240adede9e3b671778fb9a4978
F src/pager.h 6aa3050a3c684475a5a9dbad5ff1cebad612acba
F src/parse.y 8c2c3145eebe1964eb279cb3c4e502eae28bb0fa
F src/pragma.c 70e7c865dce85fdf9df81848af2169009a56ed08
F src/prepare.c 3c19149e75fbf3b08471a389f064da7302cad9c5
F src/printf.c 8b063da9dcde26b7c500a01444b718d86f21bc6e
-F src/random.c 2b2db2de4ab491f5a14d3480466f8f4b5a5db74a
+F src/random.c 362b62e26db90ec9296903377a9d74b4669aa515
F src/select.c 669687459e7d0193c89de06c5dbed55b4a41191c
F src/shell.c a12ea645271b7876c8f080146f48e20b00d367ec
F src/sqlite.h.in 48a3a643fa711141cb53b1c714be74098770e224
F src/sqlite3ext.h faacd0e6a81aabee0861c6d7883c9172e74ef5b3
-F src/sqliteInt.h 90dff45c2fa188ff8763dd5358f7b1040e1bb4fb
+F src/sqliteInt.h 24fe828d52f497d4c026ea3b5f6a01d97ea01a2d
F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
F src/table.c 1fa8f8113ac9cbc09ae4801c6d2a7f0af82c5822
F src/tclsqlite.c 4dd9ee4cb44846ad9bcc4d0da8088c1e7d4b33d9
F src/test1.c 736be7dea5cc126356bbb61a4b1ac5ff4fac7994
F src/test2.c c46d146019ab6e37474e66b3c789e5237d9ea7b7
-F src/test3.c b5c1d1047a45af03375d66b3eec603faafa3ddc6
+F src/test3.c 01ff03164cf6a2bededa3b44ecd481603e2644fc
F src/test4.c c2c0f5dc907f1346f5d4b65eb5799f11eb9e4071
F src/test5.c 3a6a5717a149d7ca2e6d14f5be72cf7555d54dc4
F src/test6.c 0a0304a69cfa4962a429d084c6d451ff9e4fb572
F src/test_loadext.c 22065d601a18878e5542191001f0eaa5d77c0ed8
F src/test_malloc.c 5c2c698355613d321f216ece25901be1040cc1fb
F src/test_md5.c 28209a4e2068711b5443c33104fe41f21d160071
-F src/test_mutex.c f3e1f04fd6a42f9e7ff47784db8bc81e497b5c65
+F src/test_mutex.c 08640d7547bfadb6997a22d72e63914feaf4bc4f
F src/test_onefile.c 1f87d4a21cbfb24a7c35e4333fa0bd34d641f68d
F src/test_osinst.c 867f1317bd135f942a63eab5a78da40fc70d1493
F src/test_schema.c e3f93725f7c5b2cff84a69dc4332040dfbc8f81a
F src/vdbe.c f6866986de706b98c2738040bc65907728650e8d
F src/vdbe.h 1e3722d471739c2b213c6283b60373290e52f7ea
F src/vdbeInt.h de321b2c02593e1420106634ed1f5a7d77ad35a7
-F src/vdbeapi.c 22b01ed175e4d4c613ee82cabc7a44a275641206
+F src/vdbeapi.c 9cf3207a58e484c74c60d61ac037c1cad8aa5b65
F src/vdbeaux.c 09d7a6923d4d71d7028e0d72b9d146d3ece6054e
F src/vdbeblob.c 9345f6dcd675fdcfdb537d2d2f487542d9ea136a
F src/vdbefifo.c c46dae1194e4277bf007144d7e5b0c0b1c24f136
F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91
F test/misc7.test 26e0d948a413bca61ed031159907a03d64647409
F test/misuse.test 30b3a458e5a70c31e74c291937b6c82204c59f33
-F test/mutex1.test 6494fe9e6747328a0b1b0d2676ff4cf1a12fb51d
+F test/mutex1.test c8de096af7ae7ccee2b8f472fecb224b214e24d0
+F test/mutex2.test 6c8f4a5425a27088bc2ad107c71b7abbc2d8534d
F test/nan.test 14c41572ff52dbc740b1c3303dd313a90dc6084c
F test/notnull.test 44d600f916b770def8b095a9962dbe3be5a70d82
F test/null.test a8b09b8ed87852742343b33441a9240022108993
F test/printf.test c3405535b418d454e8a52196a0fc592ec9eec58d
F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x
F test/ptrchng.test 83150cb7b513e33cce90fdc68f4b1817551857c0
-F test/quick.test ebd2ed55075fadf8a44f4e64372091c7bc85e32d
+F test/quick.test 58a082b4cd30ed7d5a06129a6b1ec2550610806b
F test/quote.test 215897dbe8de1a6f701265836d6601cc6ed103e6
F test/rdonly.test b34db316525440d3b42c32e83942c02c37d28ef0
F test/reindex.test 38b138abe36bf9a08c791ed44d9f76cd6b97b78b
F test/vacuum2.test d3b9691541fe6ed5c711f547a1c7d70e9760ac6f
F test/vacuum3.test 6149b24613f487915ca9cedfbb9147d5759714ec
F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
-F test/veryquick.test c08b303a9a6e5bbb27d0988858e919f3b70042aa
+F test/veryquick.test 5117ca7a26f3c86abd5bd34590a82bbccbd79d34
F test/view.test 4864e3841ab3213a95297718b94d5d6a8d3bc78b
F test/vtab1.test 47092e3ac59141f08e09a6c0cc0df8997242bc79
F test/vtab2.test 1da49b015582965a8fc386aa23d051a5a622b08e
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P c3c7bfc9db6774824be14a1394e1842716dce8ec
-R 03ee4502eba907b49b63dcad3c223959
-U drh
-Z 84afc1583f0d4ac82122bd3650c7f8b5
+P 70c6739f4e84b3433e14960346b54d0e9e0bb9c6
+R bcb69678a02b2561df6a33f19115dfbd
+U danielk1977
+Z b2748b102e9ea5fd93fb45dc8d5bd3c0
-70c6739f4e84b3433e14960346b54d0e9e0bb9c6
\ No newline at end of file
+5059644c4bc5f6679afd939e0bc26080f42a9918
\ No newline at end of file
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btree.c,v 1.465 2008/06/17 15:12:01 drh Exp $
+** $Id: btree.c,v 1.466 2008/06/18 17:09:10 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information.
return SQLITE_NOMEM;
}
sqlite3OsFullPathname(pVfs, zFilename, nFullPathname, zFullPathname);
- mutexShared = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
+ mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
sqlite3_mutex_enter(mutexShared);
for(pBt=sqlite3SharedCacheList; pBt; pBt=pBt->pNext){
assert( pBt->nRef>0 );
if( p->sharable ){
sqlite3_mutex *mutexShared;
pBt->nRef = 1;
- mutexShared = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
- if( SQLITE_THREADSAFE ){
- pBt->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
+ mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
+ if( SQLITE_THREADSAFE && sqlite3Config.bCoreMutex ){
+ pBt->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_FAST);
if( pBt->mutex==0 ){
rc = SQLITE_NOMEM;
db->mallocFailed = 0;
int removed = 0;
assert( sqlite3_mutex_notheld(pBt->mutex) );
- pMaster = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
+ pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
sqlite3_mutex_enter(pMaster);
pBt->nRef--;
if( pBt->nRef<=0 ){
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
** All other code has file scope.
**
-** $Id: date.c,v 1.84 2008/06/15 02:51:47 drh Exp $
+** $Id: date.c,v 1.85 2008/06/18 17:09:10 danielk1977 Exp $
**
** SQLite processes all times and dates as Julian Day numbers. The
** dates and times are stored as the number of days since noon
#else
{
struct tm *pTm;
- sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER));
+ sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
pTm = localtime(&t);
y.Y = pTm->tm_year + 1900;
y.M = pTm->tm_mon + 1;
y.h = pTm->tm_hour;
y.m = pTm->tm_min;
y.s = pTm->tm_sec;
- sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER));
+ sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
}
#endif
y.validYMD = 1;
#else
{
struct tm *pTm;
- sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER));
+ sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
pTm = gmtime(&t);
strftime(zBuf, 20, zFormat, pTm);
- sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER));
+ sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
}
#endif
** This file contains code used to dynamically load extensions into
** the SQLite library.
**
-** $Id: loadext.c,v 1.48 2008/06/13 18:24:27 drh Exp $
+** $Id: loadext.c,v 1.49 2008/06/18 17:09:10 danielk1977 Exp $
*/
#ifndef SQLITE_CORE
{
int i;
#ifndef SQLITE_MUTEX_NOOP
- sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
+ sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
sqlite3_mutex_enter(mutex);
for(i=0; i<autoext.nExt; i++){
#endif
{
#ifndef SQLITE_MUTEX_NOOP
- sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
+ sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
sqlite3_mutex_enter(mutex);
sqlite3_free(autoext.aExt);
for(i=0; go; i++){
char *zErrmsg = 0;
#ifndef SQLITE_MUTEX_NOOP
- sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
+ sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
sqlite3_mutex_enter(mutex);
if( i>=autoext.nExt ){
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
-** $Id: main.c,v 1.448 2008/06/18 13:27:47 drh Exp $
+** $Id: main.c,v 1.449 2008/06/18 17:09:10 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
if( sqlite3IsInit ) return SQLITE_OK;
rc = sqlite3_mutex_init();
if( rc==SQLITE_OK ){
- sqlite3_mutex *pMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
+ sqlite3_mutex *pMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
sqlite3_mutex_enter(pMutex);
if( sqlite3IsInit==0 ){
sqlite3IsInit = 1;
/* Allocate the sqlite data structure */
db = sqlite3MallocZero( sizeof(sqlite3) );
if( db==0 ) goto opendb_out;
- db->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_RECURSIVE);
- if( db->mutex==0 ){
- sqlite3_free(db);
- db = 0;
- goto opendb_out;
+ if( sqlite3Config.bFullMutex ){
+ db->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE);
+ if( db->mutex==0 ){
+ sqlite3_free(db);
+ db = 0;
+ goto opendb_out;
+ }
}
sqlite3_mutex_enter(db->mutex);
db->errMask = 0xff;
opendb_out:
if( db ){
- assert( db->mutex!=0 );
+ assert( db->mutex!=0 || sqlite3Config.bFullMutex==0 );
sqlite3_mutex_leave(db->mutex);
}
if( SQLITE_NOMEM==(rc = sqlite3_errcode(db)) ){
**
** Memory allocation functions used throughout sqlite.
**
-** $Id: malloc.c,v 1.18 2008/06/17 15:12:01 drh Exp $
+** $Id: malloc.c,v 1.19 2008/06/18 17:09:10 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
sqlite3MemSetDefault();
}
memset(&mem0, 0, sizeof(mem0));
- if( sqlite3Config.bMemstat && sqlite3Config.bCoreMutex ){
- mem0.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM);
+ if( sqlite3Config.bMemstat ){
+ mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);
}
return sqlite3Config.m.xInit(sqlite3Config.m.pAppData);
}
** This file contains implementations of the low-level memory allocation
** routines specified in the sqlite3_mem_methods object.
**
-** $Id: mem2.c,v 1.31 2008/06/17 17:21:18 danielk1977 Exp $
+** $Id: mem2.c,v 1.32 2008/06/18 17:09:10 danielk1977 Exp $
*/
#include "sqliteInt.h"
** Initialize the memory allocation subsystem.
*/
static int sqlite3MemInit(void *NotUsed){
- mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
+ mem.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);
return SQLITE_OK;
}
** This version of the memory allocation subsystem is used if
** and only if SQLITE_MEMORY_SIZE is defined.
**
-** $Id: mem3.c,v 1.13 2008/06/13 18:24:27 drh Exp $
+** $Id: mem3.c,v 1.14 2008/06/18 17:09:10 danielk1977 Exp $
*/
#include "sqliteInt.h"
*/
static void memsys3Enter(void){
if( mem.mutex==0 ){
- mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM);
+ mem.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);
mem.aPool[0].u.hdr.size4x = SQLITE_MEMORY_SIZE/2 + 2;
mem.aPool[SQLITE_MEMORY_SIZE/8].u.hdr.prevSize = SQLITE_MEMORY_SIZE/8;
mem.aPool[SQLITE_MEMORY_SIZE/8].u.hdr.size4x = 1;
** This file contains the C functions that implement a memory
** allocation subsystem for use by SQLite.
**
-** $Id: mem4.c,v 1.2 2008/02/14 23:26:56 drh Exp $
+** $Id: mem4.c,v 1.3 2008/06/18 17:09:10 danielk1977 Exp $
*/
#include "sqliteInt.h"
*/
static void memsys4Enter(void){
if( mem.mutex==0 ){
- mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM);
+ mem.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);
}
sqlite3_mutex_enter(mem.mutex);
}
** This version of the memory allocation subsystem is used if
** and only if SQLITE_POW2_MEMORY_SIZE is defined.
**
-** $Id: mem5.c,v 1.5 2008/06/13 18:24:27 drh Exp $
+** $Id: mem5.c,v 1.6 2008/06/18 17:09:10 danielk1977 Exp $
*/
#include "sqliteInt.h"
assert( sizeof(Mem5Block)==POW2_MIN );
assert( (SQLITE_POW2_MEMORY_SIZE % POW2_MAX)==0 );
assert( SQLITE_POW2_MEMORY_SIZE>=POW2_MAX );
- mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM);
+ mem.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);
sqlite3_mutex_enter(mem.mutex);
for(i=0; i<NSIZE; i++) mem.aiFreelist[i] = -1;
for(i=0; i<=NBLOCK-SZ_MAX; i += SZ_MAX){
** implementation is suitable for testing.
** debugging purposes
**
-** $Id: mutex.c,v 1.23 2008/06/18 09:45:56 danielk1977 Exp $
+** $Id: mutex.c,v 1.24 2008/06/18 17:09:10 danielk1977 Exp $
*/
#include "sqliteInt.h"
** Initialize the mutex system.
*/
int sqlite3_mutex_init(void){
- int rc;
- if( !sqlite3Config.mutex.xMutexAlloc ){
- /* If the xMutexAlloc method has not been set, then the user did not
- ** install a mutex implementation via sqlite3_config() prior to
- ** sqlite3_initialize() being called. This block copies pointers to
- ** the default implementation into the sqlite3Config structure.
- **
- ** The danger is that although sqlite3_config() is not a threadsafe
- ** API, sqlite3_initialize() is, and so multiple threads may be
- ** attempting to run this function simultaneously. To guard write
- ** access to the sqlite3Config structure, the 'MASTER' static mutex
- ** is obtained before modifying it.
- */
- sqlite3_mutex_methods *p = sqlite3DefaultMutex();
- sqlite3_mutex *pMaster;
-
- rc = p->xMutexInit();
- if( rc==SQLITE_OK ){
- pMaster = p->xMutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
- assert(pMaster);
- p->xMutexEnter(pMaster);
- assert( sqlite3Config.mutex.xMutexAlloc==0
- || sqlite3Config.mutex.xMutexAlloc==p->xMutexAlloc
- );
- if( !sqlite3Config.mutex.xMutexAlloc ){
- sqlite3Config.mutex = *p;
+ int rc = SQLITE_OK;
+ if( sqlite3Config.bCoreMutex ){
+ if( !sqlite3Config.mutex.xMutexAlloc ){
+ /* If the xMutexAlloc method has not been set, then the user did not
+ ** install a mutex implementation via sqlite3_config() prior to
+ ** sqlite3_initialize() being called. This block copies pointers to
+ ** the default implementation into the sqlite3Config structure.
+ **
+ ** The danger is that although sqlite3_config() is not a threadsafe
+ ** API, sqlite3_initialize() is, and so multiple threads may be
+ ** attempting to run this function simultaneously. To guard write
+ ** access to the sqlite3Config structure, the 'MASTER' static mutex
+ ** is obtained before modifying it.
+ */
+ sqlite3_mutex_methods *p = sqlite3DefaultMutex();
+ sqlite3_mutex *pMaster = 0;
+
+ rc = p->xMutexInit();
+ if( rc==SQLITE_OK ){
+ pMaster = p->xMutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
+ assert(pMaster);
+ p->xMutexEnter(pMaster);
+ assert( sqlite3Config.mutex.xMutexAlloc==0
+ || sqlite3Config.mutex.xMutexAlloc==p->xMutexAlloc
+ );
+ if( !sqlite3Config.mutex.xMutexAlloc ){
+ sqlite3Config.mutex = *p;
+ }
+ p->xMutexLeave(pMaster);
}
- p->xMutexLeave(pMaster);
+ }else{
+ rc = sqlite3Config.mutex.xMutexInit();
}
- }else{
- rc = sqlite3Config.mutex.xMutexInit();
}
return rc;
return sqlite3Config.mutex.xMutexAlloc(id);
}
+sqlite3_mutex *sqlite3MutexAlloc(int id){
+ if( !sqlite3Config.bCoreMutex ){
+ return 0;
+ }
+ return sqlite3Config.mutex.xMutexAlloc(id);
+}
+
/*
** Free a dynamic mutex.
*/
** This file contains OS interface code that is common to all
** architectures.
**
-** $Id: os.c,v 1.113 2008/06/15 02:51:48 drh Exp $
+** $Id: os.c,v 1.114 2008/06/18 17:09:10 danielk1977 Exp $
*/
#define _SQLITE_OS_C_ 1
#include "sqliteInt.h"
if( rc ) return 0;
#endif
#ifndef SQLITE_MUTEX_NOOP
- mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
+ mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
sqlite3_vfs *pVfs = 0;
static int isInit = 0;
** Unlink a VFS from the linked list
*/
static void vfsUnlink(sqlite3_vfs *pVfs){
- assert( sqlite3_mutex_held(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER)) );
+ assert( sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)) );
if( pVfs==0 ){
/* No-op */
}else if( vfsList==pVfs ){
if( rc ) return rc;
#endif
#ifndef SQLITE_MUTEX_NOOP
- mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
+ mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
sqlite3_vfs_find(0); /* Make sure we are initialized */
sqlite3_mutex_enter(mutex);
*/
int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
#ifndef SQLITE_MUTEX_NOOP
- sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
+ sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
sqlite3_mutex_enter(mutex);
vfsUnlink(pVfs);
**
** This file contains code that is specific to Unix systems.
**
-** $Id: os_unix.c,v 1.187 2008/06/13 18:24:27 drh Exp $
+** $Id: os_unix.c,v 1.188 2008/06/18 17:09:10 danielk1977 Exp $
*/
#include "sqliteInt.h"
#if OS_UNIX /* This file is used on unix only */
** Helper functions to obtain and relinquish the global mutex.
*/
static void enterMutex(){
- sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER));
+ sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
}
static void leaveMutex(){
- sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER));
+ sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
}
#if SQLITE_THREADSAFE
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.458 2008/06/17 15:12:01 drh Exp $
+** @(#) $Id: pager.c,v 1.459 2008/06/18 17:09:10 danielk1977 Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
if( p->iInUseMM && p->iInUseDB==1 ){
#ifndef SQLITE_MUTEX_NOOP
sqlite3_mutex *mutex;
- mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM2);
+ mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM2);
#endif
p->iInUseDB = 0;
sqlite3_mutex_enter(mutex);
listAdd(&pPg->pPager->lru, &pPg->free, pPg);
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
if( !pPg->pPager->memDb ){
- sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU));
+ sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU));
listAdd(&sqlite3LruPageList, &pPg->gfree, pPg);
- sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU));
+ sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU));
}
#endif
}
listRemove(&pPg->pPager->lru, &pPg->free, pPg);
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
if( !pPg->pPager->memDb ){
- sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU));
+ sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU));
listRemove(&sqlite3LruPageList, &pPg->gfree, pPg);
- sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU));
+ sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU));
}
#endif
}
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
if( !pPager->memDb ){
PgHdr *p;
- sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU));
+ sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU));
for(p=sqlite3LruPageList.pFirst; p && p->needSync; p=p->gfree.pNext);
assert(p==pPager->lru.pFirstSynced || p==sqlite3LruPageList.pFirstSynced);
sqlite3LruPageList.pFirstSynced = p;
- sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU));
+ sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU));
}
#endif
}
pPager->iInUseDB = 0;
if( !memDb ){
#ifndef SQLITE_MUTEX_NOOP
- sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM2);
+ sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM2);
#endif
sqlite3_mutex_enter(mutex);
pPager->pNext = sqlite3PagerList;
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
if( !MEMDB ){
#ifndef SQLITE_MUTEX_NOOP
- sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM2);
+ sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM2);
#endif
sqlite3_mutex_enter(mutex);
if( pPager->pPrev ){
*/
#ifndef SQLITE_MUTEX_NOOP
sqlite3_mutex *mutex; /* The MEM2 mutex */
- mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM2);
+ mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM2);
#endif
sqlite3_mutex_enter(mutex);
/* Try to find a page to recycle that does not require a sync(). If
** this is not possible, find one that does require a sync().
*/
- sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU));
+ sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU));
pPg = sqlite3LruPageList.pFirstSynced;
while( pPg && (pPg->needSync || pPg->pPager->iInUseDB) ){
pPg = pPg->gfree.pNext;
pPg = pPg->gfree.pNext;
}
}
- sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU));
+ sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU));
/* If pPg==0, then the block above has failed to find a page to
** recycle. In this case return early - no further memory will
** Random numbers are used by some of the database backends in order
** to generate random integer keys for tables or random filenames.
**
-** $Id: random.c,v 1.23 2008/03/21 16:45:47 drh Exp $
+** $Id: random.c,v 1.24 2008/06/18 17:09:10 danielk1977 Exp $
*/
#include "sqliteInt.h"
*/
void sqlite3_randomness(int N, void *pBuf){
unsigned char *zBuf = pBuf;
- static sqlite3_mutex *mutex = 0;
- if( mutex==0 ){
- mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PRNG);
- }
+ sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG);
sqlite3_mutex_enter(mutex);
while( N-- ){
*(zBuf++) = randomByte();
*************************************************************************
** Internal interface definitions for SQLite.
**
-** @(#) $Id: sqliteInt.h,v 1.713 2008/06/18 13:27:47 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.714 2008/06/18 17:09:10 danielk1977 Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
void sqlite3MemSetDefault(void);
sqlite3_mutex_methods *sqlite3DefaultMutex(void);
+sqlite3_mutex *sqlite3MutexAlloc(int);
int sqlite3IsNaN(double);
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
-** $Id: test3.c,v 1.97 2008/06/06 11:11:26 danielk1977 Exp $
+** $Id: test3.c,v 1.98 2008/06/18 17:09:10 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "btreeInt.h"
nRefSqlite3++;
if( nRefSqlite3==1 ){
sDb.pVfs = sqlite3_vfs_find(0);
- sDb.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_RECURSIVE);
+ sDb.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE);
sqlite3_mutex_enter(sDb.mutex);
}
rc = sqlite3BtreeOpen(argv[1], &sDb, &pBt, flags,
**
*************************************************************************
**
-** $Id: test_mutex.c,v 1.1 2008/06/18 09:45:56 danielk1977 Exp $
+** $Id: test_mutex.c,v 1.2 2008/06/18 17:09:10 danielk1977 Exp $
*/
#include "tcl.h"
return TCL_OK;
}
+/*
+** sqlite3_config OPTION
+*/
+static int test_config(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ struct ConfigOption {
+ const char *zName;
+ int iValue;
+ } aOpt[] = {
+ {"singlethread", SQLITE_CONFIG_SINGLETHREAD},
+ {"multithread", SQLITE_CONFIG_MULTITHREAD},
+ {"serialized", SQLITE_CONFIG_SERIALIZED},
+ {0, 0}
+ };
+ int s = sizeof(struct ConfigOption);
+ int i;
+ int rc;
+
+ if( objc!=2 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "");
+ return TCL_ERROR;
+ }
+
+ if( Tcl_GetIndexFromObjStruct(interp, objv[1], aOpt, s, "flag", 0, &i) ){
+ return TCL_ERROR;
+ }
+
+ rc = sqlite3_config(aOpt[i].iValue);
+ Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE);
+ return TCL_OK;
+}
+
int Sqlitetest_mutex_Init(Tcl_Interp *interp){
static struct {
char *zName;
} aCmd[] = {
{ "sqlite3_shutdown", (Tcl_ObjCmdProc*)test_shutdown },
{ "sqlite3_initialize", (Tcl_ObjCmdProc*)test_initialize },
+ { "sqlite3_config", (Tcl_ObjCmdProc*)test_config },
{ "install_mutex_counters", (Tcl_ObjCmdProc*)test_install_mutex_counters },
{ "read_mutex_counters", (Tcl_ObjCmdProc*)test_read_mutex_counters },
** This file contains code use to implement APIs that are part of the
** VDBE.
**
-** $Id: vdbeapi.c,v 1.132 2008/05/16 15:24:58 danielk1977 Exp $
+** $Id: vdbeapi.c,v 1.133 2008/06/18 17:09:10 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "vdbeInt.h"
** is protected by the SQLITE_MUTEX_STATIC_LRU mutex.
*/
static void stmtLruAdd(Vdbe *p){
- sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU2));
+ sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU2));
if( p->pLruPrev || p->pLruNext || sqlite3LruStatements.pFirst==p ){
- sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU2));
+ sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU2));
return;
}
assert( stmtLruCheck() );
- sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU2));
+ sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU2));
}
/*
** statement is not currently part of the list, this call is a no-op.
*/
static void stmtLruRemove(Vdbe *p){
- sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU2));
+ sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU2));
stmtLruRemoveNomutex(p);
- sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU2));
+ sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU2));
}
/*
Vdbe *pNext;
int nFree = 0;
- sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU2));
+ sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU2));
for(p=sqlite3LruStatements.pFirst; p && nFree<n; p=pNext){
pNext = p->pLruNext;
sqlite3_mutex_leave(p->db->mutex);
}
}
- sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU2));
+ sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU2));
return nFree;
}
#
#***********************************************************************
#
-# $Id: mutex1.test,v 1.1 2008/06/18 09:45:56 danielk1977 Exp $
+# $Id: mutex1.test,v 1.2 2008/06/18 17:09:10 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
list $counters(total) $counters(static_master)
} {0 0}
+#-------------------------------------------------------------------------
+# Tests mutex1-2.* test the three thread-safety related modes that
+# can be selected using sqlite3_config:
+#
+# * Serialized mode,
+# * Multi-threaded mode,
+# * Single-threaded mode.
+#
+
+foreach {mode mutexes} {
+ singlethread {}
+ multithread {fast static_master static_mem static_prng}
+ serialized {fast recursive static_master static_mem static_prng}
+} {
+ do_test mutex1.2.$mode.1 {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config $mode
+ } SQLITE_OK
+
+ do_test mutex1.2.$mode.2 {
+ clear_mutex_counters
+ sqlite3 db test.db
+ catchsql { CREATE TABLE abc(a, b, c) }
+ db eval {
+ INSERT INTO abc VALUES(1, 2, 3);
+ }
+ } {}
+
+ do_test mutex1.2.$mode.3 {
+ mutex_counters counters
+
+ set res [list]
+ foreach {key value} [array get counters] {
+ if {$key ne "total" && $value > 0} {
+ lappend res $key
+ }
+ }
+ lsort $res
+ } $mutexes
+}
do_test mutex1-X {
+ db close
sqlite3_shutdown
clear_mutex_counters
install_mutex_counters 0
--- /dev/null
+# 2007 March 26
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file runs some other test files after calling sqlite3_config to
+# set the thread-safety mode to SQLITE_CONFIG_SINGLETHREAD and
+# SQLITE_CONFIG_MULTITHREAD (instead of the default SQLITE_CONFIG_SERIALIZED).
+#
+# $Id: mutex2.test,v 1.1 2008/06/18 17:09:10 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!pager_pragmas} {
+ finish_test
+ return
+}
+
+rename finish_test really_finish_test2
+proc finish_test {} {}
+set ISQUICK 1
+
+rename do_test really_do_test
+proc do_test {args} {
+ set sc [concat really_do_test "mutex2-${::thread_mode}.[lindex $args 0]" \
+ [lrange $args 1 end]]
+ eval $sc
+}
+
+foreach ::thread_mode {singlethread multithread} {
+ do_test mutex2-$::thread_mode.0 {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config $::thread_mode
+ } SQLITE_OK
+
+ source $testdir/delete.test
+ source $testdir/delete2.test
+ source $testdir/insert.test
+ source $testdir/rollback.test
+ source $testdir/select1.test
+ source $testdir/select2.test
+ source $testdir/trans.test
+ source $testdir/update.test
+ source $testdir/vacuum.test
+ source $testdir/types.test
+ source $testdir/types2.test
+ source $testdir/types3.test
+
+ #source $testdir/malloc.test
+ #source $testdir/ioerr.test
+}
+
+do_test mutex2-X {
+ catch {db close}
+ sqlite3_shutdown
+ sqlite3_config serialized
+} SQLITE_OK
+
+rename finish_test ""
+rename really_finish_test2 finish_test
+rename do_test ""
+rename really_do_test do_test
+finish_test
+
#***********************************************************************
# This file runs all tests.
#
-# $Id: quick.test,v 1.78 2008/04/19 20:34:19 drh Exp $
+# $Id: quick.test,v 1.79 2008/06/18 17:09:10 danielk1977 Exp $
proc lshift {lvar} {
upvar $lvar l
memleak.test
misc7.test
misuse.test
+ mutex2.test
onefile.test
quick.test
soak.test
#***********************************************************************
# This file runs all tests.
#
-# $Id: veryquick.test,v 1.3 2008/04/19 20:34:19 drh Exp $
+# $Id: veryquick.test,v 1.4 2008/06/18 17:09:10 danielk1977 Exp $
proc lshift {lvar} {
upvar $lvar l
memleak.test
misc7.test
misuse.test
+ mutex2.test
onefile.test
quick.test
soak.test