~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/storage_engine.h

  • Committer: Brian Aker
  • Date: 2010-01-22 00:53:13 UTC
  • Revision ID: brian@gaz-20100122005313-jmizcbcdi1lt4tcx
Revert db patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
21
21
#define DRIZZLED_PLUGIN_STORAGE_ENGINE_H
22
22
 
23
23
 
24
 
#include <drizzled/cached_directory.h>
25
24
#include <drizzled/definitions.h>
26
 
#include <drizzled/error_t.h>
 
25
#include <drizzled/plugin.h>
27
26
#include <drizzled/handler_structs.h>
28
 
#include <drizzled/identifier.h>
29
 
#include <drizzled/message.h>
30
 
#include <drizzled/message/cache.h>
31
 
#include <drizzled/plugin.h>
32
 
#include <drizzled/plugin/monitored_in_transaction.h>
33
 
#include <drizzled/plugin/plugin.h>
34
 
#include <drizzled/sql_string.h>
 
27
#include <drizzled/message/table.pb.h>
 
28
#include "drizzled/plugin/plugin.h"
 
29
#include "drizzled/sql_string.h"
 
30
#include "drizzled/table_identifier.h"
 
31
#include "drizzled/cached_directory.h"
35
32
 
36
33
#include <bitset>
37
34
#include <string>
38
35
#include <vector>
39
36
#include <set>
40
37
 
41
 
#include <drizzled/visibility.h>
42
 
 
43
 
namespace drizzled
44
 
{
45
 
 
46
38
class TableList;
47
39
class Session;
 
40
class XID;
48
41
class Cursor;
49
42
typedef struct st_hash HASH;
50
43
 
51
44
class TableShare;
 
45
typedef drizzle_lex_string LEX_STRING;
52
46
typedef bool (stat_print_fn)(Session *session, const char *type, uint32_t type_len,
53
47
                             const char *file, uint32_t file_len,
54
48
                             const char *status, uint32_t status_len);
60
54
  HTON_BIT_NOT_USER_SELECTABLE,
61
55
  HTON_BIT_TEMPORARY_NOT_SUPPORTED,   // Having temporary tables not supported
62
56
  HTON_BIT_TEMPORARY_ONLY,
 
57
  HTON_BIT_FILE_BASED, // use for check_lowercase_names
 
58
  HTON_BIT_HAS_DATA_DICTIONARY,
63
59
  HTON_BIT_DOES_TRANSACTIONS,
64
60
  HTON_BIT_STATS_RECORDS_IS_EXACT,
65
61
  HTON_BIT_NULL_IN_KEY,
66
62
  HTON_BIT_CAN_INDEX_BLOBS,
 
63
  HTON_BIT_PRIMARY_KEY_REQUIRED_FOR_POSITION,
67
64
  HTON_BIT_PRIMARY_KEY_IN_READ_INDEX,
68
65
  HTON_BIT_PARTIAL_COLUMN_READ,
69
66
  HTON_BIT_TABLE_SCAN_ON_INDEX,
 
67
  HTON_BIT_MRR_CANT_SORT,
70
68
  HTON_BIT_FAST_KEY_READ,
71
69
  HTON_BIT_NO_BLOBS,
72
70
  HTON_BIT_HAS_RECORDS,
73
71
  HTON_BIT_NO_AUTO_INCREMENT,
74
72
  HTON_BIT_DUPLICATE_POS,
75
73
  HTON_BIT_AUTO_PART_KEY,
 
74
  HTON_BIT_NEED_READ_RANGE_BUFFER,
76
75
  HTON_BIT_REQUIRE_PRIMARY_KEY,
77
76
  HTON_BIT_REQUIRES_KEY_COLUMNS_FOR_DELETE,
78
77
  HTON_BIT_PRIMARY_KEY_REQUIRED_FOR_DELETE,
79
78
  HTON_BIT_NO_PREFIX_CHAR_KEYS,
80
79
  HTON_BIT_HAS_CHECKSUM,
81
80
  HTON_BIT_SKIP_STORE_LOCK,
82
 
  HTON_BIT_SCHEMA_DICTIONARY,
83
 
  HTON_BIT_FOREIGN_KEYS,
84
81
  HTON_BIT_SIZE
85
82
};
86
83
 
90
87
static const std::bitset<HTON_BIT_SIZE> HTON_NOT_USER_SELECTABLE(1 << HTON_BIT_NOT_USER_SELECTABLE);
91
88
static const std::bitset<HTON_BIT_SIZE> HTON_TEMPORARY_NOT_SUPPORTED(1 << HTON_BIT_TEMPORARY_NOT_SUPPORTED);
92
89
static const std::bitset<HTON_BIT_SIZE> HTON_TEMPORARY_ONLY(1 << HTON_BIT_TEMPORARY_ONLY);
 
90
static const std::bitset<HTON_BIT_SIZE> HTON_FILE_BASED(1 << HTON_BIT_FILE_BASED);
 
91
static const std::bitset<HTON_BIT_SIZE> HTON_HAS_DATA_DICTIONARY(1 << HTON_BIT_HAS_DATA_DICTIONARY);
93
92
static const std::bitset<HTON_BIT_SIZE> HTON_HAS_DOES_TRANSACTIONS(1 << HTON_BIT_DOES_TRANSACTIONS);
94
93
static const std::bitset<HTON_BIT_SIZE> HTON_STATS_RECORDS_IS_EXACT(1 << HTON_BIT_STATS_RECORDS_IS_EXACT);
95
94
static const std::bitset<HTON_BIT_SIZE> HTON_NULL_IN_KEY(1 << HTON_BIT_NULL_IN_KEY);
96
95
static const std::bitset<HTON_BIT_SIZE> HTON_CAN_INDEX_BLOBS(1 << HTON_BIT_CAN_INDEX_BLOBS);
 
96
static const std::bitset<HTON_BIT_SIZE> HTON_PRIMARY_KEY_REQUIRED_FOR_POSITION(1 << HTON_BIT_PRIMARY_KEY_REQUIRED_FOR_POSITION);
97
97
static const std::bitset<HTON_BIT_SIZE> HTON_PRIMARY_KEY_IN_READ_INDEX(1 << HTON_BIT_PRIMARY_KEY_IN_READ_INDEX);
98
98
static const std::bitset<HTON_BIT_SIZE> HTON_PARTIAL_COLUMN_READ(1 << HTON_BIT_PARTIAL_COLUMN_READ);
99
99
static const std::bitset<HTON_BIT_SIZE> HTON_TABLE_SCAN_ON_INDEX(1 << HTON_BIT_TABLE_SCAN_ON_INDEX);
 
100
static const std::bitset<HTON_BIT_SIZE> HTON_MRR_CANT_SORT(1 << HTON_BIT_MRR_CANT_SORT);
100
101
static const std::bitset<HTON_BIT_SIZE> HTON_FAST_KEY_READ(1 << HTON_BIT_FAST_KEY_READ);
101
102
static const std::bitset<HTON_BIT_SIZE> HTON_NO_BLOBS(1 << HTON_BIT_NO_BLOBS);
102
103
static const std::bitset<HTON_BIT_SIZE> HTON_HAS_RECORDS(1 << HTON_BIT_HAS_RECORDS);
103
104
static const std::bitset<HTON_BIT_SIZE> HTON_NO_AUTO_INCREMENT(1 << HTON_BIT_NO_AUTO_INCREMENT);
104
105
static const std::bitset<HTON_BIT_SIZE> HTON_DUPLICATE_POS(1 << HTON_BIT_DUPLICATE_POS);
105
106
static const std::bitset<HTON_BIT_SIZE> HTON_AUTO_PART_KEY(1 << HTON_BIT_AUTO_PART_KEY);
 
107
static const std::bitset<HTON_BIT_SIZE> HTON_NEED_READ_RANGE_BUFFER(1 << HTON_BIT_NEED_READ_RANGE_BUFFER);
106
108
static const std::bitset<HTON_BIT_SIZE> HTON_REQUIRE_PRIMARY_KEY(1 << HTON_BIT_REQUIRE_PRIMARY_KEY);
107
109
static const std::bitset<HTON_BIT_SIZE> HTON_REQUIRES_KEY_COLUMNS_FOR_DELETE(1 << HTON_BIT_REQUIRES_KEY_COLUMNS_FOR_DELETE);
108
110
static const std::bitset<HTON_BIT_SIZE> HTON_PRIMARY_KEY_REQUIRED_FOR_DELETE(1 << HTON_BIT_PRIMARY_KEY_REQUIRED_FOR_DELETE);
109
111
static const std::bitset<HTON_BIT_SIZE> HTON_NO_PREFIX_CHAR_KEYS(1 << HTON_BIT_NO_PREFIX_CHAR_KEYS);
110
112
static const std::bitset<HTON_BIT_SIZE> HTON_HAS_CHECKSUM(1 << HTON_BIT_HAS_CHECKSUM);
111
113
static const std::bitset<HTON_BIT_SIZE> HTON_SKIP_STORE_LOCK(1 << HTON_BIT_SKIP_STORE_LOCK);
112
 
static const std::bitset<HTON_BIT_SIZE> HTON_HAS_SCHEMA_DICTIONARY(1 << HTON_BIT_SCHEMA_DICTIONARY);
113
 
static const std::bitset<HTON_BIT_SIZE> HTON_HAS_FOREIGN_KEYS(1 << HTON_BIT_FOREIGN_KEYS);
114
114
 
115
115
 
116
116
class Table;
117
 
class NamedSavepoint;
118
117
 
 
118
namespace drizzled
 
119
{
119
120
namespace plugin
120
121
{
121
122
 
122
 
typedef std::vector<StorageEngine *> EngineVector;
123
 
 
124
 
typedef std::set<std::string> TableNameList;
125
 
 
126
123
extern const std::string UNKNOWN_STRING;
127
 
extern DRIZZLED_API const std::string DEFAULT_DEFINITION_FILE_EXT;
128
 
 
 
124
extern const std::string DEFAULT_DEFINITION_FILE_EXT;
129
125
 
130
126
/*
131
127
  StorageEngine is a singleton structure - one instance per storage engine -
135
131
  usually StorageEngine instance is defined statically in ha_xxx.cc as
136
132
 
137
133
  static StorageEngine { ... } xxx_engine;
 
134
 
 
135
  savepoint_*, prepare, recover, and *_by_xid pointers can be 0.
138
136
*/
139
 
class DRIZZLED_API StorageEngine :
140
 
  public Plugin,
141
 
  public MonitoredInTransaction
 
137
class StorageEngine : public Plugin
142
138
{
143
 
  friend class SEAPITester;
144
139
public:
145
140
  typedef uint64_t Table_flags;
146
141
 
147
142
private:
148
 
  static EngineVector &getSchemaEngines();
 
143
 
 
144
  /*
 
145
    Name used for storage engine.
 
146
  */
 
147
  const bool two_phase_commit;
 
148
  bool enabled;
 
149
 
149
150
  const std::bitset<HTON_BIT_SIZE> flags; /* global Cursor flags */
150
 
 
151
 
 
152
 
  virtual void setTransactionReadWrite(Session& session);
153
 
 
154
 
  /*
155
 
   * Indicates to a storage engine the start of a
156
 
   * new SQL statement.
157
 
   */
158
 
  virtual void doStartStatement(Session *session)
159
 
  {
160
 
    (void) session;
161
 
  }
162
 
 
163
 
  /*
164
 
   * Indicates to a storage engine the end of
165
 
   * the current SQL statement in the supplied
166
 
   * Session.
167
 
   */
168
 
  virtual void doEndStatement(Session *session)
169
 
  {
170
 
    (void) session;
171
 
  }
 
151
  /*
 
152
    to store per-savepoint data storage engine is provided with an area
 
153
    of a requested size (0 is ok here).
 
154
    savepoint_offset must be initialized statically to the size of
 
155
    the needed memory to store per-savepoint information.
 
156
    After xxx_init it is changed to be an offset to savepoint storage
 
157
    area and need not be used by storage engine.
 
158
    see binlog_engine and binlog_savepoint_set/rollback for an example.
 
159
  */
 
160
  size_t savepoint_offset;
 
161
  size_t orig_savepoint_offset;
 
162
 
 
163
  void setTransactionReadWrite(Session& session);
172
164
 
173
165
protected:
174
166
  std::string table_definition_ext;
199
191
    @brief
200
192
    Used as a protobuf storage currently by TEMP only engines.
201
193
  */
202
 
  typedef std::map <std::string, message::Table> ProtoCache;
 
194
  typedef std::map <std::string, drizzled::message::Table> ProtoCache;
203
195
  ProtoCache proto_cache;
204
196
  pthread_mutex_t proto_cache_mutex;
205
197
 
 
198
  /**
 
199
   * Implementing classes should override these to provide savepoint
 
200
   * functionality.
 
201
   */
 
202
  virtual int savepoint_set_hook(Session *, void *) { return 0; }
 
203
 
 
204
  virtual int savepoint_rollback_hook(Session *, void *) { return 0; }
 
205
 
 
206
  virtual int savepoint_release_hook(Session *, void *) { return 0; }
 
207
 
206
208
public:
 
209
 
207
210
  StorageEngine(const std::string name_arg,
208
 
                const std::bitset<HTON_BIT_SIZE> &flags_arg= HTON_NO_FLAGS);
 
211
                const std::bitset<HTON_BIT_SIZE> &flags_arg= HTON_NO_FLAGS,
 
212
                size_t savepoint_offset_arg= 0,
 
213
                bool support_2pc= false);
209
214
 
210
215
  virtual ~StorageEngine();
211
216
 
212
 
protected:
213
 
  virtual int doGetTableDefinition(Session &session,
214
 
                                   const drizzled::identifier::Table &identifier,
215
 
                                   message::Table &table_message)
 
217
  virtual int doGetTableDefinition(Session& session,
 
218
                                   const char *path,
 
219
                                   const char *db,
 
220
                                   const char *table_name,
 
221
                                   const bool is_tmp,
 
222
                                   drizzled::message::Table *table_proto)
216
223
  {
217
224
    (void)session;
218
 
    (void)identifier;
219
 
    (void)table_message;
 
225
    (void)path;
 
226
    (void)db;
 
227
    (void)table_name;
 
228
    (void)is_tmp;
 
229
    (void)table_proto;
220
230
 
221
231
    return ENOENT;
222
232
  }
223
233
 
224
234
  /* Old style cursor errors */
225
 
  void print_keydup_error(uint32_t key_nr, const char *msg, const Table &table) const;
226
 
  virtual bool get_error_message(int error, String *buf) const;
227
 
 
 
235
protected:
 
236
  void print_keydup_error(uint32_t key_nr, const char *msg, Table &table);
 
237
  void print_error(int error, myf errflag, Table *table= NULL);
 
238
  virtual bool get_error_message(int error, String *buf);
228
239
public:
229
 
  virtual void print_error(int error, myf errflag, const Table& table) const;
 
240
  virtual void print_error(int error, myf errflag, Table& table);
 
241
 
 
242
  /*
 
243
    each storage engine has it's own memory area (actually a pointer)
 
244
    in the session, for storing per-connection information.
 
245
    It is accessed as
 
246
 
 
247
      session->ha_data[xxx_engine.slot]
 
248
 
 
249
   slot number is initialized by MySQL after xxx_init() is called.
 
250
  */
 
251
  uint32_t slot;
 
252
 
 
253
  inline uint32_t getSlot (void) { return slot; }
 
254
  inline uint32_t getSlot (void) const { return slot; }
 
255
  inline void setSlot (uint32_t value) { slot= value; }
 
256
 
 
257
  bool has_2pc()
 
258
  {
 
259
    return two_phase_commit;
 
260
  }
 
261
 
 
262
 
 
263
  bool is_enabled() const
 
264
  {
 
265
    return enabled;
 
266
  }
230
267
 
231
268
  bool is_user_selectable() const
232
269
  {
240
277
 
241
278
  // @todo match check_flag interface
242
279
  virtual uint32_t index_flags(enum  ha_key_alg) const { return 0; }
243
 
  virtual void startStatement(Session *session)
244
 
  {
245
 
    doStartStatement(session);
246
 
  }
247
 
  virtual void endStatement(Session *session)
248
 
  {
249
 
    doEndStatement(session);
250
 
  }
 
280
 
 
281
 
 
282
  void enable() { enabled= true; }
 
283
  void disable() { enabled= false; }
251
284
 
252
285
  /*
253
 
   * Called during Session::cleanup() for all engines
254
 
   */
 
286
    StorageEngine methods:
 
287
 
 
288
    close_connection is only called if
 
289
    session->ha_data[xxx_engine.slot] is non-zero, so even if you don't need
 
290
    this storage area - set it to something, so that MySQL would know
 
291
    this storage engine was accessed in this connection
 
292
  */
255
293
  virtual int close_connection(Session  *)
256
294
  {
257
295
    return 0;
258
296
  }
259
 
 
260
 
  virtual Cursor *create(Table &)= 0;
 
297
  /*
 
298
    'all' is true if it's a real commit, that makes persistent changes
 
299
    'all' is false if it's not in fact a commit but an end of the
 
300
    statement that is part of the transaction.
 
301
    NOTE 'all' is also false in auto-commit mode where 'end of statement'
 
302
    and 'real commit' mean the same event.
 
303
  */
 
304
  virtual int  commit(Session *, bool)
 
305
  {
 
306
    return 0;
 
307
  }
 
308
 
 
309
  virtual int  rollback(Session *, bool)
 
310
  {
 
311
    return 0;
 
312
  }
 
313
 
 
314
  /*
 
315
    The void * points to an uninitialized storage area of requested size
 
316
    (see savepoint_offset description)
 
317
  */
 
318
  int savepoint_set(Session *session, void *sp)
 
319
  {
 
320
    return savepoint_set_hook(session, (unsigned char *)sp+savepoint_offset);
 
321
  }
 
322
 
 
323
  /*
 
324
    The void * points to a storage area, that was earlier passed
 
325
    to the savepoint_set call
 
326
  */
 
327
  int savepoint_rollback(Session *session, void *sp)
 
328
  {
 
329
     return savepoint_rollback_hook(session,
 
330
                                    (unsigned char *)sp+savepoint_offset);
 
331
  }
 
332
 
 
333
  int savepoint_release(Session *session, void *sp)
 
334
  {
 
335
    return savepoint_release_hook(session,
 
336
                                  (unsigned char *)sp+savepoint_offset);
 
337
  }
 
338
 
 
339
  virtual int  prepare(Session *, bool) { return 0; }
 
340
  virtual int  recover(XID *, uint32_t) { return 0; }
 
341
  virtual int  commit_by_xid(XID *) { return 0; }
 
342
  virtual int  rollback_by_xid(XID *) { return 0; }
 
343
  virtual Cursor *create(TableShare &, drizzled::memory::Root *)= 0;
261
344
  /* args: path */
 
345
  virtual void drop_database(char*) { }
 
346
  virtual int start_consistent_snapshot(Session *) { return 0; }
262
347
  virtual bool flush_logs() { return false; }
263
348
  virtual bool show_status(Session *, stat_print_fn *, enum ha_stat_type)
264
349
  {
265
350
    return false;
266
351
  }
267
352
 
 
353
  virtual int release_temporary_latches(Session *) { return false; }
 
354
 
268
355
  /**
269
356
    If frm_error() is called then we will use this to find out what file
270
357
    extentions exist for the storage engine. This is also used by the default
279
366
  virtual const char **bas_ext() const =0;
280
367
 
281
368
protected:
282
 
  virtual int doCreateTable(Session &session,
283
 
                            Table &table_arg,
284
 
                            const drizzled::identifier::Table &identifier,
285
 
                            message::Table &message)= 0;
286
 
 
287
 
  virtual int doRenameTable(Session &session,
288
 
                            const drizzled::identifier::Table &from, const drizzled::identifier::Table &to)= 0;
289
 
 
290
 
  virtual int doDropTable(Session &session,
291
 
                          const drizzled::identifier::Table &identifier)= 0;
292
 
 
293
 
  virtual void doGetTableIdentifiers(CachedDirectory &directory,
294
 
                                     const drizzled::identifier::Schema &schema_identifier,
295
 
                                     identifier::Table::vector &set_of_identifiers)= 0;
296
 
 
297
 
  virtual bool doDoesTableExist(Session& session, const drizzled::identifier::Table &identifier);
298
 
 
299
 
  virtual bool doCanCreateTable(const drizzled::identifier::Table &identifier)
300
 
  { (void)identifier;  return true; }
 
369
  virtual int doCreateTable(Session *session,
 
370
                            const char *table_name,
 
371
                            Table& table_arg,
 
372
                            drizzled::message::Table& proto)= 0;
 
373
 
 
374
  virtual int doRenameTable(Session* session,
 
375
                            const char *from, const char *to);
 
376
 
301
377
 
302
378
public:
303
379
 
304
 
  friend class AddSchemaNames;
305
 
  friend class AddTableIdentifier;
306
 
  friend class AlterSchema;
307
 
  friend class CanCreateTable;
308
 
  friend class CreateSchema;
309
 
  friend class DropSchema;
310
 
  friend class DropTable;
311
 
  friend class DropTables;
312
 
  friend class FindEngineByName;
313
 
  friend class Ha_delete_table_error_handler;
314
 
  friend class StorageEngineCloseConnection;
315
 
  friend class StorageEngineDoesTableExist;
316
 
  friend class StorageEngineGetSchemaDefinition;
317
 
  friend class StorageEngineGetTableDefinition;
318
 
  friend class DropTableByIdentifier;
319
 
 
320
 
  int renameTable(Session &session, const drizzled::identifier::Table &from, const drizzled::identifier::Table &to);
 
380
  int renameTable(Session *session, const char *from, const char *to) 
 
381
  {
 
382
    setTransactionReadWrite(*session);
 
383
 
 
384
    return doRenameTable(session, from, to);
 
385
  }
 
386
 
 
387
  // TODO: move these to protected
 
388
  virtual void doGetTableNames(drizzled::CachedDirectory &directory,
 
389
                               std::string& db_name,
 
390
                               std::set<std::string>& set_of_names);
 
391
  virtual int doDropTable(Session& session,
 
392
                          const std::string table_path)= 0;
 
393
 
 
394
  const char *checkLowercaseNames(const char *path, char *tmp_path);
321
395
 
322
396
  /* Class Methods for operating on plugin */
323
397
  static bool addPlugin(plugin::StorageEngine *engine);
324
398
  static void removePlugin(plugin::StorageEngine *engine);
325
399
 
326
 
  static message::table::shared_ptr getTableMessage(Session& session,
327
 
                                                    const drizzled::identifier::Table &identifier,
328
 
                                                    bool include_temporary_tables= true);
329
 
  static bool doesTableExist(Session &session,
330
 
                             const drizzled::identifier::Table &identifier,
331
 
                             bool include_temporary_tables= true);
332
 
 
333
 
  static plugin::StorageEngine *findByName(const std::string &find_str);
334
 
  static plugin::StorageEngine *findByName(Session& session, const std::string &find_str);
335
 
 
 
400
  static int getTableDefinition(Session& session,
 
401
                                TableIdentifier &identifier,
 
402
                                message::Table *table_proto= NULL);
 
403
  static int getTableDefinition(Session& session,
 
404
                                const char* path,
 
405
                                const char *db,
 
406
                                const char *table_name,
 
407
                                const bool is_tmp,
 
408
                                message::Table *table_proto= NULL);
 
409
 
 
410
  static plugin::StorageEngine *findByName(std::string find_str);
 
411
  static plugin::StorageEngine *findByName(Session& session,
 
412
                                           std::string find_str);
336
413
  static void closeConnection(Session* session);
337
414
  static void dropDatabase(char* path);
 
415
  static int commitOrRollbackByXID(XID *xid, bool commit);
 
416
  static int releaseTemporaryLatches(Session *session);
338
417
  static bool flushLogs(plugin::StorageEngine *db_type);
339
 
 
340
 
  static bool dropTable(Session& session,
341
 
                        const drizzled::identifier::Table &identifier);
342
 
  static bool dropTable(Session& session,
343
 
                        const drizzled::identifier::Table &identifier,
344
 
                        drizzled::error_t &error);
345
 
 
346
 
  static bool dropTable(Session& session,
347
 
                        StorageEngine &engine,
348
 
                        identifier::Table::const_reference identifier,
349
 
                        drizzled::error_t &error);
350
 
 
351
 
  static void getIdentifiers(Session &session,
352
 
                             const identifier::Schema &schema_identifier,
353
 
                             identifier::Table::vector &set_of_identifiers);
354
 
 
355
 
  // Check to see if any SE objects to creation.
356
 
  static bool canCreateTable(const drizzled::identifier::Table &identifier);
357
 
 
358
 
  // @note All schema methods defined here
359
 
  static void getIdentifiers(Session &session, identifier::Schema::vector &schemas);
360
 
  static message::schema::shared_ptr getSchemaDefinition(const drizzled::identifier::Table &identifier);
361
 
  static message::schema::shared_ptr getSchemaDefinition(const drizzled::identifier::Schema &identifier);
362
 
  static bool doesSchemaExist(const drizzled::identifier::Schema &identifier);
363
 
  static const CHARSET_INFO *getSchemaCollation(const drizzled::identifier::Schema &identifier);
364
 
  static bool createSchema(const drizzled::message::Schema &schema_message);
365
 
  static bool dropSchema(Session &session,
366
 
                         identifier::Schema::const_reference identifier,
367
 
                         message::schema::const_reference schema_message);
368
 
  static bool alterSchema(const drizzled::message::Schema &schema_message);
369
 
 
370
 
  // @note make private/protected
371
 
protected:
372
 
  virtual void doGetSchemaIdentifiers(identifier::Schema::vector&)
373
 
  { }
374
 
 
375
 
  virtual drizzled::message::schema::shared_ptr doGetSchemaDefinition(const drizzled::identifier::Schema&)
376
 
  { 
377
 
    return drizzled::message::schema::shared_ptr(); 
378
 
  }
379
 
 
380
 
  virtual bool doCreateSchema(const drizzled::message::Schema&)
381
 
  { return false; }
382
 
 
383
 
  virtual bool doAlterSchema(const drizzled::message::Schema&)
384
 
  { return false; }
385
 
 
386
 
  virtual bool doDropSchema(const drizzled::identifier::Schema&)
387
 
  { return false; }
388
 
 
389
 
public:
 
418
  static int recover(HASH *commit_list);
 
419
  static int startConsistentSnapshot(Session *session);
 
420
  static int dropTable(Session& session,
 
421
                       drizzled::TableIdentifier &identifier,
 
422
                       bool generate_warning);
 
423
  static void getTableNames(std::string& db_name, std::set<std::string> &set_of_names);
 
424
 
390
425
  static inline const std::string &resolveName(const StorageEngine *engine)
391
426
  {
392
427
    return engine == NULL ? UNKNOWN_STRING : engine->getName();
393
428
  }
394
429
 
395
 
  static bool createTable(Session &session,
396
 
                          const identifier::Table &identifier,
397
 
                          message::Table& table_message);
 
430
  static int createTable(Session& session,
 
431
                         drizzled::TableIdentifier &identifier,
 
432
                         bool update_create_info,
 
433
                         drizzled::message::Table& table_proto,
 
434
                         bool used= true);
398
435
 
399
436
  static void removeLostTemporaryTables(Session &session, const char *directory);
400
437
 
401
 
  Cursor *getCursor(Table &share);
 
438
  Cursor *getCursor(TableShare &share, drizzled::memory::Root *alloc);
402
439
 
403
440
  uint32_t max_record_length() const
404
 
  { return std::min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
 
441
  { return std::min((unsigned int)HA_MAX_REC_LENGTH, max_supported_record_length()); }
405
442
  uint32_t max_keys() const
406
 
  { return std::min(MAX_KEY, max_supported_keys()); }
 
443
  { return std::min((unsigned int)MAX_KEY, max_supported_keys()); }
407
444
  uint32_t max_key_parts() const
408
 
  { return std::min(MAX_REF_PARTS, max_supported_key_parts()); }
 
445
  { return std::min((unsigned int)MAX_REF_PARTS, max_supported_key_parts()); }
409
446
  uint32_t max_key_length() const
410
 
  { return std::min(MAX_KEY_LENGTH, max_supported_key_length()); }
 
447
  { return std::min((unsigned int)MAX_KEY_LENGTH, max_supported_key_length()); }
411
448
  uint32_t max_key_part_length(void) const
412
 
  { return std::min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
 
449
  { return std::min((unsigned int)MAX_KEY_LENGTH, max_supported_key_part_length()); }
413
450
 
414
451
  virtual uint32_t max_supported_record_length(void) const
415
452
  { return HA_MAX_REC_LENGTH; }
419
456
  virtual uint32_t max_supported_key_part_length(void) const { return 255; }
420
457
 
421
458
  /* TODO-> Make private */
422
 
protected:
423
 
  static int deleteDefinitionFromPath(const drizzled::identifier::Table &identifier);
424
 
  static int renameDefinitionFromPath(const drizzled::identifier::Table &dest, const drizzled::identifier::Table &src);
425
 
  static int writeDefinitionFromPath(const drizzled::identifier::Table &identifier, message::Table &proto);
426
 
  static bool readTableFile(const std::string &path, message::Table &table_message);
427
 
 
428
 
public:
429
 
  /* 
430
 
   * The below are simple virtual overrides for the plugin::MonitoredInTransaction
431
 
   * interface.
432
 
   */
433
 
  virtual bool participatesInSqlTransaction() const
434
 
  {
435
 
    return false; /* plugin::StorageEngine is non-transactional in terms of SQL */
436
 
  }
437
 
  virtual bool participatesInXaTransaction() const
438
 
  {
439
 
    return false; /* plugin::StorageEngine is non-transactional in terms of XA */
440
 
  }
441
 
  virtual bool alwaysRegisterForXaTransaction() const
442
 
  {
443
 
    return false;
444
 
  }
445
 
 
446
 
  virtual bool validateCreateTableOption(const std::string &key, const std::string &state)
447
 
  {
448
 
    (void)key;
449
 
    (void)state;
450
 
 
451
 
    return false;
452
 
  }
453
 
 
454
 
  virtual bool validateCreateSchemaOption(const std::string &key, const std::string &state)
455
 
  {
456
 
    (void)key;
457
 
    (void)state;
458
 
 
459
 
    return false;
460
 
  }
 
459
  static int readDefinitionFromPath(TableIdentifier &identifier, message::Table &proto);
 
460
  static int deleteDefinitionFromPath(TableIdentifier &identifier);
 
461
  static int renameDefinitionFromPath(TableIdentifier &dest, TableIdentifier &src);
 
462
  static int writeDefinitionFromPath(TableIdentifier &identifier, message::Table &proto);
461
463
};
462
464
 
463
 
std::ostream& operator<<(std::ostream& output, const StorageEngine &engine);
464
 
 
465
465
} /* namespace plugin */
466
466
} /* namespace drizzled */
467
467