~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/function.cc

Cleaned up name of calls around datachunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
/* This implements 'user defined functions' */
22
22
#include "config.h"
 
23
 
 
24
#include <boost/unordered_map.hpp>
 
25
 
23
26
#include <drizzled/gettext.h>
24
 
#include "drizzled/hash.h"
25
27
#include "drizzled/plugin/function.h"
26
28
 
 
29
#include "drizzled/util/string.h"
 
30
 
27
31
using namespace std;
28
32
 
29
33
namespace drizzled
30
34
{
31
35
 
32
 
typedef hash_map<string, const plugin::Function *> UdfMap;
 
36
typedef boost::unordered_map<string, const plugin::Function *, util::insensitive_hash, util::insensitive_equal_to> UdfMap;
33
37
static UdfMap udf_registry;
34
38
 
35
39
bool plugin::Function::addPlugin(const plugin::Function *udf)
36
40
{
37
 
  string lower_name(udf->getName());
38
 
  transform(lower_name.begin(), lower_name.end(),
39
 
            lower_name.begin(), ::tolower);
40
 
  if (udf_registry.find(lower_name) != udf_registry.end())
 
41
  if (udf_registry.find(udf->getName()) != udf_registry.end())
41
42
  {
42
43
    errmsg_printf(ERRMSG_LVL_ERROR,
43
44
                  _("A function named %s already exists!\n"),
45
46
    return true;
46
47
  }
47
48
  pair<UdfMap::iterator, bool> ret=
48
 
    udf_registry.insert(make_pair(lower_name, udf));
 
49
    udf_registry.insert(make_pair(udf->getName(), udf));
49
50
  if (ret.second == false)
50
51
  {
51
52
    errmsg_printf(ERRMSG_LVL_ERROR,
58
59
 
59
60
void plugin::Function::removePlugin(const plugin::Function *udf)
60
61
{
61
 
  string lower_name(udf->getName());
62
 
  transform(lower_name.begin(), lower_name.end(),
63
 
            lower_name.begin(), ::tolower);
64
 
  udf_registry.erase(lower_name);
 
62
  udf_registry.erase(udf->getName());
65
63
}
66
64
 
67
65
const plugin::Function *plugin::Function::get(const char *name, size_t length)
68
66
{
69
 
  string lower_name(name, length);
70
 
  transform(lower_name.begin(), lower_name.end(),
71
 
            lower_name.begin(), ::tolower);
72
 
  UdfMap::iterator iter= udf_registry.find(lower_name);
 
67
  UdfMap::iterator iter= udf_registry.find(std::string(name, length));
73
68
  if (iter == udf_registry.end())
74
69
  {
75
70
    return NULL;