diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/build.c | 7 | ||||
-rw-r--r-- | src/select.c | 4 | ||||
-rw-r--r-- | src/sqliteInt.h | 10 | ||||
-rw-r--r-- | src/util.c | 6 |
4 files changed, 20 insertions, 7 deletions
diff --git a/src/build.c b/src/build.c index a14a72d2f..5d247850c 100644 --- a/src/build.c +++ b/src/build.c @@ -25,7 +25,7 @@ ** ROLLBACK ** PRAGMA ** -** $Id: build.c,v 1.138 2003/03/31 02:12:47 drh Exp $ +** $Id: build.c,v 1.139 2003/03/31 13:36:09 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -2670,6 +2670,11 @@ void sqliteAttach(Parse *pParse, Token *pFilename, Token *pDbname){ if( pParse->explain ) return; db = pParse->db; + if( db->nDb>=MAX_ATTACHED ){ + sqliteErrorMsg(pParse, "too many attached databases - max %d", + MAX_ATTACHED); + return; + } if( db->aDb==db->aDbStatic ){ aNew = sqliteMalloc( sizeof(db->aDb[0])*3 ); if( aNew==0 ) return; diff --git a/src/select.c b/src/select.c index e1704d2bf..92efa61e9 100644 --- a/src/select.c +++ b/src/select.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** -** $Id: select.c,v 1.129 2003/03/31 02:12:47 drh Exp $ +** $Id: select.c,v 1.130 2003/03/31 13:36:09 drh Exp $ */ #include "sqliteInt.h" @@ -1591,7 +1591,7 @@ substExprList(ExprList *pList, int iTable, ExprList *pEList, int iSub){ ** The subquery is p->pSrc->a[iFrom]. isAgg is true if the outer query ** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates. ** -** If flattening is not attempted, this routine is a no-op and return 0. +** If flattening is not attempted, this routine is a no-op and returns 0. ** If flattening is attempted this routine returns 1. ** ** All of the expression analysis must occur on both the outer query and diff --git a/src/sqliteInt.h b/src/sqliteInt.h index f4e6999dc..93bf92262 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.168 2003/03/31 02:12:48 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.169 2003/03/31 13:36:09 drh Exp $ */ #include "config.h" #include "sqlite.h" @@ -58,6 +58,14 @@ #define NULL_DISTINCT_FOR_UNIQUE 1 /* +** The maximum number of attached databases. This must be at least 2 +** in order to support the main database file (0) and the file used to +** hold temporary tables (1). And it must be less than 256 because the +** an unsigned character is used to stored the database index. +*/ +#define MAX_ATTACHED 10 + +/* ** Integers of known sizes. These typedefs might change for architectures ** where the sizes very. Preprocessor macros are available so that the ** types can be conveniently redefined at compile-type. Like this: diff --git a/src/util.c b/src/util.c index 87e5f4431..36ffdfa2a 100644 --- a/src/util.c +++ b/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.59 2003/03/31 02:12:48 drh Exp $ +** $Id: util.c,v 1.60 2003/03/31 13:36:09 drh Exp $ */ #include "sqliteInt.h" #include <stdarg.h> @@ -413,7 +413,7 @@ void sqliteErrorMsg(Parse *pParse, const char *zFormat, ...){ nByte = 1 + strlen(zFormat); va_start(ap, zFormat); for(i=0; zFormat[i]; i++){ - if( zFormat[i]!='%' && zFormat[i+1] ) continue; + if( zFormat[i]!='%' || zFormat[i+1]==0 ) continue; i++; switch( zFormat[i] ){ case 'd': { @@ -456,7 +456,7 @@ void sqliteErrorMsg(Parse *pParse, const char *zFormat, ...){ pParse->zErrMsg = z; va_start(ap, zFormat); for(i=j=0; zFormat[i]; i++){ - if( zFormat[i]!='%' ) continue; + if( zFormat[i]!='%' || zFormat[i+1]==0 ) continue; if( i>j ){ memcpy(z, &zFormat[j], i-j); z += i-j; |