diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/build.c | 33 | ||||
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/select.c | 7 | ||||
-rw-r--r-- | src/tokenize.c | 11 |
4 files changed, 35 insertions, 20 deletions
diff --git a/src/build.c b/src/build.c index f43ee301b..70b944c7c 100644 --- a/src/build.c +++ b/src/build.c @@ -22,7 +22,7 @@ ** COMMIT ** ROLLBACK ** -** $Id: build.c,v 1.301 2005/01/29 08:32:45 danielk1977 Exp $ +** $Id: build.c,v 1.302 2005/01/31 12:42:29 danielk1977 Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -786,6 +786,19 @@ begin_table_error: } /* +** This macro is used to compare two strings in a case-insensitive manner. +** It is slightly faster than calling sqlite3StrICmp() directly, but +** produces larger code. +** +** WARNING: This macro is not compatible with the strcmp() family. It +** returns true if the two strings are equal, otherwise false. +*/ +#define STRICMP(x, y) (\ +sqlite3UpperToLower[*(unsigned char *)(x)]== \ +sqlite3UpperToLower[*(unsigned char *)(y)] \ +&& sqlite3StrICmp((x)+1,(y)+1)==0 ) + +/* ** Add a new column to the table currently being constructed. ** ** The parser calls this routine once for each column declaration @@ -802,7 +815,7 @@ void sqlite3AddColumn(Parse *pParse, Token *pName){ z = sqlite3NameFromToken(pName); if( z==0 ) return; for(i=0; i<p->nCol; i++){ - if( sqlite3StrICmp(z, p->aCol[i].zName)==0 ){ + if( STRICMP(z, p->aCol[i].zName) ){ sqlite3ErrorMsg(pParse, "duplicate column name: %s", z); sqliteFree(z); return; @@ -854,19 +867,21 @@ void sqlite3AddColumnType(Parse *pParse, Token *pFirst, Token *pLast){ Table *p; int i, j; int n; - char *z, **pz; + char *z; + const unsigned char *zIn; + Column *pCol; if( (p = pParse->pNewTable)==0 ) return; i = p->nCol-1; if( i<0 ) return; pCol = &p->aCol[i]; - pz = &pCol->zType; - n = pLast->n + (pLast->z - pFirst->z); + zIn = pFirst->z; + n = pLast->n + (pLast->z - zIn); assert( pCol->zType==0 ); - z = pCol->zType = sqlite3MPrintf("%.*s", n, pFirst->z); + z = pCol->zType = sqliteMallocRaw(n+1); if( z==0 ) return; - for(i=j=0; z[i]; i++){ - int c = z[i]; + for(i=j=0; i<n; i++){ + int c = zIn[i]; if( isspace(c) ) continue; z[j++] = c; } @@ -1203,7 +1218,7 @@ CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName, int nName){ ** Scan the column type name zType (length nType) and return the ** associated affinity type. */ -char sqlite3AffinityType(const char *zType, int nType){ +static char sqlite3AffinityType(const char *zType, int nType){ int n, i; static const struct { const char *zSub; /* Keywords substring to search for */ diff --git a/src/main.c b/src/main.c index dfcab944b..ac11f178c 100644 --- a/src/main.c +++ b/src/main.c @@ -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.276 2005/01/29 08:32:45 danielk1977 Exp $ +** $Id: main.c,v 1.277 2005/01/31 12:42:29 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -279,7 +279,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){ }else{ char *zSql; zSql = sqlite3MPrintf( - "SELECT name, rootpage, sql, %s FROM '%q'.%s", + "SELECT name, rootpage, sql, '%s' FROM '%q'.%s", zDbNum, db->aDb[iDb].zName, zMasterName); sqlite3SafetyOff(db); rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0); diff --git a/src/select.c b/src/select.c index f54538c41..0bf89932e 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.236 2005/01/30 11:11:44 danielk1977 Exp $ +** $Id: select.c,v 1.237 2005/01/31 12:42:29 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -918,10 +918,7 @@ Table *sqlite3ResultSetOfSelect(Parse *pParse, char *zTabName, Select *pSelect){ sNC.pSrcList = pSelect->pSrc; zType = sqliteStrDup(columnType(&sNC, p)); pCol->zType = zType; - pCol->affinity = SQLITE_AFF_NUMERIC; - if( zType ){ - pCol->affinity = sqlite3AffinityType(zType, strlen(zType)); - } + pCol->affinity = sqlite3ExprAffinity(p); pCol->pColl = sqlite3ExprCollSeq(pParse, p); if( !pCol->pColl ){ pCol->pColl = pParse->db->pDfltColl; diff --git a/src/tokenize.c b/src/tokenize.c index 43490cbeb..4fc1d3d7c 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -15,7 +15,7 @@ ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** -** $Id: tokenize.c,v 1.99 2005/01/18 04:00:44 drh Exp $ +** $Id: tokenize.c,v 1.100 2005/01/31 12:42:29 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -71,7 +71,7 @@ static const char isIdChar[] = { ** Return the length of the token that begins at z[0]. ** Store the token type in *tokenType before returning. */ -int sqlite3GetToken(const unsigned char *z, int *tokenType){ +static int getToken(const unsigned char *z, int *tokenType){ int i, c; switch( *z ){ case ' ': case '\t': case '\n': case '\f': case '\r': { @@ -309,13 +309,16 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ break; } for(i=1; IdChar(z[i]); i++){} - *tokenType = sqlite3KeywordCode((char*)z, i); + *tokenType = keywordCode((char*)z, i); return i; } } *tokenType = TK_ILLEGAL; return 1; } +int sqlite3GetToken(const unsigned char *z, int *tokenType){ + return getToken(z, tokenType); +} /* ** Run the parser on the given SQL string. The parser structure is @@ -355,7 +358,7 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ assert( i>=0 ); pParse->sLastToken.z = &zSql[i]; assert( pParse->sLastToken.dyn==0 ); - pParse->sLastToken.n = sqlite3GetToken((unsigned char*)&zSql[i],&tokenType); + pParse->sLastToken.n = getToken((unsigned char*)&zSql[i],&tokenType); i += pParse->sLastToken.n; switch( tokenType ){ case TK_SPACE: |