28
28
using namespace std;
29
29
using namespace drizzled;
31
static SchemaIdentifier INFORMATION_SCHEMA_IDENTIFIER("INFORMATION_SCHEMA");
32
static SchemaIdentifier DATA_DICTIONARY_IDENTIFIER("DATA_DICTIONARY");
31
34
Function::Function(const std::string &name_arg) :
32
35
drizzled::plugin::StorageEngine(name_arg,
33
36
HTON_ALTER_NOT_SUPPORTED |
34
37
HTON_HAS_SCHEMA_DICTIONARY |
35
HTON_HAS_DATA_DICTIONARY |
36
38
HTON_SKIP_STORE_LOCK |
37
39
HTON_TEMPORARY_NOT_SUPPORTED)
42
Cursor *Function::create(TableShare &table, memory::Root *mem_root)
44
Cursor *Function::create(TableShare &table)
44
return new (mem_root) FunctionCursor(*this, table);
46
return new FunctionCursor(*this, table);
47
49
int Function::doGetTableDefinition(Session &,
52
message::Table *table_proto)
50
const TableIdentifier &identifier,
51
message::Table &table_proto)
54
string tab_name(path);
55
transform(tab_name.begin(), tab_name.end(),
56
tab_name.begin(), ::tolower);
58
drizzled::plugin::TableFunction *function= getFunction(tab_name);
53
drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
67
function->define(*table_proto);
60
function->define(table_proto);
74
void Function::doGetTableNames(drizzled::CachedDirectory&,
76
set<string> &set_of_names)
78
drizzled::plugin::TableFunction::getNames(db, set_of_names);
81
void Function::doGetSchemaNames(std::set<std::string>& set_of_names)
83
set_of_names.insert("information_schema"); // special cases suck
84
set_of_names.insert("data_dictionary"); // special cases suck
87
bool Function::doGetSchemaDefinition(const std::string &schema_name, message::Schema &schema_message)
89
if (not schema_name.compare("information_schema"))
65
void Function::doGetSchemaIdentifiers(SchemaIdentifiers& schemas)
67
schemas.push_back(INFORMATION_SCHEMA_IDENTIFIER);
68
schemas.push_back(DATA_DICTIONARY_IDENTIFIER);
71
bool Function::doGetSchemaDefinition(const SchemaIdentifier &schema_identifier, message::Schema &schema_message)
73
if (schema_identifier == INFORMATION_SCHEMA_IDENTIFIER)
91
75
schema_message.set_name("information_schema");
92
76
schema_message.set_collation("utf8_general_ci");
94
else if (not schema_name.compare("data_dictionary"))
78
else if (schema_identifier == DATA_DICTIONARY_IDENTIFIER)
96
80
schema_message.set_name("data_dictionary");
97
81
schema_message.set_collation("utf8_general_ci");
107
bool Function::doCanCreateTable(const drizzled::TableIdentifier &identifier)
91
bool Function::doCanCreateTable(const drizzled::TableIdentifier &table_identifier)
109
if (not strcasecmp(identifier.getSchemaName(), "information_schema"))
93
if (static_cast<const SchemaIdentifier&>(table_identifier) == INFORMATION_SCHEMA_IDENTIFIER)
114
if (not strcasecmp(identifier.getSchemaName(), "data_dictionary"))
98
else if (static_cast<const SchemaIdentifier&>(table_identifier) == DATA_DICTIONARY_IDENTIFIER)
123
static drizzled::plugin::StorageEngine *function_plugin= NULL;
125
static int init(drizzled::plugin::Registry ®istry)
127
function_plugin= new(std::nothrow) Function("FunctionEngine");
129
if (not function_plugin)
106
bool Function::doDoesTableExist(Session&, const TableIdentifier &identifier)
108
drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
117
void Function::doGetTableIdentifiers(drizzled::CachedDirectory&,
118
const drizzled::SchemaIdentifier &schema_identifier,
119
drizzled::TableIdentifiers &set_of_identifiers)
121
set<string> set_of_names;
122
drizzled::plugin::TableFunction::getNames(schema_identifier.getSchemaName(), set_of_names);
124
for (set<string>::iterator iter= set_of_names.begin(); iter != set_of_names.end(); iter++)
126
set_of_identifiers.push_back(TableIdentifier(schema_identifier, *iter, drizzled::message::Table::FUNCTION));
134
registry.add(function_plugin);
139
static int finalize(drizzled::plugin::Registry ®istry)
130
static int init(drizzled::module::Context &context)
141
registry.remove(function_plugin);
142
delete function_plugin;
132
context.add(new Function("FunctionEngine"));