~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/embedded_innodb/embedded_innodb_engine.cc

Skeleton embedded_innodb plugin. Does nothing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Copyright (C) 2010 Stewart Smith
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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.
 
17
*/
 
18
 
 
19
#include "config.h"
 
20
#include <drizzled/table.h>
 
21
#include <drizzled/error.h>
 
22
#include "drizzled/internal/my_pthread.h"
 
23
 
 
24
#include "embedded_innodb_engine.h"
 
25
 
 
26
#include <fcntl.h>
 
27
 
 
28
#include <string>
 
29
#include <map>
 
30
#include <fstream>
 
31
#include <drizzled/message/table.pb.h>
 
32
#include "drizzled/internal/m_string.h"
 
33
 
 
34
#include "drizzled/global_charset_info.h"
 
35
 
 
36
 
 
37
using namespace std;
 
38
using namespace google;
 
39
using namespace drizzled;
 
40
 
 
41
#define EMBEDDED_INNODB_EXT ".EINNODB"
 
42
 
 
43
static const char *EmbeddedInnoDBCursor_exts[] = {
 
44
  NULL
 
45
};
 
46
 
 
47
class EmbeddedInnoDBEngine : public drizzled::plugin::StorageEngine
 
48
{
 
49
public:
 
50
  EmbeddedInnoDBEngine(const string &name_arg)
 
51
   : drizzled::plugin::StorageEngine(name_arg,
 
52
                                     HTON_NULL_IN_KEY |
 
53
                                     HTON_CAN_INDEX_BLOBS |
 
54
                                     HTON_SKIP_STORE_LOCK |
 
55
                                     HTON_AUTO_PART_KEY |
 
56
                                     HTON_HAS_DATA_DICTIONARY)
 
57
  {
 
58
    table_definition_ext= EMBEDDED_INNODB_EXT;
 
59
  }
 
60
 
 
61
  virtual Cursor *create(TableShare &table,
 
62
                         drizzled::memory::Root *mem_root)
 
63
  {
 
64
    return new (mem_root) EmbeddedInnoDBCursor(*this, table);
 
65
  }
 
66
 
 
67
  const char **bas_ext() const {
 
68
    return EmbeddedInnoDBCursor_exts;
 
69
  }
 
70
 
 
71
  int doCreateTable(Session*,
 
72
                    const char *,
 
73
                    Table&,
 
74
                    drizzled::message::Table&);
 
75
 
 
76
  int doDropTable(Session&, const string table_name);
 
77
 
 
78
  int doGetTableDefinition(Session& session,
 
79
                           const char* path,
 
80
                           const char *db,
 
81
                           const char *table_name,
 
82
                           const bool is_tmp,
 
83
                           drizzled::message::Table *table_proto);
 
84
 
 
85
  void doGetTableNames(drizzled::CachedDirectory &,
 
86
                       string&, set<string>& )
 
87
  {
 
88
  }
 
89
 
 
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; }
 
94
 
 
95
  uint32_t index_flags(enum  ha_key_alg) const
 
96
  {
 
97
    return (HA_READ_NEXT |
 
98
            HA_READ_PREV |
 
99
            HA_READ_RANGE |
 
100
            HA_READ_ORDER |
 
101
            HA_KEYREAD_ONLY);
 
102
  }
 
103
 
 
104
};
 
105
 
 
106
EmbeddedInnoDBCursor::EmbeddedInnoDBCursor(drizzled::plugin::StorageEngine &engine_arg,
 
107
                           TableShare &table_arg)
 
108
  :Cursor(engine_arg, table_arg)
 
109
{ }
 
110
 
 
111
int EmbeddedInnoDBCursor::open(const char *, int, uint32_t)
 
112
{
 
113
  return(0);
 
114
}
 
115
 
 
116
int EmbeddedInnoDBCursor::close(void)
 
117
{
 
118
  return 0;
 
119
}
 
120
 
 
121
int EmbeddedInnoDBEngine::doCreateTable(Session*, const char *,
 
122
                                   Table&,
 
123
                                   drizzled::message::Table&)
 
124
{
 
125
  return EEXIST;
 
126
}
 
127
 
 
128
 
 
129
int EmbeddedInnoDBEngine::doDropTable(Session&, const string)
 
130
{
 
131
  return EPERM;
 
132
}
 
133
 
 
134
int EmbeddedInnoDBEngine::doGetTableDefinition(Session&,
 
135
                                          const char* ,
 
136
                                          const char *,
 
137
                                          const char *,
 
138
                                          const bool,
 
139
                                          drizzled::message::Table *)
 
140
{
 
141
  return ENOENT;
 
142
}
 
143
 
 
144
const char *EmbeddedInnoDBCursor::index_type(uint32_t)
 
145
{
 
146
  return("BTREE");
 
147
}
 
148
 
 
149
int EmbeddedInnoDBCursor::write_row(unsigned char *)
 
150
{
 
151
  return(table->next_number_field ? update_auto_increment() : 0);
 
152
}
 
153
 
 
154
int EmbeddedInnoDBCursor::rnd_init(bool)
 
155
{
 
156
  return(0);
 
157
}
 
158
 
 
159
 
 
160
int EmbeddedInnoDBCursor::rnd_next(unsigned char *)
 
161
{
 
162
  return(HA_ERR_END_OF_FILE);
 
163
}
 
164
 
 
165
 
 
166
int EmbeddedInnoDBCursor::rnd_pos(unsigned char *, unsigned char *)
 
167
{
 
168
  assert(0);
 
169
  return(0);
 
170
}
 
171
 
 
172
 
 
173
void EmbeddedInnoDBCursor::position(const unsigned char *)
 
174
{
 
175
  assert(0);
 
176
  return;
 
177
}
 
178
 
 
179
 
 
180
int EmbeddedInnoDBCursor::info(uint32_t flag)
 
181
{
 
182
  memset(&stats, 0, sizeof(stats));
 
183
  if (flag & HA_STATUS_AUTO)
 
184
    stats.auto_increment_value= 1;
 
185
  return(0);
 
186
}
 
187
 
 
188
 
 
189
int EmbeddedInnoDBCursor::index_read_map(unsigned char *, const unsigned char *,
 
190
                                 key_part_map, enum ha_rkey_function)
 
191
{
 
192
  return(HA_ERR_END_OF_FILE);
 
193
}
 
194
 
 
195
 
 
196
int EmbeddedInnoDBCursor::index_read_idx_map(unsigned char *, uint32_t, const unsigned char *,
 
197
                                     key_part_map, enum ha_rkey_function)
 
198
{
 
199
  return(HA_ERR_END_OF_FILE);
 
200
}
 
201
 
 
202
 
 
203
int EmbeddedInnoDBCursor::index_read_last_map(unsigned char *, const unsigned char *, key_part_map)
 
204
{
 
205
  return(HA_ERR_END_OF_FILE);
 
206
}
 
207
 
 
208
 
 
209
int EmbeddedInnoDBCursor::index_next(unsigned char *)
 
210
{
 
211
  return(HA_ERR_END_OF_FILE);
 
212
}
 
213
 
 
214
 
 
215
int EmbeddedInnoDBCursor::index_prev(unsigned char *)
 
216
{
 
217
  return(HA_ERR_END_OF_FILE);
 
218
}
 
219
 
 
220
 
 
221
int EmbeddedInnoDBCursor::index_first(unsigned char *)
 
222
{
 
223
  return(HA_ERR_END_OF_FILE);
 
224
}
 
225
 
 
226
 
 
227
int EmbeddedInnoDBCursor::index_last(unsigned char *)
 
228
{
 
229
  return(HA_ERR_END_OF_FILE);
 
230
}
 
231
 
 
232
static drizzled::plugin::StorageEngine *embedded_innodb_engine= NULL;
 
233
 
 
234
static int embedded_innodb_init(drizzled::plugin::Registry &registry)
 
235
{
 
236
 
 
237
  embedded_innodb_engine= new EmbeddedInnoDBEngine("EmbeddedInnoDB");
 
238
  registry.add(embedded_innodb_engine);
 
239
 
 
240
  return 0;
 
241
}
 
242
 
 
243
static int embedded_innodb_fini(drizzled::plugin::Registry &registry)
 
244
{
 
245
  registry.remove(embedded_innodb_engine);
 
246
  delete embedded_innodb_engine;
 
247
 
 
248
  return 0;
 
249
}
 
250
 
 
251
DRIZZLE_DECLARE_PLUGIN
 
252
{
 
253
  DRIZZLE_VERSION_ID,
 
254
  "EMBEDDED_INNODB",
 
255
  "1.0",
 
256
  "Stewart Smith",
 
257
  "Used to test rest of server with various table proto messages",
 
258
  PLUGIN_LICENSE_GPL,
 
259
  embedded_innodb_init,     /* Plugin Init */
 
260
  embedded_innodb_fini,     /* Plugin Deinit */
 
261
  NULL,               /* status variables */
 
262
  NULL,               /* system variables */
 
263
  NULL                /* config options   */
 
264
}
 
265
DRIZZLE_DECLARE_PLUGIN_END;