~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/function_engine/function.cc

  • Committer: Monty Taylor
  • Date: 2010-10-02 05:07:25 UTC
  • mto: (1817.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 1818.
  • Revision ID: mordred@inaugust.com-20101002050725-h1b30b0nr3leeoh1
Embed a modified version of parse_config_file. There are several more bugs
that we'll want to fix in it, and then submit upstream. Eventually we should
be able to remove this- but for now the version on lucid is completely
broken.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
using namespace std;
29
29
using namespace drizzled;
30
30
 
 
31
static SchemaIdentifier INFORMATION_SCHEMA_IDENTIFIER("INFORMATION_SCHEMA");
 
32
static SchemaIdentifier DATA_DICTIONARY_IDENTIFIER("DATA_DICTIONARY");
 
33
 
31
34
Function::Function(const std::string &name_arg) :
32
35
  drizzled::plugin::StorageEngine(name_arg,
33
36
                                  HTON_ALTER_NOT_SUPPORTED |
34
 
                                  HTON_HAS_DATA_DICTIONARY |
 
37
                                  HTON_HAS_SCHEMA_DICTIONARY |
35
38
                                  HTON_SKIP_STORE_LOCK |
36
39
                                  HTON_TEMPORARY_NOT_SUPPORTED)
37
40
{
38
41
}
39
42
 
40
43
 
41
 
Cursor *Function::create(TableShare &table, memory::Root *mem_root)
 
44
Cursor *Function::create(TableShare &table)
42
45
{
43
 
  return new (mem_root) FunctionCursor(*this, table);
 
46
  return new FunctionCursor(*this, table);
44
47
}
45
48
 
46
49
int Function::doGetTableDefinition(Session &,
47
 
                                     const char *path,
48
 
                                     const char *,
49
 
                                     const char *,
50
 
                                     const bool,
51
 
                                     message::Table *table_proto)
 
50
                                   const TableIdentifier &identifier,
 
51
                                   message::Table &table_proto)
52
52
{
53
 
  string tab_name(path);
54
 
  transform(tab_name.begin(), tab_name.end(),
55
 
            tab_name.begin(), ::tolower);
56
 
 
57
 
  drizzled::plugin::TableFunction *function= getFunction(tab_name);
 
53
  drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
58
54
 
59
55
  if (not function)
60
56
  {
61
57
    return ENOENT;
62
58
  }
63
59
 
64
 
  if (table_proto)
65
 
  {
66
 
    function->define(*table_proto);
67
 
  }
 
60
  function->define(table_proto);
68
61
 
69
62
  return EEXIST;
70
63
}
71
64
 
72
 
 
73
 
void Function::doGetTableNames(drizzled::CachedDirectory&, 
74
 
                               string &db, 
75
 
                               set<string> &set_of_names)
76
 
{
77
 
  drizzled::plugin::TableFunction::getNames(db, set_of_names);
78
 
}
79
 
 
80
 
 
81
 
static drizzled::plugin::StorageEngine *function_plugin= NULL;
82
 
 
83
 
static int init(drizzled::plugin::Registry &registry)
84
 
{
85
 
  function_plugin= new(std::nothrow) Function("FunctionEngine");
86
 
 
87
 
  if (not function_plugin)
88
 
  {
89
 
    return 1;
90
 
  }
91
 
 
92
 
  registry.add(function_plugin);
93
 
 
94
 
  return 0;
95
 
}
96
 
 
97
 
static int finalize(drizzled::plugin::Registry &registry)
98
 
{
99
 
  registry.remove(function_plugin);
100
 
  delete function_plugin;
 
65
void Function::doGetSchemaIdentifiers(SchemaIdentifiers& schemas)
 
66
{
 
67
  schemas.push_back(INFORMATION_SCHEMA_IDENTIFIER);
 
68
  schemas.push_back(DATA_DICTIONARY_IDENTIFIER);
 
69
}
 
70
 
 
71
bool Function::doGetSchemaDefinition(const SchemaIdentifier &schema_identifier, message::Schema &schema_message)
 
72
{
 
73
  if (schema_identifier == INFORMATION_SCHEMA_IDENTIFIER)
 
74
  {
 
75
    schema_message.set_name("information_schema");
 
76
    schema_message.set_collation("utf8_general_ci");
 
77
  }
 
78
  else if (schema_identifier == DATA_DICTIONARY_IDENTIFIER)
 
79
  {
 
80
    schema_message.set_name("data_dictionary");
 
81
    schema_message.set_collation("utf8_general_ci");
 
82
  }
 
83
  else
 
84
  {
 
85
    return false;
 
86
  }
 
87
 
 
88
  return true;
 
89
}
 
90
 
 
91
bool Function::doCanCreateTable(const drizzled::TableIdentifier &table_identifier)
 
92
{
 
93
  if (static_cast<const SchemaIdentifier&>(table_identifier) == INFORMATION_SCHEMA_IDENTIFIER)
 
94
  {
 
95
    return false;
 
96
  }
 
97
 
 
98
  else if (static_cast<const SchemaIdentifier&>(table_identifier) == DATA_DICTIONARY_IDENTIFIER)
 
99
  {
 
100
    return false;
 
101
  }
 
102
 
 
103
  return true;
 
104
}
 
105
 
 
106
bool Function::doDoesTableExist(Session&, const TableIdentifier &identifier)
 
107
{
 
108
  drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
 
109
 
 
110
  if (function)
 
111
    return true;
 
112
 
 
113
  return false;
 
114
}
 
115
 
 
116
 
 
117
void Function::doGetTableIdentifiers(drizzled::CachedDirectory&,
 
118
                                     const drizzled::SchemaIdentifier &schema_identifier,
 
119
                                     drizzled::TableIdentifiers &set_of_identifiers)
 
120
{
 
121
  set<string> set_of_names;
 
122
  drizzled::plugin::TableFunction::getNames(schema_identifier.getSchemaName(), set_of_names);
 
123
 
 
124
  for (set<string>::iterator iter= set_of_names.begin(); iter != set_of_names.end(); iter++)
 
125
  {
 
126
    set_of_identifiers.push_back(TableIdentifier(schema_identifier, *iter, drizzled::message::Table::FUNCTION));
 
127
  }
 
128
}
 
129
 
 
130
static int init(drizzled::module::Context &context)
 
131
{
 
132
  context.add(new Function("FunctionEngine"));
101
133
 
102
134
  return 0;
103
135
}
111
143
  "Function Engine provides the infrastructure for Table Functions,etc.",
112
144
  PLUGIN_LICENSE_GPL,
113
145
  init,     /* Plugin Init */
114
 
  finalize,     /* Plugin Deinit */
115
146
  NULL,               /* system variables */
116
147
  NULL                /* config options   */
117
148
}