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 "tableprototester.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;
40
#define TABLEPROTOTESTER_EXT ".TBT"
42
static const char *TableProtoTesterCursor_exts[] = {
46
class TableProtoTesterEngine : public drizzled::plugin::StorageEngine
49
TableProtoTesterEngine(const string &name_arg)
50
: drizzled::plugin::StorageEngine(name_arg,
52
HTON_CAN_INDEX_BLOBS |
53
HTON_SKIP_STORE_LOCK |
55
HTON_HAS_DATA_DICTIONARY)
57
table_definition_ext= TABLEPROTOTESTER_EXT;
60
virtual Cursor *create(TableShare &table,
61
drizzled::memory::Root *mem_root)
63
return new (mem_root) TableProtoTesterCursor(*this, table);
66
const char **bas_ext() const {
67
return TableProtoTesterCursor_exts;
70
int doCreateTable(Session*,
73
drizzled::message::Table&);
75
int doDropTable(Session&, const string table_name);
77
int doGetTableDefinition(Session& session,
80
const char *table_name,
82
drizzled::message::Table *table_proto);
84
void doGetTableNames(drizzled::CachedDirectory &directory,
85
string&, set<string>& set_of_names)
87
// set_of_names.insert();
92
/* The following defines can be increased if necessary */
93
uint32_t max_supported_keys() const { return 64; }
94
uint32_t max_supported_key_length() const { return 1000; }
95
uint32_t max_supported_key_part_length() const { return 1000; }
97
uint32_t index_flags(enum ha_key_alg) const
99
return (HA_READ_NEXT |
108
TableProtoTesterCursor::TableProtoTesterCursor(drizzled::plugin::StorageEngine &engine_arg,
109
TableShare &table_arg)
110
:Cursor(engine_arg, table_arg)
113
int TableProtoTesterCursor::open(const char *, int, uint32_t)
118
int TableProtoTesterCursor::close(void)
123
int TableProtoTesterEngine::doCreateTable(Session*, const char *,
125
drizzled::message::Table&)
131
int TableProtoTesterEngine::doDropTable(Session&, const string)
136
int TableProtoTesterEngine::doGetTableDefinition(Session&,
141
drizzled::message::Table *table_proto)
148
const char *TableProtoTesterCursor::index_type(uint32_t)
153
int TableProtoTesterCursor::write_row(unsigned char *)
155
return(table->next_number_field ? update_auto_increment() : 0);
158
int TableProtoTesterCursor::rnd_init(bool)
164
int TableProtoTesterCursor::rnd_next(unsigned char *)
166
return(HA_ERR_END_OF_FILE);
170
int TableProtoTesterCursor::rnd_pos(unsigned char *, unsigned char *)
177
void TableProtoTesterCursor::position(const unsigned char *)
184
int TableProtoTesterCursor::info(uint32_t flag)
186
memset(&stats, 0, sizeof(stats));
187
if (flag & HA_STATUS_AUTO)
188
stats.auto_increment_value= 1;
193
int TableProtoTesterCursor::index_read_map(unsigned char *, const unsigned char *,
194
key_part_map, enum ha_rkey_function)
196
return(HA_ERR_END_OF_FILE);
200
int TableProtoTesterCursor::index_read_idx_map(unsigned char *, uint32_t, const unsigned char *,
201
key_part_map, enum ha_rkey_function)
203
return(HA_ERR_END_OF_FILE);
207
int TableProtoTesterCursor::index_read_last_map(unsigned char *, const unsigned char *, key_part_map)
209
return(HA_ERR_END_OF_FILE);
213
int TableProtoTesterCursor::index_next(unsigned char *)
215
return(HA_ERR_END_OF_FILE);
219
int TableProtoTesterCursor::index_prev(unsigned char *)
221
return(HA_ERR_END_OF_FILE);
225
int TableProtoTesterCursor::index_first(unsigned char *)
227
return(HA_ERR_END_OF_FILE);
231
int TableProtoTesterCursor::index_last(unsigned char *)
233
return(HA_ERR_END_OF_FILE);
236
static drizzled::plugin::StorageEngine *tableprototester_engine= NULL;
238
static int tableprototester_init(drizzled::plugin::Registry ®istry)
241
tableprototester_engine= new TableProtoTesterEngine("TABLEPROTOTESTER");
242
registry.add(tableprototester_engine);
247
static int tableprototester_fini(drizzled::plugin::Registry ®istry)
249
registry.remove(tableprototester_engine);
250
delete tableprototester_engine;
255
DRIZZLE_DECLARE_PLUGIN
261
"Used to test rest of server with various table proto messages",
263
tableprototester_init, /* Plugin Init */
264
tableprototester_fini, /* Plugin Deinit */
265
NULL, /* status variables */
266
NULL, /* system variables */
267
NULL /* config options */
269
DRIZZLE_DECLARE_PLUGIN_END;