diff --git a/manifest b/manifest index 40d2967aec..6abbd882b3 100644 --- a/manifest +++ b/manifest @@ -1,22 +1,22 @@ -C :-)\s(CVS\s13) -D 2000-05-30T03:28:36 +C :-)\s(CVS\s14) +D 2000-05-30T13:44:19 F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4 F Makefile.in 89921c1ee4de75275bfadfbac198396da31704d1 F README 6b5960603c7f8bf42fc022b4b6436f242f238dbb F configure 00a5b5c82147a576fa6e82d7c1b0d55c321d6d2c x F configure.in 6ccfd5fc80517f7cfe605a7fc7e0f62d962a233c F doc/lemon.html e233a3e97a779c7a87e1bc4528c664a58e49dd47 -F src/build.c 94d1bda19f4129991e4e8bef2278a0398a49b0ec +F src/build.c bc81ec2f7c3296c1f784f7c94d2d8afea9f787e7 F src/dbbe.c ab05293e89525041eaab8b4aca10516db3648792 F src/dbbe.h bedeb3a0985bb584458e7849fb59927e99e751e6 F src/main.c 25cce7bce0eb3ba10bada7c05f4b38dc6dbbc86f F src/parse.y 265c8596598afba0a94b94acd9c866d01603dfe5 F src/shell.c 125f84ea5f8b725ba474d4702b575d062cc94d92 F src/sqlite.h 2397c17a8f4ca90c09acab0100dc7e2f8f441b69 -F src/sqliteInt.h 0365970442441b5e9b74e1e828afdeac7b0662be -F src/tclsqlite.c 30f4317e1fc9119b130f29ee5dac4ab9121de68b -F src/tokenize.c ab578d90ec6ab117b7ade6e6cfbcb5b0f9cad500 -F src/util.c 321c136fc1a4d5821bad0f990c6374ef0785a118 +F src/sqliteInt.h 562760efc29cf5b37a9029de04a5a8bca156f025 +F src/tclsqlite.c 9efd29f79ded6a900aa3d142169c8bfe03b7affd +F src/tokenize.c 948b8897ba211b58069d4a4465be23a2c639cf18 +F src/util.c dc1e1814cf69587e6ed58b82dd880ddb2165f3ce F src/vdbe.c 80132b6bb9a744d1990a1c16666d54baaff2dbc3 F src/vdbe.h e721ad308f2e6ca805cebc4dd0a196ce4419d030 F src/where.c be3973952e9bb5d2bb0bc5523b03f5d1f9e9d6f9 @@ -25,7 +25,7 @@ F test/delete.test 814d53e3b0d2d7069fb17e005d4041454d6585d4 F test/expr.test 11e00880d2de0f60ff1ba7fdd4e09a0d72a01910 F test/index.test 8d4f26901a5582daa353fe3c8266cbf4a53af830 F test/insert.test 161bc67a4189738c559e3569323ceae31f4d49d6 -F test/table.test b1afc2f6d4989f9ce911acbf711ac5d7ae521eb7 +F test/table.test 2d6b3ba1024032d341aec0d3c48272c8407485b4 F test/tester.tcl 70d25b7ced0a958bc377c72399b3dc6bf6a2d09e F test/update.test 69459302ea75cafac1479e60b0e36efb88123c0e F tool/gdbmdump.c 529e67c78d920606ba196326ea55b57b75fcc82b @@ -37,7 +37,7 @@ F tool/renumberOps.awk 6d067177ad5f8d711b79577b462da9b3634bd0a9 F www/c_interface.tcl f875864edf7974157d1c257ca08de854660882a5 F www/index.tcl 2466d1b2e26c6f354b0acedee12025309a216799 F www/sqlite.tcl 947e067bcc347dc767af4c1a6e5a8d47d8404aa3 -P 20f2811fc19f937ed03bdb0e9d87a40c75452b17 -R a5c212fd65bac2f4b07651714ab486bf +P 191a7f484e0a10839e7e1c8eb6658536643e4756 +R 0c03c3a3c9ac1b3b825b1193112ad5a4 U drh -Z 182f1f474f82d5f20dd5789e51b5d83f +Z df606080358f2355e3007d65ffed4f54 diff --git a/manifest.uuid b/manifest.uuid index a80c349ceb..4e7f9b5c69 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -191a7f484e0a10839e7e1c8eb6658536643e4756 \ No newline at end of file +1bb8ee8d9f1d3c409a11910e7552e4bb5e7f5f87 \ No newline at end of file diff --git a/src/build.c b/src/build.c index dbb227a28d..40c4d39c95 100644 --- a/src/build.c +++ b/src/build.c @@ -24,7 +24,7 @@ ** This file contains C code routines that are called by the parser ** when syntax rules are reduced. ** -** $Id: build.c,v 1.5 2000/05/30 03:12:21 drh Exp $ +** $Id: build.c,v 1.6 2000/05/30 13:44:19 drh Exp $ */ #include "sqliteInt.h" @@ -243,7 +243,7 @@ void sqliteAddColumn(Parse *pParse, Token *pName){ char **pz; if( (p = pParse->pNewTable)==0 ) return; if( (p->nCol & 0x7)==0 ){ - p->azCol = sqliteRealloc( p->azCol, (p->nCol+9)*sizeof(p->azCol[0])); + p->azCol = sqliteRealloc( p->azCol, (p->nCol+8)*sizeof(p->azCol[0])); } if( p->azCol==0 ){ p->nCol = 0; @@ -473,7 +473,7 @@ void sqliteCreateIndex( /* ** Allocate the index structure. */ - pIndex = sqliteMalloc( sizeof(Index) + strlen(zName) + + pIndex = sqliteMalloc( sizeof(Index) + strlen(zName) + 1 + sizeof(int)*pList->nId ); if( pIndex==0 ){ sqliteSetString(&pParse->zErrMsg, "out of memory", 0); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index b2bf129dee..0ef51f9ba8 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -23,7 +23,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.1 2000/05/29 14:26:01 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.2 2000/05/30 13:44:20 drh Exp $ */ #include "sqlite.h" #include "dbbe.h" @@ -35,6 +35,13 @@ #include #include +/* #define MEMORY_DEBUG 1 */ +#ifdef MEMORY_DEBUG +# define sqliteMalloc(X) sqliteMalloc_(X,__FILE__,__LINE__) +# define sqliteFree(X) sqliteFree_(X,__FILE__,__LINE__) +# define sqliteRealloc(X,Y) sqliteRealloc_(X,Y,__FILE__,__LINE__) +#endif + /* ** The number of entries in the in-memory hash table holding the ** schema. @@ -200,9 +207,15 @@ int sqliteStrNICmp(const char *, const char *, int); int sqliteHashNoCase(const char *, int); int sqliteCompare(const char *, const char *); int sqliteSortCompare(const char *, const char *); -void *sqliteMalloc(int); -void sqliteFree(void*); -void *sqliteRealloc(void*,int); +#ifdef MEMORY_DEBUG + void *sqliteMalloc_(int,char*,int); + void sqliteFree_(void*,char*,int); + void *sqliteRealloc_(void*,int,char*,int); +#else + void *sqliteMalloc(int); + void sqliteFree(void*); + void *sqliteRealloc(void*,int); +#endif int sqliteGetToken(const char*, int *); void sqliteSetString(char **, const char *, ...); void sqliteSetNString(char **, ...); diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 2d4d154ebc..e261791cca 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -23,7 +23,7 @@ ************************************************************************* ** A TCL Interface to SQLite ** -** $Id: tclsqlite.c,v 1.2 2000/05/29 20:41:51 drh Exp $ +** $Id: tclsqlite.c,v 1.3 2000/05/30 13:44:20 drh Exp $ */ #include "sqlite.h" #include @@ -152,6 +152,7 @@ static int DbCmd(void *cd, Tcl_Interp *interp, int argc, char **argv){ } if( argc==5 ){ cbData.interp = interp; + cbData.once = 1; cbData.zArray = argv[3]; cbData.zCode = argv[4]; zErrMsg = 0; diff --git a/src/tokenize.c b/src/tokenize.c index f762b679d0..cc7615bac0 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -27,10 +27,11 @@ ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** -** $Id: tokenize.c,v 1.1 2000/05/29 14:26:02 drh Exp $ +** $Id: tokenize.c,v 1.2 2000/05/30 13:44:20 drh Exp $ */ #include "sqliteInt.h" #include +#include /* ** All the keywords of the SQL language are stored as in a hash @@ -287,7 +288,7 @@ int sqliteRunParser(Parse *pParse, char *zSql, char **pzErrMsg){ extern void sqliteParserTrace(FILE*, char *); i = 0; - pEngine = sqliteParserAlloc(sqliteMalloc); + pEngine = sqliteParserAlloc((void(*)())malloc); if( pEngine==0 ){ sqliteSetString(pzErrMsg, "out of memory", 0); return 1; @@ -354,7 +355,7 @@ int sqliteRunParser(Parse *pParse, char *zSql, char **pzErrMsg){ nErr++; } } - sqliteParserFree(pEngine, sqliteFree); + sqliteParserFree(pEngine, free); if( pParse->zErrMsg ){ if( pzErrMsg ){ *pzErrMsg = pParse->zErrMsg; diff --git a/src/util.c b/src/util.c index 65ccc1ab81..11e4449b6f 100644 --- a/src/util.c +++ b/src/util.c @@ -26,19 +26,109 @@ ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** -** $Id: util.c,v 1.4 2000/05/29 23:48:23 drh Exp $ +** $Id: util.c,v 1.5 2000/05/30 13:44:20 drh Exp $ */ #include "sqliteInt.h" #include #include +#ifdef MEMORY_DEBUG + + +/* +** Allocate new memory and set it to zero. Return NULL if +** no memory is available. +*/ +void *sqliteMalloc_(int n, char *zFile, int line){ + void *p; + int *pi; + int k; + k = (n+sizeof(int)-1)/sizeof(int); + pi = malloc( (3+k)*sizeof(int)); + if( pi==0 ) return 0; + pi[0] = 0xdead1122; + pi[1] = n; + pi[k+2] = 0xdead3344; + p = &pi[2]; + memset(p, 0, n); + printf("malloc %d bytes at 0x%x from %s:%d\n", n, (int)p, zFile, line); + return p; +} + +/* +** Free memory previously obtained from sqliteMalloc() +*/ +void sqliteFree_(void *p, char *zFile, int line){ + if( p ){ + int *pi, k, n; + pi = p; + pi -= 2; + if( pi[0]!=0xdead1122 ){ + printf("Low-end memory corruption at 0x%x\n", (int)p); + return; + } + n = pi[1]; + k = (n+sizeof(int)-1)/sizeof(int); + if( pi[k+2]!=0xdead3344 ){ + printf("High-end memory corruption at 0x%x\n", (int)p); + return; + } + memset(pi, 0, (k+3)*sizeof(int)); + printf("free %d bytes at 0x%x from %s:%d\n", n, (int)p, zFile, line); + free(pi); + } +} + +/* +** Resize a prior allocation. If p==0, then this routine +** works just like sqliteMalloc(). If n==0, then this routine +** works just like sqliteFree(). +*/ +void *sqliteRealloc_(void *oldP, int n, char *zFile, int line){ + int *oldPi, *pi, k, oldN, oldK; + void *p; + if( oldP==0 ){ + return sqliteMalloc_(n,zFile,line); + } + if( n==0 ){ + sqliteFree_(oldP,zFile,line); + return 0; + } + oldPi = oldP; + oldPi -= 2; + if( oldPi[0]!=0xdead1122 ){ + printf("Low-end memory corruption in realloc at 0x%x\n", (int)p); + return; + } + oldN = oldPi[1]; + oldK = (oldN+sizeof(int)-1)/sizeof(int); + if( oldPi[oldK+2]!=0xdead3344 ){ + printf("High-end memory corruption in realloc at 0x%x\n", (int)p); + return; + } + k = (n + sizeof(int) - 1)/sizeof(int); + pi = malloc( (k+3)*sizeof(int) ); + pi[0] = 0xdead1122; + pi[1] = n; + pi[k+2] = 0xdead3344; + p = &pi[2]; + memcpy(p, oldP, n>oldN ? oldN : n); + if( n>oldN ){ + memset(&((char*)p)[oldN], 0, n-oldN); + } + memset(oldPi, 0, (oldK+3)*sizeof(int)); + free(oldPi); + printf("realloc %d->%d bytes at 0x%x->0x%x at %s:%d\n", oldN, n, + (int)oldP, (int)p, zFile, line); + return p; +} +#else /* !defined(MEMORY_DEBUG) */ /* ** Allocate new memory and set it to zero. Return NULL if ** no memory is available. */ void *sqliteMalloc(int n){ void *p = malloc(n); - /* printf("alloc 0x%x size: %d bytes\n", (int)p, n); */ if( p==0 ) return 0; memset(p, 0, n); return p; @@ -49,7 +139,6 @@ void *sqliteMalloc(int n){ */ void sqliteFree(void *p){ if( p ){ - /* printf("free 0x%x\n", (int)p); */ free(p); } } @@ -67,9 +156,9 @@ void *sqliteRealloc(void *p, int n){ sqliteFree(p); return 0; } - /* printf("realloc 0x%x size: %d bytes\n", (int)p, n); */ return realloc(p, n); } +#endif /* MEMORY_DEBUG */ /* ** Create a string from the 2nd and subsequent arguments (up to the diff --git a/test/table.test b/test/table.test index 9c54a95968..dbd68ed89d 100644 --- a/test/table.test +++ b/test/table.test @@ -23,7 +23,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the CREATE TABLE statement. # -# $Id: table.test,v 1.2 2000/05/30 03:12:22 drh Exp $ +# $Id: table.test,v 1.3 2000/05/30 13:44:20 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -113,7 +113,7 @@ do_test table-2.1d { # Verify that we cannot make a table with the same name as an index # -do_test table-2.2 { +do_test table-2.2a { execsql {CREATE TABLE test2(one text); CREATE INDEX test3 ON test2(one)} set v [catch {execsql {CREATE TABLE test3(two text)}} msg] lappend v $msg @@ -143,7 +143,7 @@ set big_table \ {CREATE TABLE big( f1 varchar(20), f2 char(10), - f3 varchar(30), + f3 varchar(30) primary key, f4 text, f5 text, f6 text,