2978
2981
{ {0, 0}, NULL}
2981
static HASH native_functions_hash;
2983
extern "C" unsigned char*
2984
get_native_fct_hash_key(const unsigned char *buff, size_t *length,
2987
Native_func_registry *func= (Native_func_registry*) buff;
2988
*length= func->name.length;
2989
return (unsigned char*) func->name.str;
2984
static map<string, Native_func_registry *> native_functions_map;
2993
2987
Load the hash table for native functions.
2998
2992
int item_create_init()
3000
2996
Native_func_registry *func;
3002
if (hash_init(& native_functions_hash,
3003
system_charset_info,
3004
array_elements(func_array),
3007
(hash_get_key) get_native_fct_hash_key,
3008
NULL, /* Nothing to free */
3012
2997
for (func= func_array; func->builder != NULL; func++)
3014
if (my_hash_insert(& native_functions_hash, (unsigned char*) func))
2999
func_name.assign(func->name.str, func->name.length);
3000
transform(func_name.begin(), func_name.end(), func_name.begin(), ::tolower);
3002
native_functions_map[func_name]= func;
3022
Empty the hash table for native functions.
3023
Note: this code is not thread safe, and is intended to be used at server
3024
shutdown only (after thread requests have been executed).
3027
void item_create_cleanup()
3029
hash_free(& native_functions_hash);
3034
find_native_function_builder(Session *,
3010
find_native_function_builder(LEX_STRING name)
3037
3012
Native_func_registry *func;
3038
3013
Create_func *builder= NULL;
3041
func= (Native_func_registry*) hash_search(& native_functions_hash,
3042
(unsigned char*) name.str,
3015
string func_name(name.str, name.length);
3016
transform(func_name.begin(), func_name.end(), func_name.begin(), ::tolower);
3018
map<string, Native_func_registry *>::iterator func_iter=
3019
native_functions_map.find(func_name);
3021
if (func_iter != native_functions_map.end())
3023
func= (*func_iter).second;
3047
3024
builder= func->builder;