~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/util_function/schema.cc

  • Committer: Brian Aker
  • Date: 2010-10-21 06:52:47 UTC
  • mto: (1866.1.1 merge)
  • mto: This revision was merged to the branch mainline in revision 1867.
  • Revision ID: brian@tangent.org-20101021065247-jjtvvnfpr4dfn4lo
Move database() over to the util_function plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include <drizzled/session.h>
24
24
#include <drizzled/function/str/strfunc.h>
25
 
 
26
 
using namespace drizzled;
27
 
 
28
 
class DatabaseFunction :public Item_str_func
29
 
{
30
 
public:
31
 
  DatabaseFunction() :Item_str_func() {}
32
 
  String *val_str(String *);
33
 
  void fix_length_and_dec()
34
 
  {
35
 
    max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen;
36
 
    maybe_null=1;
37
 
  }
38
 
  const char *func_name() const { return "database"; }
39
 
  const char *fully_qualified_func_name() const { return "database()"; }
40
 
};
41
 
 
42
 
String *DatabaseFunction::val_str(String *str)
 
25
#include "plugin/util_function/functions.h"
 
26
 
 
27
namespace drizzled
 
28
{
 
29
 
 
30
namespace util_function
 
31
{
 
32
 
 
33
String *Schema::val_str(String *str)
43
34
{
44
35
  assert(fixed == 1);
45
36
  Session *session= current_session;
49
40
    return 0;
50
41
  }
51
42
  else
 
43
  {
52
44
    str->copy(session->db.c_str(), session->db.length(), system_charset_info);
 
45
  }
53
46
  return str;
54
47
}
55
48
 
56
 
plugin::Create_function<DatabaseFunction> *database_function= NULL;
57
 
 
58
 
static int initialize(drizzled::module::Context &context)
59
 
{
60
 
  database_function= new plugin::Create_function<DatabaseFunction>("database");
61
 
  context.add(database_function);
62
 
  return 0;
63
 
}
64
 
 
65
 
DRIZZLE_DECLARE_PLUGIN
66
 
{
67
 
  DRIZZLE_VERSION_ID,
68
 
  "database_function",
69
 
  "1.0",
70
 
  "Stewart Smith",
71
 
  "returns the current database",
72
 
  PLUGIN_LICENSE_GPL,
73
 
  initialize, /* Plugin Init */
74
 
  NULL,   /* system variables */
75
 
  NULL    /* config options */
76
 
}
77
 
DRIZZLE_DECLARE_PLUGIN_END;
 
49
} /* namespace util_function */
 
50
} /* namespace drizzled */