1273.13.1
by Brian Aker
First pass through data dictionary. |
1 |
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
4 |
* Copyright (C) 2010 Sun Microsystems
|
1273.13.1
by Brian Aker
First pass through data dictionary. |
5 |
*
|
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.
|
|
10 |
*
|
|
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.
|
|
15 |
*
|
|
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
|
|
19 |
*/
|
|
20 |
||
1273.14.5
by Monty Taylor
Merged trunk. |
21 |
#include "config.h" |
22 |
||
1273.13.55
by Brian Aker
Naming fixes. |
23 |
#include <plugin/function_engine/function.h> |
24 |
#include <plugin/function_engine/cursor.h> |
|
1273.13.1
by Brian Aker
First pass through data dictionary. |
25 |
|
26 |
#include <string> |
|
27 |
||
28 |
using namespace std; |
|
29 |
using namespace drizzled; |
|
30 |
||
1415
by Brian Aker
Mass overhaul to use schema_identifier. |
31 |
static SchemaIdentifier INFORMATION_SCHEMA_IDENTIFIER("INFORMATION_SCHEMA"); |
32 |
static SchemaIdentifier DATA_DICTIONARY_IDENTIFIER("DATA_DICTIONARY"); |
|
33 |
||
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
34 |
Function::Function(const std::string &name_arg) : |
1273.13.1
by Brian Aker
First pass through data dictionary. |
35 |
drizzled::plugin::StorageEngine(name_arg, |
36 |
HTON_ALTER_NOT_SUPPORTED | |
|
1273.19.30
by Brian Aker
Performance patch... we now only cycle through engines that actually have |
37 |
HTON_HAS_SCHEMA_DICTIONARY | |
1273.13.1
by Brian Aker
First pass through data dictionary. |
38 |
HTON_SKIP_STORE_LOCK | |
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
39 |
HTON_TEMPORARY_NOT_SUPPORTED) |
1273.13.1
by Brian Aker
First pass through data dictionary. |
40 |
{
|
41 |
}
|
|
42 |
||
43 |
||
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
44 |
Cursor *Function::create(TableShare &table, memory::Root *mem_root) |
1273.13.1
by Brian Aker
First pass through data dictionary. |
45 |
{
|
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
46 |
return new (mem_root) FunctionCursor(*this, table); |
1273.13.1
by Brian Aker
First pass through data dictionary. |
47 |
}
|
48 |
||
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
49 |
int Function::doGetTableDefinition(Session &, |
1618.1.1
by Brian Aker
Modify TableIdentifier to be const |
50 |
const TableIdentifier &identifier, |
1358.1.1
by Brian Aker
Fixes regression in performance from Exists patch. |
51 |
message::Table &table_proto) |
1273.13.1
by Brian Aker
First pass through data dictionary. |
52 |
{
|
1358.1.7
by Brian Aker
Remove interface bits around caller for internal lookup of create table. |
53 |
string tab_name(identifier.getPath()); |
1273.13.11
by Brian Aker
First pass through tables. |
54 |
transform(tab_name.begin(), tab_name.end(), |
55 |
tab_name.begin(), ::tolower); |
|
1273.13.1
by Brian Aker
First pass through data dictionary. |
56 |
|
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
57 |
drizzled::plugin::TableFunction *function= getFunction(tab_name); |
1273.13.6
by Brian Aker
Updates for interface/etc. |
58 |
|
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
59 |
if (not function) |
1273.13.6
by Brian Aker
Updates for interface/etc. |
60 |
{
|
1273.13.1
by Brian Aker
First pass through data dictionary. |
61 |
return ENOENT; |
62 |
}
|
|
63 |
||
1354.1.1
by Brian Aker
Modify ptr to reference. |
64 |
function->define(table_proto); |
1273.13.6
by Brian Aker
Updates for interface/etc. |
65 |
|
1273.13.1
by Brian Aker
First pass through data dictionary. |
66 |
return EEXIST; |
67 |
}
|
|
68 |
||
69 |
||
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
70 |
void Function::doGetTableNames(drizzled::CachedDirectory&, |
1415
by Brian Aker
Mass overhaul to use schema_identifier. |
71 |
drizzled::SchemaIdentifier &schema_identifier, |
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
72 |
set<string> &set_of_names) |
1273.13.1
by Brian Aker
First pass through data dictionary. |
73 |
{
|
1415
by Brian Aker
Mass overhaul to use schema_identifier. |
74 |
drizzled::plugin::TableFunction::getNames(schema_identifier.getSchemaName(), set_of_names); |
75 |
}
|
|
76 |
||
77 |
void Function::doGetSchemaIdentifiers(SchemaIdentifierList& schemas) |
|
78 |
{
|
|
79 |
schemas.push_back(INFORMATION_SCHEMA_IDENTIFIER); |
|
80 |
schemas.push_back(DATA_DICTIONARY_IDENTIFIER); |
|
81 |
}
|
|
82 |
||
83 |
bool Function::doGetSchemaDefinition(SchemaIdentifier &schema_identifier, message::Schema &schema_message) |
|
84 |
{
|
|
85 |
if (schema_identifier == INFORMATION_SCHEMA_IDENTIFIER) |
|
1273.19.23
by Brian Aker
Updated meta calls for data_dictionary |
86 |
{
|
87 |
schema_message.set_name("information_schema"); |
|
88 |
schema_message.set_collation("utf8_general_ci"); |
|
89 |
}
|
|
1415
by Brian Aker
Mass overhaul to use schema_identifier. |
90 |
else if (schema_identifier == DATA_DICTIONARY_IDENTIFIER) |
1273.19.23
by Brian Aker
Updated meta calls for data_dictionary |
91 |
{
|
92 |
schema_message.set_name("data_dictionary"); |
|
93 |
schema_message.set_collation("utf8_general_ci"); |
|
94 |
}
|
|
95 |
else
|
|
96 |
{
|
|
97 |
return false; |
|
98 |
}
|
|
99 |
||
100 |
return true; |
|
1273.19.22
by Brian Aker
Shuffled information_schema; |
101 |
}
|
102 |
||
1618.1.1
by Brian Aker
Modify TableIdentifier to be const |
103 |
bool Function::doCanCreateTable(const drizzled::TableIdentifier &table_identifier) |
1320.1.8
by Brian Aker
Temporary fix for allowing engines to say "don't do this". |
104 |
{
|
1618.1.1
by Brian Aker
Modify TableIdentifier to be const |
105 |
if (static_cast<const SchemaIdentifier&>(table_identifier) == INFORMATION_SCHEMA_IDENTIFIER) |
1320.1.8
by Brian Aker
Temporary fix for allowing engines to say "don't do this". |
106 |
{
|
107 |
return false; |
|
108 |
}
|
|
109 |
||
1618.1.1
by Brian Aker
Modify TableIdentifier to be const |
110 |
else if (static_cast<const SchemaIdentifier&>(table_identifier) == DATA_DICTIONARY_IDENTIFIER) |
1320.1.8
by Brian Aker
Temporary fix for allowing engines to say "don't do this". |
111 |
{
|
112 |
return false; |
|
113 |
}
|
|
114 |
||
115 |
return true; |
|
116 |
}
|
|
117 |
||
1618.1.1
by Brian Aker
Modify TableIdentifier to be const |
118 |
bool Function::doDoesTableExist(Session&, const TableIdentifier &identifier) |
1358.1.1
by Brian Aker
Fixes regression in performance from Exists patch. |
119 |
{
|
120 |
drizzled::plugin::TableFunction *function= getFunction(identifier.getPath()); |
|
121 |
||
122 |
if (function) |
|
123 |
return true; |
|
124 |
||
125 |
return false; |
|
126 |
}
|
|
127 |
||
1273.13.1
by Brian Aker
First pass through data dictionary. |
128 |
|
1429.1.3
by Brian Aker
Merge in work for fetching a list of table identifiers. |
129 |
void Function::doGetTableIdentifiers(drizzled::CachedDirectory&, |
130 |
drizzled::SchemaIdentifier &schema_identifier, |
|
131 |
drizzled::TableIdentifiers &set_of_identifiers) |
|
132 |
{
|
|
133 |
set<string> set_of_names; |
|
134 |
drizzled::plugin::TableFunction::getNames(schema_identifier.getSchemaName(), set_of_names); |
|
135 |
||
136 |
for (set<string>::iterator iter= set_of_names.begin(); iter != set_of_names.end(); iter++) |
|
137 |
{
|
|
138 |
set_of_identifiers.push_back(TableIdentifier(schema_identifier, *iter)); |
|
139 |
}
|
|
140 |
}
|
|
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
141 |
|
1530.2.6
by Monty Taylor
Moved plugin::Context to module::Context. |
142 |
static int init(drizzled::module::Context &context) |
1273.13.1
by Brian Aker
First pass through data dictionary. |
143 |
{
|
1429.1.3
by Brian Aker
Merge in work for fetching a list of table identifiers. |
144 |
context.add(new Function("FunctionEngine")); |
1273.13.36
by Brian Aker
Adding support for LOCAL_TABLE_NAMES and SCHEMA_NAMES |
145 |
|
1273.13.1
by Brian Aker
First pass through data dictionary. |
146 |
return 0; |
147 |
}
|
|
148 |
||
149 |
DRIZZLE_DECLARE_PLUGIN
|
|
150 |
{
|
|
151 |
DRIZZLE_VERSION_ID, |
|
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
152 |
"FunctionEngine", |
1273.13.1
by Brian Aker
First pass through data dictionary. |
153 |
"1.0", |
154 |
"Brian Aker", |
|
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
155 |
"Function Engine provides the infrastructure for Table Functions,etc.", |
1273.13.1
by Brian Aker
First pass through data dictionary. |
156 |
PLUGIN_LICENSE_GPL, |
157 |
init, /* Plugin Init */ |
|
158 |
NULL, /* system variables */ |
|
159 |
NULL /* config options */ |
|
160 |
}
|
|
161 |
DRIZZLE_DECLARE_PLUGIN_END; |