1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Progress toward implementation of sqlite3_config() and a rework of the

mutex and memory allocation subsystems.  This is an incremental check-in. (CVS 5218)

FossilOrigin-Name: a03c5af115889f477e17187a198a7d2d40bc76bf
This commit is contained in:
drh
2008-06-13 18:24:27 +00:00
parent 655194d6ae
commit 40257ffd0a
26 changed files with 453 additions and 155 deletions

View File

@@ -151,7 +151,7 @@ NAWK = @AWK@
#
OBJS0 = alter.lo analyze.lo attach.lo auth.lo bitvec.lo btmutex.lo \
btree.lo build.lo callback.lo complete.lo date.lo \
delete.lo expr.lo fault.lo func.lo \
delete.lo expr.lo fault.lo func.lo global.lo \
hash.lo journal.lo insert.lo loadext.lo \
main.lo malloc.lo mem1.lo mem2.lo mem3.lo mem4.lo mem5.lo mutex.lo \
mutex_os2.lo mutex_unix.lo mutex_w32.lo \
@@ -192,6 +192,7 @@ SRC = \
$(TOP)/src/expr.c \
$(TOP)/src/fault.c \
$(TOP)/src/func.c \
$(TOP)/src/global.c \
$(TOP)/src/hash.c \
$(TOP)/src/hash.h \
$(TOP)/src/hwtime.h \
@@ -508,6 +509,9 @@ fault.lo: $(TOP)/src/fault.c $(HDR)
func.lo: $(TOP)/src/func.c $(HDR)
$(LTCOMPILE) -c $(TOP)/src/func.c
global.lo: $(TOP)/src/global.c $(HDR)
$(LTCOMPILE) -c $(TOP)/src/global.c
hash.lo: $(TOP)/src/hash.c $(HDR)
$(LTCOMPILE) -c $(TOP)/src/hash.c

View File

@@ -50,7 +50,7 @@ TCCX = $(TCC) $(OPTS) -I. -I$(TOP)/src -I$(TOP)
#
LIBOBJ+= alter.o analyze.o attach.o auth.o bitvec.o btmutex.o btree.o build.o \
callback.o complete.o date.o delete.o \
expr.o fault.o func.o hash.o insert.o journal.o loadext.o \
expr.o fault.o func.o global.o hash.o insert.o journal.o loadext.o \
main.o malloc.o mem1.o mem2.o mem3.o mem4.o mem5.o \
mutex.o mutex_os2.o mutex_unix.o mutex_w32.o \
opcodes.o os.o os_os2.o os_unix.o os_win.o \
@@ -99,6 +99,7 @@ SRC = \
$(TOP)/src/expr.c \
$(TOP)/src/fault.c \
$(TOP)/src/func.c \
$(TOP)/src/global.c \
$(TOP)/src/hash.c \
$(TOP)/src/hash.h \
$(TOP)/src/hwtime.h \

View File

@@ -1,7 +1,7 @@
C Enhance\szeroblob\stests\sto\suse\sthe\ssqlite3_memory_highwater\sin\sorder\sto\ndouble-check\sthat\sno\slarge\sallocations\sare\soccurring.\s(CVS\s5217)
D 2008-06-12T18:17:40
C Progress\stoward\simplementation\sof\ssqlite3_config()\sand\sa\srework\sof\sthe\nmutex\sand\smemory\sallocation\ssubsystems.\s\sThis\sis\san\sincremental\scheck-in.\s(CVS\s5218)
D 2008-06-13T18:24:27
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in ce92ea8dc7adfb743757794f51c10d1b0d9c55e4
F Makefile.in dc5608df93faf4406cfd7a1c8ed9ab93d8bfbfd5
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F README b974cdc3f9f12b87e851b04e75996d720ebf81ac
F VERSION d739ba532eddc5c09ef9a55151328cd6a8a102c6
@@ -76,7 +76,7 @@ F ext/rtree/rtree_util.tcl ee0a0311eb12175319d78bfb37302320496cee6e
F ext/rtree/viewrtree.tcl 09526398dae87a5a87c5aac2b3854dbaf8376869
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
F ltmain.sh 09fe5815427dc7d0abb188bbcdf0e34896577210
F main.mk 254bdf904af5869178e6b333be5729bf24ff3f77
F main.mk 5ef9aba69a7c8a585348d1ce77bfc927e456fbc7
F mkdll.sh 712e74f3efe08a6ba12b2945d018a29a89d7fe3b
F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f
F mkextw.sh 1a866b53637dab137191341cc875575a5ca110fb
@@ -101,38 +101,39 @@ F src/btree.h b1bd7e0b8c2e33658aaf447cb0d1d94f74664b6b
F src/btreeInt.h dc04ee33d8eb84714b2acdf81336fbbf6e764530
F src/build.c a52d9d51341444a2131e3431608f245db80d9591
F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0
F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
F src/date.c 76a5ba94772346efedf0c412c47e67891bbb266c
F src/delete.c d3fc5987f2eb88f7b9549d58a5dfea079a83fe8b
F src/expr.c ecb3b23d3543427cba3e2ac12a6c6ae4bb20d39b
F src/fault.c 1f6177188edb00641673e462f3fab8cba9f7422b
F src/func.c 77a910a1ca7613d291fd0b5cba3be14c02f0dce0
F src/global.c 8a5c66b6e61c38072c697179dbc2d708e39ddc96
F src/hash.c fd8cb06fb54c2fe7d48c9195792059a2e5be8b70
F src/hash.h 031cd9f915aff27e12262cb9eb570ac1b8326b53
F src/hwtime.h 745961687a65ef8918cd551c02e5ccb4b8e772de
F src/insert.c c2ead6c36566de8e3f130e7ab1431723a269d5d7
F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
F src/legacy.c 8f5a2b25d9673b4004287cf2bf51dbf7d0738406
F src/loadext.c eac6c61810a3b531808774bec7f3d238cfe261f3
F src/main.c 25358a404194d7571cdd3be001919a53b80106db
F src/loadext.c f99a75534a53e281fa2461239ee4a4b4bf6ad564
F src/main.c 88caac737f4bdc646c7b298ebca867e9f3828208
F src/malloc.c 12c1ae98ef1eff34b13c9eb526e0b7b479e1e820
F src/md5.c 008216bbb5d34c6fbab5357aa68575ad8a31516a
F src/mem1.c fc716ff521b6dd3e43eaa211967383308800e70a
F src/mem2.c 3656205111208a847e21d81a1d5b09a010164096
F src/mem3.c 52547678a2ae50c203d54be1a5bf51eb02438a3f
F src/mem1.c 18ca1e2543252ce13cd9c1ba67853b2d8fece3dd
F src/mem2.c cb99d152253ae11cc2ccc4073611925e81c2212d
F src/mem3.c 617c2e2a72a10ecc5c01af14efc8c2596d2c2e87
F src/mem4.c 45c328ec6dcb7e8d319cb383615b5fe547ca5409
F src/mem5.c 11d98b76f77873aab86b543cbd1a8ddc4e680d58
F src/mutex.c d455f0876d5aad9935a23d01e6ae1bf4bd462d6a
F src/mutex.h 079fa6fe9da18ceb89e79012c010594c6672addb
F src/mutex_os2.c 2911ea96955ab6cba734cc4ad903fe76f834b39e
F src/mutex_unix.c 466d20378a0645fea64c3f2e2669c33b7802df56
F src/mutex_w32.c 133698096a2c4e81cd11ea6f4de7891c66f7b9f7
F src/os.c 284abcb97ffdaf5f0b08fa4c5fe1fe93dd86b416
F src/mem5.c 3d2ff00c6e3bc37f5d82cd82e1a123b246fb7b39
F src/mutex.c 1ff43a9f9a8e5a0d98ffccd77f56859d9fd9ffcf
F src/mutex.h 91292a8351b5844f7d622b0da83df4e651a8f40b
F src/mutex_os2.c b8c1231319e966875f251a7ec137bea353546b87
F src/mutex_unix.c 28588d08a2221623d66655e536880003fd5234d6
F src/mutex_w32.c 36fbcf9f50bf0cd9be2c106cd69e5f59021402be
F src/os.c 4f253152aefa4ba54ac7e2dc389a503862a9016c
F src/os.h c9a7f94e80193fd4cf27f5c5698eb56753f1b05a
F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
F src/os_os2.c 6cc3ff5e934eecfa078b5b7bf1d0bdc7ac3f5a2e
F src/os_unix.c 47936aee8265e482faa626141d97d896aa981ef4
F src/os_win.c 0d975b131b2b104d6d69d9f16bdf3c8cec28e81d
F src/os_os2.c 9f74147f1899793a106827f6bc770363ec377912
F src/os_unix.c dd4a7b19ec00869764c389560c3faf566cf98a71
F src/os_win.c 0b90d9a1ce18bfd2a5f3c4a6bdb13ec369c805a9
F src/pager.c be98ceeb55bbcda9251c1a846d28c3d323885708
F src/pager.h 6aa3050a3c684475a5a9dbad5ff1cebad612acba
F src/parse.y 8c2c3145eebe1964eb279cb3c4e502eae28bb0fa
@@ -142,9 +143,9 @@ F src/printf.c f2d4f6c5b0ec24b643e85fe60258adad8b1f6acc
F src/random.c 2b2db2de4ab491f5a14d3480466f8f4b5a5db74a
F src/select.c 669687459e7d0193c89de06c5dbed55b4a41191c
F src/shell.c a12ea645271b7876c8f080146f48e20b00d367ec
F src/sqlite.h.in c7e356869c27312291d929322b26f3cc74028299
F src/sqlite.h.in 487f5490a9677ef0c105c21a9595bb587be1da6a
F src/sqlite3ext.h faacd0e6a81aabee0861c6d7883c9172e74ef5b3
F src/sqliteInt.h 1593404d8aee13687ca7b5d552cb153de7441bef
F src/sqliteInt.h c7b8bfb55381f62962eafd9826846c9e6e8bd429
F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
F src/table.c 1fa8f8113ac9cbc09ae4801c6d2a7f0af82c5822
F src/tclsqlite.c c57e740e30bd6dda678796eed62c7f0e64689834
@@ -177,7 +178,7 @@ F src/tokenize.c d07c7482a59dd8e02f3f73e86ff55eccdc0d8f26
F src/trigger.c 1e751f8d5ceeb328d26bf1ccfb2de50653670d49
F src/update.c 2d7143b9014e955509cc4f323f9a9584fb898f34
F src/utf.c 8c94fa10efc78c2568d08d436acc59df4df7191b
F src/util.c 512027b58e8b9b11743e5ae70837c45b53696b26
F src/util.c 920d6d5dfdf25f7b85d2093705d8716f9b387e3b
F src/vacuum.c a5c289e561ed72283e97d2485491986bc7d684eb
F src/vdbe.c 1936425c3455535a1a20e26a65c470fb009a1ed8
F src/vdbe.h 1e3722d471739c2b213c6283b60373290e52f7ea
@@ -568,7 +569,7 @@ F test/where3.test 97d3936e6a443b968f1a61cdcc0f673252000e94
F test/where4.test e9b9e2f2f98f00379e6031db6a6fca29bae782a2
F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2
F test/where6.test 42c4373595f4409d9c6a9987b4a60000ad664faf
F test/zeroblob.test 92c3e7dabd2a5ceabc305f7ff5f4441a913366ca
F test/zeroblob.test 792124852ec61458a2eb527b5091791215e0be95
F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439
F tool/lemon.c a9c51c1ede7f35dc8746894e7f8cc7e3704ecef8
@@ -578,7 +579,7 @@ F tool/memleak2.awk 9cc20c8e8f3c675efac71ea0721ee6874a1566e8
F tool/memleak3.tcl 7707006ee908cffff210c98158788d85bb3fcdbf
F tool/mkkeywordhash.c ef93810fc41fb3d3dbacf9a33a29be88ea99ffa9
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x
F tool/mksqlite3c.tcl 927b9d6ccd05690f75eb67bce7cca9a90b65ceeb
F tool/mksqlite3c.tcl 687ae979ba47db01d3a6296b2e7a678a161be392
F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87
F tool/omittest.tcl 7d1fdf469e2f4d175f70c36e469db64a1626fabb
F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
@@ -593,7 +594,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P c1006fb1c817bc0b7fada873edb772abbf972012
R dc9288951ccf4af2026b613e380c37a1
P e93079be83a9df7328d9b910fcbdb762be7ec815
R b8763d642b06205a0aac83d31a5eaad0
U drh
Z a943c68dc8f656dcf324d2907bc83041
Z 7798430e342a4a876c2baf52ecfbbead

View File

@@ -1 +1 @@
e93079be83a9df7328d9b910fcbdb762be7ec815
a03c5af115889f477e17187a198a7d2d40bc76bf

View File

@@ -16,7 +16,7 @@
** separating it out, the code will be automatically omitted from
** static links that do not use it.
**
** $Id: complete.c,v 1.6 2007/08/27 23:26:59 drh Exp $
** $Id: complete.c,v 1.7 2008/06/13 18:24:27 drh Exp $
*/
#include "sqliteInt.h"
#ifndef SQLITE_OMIT_COMPLETE
@@ -258,11 +258,17 @@ int sqlite3_complete16(const void *zSql){
char const *zSql8;
int rc = SQLITE_NOMEM;
#ifndef SQLITE_OMIT_AUTOINIT
rc = sqlite3_initialize();
if( rc ) return rc;
#endif
pVal = sqlite3ValueNew(0);
sqlite3ValueSetStr(pVal, -1, zSql, SQLITE_UTF16NATIVE, SQLITE_STATIC);
zSql8 = sqlite3ValueText(pVal, SQLITE_UTF8);
if( zSql8 ){
rc = sqlite3_complete(zSql8);
}else{
rc = SQLITE_NOMEM;
}
sqlite3ValueFree(pVal);
return sqlite3ApiExit(0, rc);

69
src/global.c Normal file
View File

@@ -0,0 +1,69 @@
/*
** 2008 June 13
**
** 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 contains definitions of global variables and contants.
**
** $Id: global.c,v 1.1 2008/06/13 18:24:27 drh Exp $
*/
#include "sqliteInt.h"
/* An array to map all upper-case characters into their corresponding
** lower-case character.
**
** SQLite only considers US-ASCII (or EBCDIC) characters. We do not
** handle case conversions for the UTF character set since the tables
** involved are nearly as big or bigger than SQLite itself.
*/
const unsigned char sqlite3UpperToLower[] = {
#ifdef SQLITE_ASCII
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 97, 98, 99,100,101,102,103,
104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,
122, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103,104,105,106,107,
108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,
126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,
162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,
180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,
198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,
216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,
234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,
252,253,254,255
#endif
#ifdef SQLITE_EBCDIC
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 0x */
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 1x */
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 2x */
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */
96, 97, 66, 67, 68, 69, 70, 71, 72, 73,106,107,108,109,110,111, /* 6x */
112, 81, 82, 83, 84, 85, 86, 87, 88, 89,122,123,124,125,126,127, /* 7x */
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */
144,145,146,147,148,149,150,151,152,153,154,155,156,157,156,159, /* 9x */
160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */
192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */
208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */
224,225,162,163,164,165,166,167,168,169,232,203,204,205,206,207, /* Ex */
239,240,241,242,243,244,245,246,247,248,249,219,220,221,222,255, /* Fx */
#endif
};
/*
** The following singleton contains the global configuration for
** the SQLite library.
*/
struct Sqlite3Config sqlite3Config;

View File

@@ -12,7 +12,7 @@
** This file contains code used to dynamically load extensions into
** the SQLite library.
**
** $Id: loadext.c,v 1.47 2008/05/15 19:43:53 drh Exp $
** $Id: loadext.c,v 1.48 2008/06/13 18:24:27 drh Exp $
*/
#ifndef SQLITE_CORE
@@ -469,8 +469,14 @@ static struct {
** loaded by every new database connection.
*/
int sqlite3_auto_extension(void *xInit){
#ifndef SQLITE_OMIT_AUTOINIT
int rc = sqlite3_initialize();
if( rc ){
return rc;
}else
#endif
{
int i;
int rc = SQLITE_OK;
#ifndef SQLITE_MUTEX_NOOP
sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
@@ -494,11 +500,16 @@ int sqlite3_auto_extension(void *xInit){
assert( (rc&0xff)==rc );
return rc;
}
}
/*
** Reset the automatic extension loading mechanism.
*/
void sqlite3_reset_auto_extension(void){
#ifndef SQLITE_OMIT_AUTOINIT
if( sqlite3_initialize()==SQLITE_OK )
#endif
{
#ifndef SQLITE_MUTEX_NOOP
sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
@@ -508,6 +519,7 @@ void sqlite3_reset_auto_extension(void){
autoext.nExt = 0;
sqlite3_mutex_leave(mutex);
}
}
/*
** Load all automatic extensions.

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.442 2008/05/26 20:19:26 drh Exp $
** $Id: main.c,v 1.443 2008/06/13 18:24:27 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -53,6 +53,123 @@ void (*sqlite3IoTrace)(const char*, ...) = 0;
*/
char *sqlite3_temp_directory = 0;
/*
** Flags to help SQLite determine if it has been initialized.
*/
static int sqlite3IsInit = 0; /* Initialization has started */
static int sqlite3FullInit = 0; /* Initialization is complete */
/*
** Initialize SQLite.
**
** This routine must be called to initialize the memory allocation,
** VFS, and mutex subsystesms prior to doing any serious work with
** SQLite. But as long as you do not compile with SQLITE_OMIT_AUTOINIT
** this routine will be called automatically by key routines such as
** sqlite3_open().
**
** This routine is a no-op except on its very first call for the process,
** or for the first call after a call to sqlite3_shutdown.
*/
int sqlite3_initialize(void){
int rc;
if( sqlite3IsInit ) return SQLITE_OK;
rc = sqlite3_mutex_init();
if( rc==SQLITE_OK ){
#ifndef SQLITE_MUTEX_NOOP
sqlite3_mutex *pMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
sqlite3_mutex_enter(pMutex);
if( sqlite3IsInit==0 ){
sqlite3IsInit = 1;
if( rc==SQLITE_OK ) rc = sqlite3MallocInit();
if( rc==SQLITE_OK ) rc = sqlite3_os_init();
if( rc!=SQLITE_OK ){
sqlite3IsInit = 0;
}else{
sqlite3FullInit = 1;
}
}
sqlite3_mutex_leave(pMutex);
}
return rc;
}
/*
** Undo the effects of sqlite3_initialize(). Must not be called while
** there are outstanding database connections or memory allocations or
** while any part of SQLite is otherwise in use in any thread. This
** routine is not threadsafe. Not by a long shot.
*/
int sqlite3_shutdown(void){
sqlite3_os_end();
sqlite3_mutex_end();
sqlite3FullInit = 0;
sqlite3IsInit = 0;
return SQLITE_OK;
}
/*
** This API allows applications to modify the global configuration of
** the SQLite library at run-time.
**
** This routine should only be called when there are no outstanding
** database connections or memory allocations. This routine is not
** threadsafe. Failure to heed these warnings can lead to unpredictable
** behavior.
*/
int sqlite3_config(int op, ...){
va_list ap;
int rc = SQLITE_OK;
/* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while
** the SQLite library is in use. */
if( sqlite3FullInit ) return SQLITE_MISUSE;
va_start(ap, op);
switch( op ){
case SQLITE_CONFIG_SINGLETHREAD: {
/* Disable all mutexing */
sqlite3Config.bCoreMutex = 0;
sqlite3Config.bFullMutex = 0;
break;
}
case SQLITE_CONFIG_MULTITHREAD: {
/* Disable mutexing of database connections */
/* Enable mutexing of core data structures */
sqlite3Config.bCoreMutex = 1;
sqlite3Config.bFullMutex = 0;
break;
}
case SQLITE_CONFIG_SERIALIZED: {
/* Enable all mutexing */
sqlite3Config.bCoreMutex = 1;
sqlite3Config.bFullMutex = 1;
break;
}
case SQLITE_CONFIG_MALLOC: {
/* Specify an alternative malloc implementation */
sqlite3Config.xMalloc = va_arg(ap, void*(*)(int));
sqlite3Config.xFree = va_arg(ap, void(*)(void*));
sqlite3Config.xRealloc = va_arg(ap, void*(*)(void*,int));
sqlite3Config.xMemsize = va_arg(ap, int(*)(void*));
sqlite3Config.xRoundup = va_arg(ap, int(*)(int));
break;
}
case SQLITE_CONFIG_MEMSTATS: {
/* Enable or disable the malloc status collection */
sqlite3Config.bMemstat = va_arg(ap, int);
break;
}
default: {
rc = SQLITE_ERROR;
break;
}
}
va_end(ap);
return rc;
}
/*
** Routine needed to support the testcase() macro.
*/
@@ -1040,6 +1157,11 @@ static int openDatabase(
int rc;
CollSeq *pColl;
#ifndef SQLITE_OMIT_AUTOINIT
rc = sqlite3_initialize();
if( rc ) return rc;
#endif
/* Remove harmful bits from the flags parameter */
flags &= ~( SQLITE_OPEN_DELETEONCLOSE |
SQLITE_OPEN_MAIN_DB |
@@ -1249,11 +1371,15 @@ int sqlite3_open16(
){
char const *zFilename8; /* zFilename encoded in UTF-8 instead of UTF-16 */
sqlite3_value *pVal;
int rc = SQLITE_NOMEM;
int rc;
assert( zFilename );
assert( ppDb );
*ppDb = 0;
#ifndef SQLITE_OMIT_AUTOINIT
rc = sqlite3_initialize();
if( rc ) return rc;
#endif
pVal = sqlite3ValueNew(0);
sqlite3ValueSetStr(pVal, -1, zFilename, SQLITE_UTF16NATIVE, SQLITE_STATIC);
zFilename8 = sqlite3ValueText(pVal, SQLITE_UTF8);
@@ -1264,6 +1390,8 @@ int sqlite3_open16(
if( rc==SQLITE_OK && !DbHasProperty(*ppDb, 0, DB_SchemaLoaded) ){
ENC(*ppDb) = SQLITE_UTF16NATIVE;
}
}else{
rc = SQLITE_NOMEM;
}
sqlite3ValueFree(pVal);
@@ -1536,6 +1664,7 @@ int sqlite3_sleep(int ms){
sqlite3_vfs *pVfs;
int rc;
pVfs = sqlite3_vfs_find(0);
if( pVfs==0 ) return 0;
/* This function works in milliseconds, but the underlying OsSleep()
** API uses microseconds. Hence the 1000's.

View File

@@ -12,7 +12,7 @@
** This file contains the C functions that implement a memory
** allocation subsystem for use by SQLite.
**
** $Id: mem1.c,v 1.17 2008/03/18 00:07:11 drh Exp $
** $Id: mem1.c,v 1.18 2008/06/13 18:24:27 drh Exp $
*/
#include "sqliteInt.h"
@@ -188,6 +188,13 @@ int sqlite3MallocSize(void *p){
return pInt[-1];
}
/*
** Initialize the memmory allocation subsystem.
*/
int sqlite3MallocInit(void){
return SQLITE_OK;
}
/*
** Change the size of an existing memory allocation
*/

View File

@@ -12,7 +12,7 @@
** This file contains the C functions that implement a memory
** allocation subsystem for use by SQLite.
**
** $Id: mem2.c,v 1.26 2008/04/10 14:57:25 drh Exp $
** $Id: mem2.c,v 1.27 2008/06/13 18:24:27 drh Exp $
*/
#include "sqliteInt.h"
@@ -240,6 +240,13 @@ int sqlite3MallocSize(void *p){
return pHdr->iSize;
}
/*
** Initialize the memmory allocation subsystem.
*/
int sqlite3MallocInit(void){
return SQLITE_OK;
}
/*
** Allocate nByte bytes of memory.
*/

View File

@@ -20,7 +20,7 @@
** This version of the memory allocation subsystem is used if
** and only if SQLITE_MEMORY_SIZE is defined.
**
** $Id: mem3.c,v 1.12 2008/02/19 15:15:16 drh Exp $
** $Id: mem3.c,v 1.13 2008/06/13 18:24:27 drh Exp $
*/
#include "sqliteInt.h"
@@ -297,6 +297,13 @@ int sqlite3MallocSize(void *p){
return iSize;
}
/*
** Initialize the memmory allocation subsystem.
*/
int sqlite3MallocInit(void){
return SQLITE_OK;
}
/*
** Chunk i is a free chunk that has been unlinked. Adjust its
** size parameters for check-out and return a pointer to the

View File

@@ -20,7 +20,7 @@
** This version of the memory allocation subsystem is used if
** and only if SQLITE_POW2_MEMORY_SIZE is defined.
**
** $Id: mem5.c,v 1.4 2008/02/19 15:15:16 drh Exp $
** $Id: mem5.c,v 1.5 2008/06/13 18:24:27 drh Exp $
*/
#include "sqliteInt.h"
@@ -283,6 +283,13 @@ int sqlite3MallocSize(void *p){
return iSize;
}
/*
** Initialize the memmory allocation subsystem.
*/
int sqlite3MallocInit(void){
return SQLITE_OK;
}
/*
** Find the first entry on the freelist iLogsize. Unlink that
** entry and return its index.

View File

@@ -19,7 +19,7 @@
** implementation is suitable for testing.
** debugging purposes
**
** $Id: mutex.c,v 1.17 2008/03/26 18:34:43 danielk1977 Exp $
** $Id: mutex.c,v 1.18 2008/06/13 18:24:27 drh Exp $
*/
#include "sqliteInt.h"
@@ -38,6 +38,12 @@ struct sqlite3_mutex {
int cnt; /* Number of entries without a matching leave */
};
/*
** Initialize and deinitialize the mutex subsystem.
*/
int sqlite3_mutex_init(void){ return SQLITE_OK; }
int sqlite3_mutex_end(void){ return SQLITE_OK; }
/*
** The sqlite3_mutex_alloc() routine allocates a new
** mutex and returns a pointer to it. If it returns NULL

View File

@@ -19,7 +19,7 @@
** Source files should #include the sqliteInt.h file and let that file
** include this one indirectly.
**
** $Id: mutex.h,v 1.2 2007/08/30 14:10:30 drh Exp $
** $Id: mutex.h,v 1.3 2008/06/13 18:24:27 drh Exp $
*/
@@ -77,6 +77,8 @@
#define sqlite3_mutex_leave(X)
#define sqlite3_mutex_held(X) 1
#define sqlite3_mutex_notheld(X) 1
#define sqlite3_mutex_init()
#define sqlite3_mutex_end()
#endif
#endif /* SQLITE_MUTEX_APPDEF */

View File

@@ -11,7 +11,7 @@
*************************************************************************
** This file contains the C functions that implement mutexes for OS/2
**
** $Id: mutex_os2.c,v 1.6 2008/03/26 18:34:43 danielk1977 Exp $
** $Id: mutex_os2.c,v 1.7 2008/06/13 18:24:27 drh Exp $
*/
#include "sqliteInt.h"
@@ -39,6 +39,12 @@ struct sqlite3_mutex {
#define OS2_MUTEX_INITIALIZER 0,0,0,0
/*
** Initialize and deinitialize the mutex subsystem.
*/
int sqlite3_mutex_init(void){ return SQLITE_OK; }
int sqlite3_mutex_end(void){ return SQLITE_OK; }
/*
** The sqlite3_mutex_alloc() routine allocates a new
** mutex and returns a pointer to it. If it returns NULL
@@ -147,7 +153,7 @@ sqlite3_mutex *sqlite3_mutex_alloc(int iType){
** SQLite is careful to deallocate every mutex that it allocates.
*/
void sqlite3_mutex_free(sqlite3_mutex *p){
assert( p );
if( p==0 ) return;
assert( p->nRef==0 );
assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE );
DosCloseMutexSem( p->mutex );
@@ -169,7 +175,7 @@ void sqlite3_mutex_enter(sqlite3_mutex *p){
TID tid;
PID holder1;
ULONG holder2;
assert( p );
if( p==0 ) return;
assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(p) );
DosRequestMutexSem(p->mutex, SEM_INDEFINITE_WAIT);
DosQueryMutexSem(p->mutex, &holder1, &tid, &holder2);
@@ -181,7 +187,7 @@ int sqlite3_mutex_try(sqlite3_mutex *p){
TID tid;
PID holder1;
ULONG holder2;
assert( p );
if( p==0 ) return SQLITE_OK;
assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(p) );
if( DosRequestMutexSem(p->mutex, SEM_IMMEDIATE_RETURN) == NO_ERROR) {
DosQueryMutexSem(p->mutex, &holder1, &tid, &holder2);
@@ -205,6 +211,7 @@ void sqlite3_mutex_leave(sqlite3_mutex *p){
TID tid;
PID holder1;
ULONG holder2;
if( p==0 ) return;
assert( p->nRef>0 );
DosQueryMutexSem(p->mutex, &holder1, &tid, &holder2);
assert( p->owner==tid );

View File

@@ -11,7 +11,7 @@
*************************************************************************
** This file contains the C functions that implement mutexes for pthreads
**
** $Id: mutex_unix.c,v 1.7 2008/03/29 12:47:27 rse Exp $
** $Id: mutex_unix.c,v 1.8 2008/06/13 18:24:27 drh Exp $
*/
#include "sqliteInt.h"
@@ -45,6 +45,12 @@ struct sqlite3_mutex {
#define SQLITE3_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0, (pthread_t)0 }
#endif
/*
** Initialize and deinitialize the mutex subsystem.
*/
int sqlite3_mutex_init(void){ return SQLITE_OK; }
int sqlite3_mutex_end(void){ return SQLITE_OK; }
/*
** The sqlite3_mutex_alloc() routine allocates a new
** mutex and returns a pointer to it. If it returns NULL
@@ -142,12 +148,13 @@ sqlite3_mutex *sqlite3_mutex_alloc(int iType){
** mutex that it allocates.
*/
void sqlite3_mutex_free(sqlite3_mutex *p){
assert( p );
if( p ){
assert( p->nRef==0 );
assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE );
pthread_mutex_destroy(&p->mutex);
sqlite3_free(p);
}
}
/*
** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
@@ -161,7 +168,7 @@ void sqlite3_mutex_free(sqlite3_mutex *p){
** more than once, the behavior is undefined.
*/
void sqlite3_mutex_enter(sqlite3_mutex *p){
assert( p );
if( p==0 ) return;
assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(p) );
#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
@@ -202,7 +209,7 @@ void sqlite3_mutex_enter(sqlite3_mutex *p){
}
int sqlite3_mutex_try(sqlite3_mutex *p){
int rc;
assert( p );
if( p==0 ) return SQLITE_OK;
assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(p) );
#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
@@ -257,7 +264,7 @@ int sqlite3_mutex_try(sqlite3_mutex *p){
** is not currently allocated. SQLite will never do either.
*/
void sqlite3_mutex_leave(sqlite3_mutex *p){
assert( p );
if( p==0 ) return;
assert( sqlite3_mutex_held(p) );
p->nRef--;
assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );

View File

@@ -11,7 +11,7 @@
*************************************************************************
** This file contains the C functions that implement mutexes for win32
**
** $Id: mutex_w32.c,v 1.6 2008/03/26 18:34:43 danielk1977 Exp $
** $Id: mutex_w32.c,v 1.7 2008/06/13 18:24:27 drh Exp $
*/
#include "sqliteInt.h"
@@ -58,6 +58,12 @@ struct sqlite3_mutex {
#endif /* OS_WINCE */
/*
** Initialize and deinitialize the mutex subsystem.
*/
int sqlite3_mutex_init(void){ return SQLITE_OK; }
int sqlite3_mutex_end(void){ return SQLITE_OK; }
/*
** The sqlite3_mutex_alloc() routine allocates a new
** mutex and returns a pointer to it. If it returns NULL
@@ -161,7 +167,7 @@ void sqlite3_mutex_free(sqlite3_mutex *p){
** more than once, the behavior is undefined.
*/
void sqlite3_mutex_enter(sqlite3_mutex *p){
assert( p );
if( p==0 ) return;
assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(p) );
EnterCriticalSection(&p->mutex);
p->owner = GetCurrentThreadId();
@@ -169,7 +175,7 @@ void sqlite3_mutex_enter(sqlite3_mutex *p){
}
int sqlite3_mutex_try(sqlite3_mutex *p){
int rc = SQLITE_BUSY;
assert( p );
if( p==0 ) return SQLITE_OK;
assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(p) );
/*
** The sqlite3_mutex_try() routine is very rarely used, and when it
@@ -199,6 +205,7 @@ int sqlite3_mutex_try(sqlite3_mutex *p){
** is not currently allocated. SQLite will never do either.
*/
void sqlite3_mutex_leave(sqlite3_mutex *p){
if( p==0 ) return;
assert( p->nRef>0 );
assert( p->owner==GetCurrentThreadId() );
p->nRef--;

View File

@@ -13,7 +13,7 @@
** This file contains OS interface code that is common to all
** architectures.
**
** $Id: os.c,v 1.111 2008/06/06 11:11:26 danielk1977 Exp $
** $Id: os.c,v 1.112 2008/06/13 18:24:27 drh Exp $
*/
#define _SQLITE_OS_C_ 1
#include "sqliteInt.h"
@@ -200,7 +200,14 @@ static sqlite3_vfs *vfsList = 0;
*/
sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){
#ifndef SQLITE_MUTEX_NOOP
sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
sqlite3_mutex *mutex;
#endif
#ifndef SQLITE_OMIT_AUTOINIT
int rc = sqlite3_initialize();
if( rc ) return 0;
#endif
#ifndef SQLITE_MUTEX_NOOP
mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
sqlite3_vfs *pVfs = 0;
static int isInit = 0;
@@ -244,7 +251,14 @@ static void vfsUnlink(sqlite3_vfs *pVfs){
*/
int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){
#ifndef SQLITE_MUTEX_NOOP
sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
sqlite3_mutex *mutex;
#endif
#ifndef SQLITE_OMIT_AUTOINIT
int rc = sqlite3_initialize();
if( rc ) return rc;
#endif
#ifndef SQLITE_MUTEX_NOOP
mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
sqlite3_vfs_find(0); /* Make sure we are initialized */
sqlite3_mutex_enter(mutex);

View File

@@ -12,7 +12,7 @@
**
** This file contains code that is specific to OS/2.
**
** $Id: os_os2.c,v 1.42 2008/06/12 12:38:10 drh Exp $
** $Id: os_os2.c,v 1.43 2008/06/13 18:24:27 drh Exp $
*/
#include "sqliteInt.h"
@@ -1073,4 +1073,11 @@ sqlite3_vfs *sqlite3OsDefaultVfs(void){
return &os2Vfs;
}
/*
** Initialize and deinitialize the operating system interface.
** These are stubs for now - populate with real code later...
*/
int sqlite3_os_init(void){ return SQLITE_OK; }
int sqlite3_os_end(void){ return SQLITE_OK; }
#endif /* OS_OS2 */

View File

@@ -12,7 +12,7 @@
**
** This file contains code that is specific to Unix systems.
**
** $Id: os_unix.c,v 1.186 2008/06/06 15:49:30 danielk1977 Exp $
** $Id: os_unix.c,v 1.187 2008/06/13 18:24:27 drh Exp $
*/
#include "sqliteInt.h"
#if OS_UNIX /* This file is used on unix only */
@@ -2811,4 +2811,12 @@ sqlite3_vfs *sqlite3OsDefaultVfs(void){
return &unixVfs;
}
/*
** Initialize and deinitialize the operating system interface.
** These are stubs for now - populate with real code later...
*/
int sqlite3_os_init(void){ return SQLITE_OK; }
int sqlite3_os_end(void){ return SQLITE_OK; }
#endif /* OS_UNIX */

View File

@@ -12,7 +12,7 @@
**
** This file contains code that is specific to windows.
**
** $Id: os_win.c,v 1.126 2008/06/06 15:49:30 danielk1977 Exp $
** $Id: os_win.c,v 1.127 2008/06/13 18:24:27 drh Exp $
*/
#include "sqliteInt.h"
#if OS_WIN /* This file is used for windows only */
@@ -1584,4 +1584,11 @@ sqlite3_vfs *sqlite3OsDefaultVfs(void){
return &winVfs;
}
/*
** Initialize and deinitialize the operating system interface.
** These are stubs for now - populate with real code later...
*/
int sqlite3_os_init(void){ return SQLITE_OK; }
int sqlite3_os_end(void){ return SQLITE_OK; }
#endif /* OS_WIN */

View File

@@ -30,7 +30,7 @@
** the version number) and changes its name to "sqlite3.h" as
** part of the build process.
**
** @(#) $Id: sqlite.h.in,v 1.325 2008/06/12 00:07:29 drh Exp $
** @(#) $Id: sqlite.h.in,v 1.326 2008/06/13 18:24:27 drh Exp $
*/
#ifndef _SQLITE3_H_
#define _SQLITE3_H_
@@ -928,7 +928,7 @@ int sqlite3_os_end(void);
** may only be invoked prior to library initialization using
** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
** Note, however, that sqlite3_config() can be called as part of the
** implementation of an application-defined [sqlite3_initialize()].
** implementation of an application-defined [sqlite3_os_init()].
**
** The first argument to sqlite3_config() is an integer
** [SQLITE_CONFIG_SINGLETHREAD | configuration option] that determines
@@ -937,10 +937,8 @@ int sqlite3_os_end(void);
** in the first argument.
**
** When a configuration option is set, sqlite3_config() returns SQLITE_OK.
** If the option is unknown or SQLite is unable to set the option (for
** example if one attempts to set a threadsafe option when SQLite is
** compiled with SQLITE_THREADSAFE=0 and is thus incapable of being
** threadsafe) then this routine returns a non-zero [error code].
** If the option is unknown or SQLite is unable to set the option
** then this routine returns a non-zero [error code].
*/
int sqlite3_config(int, ...);
@@ -975,11 +973,13 @@ int sqlite3_config(int, ...);
** same [prepared statement] in different threads at the same time.</dd>
**
** <dt>SQLITE_CONFIG_MALLOC</dt>
** <dd>This option takes four arguments. The first three
** <dd>This option takes five arguments. The first three
** arguments are pointers to functions that emulate malloc(), free(),
** and realloc(), respectively. The fourth argument must be a pointer to
** a function that returns the size of a prior allocation when handed a pointer
** to the allocation. This option is used to replace the default memory
** to the allocation. The fifth argument is a pointer to a function that
** returns the rounded-up size of a memory allocation given the requested
** allocation size. This option is used to replace the default memory
** allocator with an application-defined memory allocator.</dd>
**
** <dt>SQLITE_CONFIG_MEMSTATS</dt>
@@ -990,6 +990,7 @@ int sqlite3_config(int, ...);
** <li> [sqlite3_memory_used()]
** <li> [sqlite3_memory_highwater()]
** <li> [sqlite3_soft_heap_limit()]
** <li> sqlite3_memory_status()
** </ul>
** </dd>
** </dl>
@@ -997,15 +998,11 @@ int sqlite3_config(int, ...);
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
#define SQLITE_CONFIG_SERIALIZED 3 /* nil */
#define SQLITE_CONFIG_MALLOC 4 /* malloc, free, realloc, memsize */
#define SQLITE_CONFIG_MALLOC 4 /* malloc,free,realloc,memsize,roundup */
#define SQLITE_CONFIG_MEMSTATS 5 /* boolean */
/* These options are to be added later. Currently unused and undocumented. */
#define SQLITE_CONFIG_PAGEMALLOC 6 /* malloc, free */
#define SQLITE_CONFIG_TEMPMALLOC 7 /* malloc, free */
#define SQLITE_CONFIG_HEAP 8 /* void*, int64 */
#define SQLITE_CONFIG_PAGEHEAP 9 /* void*, int64 */
#define SQLITE_CONFIG_TEMPHEAP 10 /* void*, int64 */
#define SQLITE_CONFIG_HEAP 6 /* void*, int64, min, max, tmp */
/*
@@ -5723,15 +5720,19 @@ int sqlite3_vfs_unregister(sqlite3_vfs*);
** calling thread or is not currently allocated. {F17033} SQLite will
** never do either. {END}
**
** If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
** sqlite3_mutex_leave() is a NULL pointer, then all three routines
** behave as no-ops.
**
** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
*/
int sqlite3_mutex_init();
int sqlite3_mutex_init(void);
sqlite3_mutex *sqlite3_mutex_alloc(int);
void sqlite3_mutex_free(sqlite3_mutex*);
void sqlite3_mutex_enter(sqlite3_mutex*);
int sqlite3_mutex_try(sqlite3_mutex*);
void sqlite3_mutex_leave(sqlite3_mutex*);
int sqlite_mutex_end();
int sqlite3_mutex_end(void);
/*
** CAPI3REF: Mutex Verifcation Routines {F17080}

View File

@@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.707 2008/06/06 15:04:37 drh Exp $
** @(#) $Id: sqliteInt.h,v 1.708 2008/06/13 18:24:27 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
@@ -1731,6 +1731,24 @@ typedef struct {
int rc; /* Result code stored here */
} InitData;
/*
** Structure containing global configuration data for the SQLite library.
*/
struct Sqlite3Config {
void *(*xMalloc)(int); /* Low-level malloc() */
void *(*xRealloc)(void*,int); /* Low-level realloc() */
void (*xFree)(void*); /* Low-level free() */
int (*xMemsize)(void*); /* Return size of an allocation */
int (*xRoundup)(int); /* Size of allocation given request */
void *pHeap; /* Heap storage space */
sqlite3_int64 nHeap; /* Size of pHeap[] */
int mnReq, mxReq; /* Min and max memory request sizes */
int nTemp; /* Part of pHeap for temporary allos */
int bMemstat; /* True to enable memory status */
int bCoreMutex; /* True to enable core mutexing */
int bFullMutex; /* True to enable full mutexing */
};
/*
** Assuming zIn points to the first byte of a UTF-8 character,
** advance zIn to point to the first byte of the next UTF-8 character.
@@ -1763,6 +1781,7 @@ int sqlite3StrICmp(const char *, const char *);
int sqlite3StrNICmp(const char *, const char *, int);
int sqlite3IsNumber(const char*, int*, u8);
int sqlite3MallocInit(void);
void *sqlite3MallocZero(unsigned);
void *sqlite3DbMallocZero(sqlite3*, unsigned);
void *sqlite3DbMallocRaw(sqlite3*, unsigned);
@@ -2060,6 +2079,7 @@ int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **);
void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
#ifndef SQLITE_AMALGAMATION
extern const unsigned char sqlite3UpperToLower[];
extern struct Sqlite3Config sqlite3Config;
#endif
void sqlite3RootPageMoved(Db*, int, int);
void sqlite3Reindex(Parse*, Token*, Token*);

View File

@@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.231 2008/06/12 02:16:45 shane Exp $
** $Id: util.c,v 1.232 2008/06/13 18:24:27 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@@ -150,46 +150,7 @@ void sqlite3Dequote(char *z){
}
}
/* An array to map all upper-case characters into their corresponding
** lower-case character.
*/
const unsigned char sqlite3UpperToLower[] = {
#ifdef SQLITE_ASCII
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 97, 98, 99,100,101,102,103,
104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,
122, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103,104,105,106,107,
108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,
126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,
162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,
180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,
198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,
216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,
234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,
252,253,254,255
#endif
#ifdef SQLITE_EBCDIC
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 0x */
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 1x */
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 2x */
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */
96, 97, 66, 67, 68, 69, 70, 71, 72, 73,106,107,108,109,110,111, /* 6x */
112, 81, 82, 83, 84, 85, 86, 87, 88, 89,122,123,124,125,126,127, /* 7x */
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */
144,145,146,147,148,149,150,151,152,153,154,155,156,157,156,159, /* 9x */
160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */
192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */
208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */
224,225,162,163,164,165,166,167,168,169,232,203,204,205,206,207, /* Ex */
239,240,241,242,243,244,245,246,247,248,249,219,220,221,222,255, /* Fx */
#endif
};
/* Convenient short-hand */
#define UpperToLower sqlite3UpperToLower
/*

View File

@@ -13,7 +13,7 @@
# including the sqlite3_bind_zeroblob(), sqlite3_result_zeroblob(),
# and the built-in zeroblob() SQL function.
#
# $Id: zeroblob.test,v 1.12 2008/06/12 18:17:40 drh Exp $
# $Id: zeroblob.test,v 1.13 2008/06/13 18:24:28 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -28,7 +28,7 @@ ifcapable !incrblob {
# But it does get inserted into the database correctly.
#
db eval {PRAGMA cache_size=10}
sqlite3_memory_highwater
sqlite3_memory_highwater 1
unset -nocomplain memused
set memused [sqlite3_memory_used]
do_test zeroblob-1.1 {

View File

@@ -203,6 +203,7 @@ proc copy_file {filename} {
foreach file {
sqliteInt.h
global.c
date.c
os.c