17
17
#include <drizzled/server_includes.h>
18
18
#include <drizzled/gettext.h>
19
19
#include <drizzled/sql_udf.h>
20
#include <drizzled/registry.h>
24
24
using namespace std;
26
26
static bool udf_startup= false; /* We do not lock because startup is single threaded */
27
static map<string, Function_builder *> udf_map;
27
static drizzled::Registry<Function_builder *> udf_registry;
30
29
/* This is only called if using_udf_functions != 0 */
31
30
Function_builder *find_udf(const char *name, uint32_t length)
35
* @todo: check without transform, then check with transform if needed
37
Function_builder *udf= NULL;
39
if (udf_startup == false)
42
string find_str(name, length);
43
transform(find_str.begin(), find_str.end(),
44
find_str.begin(), ::tolower);
46
map<string, Function_builder *>::iterator find_iter;
47
find_iter= udf_map.find(find_str);
48
if (find_iter != udf_map.end())
49
udf= (*find_iter).second;
32
return udf_registry.find(name, length);
54
35
static bool add_udf(Function_builder *udf)
57
* @todo: add all lower and all upper version
59
string add_str= udf->get_name();
60
transform(add_str.begin(), add_str.end(),
61
add_str.begin(), ::tolower);
63
udf_map[add_str]= udf;
65
using_udf_functions= 1;
37
return udf_registry.add(udf);
70
static bool remove_udf(Function_builder *udf)
40
static void remove_udf(Function_builder *udf)
72
return udf_map.erase(udf->get_name());
42
udf_registry.remove(udf);
75
45
int initialize_udf(st_plugin_int *plugin)