~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/uuid_function/uuid_function.cc

  • Committer: Andrew Hutchings
  • Date: 2010-11-09 13:38:01 UTC
  • mto: (1919.1.2 trunk)
  • mto: This revision was merged to the branch mainline in revision 1920.
  • Revision ID: andrew@linuxjedi.co.uk-20101109133801-byjzsao76346395x
Add FLUSH GLOBAL STATUS; command
Clears the global status variables for the server

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
#define UUID_LENGTH (8+1+4+1+4+1+4+1+12)
28
28
 
29
 
namespace plugin {
30
 
namespace uuid {
 
29
using namespace drizzled;
31
30
 
32
 
class Generate: public drizzled::Item_str_func
 
31
class UuidFunction: public Item_str_func
33
32
{
34
33
public:
35
 
  Generate(): drizzled::Item_str_func() {}
36
 
  void fix_length_and_dec()
37
 
  {
38
 
    collation.set(drizzled::system_charset_info);
 
34
  UuidFunction(): Item_str_func() {}
 
35
  void fix_length_and_dec() {
 
36
    collation.set(system_charset_info);
39
37
    /*
40
38
       NOTE! uuid() should be changed to use 'ascii'
41
39
       charset when hex(), format(), md5(), etc, and implicit
42
40
       number-to-string conversion will use 'ascii'
43
41
    */
44
 
    max_length= UUID_LENGTH * drizzled::system_charset_info->mbmaxlen;
 
42
    max_length= UUID_LENGTH * system_charset_info->mbmaxlen;
45
43
  }
46
44
  const char *func_name() const{ return "uuid"; }
47
 
  drizzled::String *val_str(drizzled::String *);
 
45
  String *val_str(String *);
48
46
};
49
47
 
50
 
drizzled::String *Generate::val_str(drizzled::String *str)
 
48
String *UuidFunction::val_str(String *str)
51
49
{
52
50
  uuid_t uu;
53
51
  char *uuid_string;
55
53
  /* 36 characters for uuid string +1 for NULL */
56
54
  str->realloc(UUID_LENGTH+1);
57
55
  str->length(UUID_LENGTH);
58
 
  str->set_charset(drizzled::system_charset_info);
 
56
  str->set_charset(system_charset_info);
59
57
  uuid_string= (char *) str->ptr();
60
 
  uuid_generate(uu);
 
58
  uuid_generate_random(uu);
61
59
  uuid_unparse(uu, uuid_string);
62
60
 
63
61
  return str;
64
62
}
65
63
 
66
 
} // uuid
67
 
} // plugin
 
64
plugin::Create_function<UuidFunction> *uuid_function= NULL;
68
65
 
69
66
static int initialize(drizzled::module::Context &context)
70
67
{
71
 
  context.add(new drizzled::plugin::Create_function<plugin::uuid::Generate>("uuid"));
72
 
 
 
68
  uuid_function= new plugin::Create_function<UuidFunction>("uuid");
 
69
  context.add(uuid_function);
73
70
  return 0;
74
71
}
75
72
 
77
74
{
78
75
  DRIZZLE_VERSION_ID,
79
76
  "uuid",
80
 
  "1.1",
81
 
  "Stewart Smith, Brian Aker",
 
77
  "1.0",
 
78
  "Stewart Smith",
82
79
  "UUID() function using libuuid",
83
 
  drizzled::PLUGIN_LICENSE_GPL,
 
80
  PLUGIN_LICENSE_GPL,
84
81
  initialize, /* Plugin Init */
85
82
  NULL,   /* system variables */
86
83
  NULL    /* config options */