Drizzled Public API Documentation

function_hash.h
00001 /* C++ code produced by gperf version 3.0.3 */
00002 /* 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  */
00003 /* Computed positions: -k'1,3,6' */
00004 
00005 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
00006       && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
00007       && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
00008       && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
00009       && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
00010       && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
00011       && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
00012       && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
00013       && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
00014       && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
00015       && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
00016       && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
00017       && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
00018       && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
00019       && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
00020       && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
00021       && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
00022       && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
00023       && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
00024       && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
00025       && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
00026       && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
00027       && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
00028 /* The character set is not based on ISO-646.  */
00029 #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
00030 #endif
00031 
00032 #line 1 "drizzled/function_hash.gperf"
00033 
00034 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00035  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00036  *
00037  *  Copyright (C) 2008 Sun Microsystems, Inc.
00038  *
00039  *  This program is free software; you can redistribute it and/or modify
00040  *  it under the terms of the GNU General Public License as published by
00041  *  the Free Software Foundation; version 2 of the License.
00042  *
00043  *  This program is distributed in the hope that it will be useful,
00044  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00045  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00046  *  GNU General Public License for more details.
00047  *
00048  *  You should have received a copy of the GNU General Public License
00049  *  along with this program; if not, write to the Free Software
00050  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00051  */
00052 
00053 
00054 /* This file includes all functions */
00055 
00056 #include <drizzled/foreign_key.h>
00057 #include <drizzled/sql_yacc.h>
00058 #include <drizzled/lex_symbol.h>
00059 
00060 using namespace drizzled;
00061 
00062 /*
00063   Symbols are broken into separated arrays to allow field names with
00064   same name as functions.
00065   These are kept sorted for human lookup (the symbols are hashed).
00066 
00067   NOTE! The symbol tables should be the same regardless of what features
00068   are compiled into the server. Don't add ifdef'ed symbols to the
00069   lists
00070 */
00071 /* maximum key range = 53, duplicates = 0 */
00072 
00073 class function_hash
00074 {
00075 private:
00076   static inline unsigned int hash (const char *str, unsigned int len);
00077 public:
00078   static const struct st_symbol *in_word_set (const char *str, unsigned int len);
00079 };
00080 
00081 inline unsigned int
00082 function_hash::hash (register const char *str, register unsigned int len)
00083 {
00084   static const unsigned char asso_values[] =
00085     {
00086       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00087       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00088       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00089       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00090       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00091       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00092       57, 57, 57, 57, 57,  5,  5,  0, 15,  3,
00093       57,  5, 57,  0, 57, 57, 57,  5, 23, 10,
00094        3, 57, 25,  0,  5,  0,  0, 15,  5, 57,
00095       57, 57, 57, 57, 57,  0, 57, 57, 57, 57,
00096       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00097       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00098       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00099       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00100       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00101       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00102       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00103       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00104       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00105       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00106       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00107       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00108       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00109       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00110       57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
00111       57, 57, 57, 57, 57, 57
00112     };
00113   register int hval = len;
00114 
00115   switch (hval)
00116     {
00117       default:
00118         hval += asso_values[(unsigned char)str[5]];
00119       /*FALLTHROUGH*/
00120       case 5:
00121       case 4:
00122       case 3:
00123         hval += asso_values[(unsigned char)str[2]];
00124       /*FALLTHROUGH*/
00125       case 2:
00126       case 1:
00127         hval += asso_values[(unsigned char)str[0]];
00128         break;
00129     }
00130   return hval;
00131 }
00132 
00133 const struct st_symbol *
00134 function_hash::in_word_set (register const char *str, register unsigned int len)
00135 {
00136   enum
00137     {
00138       TOTAL_KEYWORDS = 28,
00139       MIN_WORD_LENGTH = 3,
00140       MAX_WORD_LENGTH = 12,
00141       MIN_HASH_VALUE = 4,
00142       MAX_HASH_VALUE = 56
00143     };
00144 
00145   static const struct st_symbol wordlist[] =
00146     {
00147 #line 46 "drizzled/function_hash.gperf"
00148       {"CAST",CAST_SYM},
00149 #line 47 "drizzled/function_hash.gperf"
00150       {"COUNT",COUNT_SYM},
00151 #line 67 "drizzled/function_hash.gperf"
00152       {"SUM",SUM_SYM},
00153 #line 70 "drizzled/function_hash.gperf"
00154       {"TRIM",TRIM},
00155 #line 58 "drizzled/function_hash.gperf"
00156       {"POSITION",POSITION_SYM},
00157 #line 68 "drizzled/function_hash.gperf"
00158       {"SYSDATE",SYSDATE},
00159 #line 53 "drizzled/function_hash.gperf"
00160       {"MAX",MAX_SYM},
00161 #line 51 "drizzled/function_hash.gperf"
00162       {"EXTRACT",EXTRACT_SYM},
00163 #line 69 "drizzled/function_hash.gperf"
00164       {"SYSTEM_USER",USER},
00165 #line 64 "drizzled/function_hash.gperf"
00166       {"SUBDATE",SUBDATE_SYM},
00167 #line 60 "drizzled/function_hash.gperf"
00168       {"STD",STD_SYM},
00169 #line 61 "drizzled/function_hash.gperf"
00170       {"STDDEV",STD_SYM},
00171 #line 59 "drizzled/function_hash.gperf"
00172       {"SESSION_USER",USER},
00173 #line 55 "drizzled/function_hash.gperf"
00174       {"MID",SUBSTRING},
00175 #line 62 "drizzled/function_hash.gperf"
00176       {"STDDEV_POP",STD_SYM},
00177 #line 63 "drizzled/function_hash.gperf"
00178       {"STDDEV_SAMP",STDDEV_SAMP_SYM},
00179 #line 52 "drizzled/function_hash.gperf"
00180       {"GROUP_CONCAT",GROUP_CONCAT_SYM},
00181 #line 50 "drizzled/function_hash.gperf"
00182       {"DATE_SUB",DATE_SUB_INTERVAL},
00183 #line 56 "drizzled/function_hash.gperf"
00184       {"MIN",MIN_SYM},
00185 #line 45 "drizzled/function_hash.gperf"
00186       {"ADDDATE",ADDDATE_SYM},
00187 #line 49 "drizzled/function_hash.gperf"
00188       {"DATE_ADD",DATE_ADD_INTERVAL},
00189 #line 65 "drizzled/function_hash.gperf"
00190       {"SUBSTR",SUBSTRING},
00191 #line 48 "drizzled/function_hash.gperf"
00192       {"CURDATE",CURDATE},
00193 #line 73 "drizzled/function_hash.gperf"
00194       {"VAR_SAMP",VAR_SAMP_SYM},
00195 #line 66 "drizzled/function_hash.gperf"
00196       {"SUBSTRING",SUBSTRING},
00197 #line 57 "drizzled/function_hash.gperf"
00198       {"NOW",NOW_SYM},
00199 #line 72 "drizzled/function_hash.gperf"
00200       {"VAR_POP",VARIANCE_SYM},
00201 #line 71 "drizzled/function_hash.gperf"
00202       {"VARIANCE",VARIANCE_SYM}
00203     };
00204 
00205   static const signed char lookup[] =
00206     {
00207       -1, -1, -1, -1,  0,  1, -1, -1,  2,  3, -1,  4,  5,  6,
00208       -1,  7,  8,  9, 10, -1, -1, 11, 12, 13, -1, 14, 15, 16,
00209       17, -1, -1, 18, 19, 20, -1, -1, 21, 22, 23, 24, -1, 25,
00210       26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
00211       27
00212     };
00213 
00214   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
00215     {
00216       register int key = hash (str, len);
00217 
00218       if (key <= MAX_HASH_VALUE && key >= 0)
00219         {
00220           register int index = lookup[key];
00221 
00222           if (index >= 0)
00223             {
00224               register const char *s = wordlist[index].name;
00225 
00226               if (*str == *s && !strcmp (str + 1, s + 1))
00227                 return &wordlist[index];
00228             }
00229         }
00230     }
00231   return 0;
00232 }
00233 #line 74 "drizzled/function_hash.gperf"
00234