~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_udf.cc

  • Committer: Brian Aker
  • Date: 2009-02-05 10:38:55 UTC
  • Revision ID: brian@tangent.org-20090205103855-wajzccrbu7zbvmh4
Reworked some classes out of session.h
Also updated ignore file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
/* This implements 'user defined functions' */
17
17
#include <drizzled/server_includes.h>
18
 
#include <libdrizzle/gettext.h>
 
18
#include <drizzled/gettext.h>
 
19
#include <mysys/hash.h>
 
20
#include <drizzled/sql_udf.h>
19
21
 
20
22
static bool udf_startup= false; /* We do not lock because startup is single threaded */
21
23
static MEM_ROOT mem;
22
24
static HASH udf_hash;
23
25
 
24
26
extern "C" unsigned char* get_hash_key(const unsigned char *buff, size_t *length,
25
 
                               bool not_used __attribute__((unused)))
 
27
                               bool )
26
28
{
27
29
  udf_func *udf= (udf_func*) buff;
28
30
  *length= (uint) udf->name.length;
36
38
 
37
39
  if (hash_init(&udf_hash, system_charset_info, 32, 0, 0, get_hash_key, NULL, 0))
38
40
  {
39
 
    sql_print_error(_("Can't allocate memory for udf structures"));
 
41
    errmsg_printf(ERRMSG_LVL_ERROR, _("Can't allocate memory for udf structures"));
40
42
    hash_free(&udf_hash);
41
43
    free_root(&mem, MYF(0));
42
44
    return;
90
92
    int r;
91
93
    if ((r= plugin->plugin->init((void *)&f)))
92
94
    {
93
 
      sql_print_error("Plugin '%s' init function returned error %d.",
94
 
                      plugin->name.str, r);
 
95
      errmsg_printf(ERRMSG_LVL_ERROR, "Plugin '%s' init function returned error %d.",
 
96
                    plugin->name.str, r);
95
97
      return r;
96
98
    }
97
99
  }
98
100
  else
99
101
    return 1;
100
102
 
101
 
  if(!add_udf(f))
102
 
    return 2;
 
103
  if (!add_udf(f))
 
104
    return 1;
 
105
 
 
106
  plugin->state= PLUGIN_IS_READY;
103
107
 
104
108
  return 0;
105
109
 
106
110
}
107
111
 
108
112
int finalize_udf(st_plugin_int *plugin)
109
 
 
113
{
110
114
  udf_func *udff = (udf_func *)plugin->data;
111
115
 
112
116
  /* TODO: Issue warning on failure */