~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/storage_engine.h

  • Committer: Stewart Smith
  • Date: 2011-01-14 05:13:52 UTC
  • mto: (2086.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 2087.
  • Revision ID: stewart@flamingspork.com-20110114051352-ytdw2wn6thbf4dr8
fix tpyo

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
27
#include <drizzled/message.h>
30
28
#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>
 
29
#include "drizzled/plugin/plugin.h"
 
30
#include "drizzled/sql_string.h"
 
31
#include "drizzled/identifier.h"
 
32
#include "drizzled/cached_directory.h"
 
33
#include "drizzled/plugin/monitored_in_transaction.h"
 
34
 
 
35
#include <drizzled/error_t.h>
35
36
 
36
37
#include <bitset>
37
38
#include <string>
38
39
#include <vector>
39
40
#include <set>
40
41
 
41
 
#include <drizzled/visibility.h>
42
 
 
43
42
namespace drizzled
44
43
{
45
44
 
49
48
typedef struct st_hash HASH;
50
49
 
51
50
class TableShare;
 
51
typedef drizzle_lex_string LEX_STRING;
52
52
typedef bool (stat_print_fn)(Session *session, const char *type, uint32_t type_len,
53
53
                             const char *file, uint32_t file_len,
54
54
                             const char *status, uint32_t status_len);
124
124
typedef std::set<std::string> TableNameList;
125
125
 
126
126
extern const std::string UNKNOWN_STRING;
127
 
extern DRIZZLED_API const std::string DEFAULT_DEFINITION_FILE_EXT;
 
127
extern const std::string DEFAULT_DEFINITION_FILE_EXT;
128
128
 
129
129
 
130
130
/*
136
136
 
137
137
  static StorageEngine { ... } xxx_engine;
138
138
*/
139
 
class DRIZZLED_API StorageEngine :
140
 
  public Plugin,
141
 
  public MonitoredInTransaction
 
139
class StorageEngine : public Plugin,
 
140
                      public MonitoredInTransaction
142
141
{
143
142
  friend class SEAPITester;
144
143
public:
211
210
 
212
211
protected:
213
212
  virtual int doGetTableDefinition(Session &session,
214
 
                                   const drizzled::identifier::Table &identifier,
 
213
                                   const drizzled::TableIdentifier &identifier,
215
214
                                   message::Table &table_message)
216
215
  {
217
216
    (void)session;
222
221
  }
223
222
 
224
223
  /* 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;
 
224
  void print_keydup_error(uint32_t key_nr, const char *msg, Table &table);
 
225
  virtual bool get_error_message(int error, String *buf);
227
226
 
228
227
public:
229
 
  virtual void print_error(int error, myf errflag, const Table& table) const;
 
228
  virtual void print_error(int error, myf errflag, Table& table);
230
229
 
231
230
  bool is_user_selectable() const
232
231
  {
281
280
protected:
282
281
  virtual int doCreateTable(Session &session,
283
282
                            Table &table_arg,
284
 
                            const drizzled::identifier::Table &identifier,
 
283
                            const drizzled::TableIdentifier &identifier,
285
284
                            message::Table &message)= 0;
286
285
 
287
286
  virtual int doRenameTable(Session &session,
288
 
                            const drizzled::identifier::Table &from, const drizzled::identifier::Table &to)= 0;
 
287
                            const drizzled::TableIdentifier &from, const drizzled::TableIdentifier &to)= 0;
289
288
 
290
289
  virtual int doDropTable(Session &session,
291
 
                          const drizzled::identifier::Table &identifier)= 0;
 
290
                          const drizzled::TableIdentifier &identifier)= 0;
292
291
 
293
292
  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)
 
293
                                     const drizzled::SchemaIdentifier &schema_identifier,
 
294
                                     TableIdentifier::vector &set_of_identifiers)= 0;
 
295
 
 
296
  virtual bool doDoesTableExist(Session& session, const drizzled::TableIdentifier &identifier);
 
297
 
 
298
  virtual bool doCanCreateTable(const drizzled::TableIdentifier &identifier)
300
299
  { (void)identifier;  return true; }
301
300
 
302
301
public:
317
316
  friend class StorageEngineGetTableDefinition;
318
317
  friend class DropTableByIdentifier;
319
318
 
320
 
  int renameTable(Session &session, const drizzled::identifier::Table &from, const drizzled::identifier::Table &to);
 
319
  int renameTable(Session &session, const drizzled::TableIdentifier &from, const drizzled::TableIdentifier &to);
321
320
 
322
321
  /* Class Methods for operating on plugin */
323
322
  static bool addPlugin(plugin::StorageEngine *engine);
324
323
  static void removePlugin(plugin::StorageEngine *engine);
325
324
 
326
 
  static message::table::shared_ptr getTableMessage(Session& session,
327
 
                                                    const drizzled::identifier::Table &identifier,
328
 
                                                    bool include_temporary_tables= true);
 
325
  static int getTableDefinition(Session& session,
 
326
                                const drizzled::TableIdentifier &identifier,
 
327
                                message::table::shared_ptr &table_proto,
 
328
                                bool include_temporary_tables= true);
329
329
  static bool doesTableExist(Session &session,
330
 
                             const drizzled::identifier::Table &identifier,
 
330
                             const drizzled::TableIdentifier &identifier,
331
331
                             bool include_temporary_tables= true);
332
332
 
333
333
  static plugin::StorageEngine *findByName(const std::string &find_str);
338
338
  static bool flushLogs(plugin::StorageEngine *db_type);
339
339
 
340
340
  static bool dropTable(Session& session,
341
 
                        const drizzled::identifier::Table &identifier);
 
341
                        const drizzled::TableIdentifier &identifier);
342
342
  static bool dropTable(Session& session,
343
 
                        const drizzled::identifier::Table &identifier,
 
343
                        const drizzled::TableIdentifier &identifier,
344
344
                        drizzled::error_t &error);
345
345
 
346
346
  static bool dropTable(Session& session,
347
347
                        StorageEngine &engine,
348
 
                        identifier::Table::const_reference identifier,
 
348
                        TableIdentifier::const_reference identifier,
349
349
                        drizzled::error_t &error);
350
350
 
351
351
  static void getIdentifiers(Session &session,
352
 
                             const identifier::Schema &schema_identifier,
353
 
                             identifier::Table::vector &set_of_identifiers);
 
352
                             const SchemaIdentifier &schema_identifier,
 
353
                             TableIdentifier::vector &set_of_identifiers);
354
354
 
355
355
  // Check to see if any SE objects to creation.
356
 
  static bool canCreateTable(const drizzled::identifier::Table &identifier);
 
356
  static bool canCreateTable(const drizzled::TableIdentifier &identifier);
357
357
 
358
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);
 
359
  static void getIdentifiers(Session &session, SchemaIdentifier::vector &schemas);
 
360
  static bool getSchemaDefinition(const drizzled::TableIdentifier &identifier, message::schema::shared_ptr &proto);
 
361
  static bool getSchemaDefinition(const drizzled::SchemaIdentifier &identifier, message::schema::shared_ptr &proto);
 
362
  static bool doesSchemaExist(const drizzled::SchemaIdentifier &identifier);
 
363
  static const CHARSET_INFO *getSchemaCollation(const drizzled::SchemaIdentifier &identifier);
364
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);
 
365
  static bool dropSchema(drizzled::Session& session, SchemaIdentifier::const_reference identifier);
368
366
  static bool alterSchema(const drizzled::message::Schema &schema_message);
369
367
 
370
368
  // @note make private/protected
371
369
protected:
372
 
  virtual void doGetSchemaIdentifiers(identifier::Schema::vector&)
 
370
  virtual void doGetSchemaIdentifiers(SchemaIdentifier::vector&)
373
371
  { }
374
372
 
375
 
  virtual drizzled::message::schema::shared_ptr doGetSchemaDefinition(const drizzled::identifier::Schema&)
 
373
  virtual bool doGetSchemaDefinition(const drizzled::SchemaIdentifier&, drizzled::message::schema::shared_ptr&)
376
374
  { 
377
 
    return drizzled::message::schema::shared_ptr(); 
 
375
    return false; 
378
376
  }
379
377
 
380
378
  virtual bool doCreateSchema(const drizzled::message::Schema&)
383
381
  virtual bool doAlterSchema(const drizzled::message::Schema&)
384
382
  { return false; }
385
383
 
386
 
  virtual bool doDropSchema(const drizzled::identifier::Schema&)
 
384
  virtual bool doDropSchema(const drizzled::SchemaIdentifier&)
387
385
  { return false; }
388
386
 
389
387
public:
392
390
    return engine == NULL ? UNKNOWN_STRING : engine->getName();
393
391
  }
394
392
 
395
 
  static bool createTable(Session &session,
396
 
                          const identifier::Table &identifier,
397
 
                          message::Table& table_message);
 
393
  static int createTable(Session& session,
 
394
                         const drizzled::TableIdentifier &identifier,
 
395
                         message::Table& table_proto);
398
396
 
399
397
  static void removeLostTemporaryTables(Session &session, const char *directory);
400
398
 
401
399
  Cursor *getCursor(Table &share);
402
400
 
403
401
  uint32_t max_record_length() const
404
 
  { return std::min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
 
402
  { return std::min((unsigned int)HA_MAX_REC_LENGTH, max_supported_record_length()); }
405
403
  uint32_t max_keys() const
406
 
  { return std::min(MAX_KEY, max_supported_keys()); }
 
404
  { return std::min((unsigned int)MAX_KEY, max_supported_keys()); }
407
405
  uint32_t max_key_parts() const
408
 
  { return std::min(MAX_REF_PARTS, max_supported_key_parts()); }
 
406
  { return std::min((unsigned int)MAX_REF_PARTS, max_supported_key_parts()); }
409
407
  uint32_t max_key_length() const
410
 
  { return std::min(MAX_KEY_LENGTH, max_supported_key_length()); }
 
408
  { return std::min((unsigned int)MAX_KEY_LENGTH, max_supported_key_length()); }
411
409
  uint32_t max_key_part_length(void) const
412
 
  { return std::min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
 
410
  { return std::min((unsigned int)MAX_KEY_LENGTH, max_supported_key_part_length()); }
413
411
 
414
412
  virtual uint32_t max_supported_record_length(void) const
415
413
  { return HA_MAX_REC_LENGTH; }
420
418
 
421
419
  /* TODO-> Make private */
422
420
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);
 
421
  static int deleteDefinitionFromPath(const drizzled::TableIdentifier &identifier);
 
422
  static int renameDefinitionFromPath(const drizzled::TableIdentifier &dest, const drizzled::TableIdentifier &src);
 
423
  static int writeDefinitionFromPath(const drizzled::TableIdentifier &identifier, message::Table &proto);
426
424
  static bool readTableFile(const std::string &path, message::Table &table_message);
427
425
 
428
426
public: