2
Copyright (C) 2010 Stewart Smith
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License
6
as published by the Free Software Foundation; either version 2
7
of the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
#include <drizzled/table.h>
21
#include <drizzled/error.h>
22
#include "drizzled/internal/my_pthread.h"
24
#include "embedded_innodb_engine.h"
31
#include <drizzled/message/table.pb.h>
32
#include "drizzled/internal/m_string.h"
34
#include "drizzled/global_charset_info.h"
38
using namespace google;
39
using namespace drizzled;
41
#define EMBEDDED_INNODB_EXT ".EINNODB"
43
static const char *EmbeddedInnoDBCursor_exts[] = {
47
class EmbeddedInnoDBEngine : public drizzled::plugin::StorageEngine
50
EmbeddedInnoDBEngine(const string &name_arg)
51
: drizzled::plugin::StorageEngine(name_arg,
53
HTON_CAN_INDEX_BLOBS |
54
HTON_SKIP_STORE_LOCK |
56
HTON_HAS_DATA_DICTIONARY)
58
table_definition_ext= EMBEDDED_INNODB_EXT;
61
virtual Cursor *create(TableShare &table,
62
drizzled::memory::Root *mem_root)
64
return new (mem_root) EmbeddedInnoDBCursor(*this, table);
67
const char **bas_ext() const {
68
return EmbeddedInnoDBCursor_exts;
71
int doCreateTable(Session*,
74
drizzled::message::Table&);
76
int doDropTable(Session&, const string table_name);
78
int doGetTableDefinition(Session& session,
81
const char *table_name,
83
drizzled::message::Table *table_proto);
85
void doGetTableNames(drizzled::CachedDirectory &,
86
string&, set<string>& )
90
/* The following defines can be increased if necessary */
91
uint32_t max_supported_keys() const { return 64; }
92
uint32_t max_supported_key_length() const { return 1000; }
93
uint32_t max_supported_key_part_length() const { return 1000; }
95
uint32_t index_flags(enum ha_key_alg) const
97
return (HA_READ_NEXT |
106
EmbeddedInnoDBCursor::EmbeddedInnoDBCursor(drizzled::plugin::StorageEngine &engine_arg,
107
TableShare &table_arg)
108
:Cursor(engine_arg, table_arg)
111
int EmbeddedInnoDBCursor::open(const char *, int, uint32_t)
116
int EmbeddedInnoDBCursor::close(void)
121
int EmbeddedInnoDBEngine::doCreateTable(Session*, const char *,
123
drizzled::message::Table&)
129
int EmbeddedInnoDBEngine::doDropTable(Session&, const string)
134
int EmbeddedInnoDBEngine::doGetTableDefinition(Session&,
139
drizzled::message::Table *)
144
const char *EmbeddedInnoDBCursor::index_type(uint32_t)
149
int EmbeddedInnoDBCursor::write_row(unsigned char *)
151
return(table->next_number_field ? update_auto_increment() : 0);
154
int EmbeddedInnoDBCursor::rnd_init(bool)
160
int EmbeddedInnoDBCursor::rnd_next(unsigned char *)
162
return(HA_ERR_END_OF_FILE);
166
int EmbeddedInnoDBCursor::rnd_pos(unsigned char *, unsigned char *)
173
void EmbeddedInnoDBCursor::position(const unsigned char *)
180
int EmbeddedInnoDBCursor::info(uint32_t flag)
182
memset(&stats, 0, sizeof(stats));
183
if (flag & HA_STATUS_AUTO)
184
stats.auto_increment_value= 1;
189
int EmbeddedInnoDBCursor::index_read_map(unsigned char *, const unsigned char *,
190
key_part_map, enum ha_rkey_function)
192
return(HA_ERR_END_OF_FILE);
196
int EmbeddedInnoDBCursor::index_read_idx_map(unsigned char *, uint32_t, const unsigned char *,
197
key_part_map, enum ha_rkey_function)
199
return(HA_ERR_END_OF_FILE);
203
int EmbeddedInnoDBCursor::index_read_last_map(unsigned char *, const unsigned char *, key_part_map)
205
return(HA_ERR_END_OF_FILE);
209
int EmbeddedInnoDBCursor::index_next(unsigned char *)
211
return(HA_ERR_END_OF_FILE);
215
int EmbeddedInnoDBCursor::index_prev(unsigned char *)
217
return(HA_ERR_END_OF_FILE);
221
int EmbeddedInnoDBCursor::index_first(unsigned char *)
223
return(HA_ERR_END_OF_FILE);
227
int EmbeddedInnoDBCursor::index_last(unsigned char *)
229
return(HA_ERR_END_OF_FILE);
232
static drizzled::plugin::StorageEngine *embedded_innodb_engine= NULL;
234
static int embedded_innodb_init(drizzled::plugin::Registry ®istry)
237
embedded_innodb_engine= new EmbeddedInnoDBEngine("EmbeddedInnoDB");
238
registry.add(embedded_innodb_engine);
243
static int embedded_innodb_fini(drizzled::plugin::Registry ®istry)
245
registry.remove(embedded_innodb_engine);
246
delete embedded_innodb_engine;
251
DRIZZLE_DECLARE_PLUGIN
257
"Used to test rest of server with various table proto messages",
259
embedded_innodb_init, /* Plugin Init */
260
embedded_innodb_fini, /* Plugin Deinit */
261
NULL, /* status variables */
262
NULL, /* system variables */
263
NULL /* config options */
265
DRIZZLE_DECLARE_PLUGIN_END;