00001 /***** This file contains automatically generated code ****** 00002 ** 00003 ** The code in this file has been automatically generated by 00004 ** 00005 ** $Header: /sqlite/sqlite/tool/mkkeywordhash.c,v 1.32 2008/10/06 05:32:19 danielk1977 Exp $ 00006 ** 00007 ** The code in this file implements a function that determines whether 00008 ** or not a given identifier is really an SQL keyword. The same thing 00009 ** might be implemented more directly using a hand-written hash table. 00010 ** But by using this automatically generated code, the size of the code 00011 ** is substantially reduced. This is important for embedded applications 00012 ** on platforms with limited memory. 00013 */ 00014 /* Hash score: 167 */ 00015 static int keywordCode(const char *z, int n){ 00016 /* zText[] encodes 783 bytes of keywords in 528 bytes */ 00017 static const char zText[528] = 00018 "REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECTABLE" 00019 "FTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVEXISTSCONSTRAINT" 00020 "ERSECTRIGGEREFERENCESUNIQUERYATTACHAVINGROUPDATEMPORARYBEGINNER" 00021 "ENAMEBETWEENOTNULLIKECASCADELETECASECOLLATECREATECURRENT_DATE" 00022 "DETACHIMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMIT" 00023 "WHENWHEREPLACEAFTERESTRICTANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMIT" 00024 "CONFLICTCROSSCURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAILFROM" 00025 "FULLGLOBYIFINTOFFSETISNULLORDERIGHTOUTEROLLBACKROWUNIONUSINGVACUUM" 00026 "VIEWINITIALLY"; 00027 static const unsigned char aHash[127] = { 00028 65, 94, 110, 63, 0, 44, 0, 0, 71, 0, 66, 0, 0, 00029 104, 12, 67, 15, 0, 108, 74, 105, 101, 0, 19, 0, 0, 00030 114, 0, 112, 78, 0, 22, 82, 0, 9, 0, 0, 59, 60, 00031 0, 58, 6, 0, 39, 79, 91, 0, 111, 90, 0, 0, 45, 00032 0, 92, 24, 0, 17, 0, 115, 40, 23, 0, 5, 99, 25, 00033 85, 0, 0, 117, 95, 50, 116, 47, 7, 42, 0, 80, 0, 00034 89, 26, 0, 88, 0, 0, 0, 84, 81, 86, 77, 98, 14, 00035 34, 97, 0, 70, 0, 18, 76, 100, 31, 0, 113, 69, 106, 00036 52, 46, 73, 0, 0, 83, 102, 0, 109, 0, 35, 0, 0, 00037 28, 0, 75, 48, 53, 0, 20, 51, 0, 43, 00038 }; 00039 static const unsigned char aNext[117] = { 00040 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 00041 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 00042 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 00043 0, 0, 3, 38, 0, 32, 21, 0, 0, 0, 0, 29, 0, 00044 0, 37, 0, 0, 0, 1, 55, 0, 0, 56, 0, 0, 0, 00045 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 0, 30, 0, 00046 16, 33, 10, 0, 0, 0, 0, 0, 0, 0, 11, 61, 68, 00047 0, 8, 0, 93, 87, 0, 96, 0, 49, 0, 0, 64, 0, 00048 41, 103, 0, 27, 107, 36, 62, 72, 0, 0, 57, 0, 0, 00049 }; 00050 static const unsigned char aLen[117] = { 00051 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6, 00052 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6, 00053 11, 2, 7, 5, 5, 9, 6, 10, 9, 7, 10, 6, 5, 00054 6, 6, 5, 6, 4, 9, 2, 5, 5, 6, 7, 7, 3, 00055 4, 4, 7, 3, 6, 4, 7, 6, 12, 6, 9, 4, 6, 00056 5, 4, 7, 6, 5, 6, 7, 5, 4, 5, 7, 5, 8, 00057 3, 7, 13, 2, 2, 4, 6, 6, 8, 5, 17, 12, 7, 00058 8, 8, 2, 4, 4, 4, 4, 4, 2, 2, 4, 6, 2, 00059 3, 6, 5, 5, 5, 8, 3, 5, 5, 6, 4, 9, 3, 00060 }; 00061 static const unsigned short int aOffset[117] = { 00062 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33, 00063 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81, 00064 86, 95, 96, 101, 105, 109, 117, 123, 130, 138, 144, 154, 157, 00065 162, 167, 172, 175, 179, 179, 183, 188, 191, 195, 201, 207, 207, 00066 210, 213, 217, 218, 222, 228, 232, 239, 245, 257, 263, 272, 274, 00067 280, 285, 287, 294, 299, 304, 310, 316, 321, 325, 328, 335, 339, 00068 347, 349, 356, 358, 360, 369, 373, 379, 385, 393, 398, 398, 414, 00069 421, 428, 429, 436, 440, 444, 448, 452, 455, 457, 459, 462, 462, 00070 465, 468, 474, 478, 483, 487, 495, 498, 503, 508, 514, 518, 523, 00071 }; 00072 static const unsigned char aCode[117] = { 00073 TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE, 00074 TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN, 00075 TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD, 00076 TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE, 00077 TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE, 00078 TK_EXCEPT, TK_TRANSACTION,TK_ON, TK_JOIN_KW, TK_ALTER, 00079 TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_CONSTRAINT, TK_INTERSECT, 00080 TK_TRIGGER, TK_REFERENCES, TK_UNIQUE, TK_QUERY, TK_ATTACH, 00081 TK_HAVING, TK_GROUP, TK_UPDATE, TK_TEMP, TK_TEMP, 00082 TK_OR, TK_BEGIN, TK_JOIN_KW, TK_RENAME, TK_BETWEEN, 00083 TK_NOTNULL, TK_NOT, TK_NULL, TK_LIKE_KW, TK_CASCADE, 00084 TK_ASC, TK_DELETE, TK_CASE, TK_COLLATE, TK_CREATE, 00085 TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, TK_JOIN, TK_INSERT, 00086 TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT, 00087 TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN, TK_WHERE, 00088 TK_REPLACE, TK_AFTER, TK_RESTRICT, TK_AND, TK_DEFAULT, 00089 TK_AUTOINCR, TK_TO, TK_IN, TK_CAST, TK_COLUMNKW, 00090 TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW, 00091 TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DROP, 00092 TK_FAIL, TK_FROM, TK_JOIN_KW, TK_LIKE_KW, TK_BY, 00093 TK_IF, TK_INTO, TK_OFFSET, TK_OF, TK_SET, 00094 TK_ISNULL, TK_ORDER, TK_JOIN_KW, TK_JOIN_KW, TK_ROLLBACK, 00095 TK_ROW, TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, 00096 TK_INITIALLY, TK_ALL, 00097 }; 00098 int h, i; 00099 if( n<2 ) return TK_ID; 00100 h = ((charMap(z[0])*4) ^ 00101 (charMap(z[n-1])*3) ^ 00102 n) % 127; 00103 for(i=((int)aHash[h])-1; i>=0; i=((int)aNext[i])-1){ 00104 if( aLen[i]==n && sqlite3StrNICmp(&zText[aOffset[i]],z,n)==0 ){ 00105 return aCode[i]; 00106 } 00107 } 00108 return TK_ID; 00109 } 00110 int sqlite3KeywordCode(const unsigned char *z, int n){ 00111 return keywordCode((char*)z, n); 00112 }
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:54 2011 by Doxygen 1.6.1