annotate sqlite/keywordhash.h @ 1453:1c0cd95ef1ed trunk

[svn] - fix nemo's bug
author nenolod
date Fri, 28 Jul 2006 14:12:59 -0700
parents b6b61becdf4e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1434
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
1 /* Hash score: 159 */
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
2 static int keywordCode(const char *z, int n){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
3 static const char zText[537] =
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
4 "ABORTABLEFTEMPORARYADDATABASELECTHENDEFAULTRANSACTIONATURALTER"
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
5 "AISEACHECKEYAFTEREFERENCESCAPELSEXCEPTRIGGEREGEXPLAINITIALLYANALYZE"
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
6 "XCLUSIVEXISTSTATEMENTANDEFERRABLEATTACHAVINGLOBEFOREIGNOREINDEX"
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
7 "AUTOINCREMENTBEGINNERENAMEBETWEENOTNULLIKEBYCASCADEFERREDELETE"
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
8 "CASECASTCOLLATECOLUMNCOMMITCONFLICTCONSTRAINTERSECTCREATECROSS"
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
9 "CURRENT_DATECURRENT_TIMESTAMPLANDESCDETACHDISTINCTDROPRAGMATCH"
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
10 "FAILIMITFROMFULLGROUPDATEIFIMMEDIATEINSERTINSTEADINTOFFSETISNULL"
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
11 "JOINORDEREPLACEOUTERESTRICTPRIMARYQUERYRIGHTROLLBACKROWHENUNION"
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
12 "UNIQUEUSINGVACUUMVALUESVIEWHERE";
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
13 static const unsigned char aHash[127] = {
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
14 92, 80, 107, 91, 0, 4, 0, 0, 114, 0, 83, 0, 0,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
15 95, 44, 76, 93, 0, 106, 109, 97, 90, 0, 10, 0, 0,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
16 113, 0, 110, 103, 0, 28, 48, 0, 41, 0, 0, 65, 71,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
17 0, 63, 19, 0, 105, 36, 104, 0, 108, 74, 0, 0, 33,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
18 0, 61, 37, 0, 8, 0, 115, 38, 12, 0, 77, 40, 25,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
19 66, 0, 0, 31, 81, 53, 30, 50, 20, 88, 0, 34, 0,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
20 75, 26, 0, 72, 0, 0, 0, 64, 47, 67, 22, 87, 29,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
21 69, 86, 0, 1, 0, 9, 101, 58, 18, 0, 112, 82, 99,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
22 54, 6, 85, 0, 0, 49, 94, 0, 102, 0, 70, 0, 0,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
23 15, 0, 116, 51, 56, 0, 2, 55, 0, 111,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
24 };
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
25 static const unsigned char aNext[116] = {
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
26 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
27 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
28 0, 11, 0, 0, 0, 0, 5, 13, 0, 7, 0, 0, 0,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
29 0, 0, 0, 0, 0, 0, 0, 43, 0, 0, 0, 0, 0,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
30 0, 0, 16, 0, 23, 52, 0, 0, 0, 0, 45, 0, 59,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
31 0, 0, 0, 0, 0, 0, 0, 0, 73, 42, 0, 24, 60,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
32 21, 0, 79, 0, 0, 68, 0, 0, 84, 46, 0, 0, 0,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
33 0, 0, 0, 0, 0, 39, 96, 98, 0, 0, 100, 0, 32,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
34 0, 14, 27, 78, 0, 57, 89, 0, 35, 0, 62, 0,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
35 };
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
36 static const unsigned char aLen[116] = {
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
37 5, 5, 4, 4, 9, 2, 3, 8, 2, 6, 4, 3, 7,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
38 11, 2, 7, 5, 5, 4, 5, 3, 5, 10, 6, 4, 6,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
39 7, 6, 7, 9, 3, 7, 9, 6, 9, 3, 10, 6, 6,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
40 4, 6, 3, 7, 6, 7, 5, 13, 2, 2, 5, 5, 6,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
41 7, 3, 7, 4, 4, 2, 7, 3, 8, 6, 4, 4, 7,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
42 6, 6, 8, 10, 9, 6, 5, 12, 12, 17, 4, 4, 6,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
43 8, 2, 4, 6, 5, 4, 5, 4, 4, 5, 6, 2, 9,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
44 6, 7, 4, 2, 6, 3, 6, 4, 5, 7, 5, 8, 7,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
45 5, 5, 8, 3, 4, 5, 6, 5, 6, 6, 4, 5,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
46 };
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
47 static const unsigned short int aOffset[116] = {
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
48 0, 4, 7, 10, 10, 14, 19, 21, 26, 27, 32, 34, 36,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
49 42, 51, 52, 57, 61, 65, 67, 71, 74, 78, 86, 91, 94,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
50 99, 105, 108, 113, 118, 122, 128, 136, 141, 150, 152, 162, 167,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
51 172, 175, 177, 177, 181, 185, 187, 192, 194, 196, 205, 208, 212,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
52 218, 224, 224, 227, 230, 234, 236, 237, 241, 248, 254, 258, 262,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
53 269, 275, 281, 289, 296, 305, 311, 316, 328, 328, 344, 348, 352,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
54 358, 359, 366, 369, 373, 378, 381, 386, 390, 394, 397, 403, 405,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
55 414, 420, 427, 430, 430, 433, 436, 442, 446, 450, 457, 461, 469,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
56 476, 481, 486, 494, 496, 500, 505, 511, 516, 522, 528, 531,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
57 };
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
58 static const unsigned char aCode[116] = {
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
59 TK_ABORT, TK_TABLE, TK_JOIN_KW, TK_TEMP, TK_TEMP,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
60 TK_OR, TK_ADD, TK_DATABASE, TK_AS, TK_SELECT,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
61 TK_THEN, TK_END, TK_DEFAULT, TK_TRANSACTION,TK_ON,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
62 TK_JOIN_KW, TK_ALTER, TK_RAISE, TK_EACH, TK_CHECK,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
63 TK_KEY, TK_AFTER, TK_REFERENCES, TK_ESCAPE, TK_ELSE,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
64 TK_EXCEPT, TK_TRIGGER, TK_LIKE_KW, TK_EXPLAIN, TK_INITIALLY,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
65 TK_ALL, TK_ANALYZE, TK_EXCLUSIVE, TK_EXISTS, TK_STATEMENT,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
66 TK_AND, TK_DEFERRABLE, TK_ATTACH, TK_HAVING, TK_LIKE_KW,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
67 TK_BEFORE, TK_FOR, TK_FOREIGN, TK_IGNORE, TK_REINDEX,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
68 TK_INDEX, TK_AUTOINCR, TK_TO, TK_IN, TK_BEGIN,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
69 TK_JOIN_KW, TK_RENAME, TK_BETWEEN, TK_NOT, TK_NOTNULL,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
70 TK_NULL, TK_LIKE_KW, TK_BY, TK_CASCADE, TK_ASC,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
71 TK_DEFERRED, TK_DELETE, TK_CASE, TK_CAST, TK_COLLATE,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
72 TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_CONSTRAINT, TK_INTERSECT,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
73 TK_CREATE, TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW, TK_CTIME_KW,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
74 TK_PLAN, TK_DESC, TK_DETACH, TK_DISTINCT, TK_IS,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
75 TK_DROP, TK_PRAGMA, TK_MATCH, TK_FAIL, TK_LIMIT,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
76 TK_FROM, TK_JOIN_KW, TK_GROUP, TK_UPDATE, TK_IF,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
77 TK_IMMEDIATE, TK_INSERT, TK_INSTEAD, TK_INTO, TK_OF,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
78 TK_OFFSET, TK_SET, TK_ISNULL, TK_JOIN, TK_ORDER,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
79 TK_REPLACE, TK_JOIN_KW, TK_RESTRICT, TK_PRIMARY, TK_QUERY,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
80 TK_JOIN_KW, TK_ROLLBACK, TK_ROW, TK_WHEN, TK_UNION,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
81 TK_UNIQUE, TK_USING, TK_VACUUM, TK_VALUES, TK_VIEW,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
82 TK_WHERE,
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
83 };
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
84 int h, i;
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
85 if( n<2 ) return TK_ID;
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
86 h = ((charMap(z[0])*4) ^
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
87 (charMap(z[n-1])*3) ^
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
88 n) % 127;
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
89 for(i=((int)aHash[h])-1; i>=0; i=((int)aNext[i])-1){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
90 if( aLen[i]==n && sqlite3StrNICmp(&zText[aOffset[i]],z,n)==0 ){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
91 return aCode[i];
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
92 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
93 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
94 return TK_ID;
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
95 }
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
96 int sqlite3KeywordCode(const unsigned char *z, int n){
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
97 return keywordCode((char*)z, n);
b6b61becdf4e [svn] - add sqlite/ directory
nenolod
parents:
diff changeset
98 }