Index: src/build.c ================================================================== --- src/build.c +++ src/build.c @@ -20,11 +20,11 @@ ** creating ID lists ** BEGIN TRANSACTION ** COMMIT ** ROLLBACK ** -** $Id: build.c,v 1.302 2005/01/31 12:42:29 danielk1977 Exp $ +** $Id: build.c,v 1.303 2005/01/31 12:56:44 danielk1977 Exp $ */ #include "sqliteInt.h" #include /* @@ -851,10 +851,47 @@ int i; if( (p = pParse->pNewTable)==0 ) return; i = p->nCol-1; if( i>=0 ) p->aCol[i].notNull = onError; } + +/* +** Scan the column type name zType (length nType) and return the +** associated affinity type. +*/ +static char sqlite3AffinityType(const char *zType, int nType){ + int n, i; + static const struct { + const char *zSub; /* Keywords substring to search for */ + char nSub; /* length of zSub */ + char affinity; /* Affinity to return if it matches */ + } substrings[] = { + {"INT", 3, SQLITE_AFF_INTEGER}, + {"CHAR", 4, SQLITE_AFF_TEXT}, + {"CLOB", 4, SQLITE_AFF_TEXT}, + {"TEXT", 4, SQLITE_AFF_TEXT}, + {"BLOB", 4, SQLITE_AFF_NONE}, + }; + + if( nType==0 ){ + return SQLITE_AFF_NONE; + } + for(i=0; i /* Turn bulk memory into a hash table object by initializing the @@ -96,11 +96,18 @@ /* ** Hash and comparison functions when the mode is SQLITE_HASH_STRING */ static int strHash(const void *pKey, int nKey){ - return sqlite3HashNoCase((const char*)pKey, nKey); + const char *z = (const char *)pKey; + int h = 0; + if( nKey<=0 ) nKey = strlen(z); + while( nKey > 0 ){ + h = (h<<3) ^ h ^ sqlite3UpperToLower[(unsigned char)*z++]; + nKey--; + } + return h & 0x7fffffff; } static int strCompare(const void *pKey1, int n1, const void *pKey2, int n2){ if( n1!=n2 ) return 1; return sqlite3StrNICmp((const char*)pKey1,(const char*)pKey2,n1); } Index: src/sqliteInt.h ================================================================== --- src/sqliteInt.h +++ src/sqliteInt.h @@ -9,11 +9,11 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.364 2005/01/29 08:32:45 danielk1977 Exp $ +** @(#) $Id: sqliteInt.h,v 1.365 2005/01/31 12:56:44 danielk1977 Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ /* @@ -1539,11 +1539,10 @@ int sqlite3ReadUtf8(const unsigned char *); int sqlite3PutVarint(unsigned char *, u64); int sqlite3GetVarint(const unsigned char *, u64 *); int sqlite3GetVarint32(const unsigned char *, u32 *); int sqlite3VarintLen(u64 v); -char sqlite3AffinityType(const char *, int); void sqlite3IndexAffinityStr(Vdbe *, Index *); void sqlite3TableAffinityStr(Vdbe *, Table *); char sqlite3CompareAffinity(Expr *pExpr, char aff2); int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity); char sqlite3ExprAffinity(Expr *pExpr); Index: src/util.c ================================================================== --- src/util.c +++ src/util.c @@ -12,11 +12,11 @@ ** Utility functions used throughout sqlite. ** ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** -** $Id: util.c,v 1.128 2005/01/20 22:48:48 drh Exp $ +** $Id: util.c,v 1.129 2005/01/31 12:56:44 danielk1977 Exp $ */ #include "sqliteInt.h" #include #include @@ -490,24 +490,10 @@ 234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251, 252,253,254,255 }; #define UpperToLower sqlite3UpperToLower -/* -** This function computes a hash on the name of a keyword. -** Case is not significant. -*/ -int sqlite3HashNoCase(const char *z, int n){ - int h = 0; - if( n<=0 ) n = strlen(z); - while( n > 0 ){ - h = (h<<3) ^ h ^ UpperToLower[(unsigned char)*z++]; - n--; - } - return h & 0x7fffffff; -} - /* ** Some systems have stricmp(). Others have strcasecmp(). Because ** there is no consistency, we will define our own. */ int sqlite3StrICmp(const char *zLeft, const char *zRight){