engine/sqlite/src/keywordhash.h
author Sebastian Brannstrom <sebastianb@symbian.org>
Fri, 22 Oct 2010 14:28:27 +0100
branchsymbian1
changeset 266 ff6cd24e77e2
parent 2 29cda98b007e
permissions -rw-r--r--
Slightly tweaked icons
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     1
/***** This file contains automatically generated code ******
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     2
**
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     3
** The code in this file has been automatically generated by
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     4
**
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     5
**     $Header: /sqlite/sqlite/tool/mkkeywordhash.c,v 1.31 2007/07/30 18:26:20 rse Exp $
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     6
**
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     7
** The code in this file implements a function that determines whether
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     8
** or not a given identifier is really an SQL keyword.  The same thing
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     9
** might be implemented more directly using a hand-written hash table.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    10
** But by using this automatically generated code, the size of the code
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    11
** is substantially reduced.  This is important for embedded applications
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    12
** on platforms with limited memory.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    13
*/
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    14
/* Hash score: 165 */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    15
static int keywordCode(const char *z, int n){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    16
  /* zText[] encodes 775 bytes of keywords in 526 bytes */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    17
  static const char zText[526] =
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    18
    "BEFOREIGNOREGEXPLAINSTEADDESCAPEACHECKEYCONSTRAINTERSECTABLEFT"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    19
    "HENDATABASELECTRANSACTIONATURALTERAISELSEXCEPTRIGGEREFERENCES"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    20
    "UNIQUERYATTACHAVINGROUPDATEMPORARYBEGINNEREINDEXCLUSIVEXISTSBETWEEN"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    21
    "OTNULLIKECASCADEFERRABLECASECOLLATECREATECURRENT_DATEDELETEDETACH"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    22
    "IMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHEN"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    23
    "WHERENAMEAFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMITCONFLICT"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    24
    "CROSSCURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAILFROMFULLGLOB"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    25
    "YIFINTOFFSETISNULLORDERESTRICTOUTERIGHTROLLBACKROWUNIONUSINGVACUUM"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    26
    "VIEWINITIALLY";
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    27
  static const unsigned char aHash[127] = {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    28
      63,  92, 109,  61,   0,  38,   0,   0,  69,   0,  64,   0,   0,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    29
     102,   4,  65,   7,   0, 108,  72, 103,  99,   0,  22,   0,   0,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    30
     113,   0, 111, 106,   0,  18,  80,   0,   1,   0,   0,  56,  57,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    31
       0,  55,  11,   0,  33,  77,  89,   0, 110,  88,   0,   0,  45,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    32
       0,  90,  54,   0,  20,   0, 114,  34,  19,   0,  10,  97,  28,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    33
      83,   0,   0, 116,  93,  47, 115,  41,  12,  44,   0,  78,   0,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    34
      87,  29,   0,  86,   0,   0,   0,  82,  79,  84,  75,  96,   6,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    35
      14,  95,   0,  68,   0,  21,  76,  98,  27,   0, 112,  67, 104,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    36
      49,  40,  71,   0,   0,  81, 100,   0, 107,   0,  15,   0,   0,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    37
      24,   0,  73,  42,  50,   0,  16,  48,   0,  37,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    38
  };
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    39
  static const unsigned char aNext[116] = {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    40
       0,   0,   0,   0,   0,   0,   0,   0,   0,   9,   0,   0,   0,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    41
       0,   0,   0,   0,   5,   0,   0,   0,   0,   0,   0,   0,   0,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    42
       0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  32,   0,   0,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    43
      17,   0,   0,   0,  36,  39,   0,   0,  25,   0,   0,  31,   0,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    44
       0,   0,  43,  52,   0,   0,   0,  53,   0,   0,   0,   0,   0,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    45
       0,   0,   0,   0,  51,   0,   0,   0,   0,  26,   0,   8,  46,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    46
       2,   0,   0,   0,   0,   0,   0,   0,   3,  58,  66,   0,  13,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    47
       0,  91,  85,   0,  94,   0,  74,   0,   0,  62,   0,  35, 101,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    48
       0,   0, 105,  23,  30,  60,  70,   0,   0,  59,   0,   0,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    49
  };
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    50
  static const unsigned char aLen[116] = {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    51
       6,   7,   3,   6,   6,   7,   7,   3,   4,   6,   4,   5,   3,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    52
      10,   9,   5,   4,   4,   3,   8,   2,   6,  11,   2,   7,   5,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    53
       5,   4,   6,   7,  10,   6,   5,   6,   6,   5,   6,   4,   9,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    54
       2,   5,   5,   7,   5,   9,   6,   7,   7,   3,   4,   4,   7,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    55
       3,  10,   4,   7,   6,  12,   6,   6,   9,   4,   6,   5,   4,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    56
       7,   6,   5,   6,   7,   5,   4,   5,   6,   5,   7,   3,   7,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    57
      13,   2,   2,   4,   6,   6,   8,   5,  17,  12,   7,   8,   8,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    58
       2,   4,   4,   4,   4,   4,   2,   2,   4,   6,   2,   3,   6,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    59
       5,   8,   5,   5,   8,   3,   5,   5,   6,   4,   9,   3,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    60
  };
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    61
  static const unsigned short int aOffset[116] = {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    62
       0,   2,   2,   6,  10,  13,  18,  23,  25,  26,  31,  33,  37,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    63
      40,  47,  55,  58,  61,  63,  65,  70,  71,  76,  85,  86,  91,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    64
      95,  99, 102, 107, 113, 123, 126, 131, 136, 141, 144, 148, 148,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    65
     152, 157, 160, 164, 166, 169, 177, 183, 189, 189, 192, 195, 199,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    66
     200, 204, 214, 218, 225, 231, 243, 249, 255, 264, 266, 272, 277,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    67
     279, 286, 291, 296, 302, 308, 313, 317, 320, 326, 330, 337, 339,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    68
     346, 348, 350, 359, 363, 369, 375, 383, 388, 388, 404, 411, 418,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    69
     419, 426, 430, 434, 438, 442, 445, 447, 449, 452, 452, 455, 458,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    70
     464, 468, 476, 480, 485, 493, 496, 501, 506, 512, 516, 521,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    71
  };
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    72
  static const unsigned char aCode[116] = {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    73
    TK_BEFORE,     TK_FOREIGN,    TK_FOR,        TK_IGNORE,     TK_LIKE_KW,    
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    74
    TK_EXPLAIN,    TK_INSTEAD,    TK_ADD,        TK_DESC,       TK_ESCAPE,     
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    75
    TK_EACH,       TK_CHECK,      TK_KEY,        TK_CONSTRAINT, TK_INTERSECT,  
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    76
    TK_TABLE,      TK_JOIN_KW,    TK_THEN,       TK_END,        TK_DATABASE,   
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    77
    TK_AS,         TK_SELECT,     TK_TRANSACTION,TK_ON,         TK_JOIN_KW,    
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    78
    TK_ALTER,      TK_RAISE,      TK_ELSE,       TK_EXCEPT,     TK_TRIGGER,    
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    79
    TK_REFERENCES, TK_UNIQUE,     TK_QUERY,      TK_ATTACH,     TK_HAVING,     
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    80
    TK_GROUP,      TK_UPDATE,     TK_TEMP,       TK_TEMP,       TK_OR,         
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    81
    TK_BEGIN,      TK_JOIN_KW,    TK_REINDEX,    TK_INDEX,      TK_EXCLUSIVE,  
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    82
    TK_EXISTS,     TK_BETWEEN,    TK_NOTNULL,    TK_NOT,        TK_NULL,       
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    83
    TK_LIKE_KW,    TK_CASCADE,    TK_ASC,        TK_DEFERRABLE, TK_CASE,       
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    84
    TK_COLLATE,    TK_CREATE,     TK_CTIME_KW,   TK_DELETE,     TK_DETACH,     
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    85
    TK_IMMEDIATE,  TK_JOIN,       TK_INSERT,     TK_MATCH,      TK_PLAN,       
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    86
    TK_ANALYZE,    TK_PRAGMA,     TK_ABORT,      TK_VALUES,     TK_VIRTUAL,    
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    87
    TK_LIMIT,      TK_WHEN,       TK_WHERE,      TK_RENAME,     TK_AFTER,      
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    88
    TK_REPLACE,    TK_AND,        TK_DEFAULT,    TK_AUTOINCR,   TK_TO,         
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    89
    TK_IN,         TK_CAST,       TK_COLUMNKW,   TK_COMMIT,     TK_CONFLICT,   
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    90
    TK_JOIN_KW,    TK_CTIME_KW,   TK_CTIME_KW,   TK_PRIMARY,    TK_DEFERRED,   
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    91
    TK_DISTINCT,   TK_IS,         TK_DROP,       TK_FAIL,       TK_FROM,       
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    92
    TK_JOIN_KW,    TK_LIKE_KW,    TK_BY,         TK_IF,         TK_INTO,       
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    93
    TK_OFFSET,     TK_OF,         TK_SET,        TK_ISNULL,     TK_ORDER,      
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    94
    TK_RESTRICT,   TK_JOIN_KW,    TK_JOIN_KW,    TK_ROLLBACK,   TK_ROW,        
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    95
    TK_UNION,      TK_USING,      TK_VACUUM,     TK_VIEW,       TK_INITIALLY,  
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    96
    TK_ALL,        
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    97
  };
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    98
  int h, i;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    99
  if( n<2 ) return TK_ID;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   100
  h = ((charMap(z[0])*4) ^
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   101
      (charMap(z[n-1])*3) ^
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   102
      n) % 127;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   103
  for(i=((int)aHash[h])-1; i>=0; i=((int)aNext[i])-1){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   104
    if( aLen[i]==n && sqlite3StrNICmp(&zText[aOffset[i]],z,n)==0 ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   105
      return aCode[i];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   106
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   107
  }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   108
  return TK_ID;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   109
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   110
int sqlite3KeywordCode(const unsigned char *z, int n){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   111
  return keywordCode((char*)z, n);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   112
}