Index: Makefile.in ================================================================== --- Makefile.in +++ Makefile.in @@ -155,11 +155,11 @@ # Object files for the SQLite library (non-amalgamation). # OBJS0 = alter.lo analyze.lo attach.lo auth.lo bitvec.lo btmutex.lo \ btree.lo build.lo callback.lo complete.lo date.lo \ - delete.lo expr.lo fault.lo func2.lo global.lo \ + delete.lo expr.lo fault.lo func.lo global.lo \ hash.lo journal.lo insert.lo loadext.lo \ main.lo malloc.lo mem1.lo mem2.lo mem3.lo mem4.lo mem5.lo mem6.lo \ mutex.lo mutex_os2.lo mutex_unix.lo mutex_w32.lo \ opcodes.lo os.lo os_unix.lo os_win.lo os_os2.lo \ pager.lo parse.lo pcache.lo pragma.lo prepare.lo printf.lo random.lo \ @@ -196,10 +196,11 @@ $(TOP)/src/complete.c \ $(TOP)/src/date.c \ $(TOP)/src/delete.c \ $(TOP)/src/expr.c \ $(TOP)/src/fault.c \ + $(TOP)/src/func.c \ $(TOP)/src/global.c \ $(TOP)/src/hash.c \ $(TOP)/src/hash.h \ $(TOP)/src/hwtime.h \ $(TOP)/src/insert.c \ @@ -263,11 +264,10 @@ $(TOP)/src/where.c # Generated source code files # SRC += \ - func2.c \ keywordhash.h \ opcodes.c \ opcodes.h \ parse.c \ parse.h \ @@ -519,12 +519,12 @@ $(LTCOMPILE) -c $(TOP)/src/expr.c fault.lo: $(TOP)/src/fault.c $(HDR) $(LTCOMPILE) -c $(TOP)/src/fault.c -func2.lo: func2.c $(HDR) - $(LTCOMPILE) -c func2.c +func.lo: $(TOP)/src/func.c $(HDR) + $(LTCOMPILE) -c $(TOP)/src/func.c global.lo: $(TOP)/src/global.c $(HDR) $(LTCOMPILE) -c $(TOP)/src/global.c hash.lo: $(TOP)/src/hash.c $(HDR) @@ -614,15 +614,10 @@ cp $(TOP)/src/parse.y . ./lemon$(BEXE) $(OPTS) $(OPT_FEATURE_FLAGS) parse.y mv parse.h parse.h.temp $(NAWK) -f $(TOP)/addopcodes.awk parse.h.temp >parse.h -func2.c: $(TOP)/src/func.c $(HDR) - $(BCC) -o mkfunction$(BEXE) $(OPTS) $(OPT_FEATURE_FLAGS) $(TOP)/tool/mkfunction.c -I$(TOP)/src -I. - cat $(TOP)/src/func.c > func2.c - ./mkfunction$(BEXE) >> func2.c - pragma.lo: $(TOP)/src/pragma.c $(HDR) $(LTCOMPILE) -c $(TOP)/src/pragma.c prepare.lo: $(TOP)/src/prepare.c $(HDR) $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/prepare.c Index: main.mk ================================================================== --- main.mk +++ main.mk @@ -49,11 +49,11 @@ # Object files for the SQLite library. # LIBOBJ+= alter.o analyze.o attach.o auth.o \ bitvec.o btmutex.o btree.o build.o \ callback.o complete.o date.o delete.o \ - expr.o fault.o func2.o global.o hash.o \ + expr.o fault.o func.o global.o hash.o \ icu.o insert.o journal.o legacy.o loadext.o \ main.o malloc.o mem1.o mem2.o mem3.o mem4.o mem5.o mem6.o \ mutex.o mutex_os2.o mutex_unix.o mutex_w32.o \ opcodes.o os.o os_os2.o os_unix.o os_win.o \ pager.o parse.o pcache.o pragma.o prepare.o printf.o \ @@ -81,10 +81,11 @@ $(TOP)/src/complete.c \ $(TOP)/src/date.c \ $(TOP)/src/delete.c \ $(TOP)/src/expr.c \ $(TOP)/src/fault.c \ + $(TOP)/src/func.c \ $(TOP)/src/global.c \ $(TOP)/src/hash.c \ $(TOP)/src/hash.h \ $(TOP)/src/hwtime.h \ $(TOP)/src/insert.c \ @@ -140,11 +141,10 @@ $(TOP)/src/vdbeapi.c \ $(TOP)/src/vdbeaux.c \ $(TOP)/src/vdbeblob.c \ $(TOP)/src/vdbefifo.c \ $(TOP)/src/vdbemem.c \ - $(TOP)/src/pcache.c \ $(TOP)/src/vdbeInt.h \ $(TOP)/src/vtab.c \ $(TOP)/src/walker.c \ $(TOP)/src/where.c @@ -191,11 +191,10 @@ keywordhash.h \ opcodes.c \ opcodes.h \ parse.c \ parse.h \ - func2.c \ sqlite3.h # Source code to the test files. # @@ -229,11 +228,11 @@ #TESTSRC += $(TOP)/ext/fts2/fts2_tokenizer.c #TESTSRC += $(TOP)/ext/fts3/fts3_tokenizer.c TESTSRC2 = \ $(TOP)/src/attach.c $(TOP)/src/btree.c $(TOP)/src/build.c $(TOP)/src/date.c \ - $(TOP)/src/expr.c func2.c $(TOP)/src/insert.c $(TOP)/src/os.c \ + $(TOP)/src/expr.c $(TOP)/src/func.c $(TOP)/src/insert.c $(TOP)/src/os.c \ $(TOP)/src/os_os2.c $(TOP)/src/os_unix.c $(TOP)/src/os_win.c \ $(TOP)/src/pager.c $(TOP)/src/pragma.c $(TOP)/src/prepare.c \ $(TOP)/src/printf.c $(TOP)/src/random.c $(TOP)/src/pcache.c \ $(TOP)/src/select.c $(TOP)/src/tokenize.c \ $(TOP)/src/utf.c $(TOP)/src/util.c $(TOP)/src/vdbeapi.c $(TOP)/src/vdbeaux.c \ @@ -347,16 +346,12 @@ # opcodes.c: opcodes.h $(TOP)/mkopcodec.awk sort -n -b -k 3 opcodes.h | $(NAWK) -f $(TOP)/mkopcodec.awk >opcodes.c opcodes.h: parse.h $(TOP)/src/vdbe.c $(TOP)/mkopcodeh.awk - cat parse.h $(TOP)/src/vdbe.c |$(NAWK) -f $(TOP)/mkopcodeh.awk >opcodes.h - -func2.c: $(TOP)/src/func.c $(HDR) - $(BCC) -o mkfunction $(OPTS) $(TOP)/tool/mkfunction.c -I$(TOP)/src -I. - cat $(TOP)/src/func.c > func2.c - ./mkfunction >> func2.c + cat parse.h $(TOP)/src/vdbe.c | \ + $(NAWK) -f $(TOP)/mkopcodeh.awk >opcodes.h # Rules to build parse.c and parse.h - the outputs of lemon. # parse.h: parse.c @@ -495,6 +490,6 @@ rm -f lemon lempar.c parse.* sqlite*.tar.gz mkkeywordhash keywordhash.h rm -f $(PUBLISH) rm -f *.da *.bb *.bbg gmon.out rm -rf tsrc target_source rm -f testloadext.dll libtestloadext.so - rm -f sqlite3.c fts?amal.c tclsqlite3.c func2.c + rm -f sqlite3.c fts?amal.c tclsqlite3.c Index: src/callback.c ================================================================== --- src/callback.c +++ src/callback.c @@ -11,11 +11,11 @@ ************************************************************************* ** ** This file contains functions used to access the internal hash tables ** of user defined functions and collation sequences. ** -** $Id: callback.c,v 1.27 2008/08/20 14:49:24 danielk1977 Exp $ +** $Id: callback.c,v 1.28 2008/08/21 18:49:28 drh Exp $ */ #include "sqliteInt.h" /* @@ -258,10 +258,53 @@ } } return match; } +/* +** Search a FuncDefHash for a function with the given name. Return +** a pointer to the matching FuncDef if found, or 0 if there is no match. +*/ +static FuncDef *functionSearch( + FuncDefHash *pHash, /* Hash table to search */ + int h, /* Hash of the name */ + const char *zFunc, /* Name of function */ + int nFunc /* Number of bytes in zFunc */ +){ + FuncDef *p; + for(p=pHash->a[h]; p; p=p->pHash){ + if( sqlite3StrNICmp(p->zName, zFunc, nFunc)==0 && p->zName[nFunc]==0 ){ + return p; + } + } + return 0; +} + +/* +** Insert a new FuncDef into a FuncDefHash hash table. +*/ +void sqlite3FuncDefInsert( + FuncDefHash *pHash, /* The hash table into which to insert */ + FuncDef *pDef /* The function definition to insert */ +){ + FuncDef *pOther; + int nName = strlen(pDef->zName); + u8 c1 = (u8)pDef->zName[0]; + int h = (sqlite3UpperToLower[c1] + nName) % ArraySize(pHash->a); + pOther = functionSearch(pHash, h, pDef->zName, nName); + if( pOther ){ + pDef->pNext = pOther->pNext; + pOther->pNext = pDef; + }else{ + pDef->pNext = 0; + pDef->pHash = pHash->a[h]; + pHash->a[h] = pDef; + } +} + + + /* ** Locate a user function given a name, a number of arguments and a flag ** indicating whether the function prefers UTF-16 over UTF-8. Return a ** pointer to the FuncDef structure that defines that function, or return ** NULL if the function does not exist. @@ -287,62 +330,58 @@ int nArg, /* Number of arguments. -1 means any number */ u8 enc, /* Preferred text encoding */ int createFlag /* Create new entry if true and does not otherwise exist */ ){ FuncDef *p; /* Iterator variable */ - FuncDef *pFirst; /* First function with this name */ FuncDef *pBest = 0; /* Best match found so far */ - int bestmatch = 0; + int bestScore = 0; /* Score of best match */ + int h; /* Hash value */ assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE ); if( nArg<-1 ) nArg = -1; + h = (sqlite3UpperToLower[(u8)zName[0]] + nName) % ArraySize(db->aFunc.a); + - pFirst = (FuncDef*)sqlite3HashFind(&db->aFunc, zName, nName); - for(p=pFirst; p; p=p->pNext){ - int match = matchQuality(p, nArg, enc); - if( match>bestmatch ){ + p = functionSearch(&db->aFunc, h, zName, nName); + while( p ){ + int score = matchQuality(p, nArg, enc); + if( score>bestScore ){ pBest = p; - bestmatch = match; + bestScore = score; } + p = p->pNext; } /* If the createFlag parameter is false and no match was found amongst ** the custom functions stored in sqlite3.aFunc, try to find a built-in ** function to use. */ if( !createFlag && !pBest ){ - FuncDef *aFunc; - int nFunc; - int i; - nFunc = sqlite3GetBuiltinFunction(zName, nName, &aFunc); - for(i=0; ibestmatch ){ - pBest = &aFunc[i]; - bestmatch = match; - } + p = functionSearch(&sqlite3FuncBuiltins, h, zName, nName); + while( p ){ + int score = matchQuality(p, nArg, enc); + if( score>bestScore ){ + pBest = p; + bestScore = score; + } + p = p->pNext; } } /* If the createFlag parameter is true, and the seach did not reveal an ** exact match for the name, number of arguments and encoding, then add a ** new entry to the hash table and return it. */ - if( createFlag && bestmatch<6 && + if( createFlag && bestScore<6 && (pBest = sqlite3DbMallocZero(db, sizeof(*pBest)+nName+1))!=0 ){ pBest->zName = (char *)&pBest[1]; pBest->nArg = nArg; - pBest->pNext = pFirst; pBest->iPrefEnc = enc; memcpy(pBest->zName, zName, nName); pBest->zName[nName] = 0; - if( pBest==sqlite3HashInsert(&db->aFunc,pBest->zName,nName,(void*)pBest) ){ - db->mallocFailed = 1; - sqlite3DbFree(db, pBest); - return 0; - } + sqlite3FuncDefInsert(&db->aFunc, pBest); } if( pBest && (pBest->xStep || pBest->xFunc || createFlag) ){ return pBest; } Index: src/func.c ================================================================== --- src/func.c +++ src/func.c @@ -14,11 +14,11 @@ ** ** There is only one exported symbol in this file - the function ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** -** $Id: func.c,v 1.197 2008/08/20 14:49:24 danielk1977 Exp $ +** $Id: func.c,v 1.198 2008/08/21 18:49:28 drh Exp $ */ #ifndef CREATE_BUILTIN_HASHTABLE #include "sqliteInt.h" @@ -1420,5 +1420,15 @@ LIKEFUNC(like, 2, &likeInfoNorm, SQLITE_FUNC_LIKE), LIKEFUNC(like, 3, &likeInfoNorm, SQLITE_FUNC_LIKE), #endif }; +/* +** Build up the global built-in function table at initialization +** time. +*/ +void sqlite3RegisterGlobalFunctions(void){ + int i; + for(i=0; i #ifdef SQLITE_ENABLE_FTS3 @@ -145,10 +145,12 @@ ** recursive calls might also be possible. */ sqlite3_mutex_enter(sqlite3Config.pInitMutex); if( sqlite3Config.isInit==0 && inProgress==0 ){ inProgress = 1; + memset(&sqlite3FuncBuiltins, 0, sizeof(sqlite3FuncBuiltins)); + sqlite3RegisterGlobalFunctions(); rc = sqlite3_os_init(); if( rc==SQLITE_OK ){ rc = sqlite3PcacheInitialize(); sqlite3PCacheBufferSetup(sqlite3Config.pPage, sqlite3Config.szPage, sqlite3Config.nPage); @@ -564,18 +566,21 @@ } } sqlite3ResetInternalSchema(db, 0); assert( db->nDb<=2 ); assert( db->aDb==db->aDbStatic ); - for(i=sqliteHashFirst(&db->aFunc); i; i=sqliteHashNext(i)){ - FuncDef *pFunc, *pNext; - for(pFunc = (FuncDef*)sqliteHashData(i); pFunc; pFunc=pNext){ - pNext = pFunc->pNext; - sqlite3DbFree(db, pFunc); + for(j=0; jaFunc.a); j++){ + FuncDef *pNext, *pHash, *p; + for(p=db->aFunc.a[j]; p; p=pHash){ + pHash = p->pHash; + while( p ){ + pNext = p->pNext; + sqlite3DbFree(db, p); + p = pNext; + } } } - for(i=sqliteHashFirst(&db->aCollSeq); i; i=sqliteHashNext(i)){ CollSeq *pColl = (CollSeq *)sqliteHashData(i); /* Invoke any destructors registered for collation sequence user data. */ for(j=0; j<3; j++){ if( pColl[j].xDel ){ @@ -594,11 +599,10 @@ sqlite3DbFree(db, pMod); } sqlite3HashClear(&db->aModule); #endif - sqlite3HashClear(&db->aFunc); sqlite3Error(db, SQLITE_OK, 0); /* Deallocates any cached error strings. */ if( db->pErr ){ sqlite3ValueFree(db->pErr); } sqlite3CloseExtensions(db); @@ -1369,10 +1373,13 @@ # error SQLITE_MAX_LIKE_PATTERN_LENGTH must be at least 1 #endif #if SQLITE_MAX_VARIABLE_NUMBER<1 # error SQLITE_MAX_VARIABLE_NUMBER must be at least 1 #endif +#if SQLITE_MAX_COLUMN>32767 +# error SQLITE_MAX_COLUMN must not exceed 32767 +#endif /* ** Change the value of a limit. Report the old value. ** If an invalid limit index is supplied, report -1. @@ -1464,11 +1471,10 @@ #endif #ifdef SQLITE_ENABLE_LOAD_EXTENSION | SQLITE_LoadExtension #endif ; - sqlite3HashInit(&db->aFunc, SQLITE_HASH_STRING, 0); sqlite3HashInit(&db->aCollSeq, SQLITE_HASH_STRING, 0); #ifndef SQLITE_OMIT_VIRTUALTABLE sqlite3HashInit(&db->aModule, SQLITE_HASH_STRING, 0); #endif 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.757 2008/08/20 16:35:10 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.758 2008/08/21 18:49:28 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ /* @@ -364,11 +364,11 @@ typedef sqlite_uint64 u64; /* 8-byte unsigned integer */ typedef UINT32_TYPE u32; /* 4-byte unsigned integer */ typedef UINT16_TYPE u16; /* 2-byte unsigned integer */ typedef INT16_TYPE i16; /* 2-byte signed integer */ typedef UINT8_TYPE u8; /* 1-byte unsigned integer */ -typedef UINT8_TYPE i8; /* 1-byte signed integer */ +typedef INT8_TYPE i8; /* 1-byte signed integer */ /* ** Macros to determine whether the machine is big or little endian, ** evaluated at runtime. */ @@ -453,10 +453,11 @@ typedef struct Schema Schema; typedef struct Expr Expr; typedef struct ExprList ExprList; typedef struct FKey FKey; typedef struct FuncDef FuncDef; +typedef struct FuncDefHash FuncDefHash; typedef struct IdList IdList; typedef struct Index Index; typedef struct KeyClass KeyClass; typedef struct KeyInfo KeyInfo; typedef struct Lookaside Lookaside; @@ -590,10 +591,20 @@ }; struct LookasideSlot { LookasideSlot *pNext; /* Next buffer in the list of free buffers */ }; +/* +** A hash table for function definitions. +** +** Hash each FuncDef structure into one of the FuncDefHash.a[] slots. +** Collisions are on the FuncDef.pHash chain. +*/ +struct FuncDefHash { + FuncDef *a[23]; /* Hash table for functions */ +}; + /* ** Each database is an instance of the following structure. ** ** The sqlite.lastRowid records the last insert rowid generated by an ** insert statement. Inserts on views do not affect its value. Each @@ -686,11 +697,11 @@ Hash aModule; /* populated by sqlite3_create_module() */ Table *pVTab; /* vtab with active Connect/Create method */ sqlite3_vtab **aVTrans; /* Virtual tables with open transactions */ int nVTrans; /* Allocated size of aVTrans */ #endif - Hash aFunc; /* All functions that can be in SQL exprs */ + FuncDefHash aFunc; /* Hash table of connection functions */ Hash aCollSeq; /* All collating sequences */ BusyHandler busyHandler; /* Busy callback */ int busyTimeout; /* Busy handler timeout, in msec */ Db aDbStatic[2]; /* Static space for the 2 default backends */ #ifdef SQLITE_SSE @@ -751,28 +762,29 @@ ** structure. A pointer to this structure is stored in the sqlite.aFunc ** hash table. When multiple functions have the same name, the hash table ** points to a linked list of these structures. */ struct FuncDef { - i16 nArg; /* Number of arguments. -1 means unlimited */ + i8 nArg; /* Number of arguments. -1 means unlimited */ u8 iPrefEnc; /* Preferred text encoding (SQLITE_UTF8, 16LE, 16BE) */ u8 needCollSeq; /* True if sqlite3GetFuncCollSeq() might be called */ u8 flags; /* Some combination of SQLITE_FUNC_* */ void *pUserData; /* User data parameter */ FuncDef *pNext; /* Next function with same name */ void (*xFunc)(sqlite3_context*,int,sqlite3_value**); /* Regular function */ void (*xStep)(sqlite3_context*,int,sqlite3_value**); /* Aggregate step */ void (*xFinalize)(sqlite3_context*); /* Aggregate finializer */ char *zName; /* SQL name of the function. */ + FuncDef *pHash; /* Next with a different name but the same hash */ }; /* ** Possible values for FuncDef.flags */ -#define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */ -#define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */ -#define SQLITE_FUNC_EPHEM 0x04 /* Ephermeral. Delete with VDBE */ +#define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */ +#define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */ +#define SQLITE_FUNC_EPHEM 0x04 /* Ephermeral. Delete with VDBE */ /* ** Each SQLite module (virtual table definition) is defined by an ** instance of the following structure, stored in the sqlite3.aModule ** hash table. @@ -2125,13 +2137,15 @@ void sqlite3TokenCopy(sqlite3*,Token*, Token*); ExprList *sqlite3ExprListDup(sqlite3*,ExprList*); SrcList *sqlite3SrcListDup(sqlite3*,SrcList*); IdList *sqlite3IdListDup(sqlite3*,IdList*); Select *sqlite3SelectDup(sqlite3*,Select*); +void sqlite3FuncDefInsert(FuncDefHash*, FuncDef*); FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,int); void sqlite3RegisterBuiltinFunctions(sqlite3*); void sqlite3RegisterDateTimeFunctions(sqlite3*); +void sqlite3RegisterGlobalFunctions(void); int sqlite3GetBuiltinFunction(const char *, int, FuncDef **); #ifdef SQLITE_DEBUG int sqlite3SafetyOn(sqlite3*); int sqlite3SafetyOff(sqlite3*); #else @@ -2266,10 +2280,11 @@ int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **); void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8); #ifndef SQLITE_AMALGAMATION extern const unsigned char sqlite3UpperToLower[]; extern struct Sqlite3Config sqlite3Config; +extern FuncDefHash sqlite3FuncBuiltins; #endif void sqlite3RootPageMoved(Db*, int, int); void sqlite3Reindex(Parse*, Token*, Token*); void sqlite3AlterFunctions(sqlite3*); void sqlite3AlterRenameTable(Parse*, SrcList*, Token*); DELETED tool/mkfunction.c Index: tool/mkfunction.c ================================================================== --- tool/mkfunction.c +++ /dev/null @@ -1,186 +0,0 @@ - -/* -** This file contains a standalone program used to generate C code that -** implements a static hash table to store the definitions of built-in -** SQL functions in SQLite. -*/ - -#include -#include -#include - -/* -** The SQLite source file "func.c" is included below. -** -** By defining the 4 macros and typedef below before including "func.c", -** most of the code is excluded. What is left is an array of constant -** strings, aBuiltinFunc[], containing the names of SQLite's built-in -** SQL functions. i.e.: -** -** const char aBuiltinFunc[] = { "like", "glob", "min", "max" ... }; -** -** The data from aBuiltinFunc[] is used by this program to create the -** static hash table. -*/ -#define CREATE_BUILTIN_HASHTABLE 1 -#define FUNCTION(zName,w,x,y,z) #zName -#define AGGREGATE(zName,v,w,x,y,z) #zName -#define LIKEFUNC(zName,x,y,z) #zName -#define FuncDef const char * - -#include "func.c" - -/* The number of buckets in the static hash table. */ -#define HASHSIZE 127 - -typedef unsigned char u8; - -/* An array to map all upper-case characters into their corresponding -** lower-case character. -*/ -static const u8 sqlite3UpperToLower[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 97, 98, 99,100,101,102,103, - 104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121, - 122, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103,104,105,106,107, - 108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125, - 126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, - 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161, - 162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179, - 180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197, - 198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215, - 216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233, - 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 - -int sqlite3StrICmp(const char *zLeft, const char *zRight){ - register unsigned char *a, *b; - a = (unsigned char *)zLeft; - b = (unsigned char *)zRight; - while( *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; } - return UpperToLower[*a] - UpperToLower[*b]; -} - -static int hashstring(const char *zName){ - int ii; - unsigned int iKey = 0; - for(ii=0; zName[ii]; ii++){ - iKey = (iKey<<3) + (u8)sqlite3UpperToLower[(u8)zName[ii]]; - } - iKey = iKey%HASHSIZE; - return iKey; -} - -static void printarray(const char *zName, u8 *aArray, int nArray){ - int ii; - printf(" static u8 %s[%d] = {", zName, nArray); - for(ii=0; ii=0 && 0==sqlite3StrICmp(aBuiltinFunc[ii], aBuiltinFunc[iHead]) ){ - anFunc[iHead]++; - continue; - }else{ - /* The routine generated by this program assumes that if there are - ** two or more entries in the aBuiltinFunc[] array with the same - ** name (i.e. two versions of the "max" function), then they must - ** be stored in adjacent slots. The following block detects the - ** problem if this is not the case. - */ - int jj; - for(jj=0; jjzName, zName, nName) ){\n" - " pFunc = &aBuiltinFunc[iKey = aNext[iKey]];\n" - " }\n" - "\n" - " *paFunc = pFunc;\n" - " return anFunc[iKey];\n" - "}\n" - ); - - return 0; -} Index: tool/mksqlite3c.tcl ================================================================== --- tool/mksqlite3c.tcl +++ tool/mksqlite3c.tcl @@ -254,11 +254,11 @@ attach.c auth.c build.c callback.c delete.c - func2.c + func.c insert.c legacy.c loadext.c pragma.c prepare.c