Drizzled Public API Documentation

function_hash.h
1 /* C++ code produced by gperf version 3.0.3 */
2 /* Command-line: /usr/bin/gperf -D --initializer-suffix=,0 --struct-type --enum --omit-struct-type --readonly-tables --language=C++ --class-name=function_hash drizzled/function_hash.gperf */
3 /* Computed positions: -k'1,3,6' */
4 
5 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
6  && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
7  && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
8  && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
9  && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
10  && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
11  && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
12  && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
13  && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
14  && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
15  && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
16  && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
17  && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
18  && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
19  && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
20  && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
21  && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
22  && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
23  && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
24  && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
25  && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
26  && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
27  && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
28 /* The character set is not based on ISO-646. */
29 #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
30 #endif
31 
32 #line 1 "drizzled/function_hash.gperf"
33 
34 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
35  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
36  *
37  * Copyright (C) 2008 Sun Microsystems, Inc.
38  *
39  * This program is free software; you can redistribute it and/or modify
40  * it under the terms of the GNU General Public License as published by
41  * the Free Software Foundation; version 2 of the License.
42  *
43  * This program is distributed in the hope that it will be useful,
44  * but WITHOUT ANY WARRANTY; without even the implied warranty of
45  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46  * GNU General Public License for more details.
47  *
48  * You should have received a copy of the GNU General Public License
49  * along with this program; if not, write to the Free Software
50  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
51  */
52 
53 
54 /* This file includes all functions */
55 
56 #include <drizzled/foreign_key.h>
57 #include <drizzled/sql_yacc.hh>
58 #include <drizzled/lex_symbol.h>
59 
60 using namespace drizzled;
61 
62 /*
63  Symbols are broken into separated arrays to allow field names with
64  same name as functions.
65  These are kept sorted for human lookup (the symbols are hashed).
66 
67  NOTE! The symbol tables should be the same regardless of what features
68  are compiled into the server. Don't add ifdef'ed symbols to the
69  lists
70 */
71 /* maximum key range = 50, duplicates = 0 */
72 
74 {
75 private:
76  static inline unsigned int hash (const char *str, unsigned int len);
77 public:
78  static const struct SYMBOL *in_word_set (const char *str, unsigned int len);
79 };
80 
81 inline unsigned int
82 function_hash::hash (register const char *str, register unsigned int len)
83 {
84  static const unsigned char asso_values[] =
85  {
86  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
87  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
88  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
89  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
90  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
91  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
92  54, 54, 54, 54, 54, 10, 15, 0, 15, 20,
93  54, 10, 54, 0, 54, 54, 54, 5, 30, 3,
94  3, 54, 10, 0, 10, 0, 0, 20, 5, 54,
95  54, 54, 54, 54, 54, 5, 54, 54, 54, 54,
96  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
97  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
98  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
99  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
100  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
101  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
102  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
103  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
104  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
105  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
106  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
107  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
108  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
109  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
110  54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
111  54, 54, 54, 54, 54, 54
112  };
113  register int hval = len;
114 
115  switch (hval)
116  {
117  default:
118  hval += asso_values[(unsigned char)str[5]];
119  /*FALLTHROUGH*/
120  case 5:
121  case 4:
122  case 3:
123  hval += asso_values[(unsigned char)str[2]];
124  /*FALLTHROUGH*/
125  case 2:
126  case 1:
127  hval += asso_values[(unsigned char)str[0]];
128  break;
129  }
130  return hval;
131 }
132 
133 const struct SYMBOL *
134 function_hash::in_word_set (register const char *str, register unsigned int len)
135 {
136  enum
137  {
138  TOTAL_KEYWORDS = 29,
139  MIN_WORD_LENGTH = 3,
140  MAX_WORD_LENGTH = 12,
141  MIN_HASH_VALUE = 4,
142  MAX_HASH_VALUE = 53
143  };
144 
145  static const struct SYMBOL wordlist[] =
146  {
147 #line 46 "drizzled/function_hash.gperf"
148  {"CAST",CAST_SYM},
149 #line 47 "drizzled/function_hash.gperf"
150  {"COUNT",COUNT_SYM},
151 #line 68 "drizzled/function_hash.gperf"
152  {"SUM",SUM_SYM},
153 #line 59 "drizzled/function_hash.gperf"
154  {"POSITION",POSITION_SYM},
155 #line 54 "drizzled/function_hash.gperf"
156  {"MAX",MAX_SYM},
157 #line 71 "drizzled/function_hash.gperf"
158  {"TRIM",TRIM},
159 #line 60 "drizzled/function_hash.gperf"
160  {"SESSION_USER",USER},
161 #line 70 "drizzled/function_hash.gperf"
162  {"SYSTEM_USER",USER},
163 #line 69 "drizzled/function_hash.gperf"
164  {"SYSDATE",SYSDATE},
165 #line 61 "drizzled/function_hash.gperf"
166  {"STD",STD_SYM},
167 #line 73 "drizzled/function_hash.gperf"
168  {"VAR_POP",VARIANCE_SYM},
169 #line 62 "drizzled/function_hash.gperf"
170  {"STDDEV",STD_SYM},
171 #line 49 "drizzled/function_hash.gperf"
172  {"CURTIME",CURTIME},
173 #line 56 "drizzled/function_hash.gperf"
174  {"MID",SUBSTRING},
175 #line 63 "drizzled/function_hash.gperf"
176  {"STDDEV_POP",STD_SYM},
177 #line 64 "drizzled/function_hash.gperf"
178  {"STDDEV_SAMP",STDDEV_SAMP_SYM},
179 #line 48 "drizzled/function_hash.gperf"
180  {"CURDATE",CURDATE},
181 #line 74 "drizzled/function_hash.gperf"
182  {"VAR_SAMP",VAR_SAMP_SYM},
183 #line 53 "drizzled/function_hash.gperf"
184  {"GROUP_CONCAT",GROUP_CONCAT_SYM},
185 #line 66 "drizzled/function_hash.gperf"
186  {"SUBSTR",SUBSTRING},
187 #line 65 "drizzled/function_hash.gperf"
188  {"SUBDATE",SUBDATE_SYM},
189 #line 51 "drizzled/function_hash.gperf"
190  {"DATE_SUB",DATE_SUB_INTERVAL},
191 #line 67 "drizzled/function_hash.gperf"
192  {"SUBSTRING",SUBSTRING},
193 #line 52 "drizzled/function_hash.gperf"
194  {"EXTRACT",EXTRACT_SYM},
195 #line 57 "drizzled/function_hash.gperf"
196  {"MIN",MIN_SYM},
197 #line 45 "drizzled/function_hash.gperf"
198  {"ADDDATE",ADDDATE_SYM},
199 #line 50 "drizzled/function_hash.gperf"
200  {"DATE_ADD",DATE_ADD_INTERVAL},
201 #line 72 "drizzled/function_hash.gperf"
202  {"VARIANCE",VARIANCE_SYM},
203 #line 58 "drizzled/function_hash.gperf"
204  {"NOW",NOW_SYM}
205  };
206 
207  static const signed char lookup[] =
208  {
209  -1, -1, -1, -1, 0, 1, -1, -1, 2, -1, -1, 3, -1, 4,
210  5, 6, 7, 8, 9, -1, 10, 11, 12, 13, -1, 14, 15, 16,
211  17, -1, 18, 19, 20, 21, 22, -1, -1, 23, 24, -1, -1, -1,
212  25, 26, -1, -1, -1, -1, 27, -1, -1, -1, -1, 28
213  };
214 
215  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
216  {
217  register int key = hash (str, len);
218 
219  if (key <= MAX_HASH_VALUE && key >= 0)
220  {
221  register int index = lookup[key];
222 
223  if (index >= 0)
224  {
225  register const char *s = wordlist[index].name;
226 
227  if (*str == *s && !strcmp (str + 1, s + 1))
228  return &wordlist[index];
229  }
230  }
231  }
232  return 0;
233 }
234 #line 75 "drizzled/function_hash.gperf"
235