1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
#include <plugin/function_engine/function.h>
24
#include <plugin/function_engine/cursor.h>
29
using namespace drizzled;
31
static SchemaIdentifier INFORMATION_SCHEMA_IDENTIFIER("INFORMATION_SCHEMA");
32
static SchemaIdentifier DATA_DICTIONARY_IDENTIFIER("DATA_DICTIONARY");
34
Function::Function(const std::string &name_arg) :
35
drizzled::plugin::StorageEngine(name_arg,
36
HTON_ALTER_NOT_SUPPORTED |
37
HTON_HAS_SCHEMA_DICTIONARY |
38
HTON_SKIP_STORE_LOCK |
39
HTON_TEMPORARY_NOT_SUPPORTED)
44
Cursor *Function::create(TableShare &table, memory::Root *mem_root)
46
return new (mem_root) FunctionCursor(*this, table);
49
int Function::doGetTableDefinition(Session &,
50
TableIdentifier &identifier,
51
message::Table &table_proto)
53
string tab_name(identifier.getPath());
54
transform(tab_name.begin(), tab_name.end(),
55
tab_name.begin(), ::tolower);
57
drizzled::plugin::TableFunction *function= getFunction(tab_name);
64
function->define(table_proto);
70
void Function::doGetTableNames(drizzled::CachedDirectory&,
71
drizzled::SchemaIdentifier &schema_identifier,
72
set<string> &set_of_names)
74
drizzled::plugin::TableFunction::getNames(schema_identifier.getSchemaName(), set_of_names);
77
void Function::doGetSchemaIdentifiers(SchemaIdentifierList& schemas)
79
schemas.push_back(INFORMATION_SCHEMA_IDENTIFIER);
80
schemas.push_back(DATA_DICTIONARY_IDENTIFIER);
83
bool Function::doGetSchemaDefinition(SchemaIdentifier &schema_identifier, message::Schema &schema_message)
85
if (schema_identifier == INFORMATION_SCHEMA_IDENTIFIER)
87
schema_message.set_name("information_schema");
88
schema_message.set_collation("utf8_general_ci");
90
else if (schema_identifier == DATA_DICTIONARY_IDENTIFIER)
92
schema_message.set_name("data_dictionary");
93
schema_message.set_collation("utf8_general_ci");
103
bool Function::doCanCreateTable(drizzled::TableIdentifier &table_identifier)
105
if (static_cast<SchemaIdentifier&>(table_identifier) == INFORMATION_SCHEMA_IDENTIFIER)
110
else if (static_cast<SchemaIdentifier&>(table_identifier) == DATA_DICTIONARY_IDENTIFIER)
118
bool Function::doDoesTableExist(Session&, TableIdentifier &identifier)
120
drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
129
void Function::doGetTableIdentifiers(drizzled::CachedDirectory&,
130
drizzled::SchemaIdentifier &schema_identifier,
131
drizzled::TableIdentifiers &set_of_identifiers)
133
set<string> set_of_names;
134
drizzled::plugin::TableFunction::getNames(schema_identifier.getSchemaName(), set_of_names);
136
for (set<string>::iterator iter= set_of_names.begin(); iter != set_of_names.end(); iter++)
138
set_of_identifiers.push_back(TableIdentifier(schema_identifier, *iter));
142
static int init(drizzled::plugin::Context &context)
144
context.add(new Function("FunctionEngine"));
149
DRIZZLE_DECLARE_PLUGIN
155
"Function Engine provides the infrastructure for Table Functions,etc.",
157
init, /* Plugin Init */
158
NULL, /* system variables */
159
NULL /* config options */
161
DRIZZLE_DECLARE_PLUGIN_END;