Change the MEMORY_DEBUG macro to SQLITE_DEBUG. (CVS 1546)
FossilOrigin-Name: 428b685b7174ef4589176def1028ad1c9461ff7e
This commit is contained in:
parent
c039139807
commit
faa57acc9f
@ -41,16 +41,16 @@ THREADSAFE = -DTHREADSAFE=0
|
||||
#THREADLIB = -lpthread
|
||||
THREADLIB =
|
||||
|
||||
#### Leave MEMORY_DEBUG undefined for maximum speed. Use MEMORY_DEBUG=1
|
||||
# to check for memory leaks. Use MEMORY_DEBUG=2 to print a log of all
|
||||
#### Leave SQLITE_DEBUG undefined for maximum speed. Use SQLITE_DEBUG=1
|
||||
# to check for memory leaks. Use SQLITE_DEBUG=2 to print a log of all
|
||||
# malloc()s and free()s in order to track down memory leaks.
|
||||
#
|
||||
# SQLite uses some expensive assert() statements in the inner loop.
|
||||
# You can make the library go almost twice as fast if you compile
|
||||
# with -DNDEBUG=1
|
||||
#
|
||||
#OPTS = -DMEMORY_DEBUG=2
|
||||
#OPTS = -DMEMORY_DEBUG=1
|
||||
#OPTS = -DSQLITE_DEBUG=2
|
||||
#OPTS = -DSQLITE_DEBUG=1
|
||||
#OPTS =
|
||||
OPTS = -DNDEBUG=1
|
||||
|
||||
|
24
manifest
24
manifest
@ -1,7 +1,7 @@
|
||||
C Fix\serror\sreporting\swhen\strying\sto\sattach\sa\sdatabase\swith\sa\sforiegn\stext\nencoding.\s(CVS\s1545)
|
||||
D 2004-06-09T12:30:05
|
||||
C Change\sthe\sMEMORY_DEBUG\smacro\sto\sSQLITE_DEBUG.\s(CVS\s1546)
|
||||
D 2004-06-09T14:01:51
|
||||
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
|
||||
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
||||
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
|
||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||
F VERSION 4490ff094970c0e36eff0cbe2adcdb3a701f6ad6
|
||||
F aclocal.m4 7daea4c35e88de30d5a3f6f7a2ab99720e803bbd
|
||||
@ -56,10 +56,10 @@ F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
|
||||
F src/select.c 1f8355e702f109f6771f82a9bfe7aac4c82cbaf2
|
||||
F src/shell.c ca519519dcbbc582f6d88f7d0e7583b857fd3469
|
||||
F src/sqlite.h.in 6ad05abc7fd72da74691e1eb45f0eff4117eba4e
|
||||
F src/sqliteInt.h f445d8085f826158a5ad28939987d52c3d14ed88
|
||||
F src/sqliteInt.h c0a328c7567cdeebe14d7a4668f22946e281ebc9
|
||||
F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2
|
||||
F src/tclsqlite.c f5c5116720baefb7de5d6acf18baedf1e42756cc
|
||||
F src/test1.c 73770f2cd2bf97027e2edf62ee345e90c78dfcef
|
||||
F src/test1.c fa01e3db097df48963e29cec66f2e080735767d4
|
||||
F src/test2.c ae18537d8a85e5028c955837797f9da461b908b8
|
||||
F src/test3.c beafd0ccf7b9ae784744be1b1e66ffe8f64c25da
|
||||
F src/test4.c a921a69821fd30209589228e64f94e9f715b6fe2
|
||||
@ -68,18 +68,18 @@ F src/tokenize.c 183c5d7da11affab5d70d903d33409c8c0ce6c5b
|
||||
F src/trigger.c d1a4d7a59b34c811bf6070d64d0497baa0140dcf
|
||||
F src/update.c 259f06e7b22c684b2d3dda54a18185892d6e9573
|
||||
F src/utf.c c2c8e445bfea724f3502609d6389fe66651f02ab
|
||||
F src/util.c ad379519d8267ea1f626874ad4e629e982e8ca58
|
||||
F src/util.c e8629f04d920ae968fced709dc7a3a2c62b65ac4
|
||||
F src/vacuum.c b921eb778842592e1fb48a9d4cef7e861103878f
|
||||
F src/vdbe.c fec13be8b6f03158bfb3069c7bd6182eb3ef4fca
|
||||
F src/vdbe.h 46f74444a213129bc4b5ce40124dd8ed613b0cde
|
||||
F src/vdbeInt.h ab592f23ed5a1913f9a506bd7b76c5e39377942a
|
||||
F src/vdbeapi.c 4ac95766b0515538037a7aec172ed26142f97cf9
|
||||
F src/vdbeaux.c 8547c18b160f3e02fb14e90f0162c195af702c00
|
||||
F src/vdbeaux.c 136442a40335974a5088dbd684a2168d4d0fec9a
|
||||
F src/vdbemem.c 04502b81039f9a2b1c9a096e894eecf6d4877508
|
||||
F src/where.c 32578882a245f8ac3303c5cea4664cd51fc73891
|
||||
F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242
|
||||
F test/attach.test aed659e52635662bcd5069599aaca823533edf5a
|
||||
F test/attach2.test 2185dce04ef9ceb7b2d3df7d17fb2c3817028dea
|
||||
F test/attach2.test fe8480cd1aecbe393f2ae60a92c4f60734d89b49
|
||||
F test/attach3.test 8259ab833b5dcdf4acd75d9653f42f703ce2e013
|
||||
F test/auth.test 95809b8f6a9bec18b94d28cafd03fe27d2f8a9e9
|
||||
F test/bigfile.test ea904b853ce2d703b16c5ce90e2b54951bc1ae81
|
||||
@ -218,7 +218,7 @@ F www/support.tcl 1801397edd271cc39a2aadd54e701184b5181248
|
||||
F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
|
||||
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
|
||||
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
||||
P c634e71f1909819fb55c728bc410e5cc390428e3
|
||||
R 9b06499f09555f5a8d25ad8905d9a708
|
||||
U danielk1977
|
||||
Z 94cfe73075b9a13ff300fa5270c56964
|
||||
P beab038c71eecbabb1351b0c98a71f32ea013285
|
||||
R 4fb29233149257f0d3747b745eb94817
|
||||
U drh
|
||||
Z 903dfd3a43373a03e2e446ce02ca114d
|
||||
|
@ -1 +1 @@
|
||||
beab038c71eecbabb1351b0c98a71f32ea013285
|
||||
428b685b7174ef4589176def1028ad1c9461ff7e
|
@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** Internal interface definitions for SQLite.
|
||||
**
|
||||
** @(#) $Id: sqliteInt.h,v 1.274 2004/06/09 12:30:06 danielk1977 Exp $
|
||||
** @(#) $Id: sqliteInt.h,v 1.275 2004/06/09 14:01:51 drh Exp $
|
||||
*/
|
||||
#include "config.h"
|
||||
#include "sqlite3.h"
|
||||
@ -174,18 +174,18 @@ extern const int sqlite3one;
|
||||
/*
|
||||
** If memory allocation problems are found, recompile with
|
||||
**
|
||||
** -DMEMORY_DEBUG=1
|
||||
** -DSQLITE_DEBUG=1
|
||||
**
|
||||
** to enable some sanity checking on malloc() and free(). To
|
||||
** check for memory leaks, recompile with
|
||||
**
|
||||
** -DMEMORY_DEBUG=2
|
||||
** -DSQLITE_DEBUG=2
|
||||
**
|
||||
** and a line of text will be written to standard error for
|
||||
** each malloc() and free(). This output can be analyzed
|
||||
** by an AWK script to determine if there are any leaks.
|
||||
*/
|
||||
#ifdef MEMORY_DEBUG
|
||||
#ifdef SQLITE_DEBUG
|
||||
# define sqliteMalloc(X) sqlite3Malloc_(X,1,__FILE__,__LINE__)
|
||||
# define sqliteMallocRaw(X) sqlite3Malloc_(X,0,__FILE__,__LINE__)
|
||||
# define sqliteFree(X) sqlite3Free_(X,__FILE__,__LINE__)
|
||||
@ -206,9 +206,9 @@ extern int sqlite3_malloc_failed;
|
||||
|
||||
/*
|
||||
** The following global variables are used for testing and debugging
|
||||
** only. They only work if MEMORY_DEBUG is defined.
|
||||
** only. They only work if SQLITE_DEBUG is defined.
|
||||
*/
|
||||
#ifdef MEMORY_DEBUG
|
||||
#ifdef SQLITE_DEBUG
|
||||
extern int sqlite3_nMalloc; /* Number of sqliteMalloc() calls */
|
||||
extern int sqlite3_nFree; /* Number of sqliteFree() calls */
|
||||
extern int sqlite3_iMallocFail; /* Fail sqliteMalloc() after this many calls */
|
||||
@ -1194,7 +1194,7 @@ int sqlite3IsNumber(const char*, int*, u8);
|
||||
int sqlite3Compare(const char *, const char *);
|
||||
int sqlite3SortCompare(const char *, const char *);
|
||||
void sqlite3RealToSortable(double r, char *);
|
||||
#ifdef MEMORY_DEBUG
|
||||
#ifdef SQLITE_DEBUG
|
||||
void *sqlite3Malloc_(int,int,char*,int);
|
||||
void sqlite3Free_(void*,char*,int);
|
||||
void *sqlite3Realloc_(void*,int,char*,int);
|
||||
|
@ -13,7 +13,7 @@
|
||||
** is not included in the SQLite library. It is used for automated
|
||||
** testing of the SQLite library.
|
||||
**
|
||||
** $Id: test1.c,v 1.72 2004/06/09 09:55:19 danielk1977 Exp $
|
||||
** $Id: test1.c,v 1.73 2004/06/09 14:01:51 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "tcl.h"
|
||||
@ -625,7 +625,7 @@ static int sqlite3_mprintf_scaled(
|
||||
** Rig sqliteMalloc() to fail on the N-th call. Turn off this mechanism
|
||||
** and reset the sqlite3_malloc_failed variable is N==0.
|
||||
*/
|
||||
#ifdef MEMORY_DEBUG
|
||||
#ifdef SQLITE_DEBUG
|
||||
static int sqlite_malloc_fail(
|
||||
void *NotUsed,
|
||||
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
|
||||
@ -649,7 +649,7 @@ static int sqlite_malloc_fail(
|
||||
**
|
||||
** Return the number of prior calls to sqliteMalloc() and sqliteFree().
|
||||
*/
|
||||
#ifdef MEMORY_DEBUG
|
||||
#ifdef SQLITE_DEBUG
|
||||
static int sqlite_malloc_stat(
|
||||
void *NotUsed,
|
||||
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
|
||||
@ -1815,7 +1815,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
|
||||
{ "sqlite3_create_aggregate", (Tcl_CmdProc*)test_create_aggregate },
|
||||
{ "sqlite_register_test_function", (Tcl_CmdProc*)test_register_func },
|
||||
{ "sqlite_abort", (Tcl_CmdProc*)sqlite_abort },
|
||||
#ifdef MEMORY_DEBUG
|
||||
#ifdef SQLITE_DEBUG
|
||||
{ "sqlite_malloc_fail", (Tcl_CmdProc*)sqlite_malloc_fail },
|
||||
{ "sqlite_malloc_stat", (Tcl_CmdProc*)sqlite_malloc_stat },
|
||||
#endif
|
||||
|
30
src/util.c
30
src/util.c
@ -14,7 +14,7 @@
|
||||
** This file contains functions for allocating memory, comparing
|
||||
** strings, and stuff like that.
|
||||
**
|
||||
** $Id: util.c,v 1.99 2004/06/09 09:55:19 danielk1977 Exp $
|
||||
** $Id: util.c,v 1.100 2004/06/09 14:01:53 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <stdarg.h>
|
||||
@ -27,10 +27,10 @@
|
||||
int sqlite3_malloc_failed = 0;
|
||||
|
||||
/*
|
||||
** If MEMORY_DEBUG is defined, then use versions of malloc() and
|
||||
** If SQLITE_DEBUG is defined, then use versions of malloc() and
|
||||
** free() that track memory usage and check for buffer overruns.
|
||||
*/
|
||||
#ifdef MEMORY_DEBUG
|
||||
#ifdef SQLITE_DEBUG
|
||||
|
||||
/*
|
||||
** For keeping track of the number of mallocs and frees. This
|
||||
@ -39,7 +39,7 @@ int sqlite3_malloc_failed = 0;
|
||||
int sqlite3_nMalloc; /* Number of sqliteMalloc() calls */
|
||||
int sqlite3_nFree; /* Number of sqliteFree() calls */
|
||||
int sqlite3_iMallocFail; /* Fail sqliteMalloc() after this many calls */
|
||||
#if MEMORY_DEBUG>1
|
||||
#if SQLITE_DEBUG>1
|
||||
static int memcnt = 0;
|
||||
#endif
|
||||
|
||||
@ -60,7 +60,7 @@ void *sqlite3Malloc_(int n, int bZero, char *zFile, int line){
|
||||
sqlite3_iMallocFail--;
|
||||
if( sqlite3_iMallocFail==0 ){
|
||||
sqlite3_malloc_failed++;
|
||||
#if MEMORY_DEBUG>1
|
||||
#if SQLITE_DEBUG>1
|
||||
fprintf(stderr,"**** failed to allocate %d bytes at %s:%d\n",
|
||||
n, zFile,line);
|
||||
#endif
|
||||
@ -81,7 +81,7 @@ void *sqlite3Malloc_(int n, int bZero, char *zFile, int line){
|
||||
for(i=0; i<N_GUARD; i++) pi[k+1+N_GUARD+i] = 0xdead3344;
|
||||
p = &pi[N_GUARD+1];
|
||||
memset(p, bZero==0, n);
|
||||
#if MEMORY_DEBUG>1
|
||||
#if SQLITE_DEBUG>1
|
||||
fprintf(stderr,"%06d malloc %d bytes at 0x%x from %s:%d\n",
|
||||
++memcnt, n, (int)p, zFile,line);
|
||||
#endif
|
||||
@ -134,7 +134,7 @@ void sqlite3Free_(void *p, char *zFile, int line){
|
||||
}
|
||||
}
|
||||
memset(pi, 0xff, (k+N_GUARD*2+1)*sizeof(int));
|
||||
#if MEMORY_DEBUG>1
|
||||
#if SQLITE_DEBUG>1
|
||||
fprintf(stderr,"%06d free %d bytes at 0x%x from %s:%d\n",
|
||||
++memcnt, n, (int)p, zFile,line);
|
||||
#endif
|
||||
@ -188,7 +188,7 @@ void *sqlite3Realloc_(void *oldP, int n, char *zFile, int line){
|
||||
}
|
||||
memset(oldPi, 0xab, (oldK+N_GUARD+2)*sizeof(int));
|
||||
free(oldPi);
|
||||
#if MEMORY_DEBUG>1
|
||||
#if SQLITE_DEBUG>1
|
||||
fprintf(stderr,"%06d realloc %d to %d bytes at 0x%x to 0x%x at %s:%d\n",
|
||||
++memcnt, oldN, n, (int)oldP, (int)p, zFile, line);
|
||||
#endif
|
||||
@ -237,13 +237,13 @@ char *sqlite3StrNDup_(const char *z, int n, char *zFile, int line){
|
||||
}
|
||||
return zNew;
|
||||
}
|
||||
#endif /* MEMORY_DEBUG */
|
||||
#endif /* SQLITE_DEBUG */
|
||||
|
||||
/*
|
||||
** The following versions of malloc() and free() are for use in a
|
||||
** normal build.
|
||||
*/
|
||||
#if !defined(MEMORY_DEBUG)
|
||||
#if !defined(SQLITE_DEBUG)
|
||||
|
||||
/*
|
||||
** Allocate new memory and set it to zero. Return NULL if
|
||||
@ -321,7 +321,7 @@ char *sqliteStrNDup(const char *z, int n){
|
||||
}
|
||||
return zNew;
|
||||
}
|
||||
#endif /* !defined(MEMORY_DEBUG) */
|
||||
#endif /* !defined(SQLITE_DEBUG) */
|
||||
|
||||
/*
|
||||
** Create a string from the 2nd and subsequent arguments (up to the
|
||||
@ -356,8 +356,8 @@ void sqlite3SetString(char **pz, const char *zFirst, ...){
|
||||
zResult += strlen(zResult);
|
||||
}
|
||||
va_end(ap);
|
||||
#ifdef MEMORY_DEBUG
|
||||
#if MEMORY_DEBUG>1
|
||||
#ifdef SQLITE_DEBUG
|
||||
#if SQLITE_DEBUG>1
|
||||
fprintf(stderr,"string at 0x%x is %s\n", (int)*pz, *pz);
|
||||
#endif
|
||||
#endif
|
||||
@ -397,8 +397,8 @@ void sqlite3SetNString(char **pz, ...){
|
||||
zResult += n;
|
||||
}
|
||||
*zResult = 0;
|
||||
#ifdef MEMORY_DEBUG
|
||||
#if MEMORY_DEBUG>1
|
||||
#ifdef SQLITE_DEBUG
|
||||
#if SQLITE_DEBUG>1
|
||||
fprintf(stderr,"string at 0x%x is %s\n", (int)*pz, *pz);
|
||||
#endif
|
||||
#endif
|
||||
|
@ -653,7 +653,7 @@ void sqlite3VdbeMakeReady(
|
||||
|
||||
sqlite3HashInit(&p->agg.hash, SQLITE_HASH_BINARY, 0);
|
||||
p->agg.pSearch = 0;
|
||||
#ifdef MEMORY_DEBUG
|
||||
#ifdef SQLITE_DEBUG
|
||||
if( sqlite3OsFileExists("vdbe_explain") ){
|
||||
int i;
|
||||
printf("VDBE Program Listing:\n");
|
||||
|
@ -12,7 +12,7 @@
|
||||
# focus of this script is testing the ATTACH and DETACH commands
|
||||
# and related functionality.
|
||||
#
|
||||
# $Id: attach2.test,v 1.12 2004/06/07 16:27:47 drh Exp $
|
||||
# $Id: attach2.test,v 1.13 2004/06/09 14:01:58 drh Exp $
|
||||
#
|
||||
set sqlite_os_trace 0
|
||||
|
||||
@ -162,31 +162,37 @@ do_test attach2-4.2 {
|
||||
# Handle 'db' read-locks test.db
|
||||
execsql {BEGIN}
|
||||
execsql {SELECT * FROM t1}
|
||||
# Lock status:
|
||||
# db - shared(main)
|
||||
# db2 -
|
||||
} {}
|
||||
do_test attach2-4.3 {
|
||||
# The read lock held by db does not prevent db2 from reading test.db
|
||||
execsql {SELECT * FROM t1} db2
|
||||
} {}
|
||||
do_test attach2-4.4 {
|
||||
# db is only holding a read lock on test.db, so we should not be able
|
||||
# db is holding a read lock on test.db, so we should not be able
|
||||
# to commit a write to test.db from db2
|
||||
set r [catch {
|
||||
execsql {
|
||||
INSERT INTO t1 VALUES(1, 2)
|
||||
} db2
|
||||
} msg]
|
||||
list $r $msg
|
||||
catchsql {
|
||||
INSERT INTO t1 VALUES(1, 2)
|
||||
} db2
|
||||
} {1 {database is locked}}
|
||||
do_test attach2-4.5 {
|
||||
# Handle 'db2' reserves file2.
|
||||
execsql {BEGIN} db2
|
||||
execsql {INSERT INTO file2.t1 VALUES(1, 2)} db2
|
||||
# Lock status:
|
||||
# db - shared(main)
|
||||
# db2 - reserved(file2)
|
||||
} {}
|
||||
do_test attach2-4.6.1 {
|
||||
# Reads are allowed against a reserved database.
|
||||
catchsql {
|
||||
SELECT * FROM file2.t1;
|
||||
}
|
||||
# Lock status:
|
||||
# db - shared(main), shared(file2)
|
||||
# db2 - reserved(file2)
|
||||
} {0 {}}
|
||||
do_test attach2-4.6.2 {
|
||||
# Writes against a reserved database are not allowed.
|
||||
@ -205,6 +211,9 @@ do_test attach2-4.8 {
|
||||
# Read lock the main file with db2. Now both db and db2 have a read lock
|
||||
# on the main file, db2 has a write-lock on file2.
|
||||
execsql {SELECT * FROM t1} db2
|
||||
# Lock status:
|
||||
# db - shared(main), shared(file2)
|
||||
# db2 - shared(main), reserved(file2)
|
||||
} {}
|
||||
do_test attach2-4.9 {
|
||||
# Try to upgrade the handle 'db' lock.
|
||||
|
Loading…
Reference in New Issue
Block a user