-C Modify\sthe\sconfigure\sscript\sto\savoid\susing\sthe\s+=\soperator.\sNot\sall\sshells\ssupport\sit.\s(CVS\s5535)
-D 2008-08-04T14:50:05
+C Separate\sverbs\sof\ssqlite3_config()\sand\ssqlite3_db_config()\sinto\stheir\nown\snamespaces.\s\sAllow\sSQLITE3_DBCONFIG_LOOKASIDE\sto\sspecific\san\sexternal\nmemory\sbuffer.\s(CVS\s5536)
+D 2008-08-04T20:13:27
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 2713ea64947be3b35f35d9a3158bb8299c90b019
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
F src/legacy.c aac57bd984e666059011ea01ec4383892a253be3
F src/loadext.c eb1fe4f44d7c8ff53fc0c6a4388ab79fbd34cd64
-F src/main.c 730c6f40379e2258718ee2e591a4ae091d4e26c6
+F src/main.c d750c6c0d381252851401f6ea2ee72185de005ed
F src/malloc.c f0ad28008351cac2337ef502a3fdc8ffd3e5d9a9
F src/md5.c 008216bbb5d34c6fbab5357aa68575ad8a31516a
F src/mem1.c 3a7fe31d8290baa3bb203af72f7dfd6323966bcd
F src/random.c 5c754319d38abdd6acd74601ee0105504adc508a
F src/select.c c1899b14f5eb3d3b71aeb02d541d6c5052ad3b70
F src/shell.c 4b835fe734304ac22a3385868cd3790c1e4f7aa1
-F src/sqlite.h.in e149baf6c77cba40fa462d76e3c0b37535be6a36
+F src/sqlite.h.in 286cbb5e5bbe31949d4537f532e44a22a3d14184
F src/sqlite3ext.h 1e3887c9bd3ae66cb599e922824b04cd0d0f2c3e
-F src/sqliteInt.h 8bd67fa1beb4eb67f9c543f1f27bd454bbca9fb4
+F src/sqliteInt.h 685b9cf6537e59e4453269b43acb33c59b566346
F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
F src/status.c 8ad1f215934c5f5afb91df86e44dccff7ef3c1d0
F src/table.c 22744786199c9195720c15a7a42cb97b2e2728d8
F src/test_func.c df7ddd5abfc5c8d6cd3e36ae9ecb0c276b0e9039
F src/test_hexio.c 2f1122aa3f012fa0142ee3c36ce5c902a70cd12f
F src/test_loadext.c 97dc8800e46a46ed002c2968572656f37e9c0dd9
-F src/test_malloc.c 3919ed155da54a1ee1e06282a69fb8a035b2749f
+F src/test_malloc.c 75f639a723e498a67c0ee68e81318c671388d1a3
F src/test_md5.c 28209a4e2068711b5443c33104fe41f21d160071
F src/test_mutex.c d3422d9f60cc1330249d102e74b333f0d24a0cb6
F src/test_onefile.c 243157b10275251c5dc2d6619aee2ff9ae22379c
F test/alter.test 6353aae6839e486c9b7d8f73b1f4a1e98e57332c
F test/alter2.test dd55146e812622c8fc51fd2216bcd8dca8880752
F test/alter3.test 25b95a136708f22b87184fa6a4309eea03d65153
-F test/altermalloc.test b97c213c410f7c6af4590d52d2c79f7a74df36fe
+F test/altermalloc.test 11116c58953b6275a48a87c2912b7d4b72c52840
F test/analyze.test a881c145565de9ae1d37aaf385d9a0bbcbb98391
F test/async.test aecaa46ed0618a3c338f3651ca4f10fbb4021044
F test/async2.test 8998e089b0fbb3d84cdd51c25a78833486d721af
F test/attach.test 75a5d22f88e730967d68f2c9f95e786e3953d8e3
F test/attach2.test a295d2d7061adcee5884ef4a93c7c96a82765437
F test/attach3.test 7b92dc8e40c1ebca9732ca6f2d3fefbd46f196df
-F test/attachmalloc.test f7f62363896475080b0d41907a85a9fd94625296
+F test/attachmalloc.test ccbde53bcb0a61020afa3e0670ca9c6c5b99af32
F test/auth.test 9eb4b6b99eee54c95711c74c4b9694acf4d850ed
F test/auth2.test ee3ba272e2b975e913afc9b041ee75706e190005
F test/autoinc.test 42af2c407c4e37d0626f9cda57ed381e94522c9d
F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9
F test/lock4.test 09d97d52cae18fadfe631552af9880dac6b3ae90
F test/lock5.test f4eeb0400cf65c37f733cb3c74401136f8c46acd
-F test/lookaside.test cd7f89dc05d8b5d1c3d56df2241b5edfbdd87218
+F test/lookaside.test 22a518a780de0797d428d2ed6de56828ee7b5544
F test/main.test 8d77c161757ef7d96eaff0413daa7120c3b316fe
F test/malloc.test 69f5bb5a13b24edb1322fc1f42894f9d2f6446b1
F test/malloc3.test 094f8195fe8e409bd4da0f1d769f7745faec62c8
F test/mallocG.test 4584d0d8ddb8009f16ca0c8bab1fa37f6358efa2
F test/mallocH.test 79b65aed612c9b3ed2dcdaa727c85895fd1bfbdb
F test/mallocI.test 6e24fe6444bd2999ccc81f984977b44c0d6e5591
-F test/malloc_common.tcl 753eb1ff3481f6cddb65cff33b9ef9f72c5ccdf7
+F test/malloc_common.tcl e082fe4791dad22b49d2ad3f7dcf1dcbee1a4cec
F test/manydb.test 8de36b8d33aab5ef295b11d9e95310aeded31af8
F test/memdb.test a67bda4ff90a38f2b19f6c7f95aa7289e051d893
F test/memleak.test d2d2a1ff7105d32dc3fdf691458cf6cba58c7217
-F test/memsubsys1.test 45c873e6c31bf70389048e3e0fd63191c75a99f6
+F test/memsubsys1.test 4896d75373f55e61d80b12261d88192861d18b53
F test/memsubsys2.test c05b541f9c2a1234a9dc2ff2233b3a9544fa5139
F test/minmax.test 722d80816f7e096bf2c04f4111f1a6c1ba65453d
F test/minmax2.test 33504c01a03bd99226144e4b03f7631a274d66e0
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 7e6ec5d53d9e002848fa437ec21bf009798a9a3b
-R 4d3a854b4d64fe4c3d561b28ac8712bc
-U danielk1977
-Z 38ad1e873bd8c9c39f5e63fd276f0978
+P f167b2745d491a1adb2b6c869b2169cd6fa53af8
+R d131d66bc7d60253653f16ca16c768cd
+U drh
+Z d5dc59ad71fc51bae7a99c7ae5dfa84b
-f167b2745d491a1adb2b6c869b2169cd6fa53af8
\ No newline at end of file
+5dd865da5e787c10ef4c9e96647724bfab9dea01
\ No newline at end of file
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
-** $Id: main.c,v 1.485 2008/08/01 18:47:02 drh Exp $
+** $Id: main.c,v 1.486 2008/08/04 20:13:27 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
** Set up the lookaside buffers for a database connection.
** Return SQLITE_OK on success.
** If lookaside is already active, return SQLITE_BUSY.
+**
+** The sz parameter is the number of bytes in each lookaside slot.
+** The cnt parameter is the number of slots. If pStart is NULL the
+** space for the lookaside memory is obtained from sqlite3_malloc().
+** If pStart is not NULL then it is sz*cnt bytes of memory to use for
+** the lookaside memory.
*/
-static int setupLookaside(sqlite3 *db, int sz, int cnt){
+static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
void *pStart;
if( db->lookaside.nOut ){
return SQLITE_BUSY;
if( sz<0 ) sz = 0;
if( cnt<0 ) cnt = 0;
sz = (sz+7)&~7;
- sqlite3BeginBenignMalloc();
- pStart = sqlite3Malloc( sz*cnt );
- sqlite3EndBenignMalloc();
- sqlite3_free(db->lookaside.pStart);
+ if( pBuf==0 ){
+ sqlite3BeginBenignMalloc();
+ pStart = sqlite3Malloc( sz*cnt );
+ sqlite3EndBenignMalloc();
+ }else{
+ pStart = pBuf;
+ }
+ if( db->lookaside.bMalloced ){
+ sqlite3_free(db->lookaside.pStart);
+ }
db->lookaside.pStart = pStart;
db->lookaside.pFree = 0;
db->lookaside.sz = sz;
+ db->lookaside.bMalloced = pBuf==0;
if( pStart ){
int i;
LookasideSlot *p;
int rc;
va_start(ap, op);
switch( op ){
- case SQLITE_CONFIG_LOOKASIDE: {
+ case SQLITE_DBCONFIG_LOOKASIDE: {
+ void *pBuf = va_arg(ap, void*);
int sz = va_arg(ap, int);
int cnt = va_arg(ap, int);
- rc = setupLookaside(db, sz, cnt);
+ rc = setupLookaside(db, pBuf, sz, cnt);
break;
}
default: {
sqlite3_mutex_leave(db->mutex);
db->magic = SQLITE_MAGIC_CLOSED;
sqlite3_mutex_free(db->mutex);
- sqlite3_free(db->lookaside.pStart);
+ if( db->lookaside.bMalloced ){
+ sqlite3_free(db->lookaside.pStart);
+ }
sqlite3_free(db);
return SQLITE_OK;
}
#endif
/* Enable the lookaside-malloc subsystem */
- setupLookaside(db, sqlite3Config.szLookaside, sqlite3Config.nLookaside);
+ setupLookaside(db, 0, sqlite3Config.szLookaside, sqlite3Config.nLookaside);
opendb_out:
if( db ){
** the version number) and changes its name to "sqlite3.h" as
** part of the build process.
**
-** @(#) $Id: sqlite.h.in,v 1.385 2008/08/04 13:44:57 drh Exp $
+** @(#) $Id: sqlite.h.in,v 1.386 2008/08/04 20:13:27 drh Exp $
*/
#ifndef _SQLITE3_H_
#define _SQLITE3_H_
** The second argument to sqlite3_db_config(D,V,...) is the
** configuration verb - an integer code that indicates what
** aspect of the [database connection] is being configured.
-** Choices for this value are [SQLITE_CONFIG_LOOKASIDE].
+** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE].
** New verbs are likely to be added in future releases of SQLite.
+** Additional arguments depend on the verb.
*/
int sqlite3_db_config(sqlite3*, int op, ...);
#define SQLITE_CONFIG_CHUNKALLOC 12 /* int threshold */
#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
+/*
+** CAPI3REF: Configuration Options {H10170} <S20000>
+** EXPERIMENTAL
+**
+** These constants are the available integer configuration options that
+** can be passed as the second argument to the [sqlite3_db_config()] interface.
+**
+** New configuration options may be added in future releases of SQLite.
+** Existing configuration options might be discontinued. Applications
+** should check the return code from [sqlite3_db_config()] to make sure that
+** the call worked. The [sqlite3_db_config()] interface will return a
+** non-zero [error code] if a discontinued or unsupported configuration option
+** is invoked.
+**
+** <dl>
+** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
+** <dd>This option takes three additional arguments that determine the
+** [lookaside memory allocator] configuration for the [database connection].
+** The first argument (the third parameter to [sqlite3_db_config()] is a
+** pointer to a memory buffer to use for lookaside memory. The first
+** argument may be NULL in which case SQLite will allocate the lookaside
+** buffer itself using [sqlite3_malloc()]. The second argument is the
+** size of each lookaside buffer slot and the third argument is the number of
+** slots. The size of the buffer in the first argument must be greater than
+** or equal to the product of the second and third arguments.</dd>
+**
+** </dl>
+*/
+#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
+
/*
** CAPI3REF: Enable Or Disable Extended Result Codes {H12200} <S10700>
*************************************************************************
** Internal interface definitions for SQLite.
**
-** @(#) $Id: sqliteInt.h,v 1.751 2008/08/02 15:32:40 danielk1977 Exp $
+** @(#) $Id: sqliteInt.h,v 1.752 2008/08/04 20:13:27 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
struct Lookaside {
u16 sz; /* Size of each buffer in bytes */
u8 bEnabled; /* True if use lookaside. False to ignore it */
+ u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */
int nOut; /* Number of buffers currently checked out */
int mxOut; /* Highwater mark for nOut */
LookasideSlot *pFree; /* List if available buffers */
** This file contains code used to implement test interfaces to the
** memory allocation subsystem.
**
-** $Id: test_malloc.c,v 1.45 2008/08/01 16:31:14 drh Exp $
+** $Id: test_malloc.c,v 1.46 2008/08/04 20:13:27 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
/*
-** Usage: sqlite3_db_config_lookaside CONNECTION SIZE COUNT
+** Usage: sqlite3_db_config_lookaside CONNECTION BUFID SIZE COUNT
**
+** There are two static buffers with BUFID 1 and 2. Each static buffer
+** is 10KB in size. A BUFID of 0 indicates that the buffer should be NULL
+** which will cause sqlite3_db_config() to allocate space on its own.
*/
static int test_db_config_lookaside(
void * clientData,
int rc;
int sz, cnt;
sqlite3 *db;
+ int bufid;
+ static char azBuf[2][10000];
int getDbPointer(Tcl_Interp*, const char*, sqlite3**);
- if( objc!=4 ){
- Tcl_WrongNumArgs(interp, 1, objv, "SIZE COUNT");
+ if( objc!=5 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "BUFID SIZE COUNT");
return TCL_ERROR;
}
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
- if( Tcl_GetIntFromObj(interp, objv[2], &sz) ) return TCL_ERROR;
- if( Tcl_GetIntFromObj(interp, objv[3], &cnt) ) return TCL_ERROR;
- rc = sqlite3_db_config(db, SQLITE_CONFIG_LOOKASIDE, sz, cnt);
+ if( Tcl_GetIntFromObj(interp, objv[2], &bufid) ) return TCL_ERROR;
+ if( Tcl_GetIntFromObj(interp, objv[3], &sz) ) return TCL_ERROR;
+ if( Tcl_GetIntFromObj(interp, objv[4], &cnt) ) return TCL_ERROR;
+ if( bufid==0 ){
+ rc = sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE, 0, sz, cnt);
+ }else if( bufid>=1 && bufid<=2 && sz*cnt<=sizeof(azBuf[0]) ){
+ rc = sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE, azBuf[bufid], sz,cnt);
+ }else{
+ Tcl_AppendResult(interp, "illegal arguments - see documentation", (char*)0);
+ return TCL_ERROR;
+ }
Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
return TCL_OK;
}
# focus of this script is testing the ALTER TABLE statement and
# specifically out-of-memory conditions within that command.
#
-# $Id: altermalloc.test,v 1.8 2008/08/01 18:47:02 drh Exp $
+# $Id: altermalloc.test,v 1.9 2008/08/04 20:13:27 drh Exp $
#
set testdir [file dirname $argv0]
if {[catch {sqlite3 db test.db}]} {
error "out of memory"
}
- sqlite3_db_config_lookaside db 0 0
+ sqlite3_db_config_lookaside db 0 0 0
sqlite3_extended_result_codes db 1
} -sqlbody {
CREATE TABLE t1(a int);
ifcapable vtab {
do_malloc_test altermalloc-vtab -tclprep {
sqlite3 db2 test.db
- sqlite3_db_config_lookaside db2 0 0
+ sqlite3_db_config_lookaside db2 0 0 0
sqlite3_extended_result_codes db2 1
register_echo_module [sqlite3_connection_pointer db2]
db2 eval {
# focus of this script is testing the ATTACH statement and
# specifically out-of-memory conditions within that command.
#
-# $Id: attachmalloc.test,v 1.8 2008/08/01 20:10:09 drh Exp $
+# $Id: attachmalloc.test,v 1.9 2008/08/04 20:13:27 drh Exp $
#
set testdir [file dirname $argv0]
if {[catch {sqlite3 db test.db}]} {
error "out of memory"
}
- sqlite3_db_config_lookaside db 0 0
+ sqlite3_db_config_lookaside db 0 0 0
sqlite3_extended_result_codes db 1
} -sqlbody {
ATTACH 'test2.db' AS two;
#
# Tests for the lookaside memory allocator.
#
-# $Id: lookaside.test,v 1.2 2008/08/01 18:47:02 drh Exp $
+# $Id: lookaside.test,v 1.3 2008/08/04 20:13:27 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
catch {sqlite3_config_error db}
} {0}
do_test lookaside-1.2 {
- sqlite3_db_config_lookaside db 20 20
+ sqlite3_db_config_lookaside db 1 20 20
} {0}
do_test lookaside-1.3 {
sqlite3_db_status db SQLITE_DBSTATUS_LOOKASIDE_USED 0
} {0 0 0}
do_test lookaside-2.1 {
- sqlite3_db_config_lookaside db 100 1000
+ sqlite3_db_config_lookaside db 0 100 1000
} {0}
do_test lookaside-2.2 {
db eval {CREATE TABLE t2(x);}
expr {$x==0 && $y<$z && $z>10 && $z<100}
} {1}
do_test lookaside-2.3 {
- sqlite3_db_config_lookaside db 50 50
+ sqlite3_db_config_lookaside db 0 50 50
} {5} ;# SQLITE_BUSY
do_test lookaside-2.4 {
db cache flush
- sqlite3_db_config_lookaside db 50 50
+ sqlite3_db_config_lookaside db 0 50 50
} {0} ;# SQLITE_OK
# sqlite3_db_status() with an invalid verb returns an error.
# This file contains common code used by many different malloc tests
# within the test suite.
#
-# $Id: malloc_common.tcl,v 1.20 2008/08/01 18:47:02 drh Exp $
+# $Id: malloc_common.tcl,v 1.21 2008/08/04 20:13:27 drh Exp $
# If we did not compile with malloc testing enabled, then do nothing.
#
if {[info commands db] ne ""} {
sqlite3_extended_result_codes db 1
}
- sqlite3_db_config_lookaside db 0 0
+ sqlite3_db_config_lookaside db 0 0 0
# Execute any -tclprep and -sqlprep scripts.
#
#
# This file contains tests of the memory allocation subsystem
#
-# $Id: memsubsys1.test,v 1.7 2008/07/31 17:20:59 drh Exp $
+# $Id: memsubsys1.test,v 1.8 2008/08/04 20:13:27 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
catch {db close}
file delete -force test.db test.db-journal
sqlite3 db test.db
- sqlite3_db_config_lookaside db 0 0
+ sqlite3_db_config_lookaside db 0 0 0
db eval $pragmas
db eval {
CREATE TABLE t1(x, y);