~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/storage_engine.h

  • Committer: Brian Aker
  • Date: 2010-12-24 03:44:02 UTC
  • mfrom: (2015.1.3 timestamp)
  • mto: This revision was merged to the branch mainline in revision 2028.
  • Revision ID: brian@tangent.org-20101224034402-n1hpg1yxwjz59hpw
Finish up issues with unsigned/int by fixing cast().

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"
35
34
 
36
35
#include <bitset>
37
36
#include <string>
38
37
#include <vector>
39
38
#include <set>
40
39
 
41
 
#include <drizzled/visibility.h>
42
 
 
43
40
namespace drizzled
44
41
{
45
42
 
49
46
typedef struct st_hash HASH;
50
47
 
51
48
class TableShare;
 
49
typedef drizzle_lex_string LEX_STRING;
52
50
typedef bool (stat_print_fn)(Session *session, const char *type, uint32_t type_len,
53
51
                             const char *file, uint32_t file_len,
54
52
                             const char *status, uint32_t status_len);
124
122
typedef std::set<std::string> TableNameList;
125
123
 
126
124
extern const std::string UNKNOWN_STRING;
127
 
extern DRIZZLED_API const std::string DEFAULT_DEFINITION_FILE_EXT;
 
125
extern const std::string DEFAULT_DEFINITION_FILE_EXT;
128
126
 
129
127
 
130
128
/*
136
134
 
137
135
  static StorageEngine { ... } xxx_engine;
138
136
*/
139
 
class DRIZZLED_API StorageEngine :
140
 
  public Plugin,
141
 
  public MonitoredInTransaction
 
137
class StorageEngine : public Plugin,
 
138
                      public MonitoredInTransaction
142
139
{
143
140
  friend class SEAPITester;
144
141
public:
145
142
  typedef uint64_t Table_flags;
146
143
 
147
144
private:
 
145
  const std::bitset<HTON_BIT_SIZE> flags; /* global Cursor flags */
 
146
 
148
147
  static EngineVector &getSchemaEngines();
149
 
  const std::bitset<HTON_BIT_SIZE> flags; /* global Cursor flags */
150
 
 
151
148
 
152
149
  virtual void setTransactionReadWrite(Session& session);
153
150
 
204
201
  pthread_mutex_t proto_cache_mutex;
205
202
 
206
203
public:
 
204
 
207
205
  StorageEngine(const std::string name_arg,
208
206
                const std::bitset<HTON_BIT_SIZE> &flags_arg= HTON_NO_FLAGS);
209
207
 
210
208
  virtual ~StorageEngine();
211
209
 
212
 
protected:
213
210
  virtual int doGetTableDefinition(Session &session,
214
 
                                   const drizzled::identifier::Table &identifier,
 
211
                                   const drizzled::TableIdentifier &identifier,
215
212
                                   message::Table &table_message)
216
213
  {
217
214
    (void)session;
222
219
  }
223
220
 
224
221
  /* 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
 
 
 
222
protected:
 
223
  void print_keydup_error(uint32_t key_nr, const char *msg, Table &table);
 
224
  void print_error(int error, myf errflag, Table *table= NULL);
 
225
  virtual bool get_error_message(int error, String *buf);
228
226
public:
229
 
  virtual void print_error(int error, myf errflag, const Table& table) const;
 
227
  virtual void print_error(int error, myf errflag, Table& table);
230
228
 
231
229
  bool is_user_selectable() const
232
230
  {
256
254
  {
257
255
    return 0;
258
256
  }
259
 
 
260
257
  virtual Cursor *create(Table &)= 0;
261
258
  /* args: path */
262
259
  virtual bool flush_logs() { return false; }
281
278
protected:
282
279
  virtual int doCreateTable(Session &session,
283
280
                            Table &table_arg,
284
 
                            const drizzled::identifier::Table &identifier,
 
281
                            const drizzled::TableIdentifier &identifier,
285
282
                            message::Table &message)= 0;
286
283
 
287
284
  virtual int doRenameTable(Session &session,
288
 
                            const drizzled::identifier::Table &from, const drizzled::identifier::Table &to)= 0;
 
285
                            const drizzled::TableIdentifier &from, const drizzled::TableIdentifier &to)= 0;
 
286
 
 
287
public:
 
288
 
 
289
  int renameTable(Session &session, const drizzled::TableIdentifier &from, const drizzled::TableIdentifier &to);
 
290
 
 
291
  virtual void doGetTableIdentifiers(CachedDirectory &directory,
 
292
                                     const drizzled::SchemaIdentifier &schema_identifier,
 
293
                                     TableIdentifier::vector &set_of_identifiers)= 0;
289
294
 
290
295
  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; }
301
 
 
302
 
public:
303
 
 
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);
 
296
                          const drizzled::TableIdentifier &identifier)= 0;
321
297
 
322
298
  /* Class Methods for operating on plugin */
323
299
  static bool addPlugin(plugin::StorageEngine *engine);
324
300
  static void removePlugin(plugin::StorageEngine *engine);
325
301
 
326
 
  static message::table::shared_ptr getTableMessage(Session& session,
327
 
                                                    const drizzled::identifier::Table &identifier,
328
 
                                                    bool include_temporary_tables= true);
 
302
  static int getTableDefinition(Session& session,
 
303
                                const drizzled::TableIdentifier &identifier,
 
304
                                message::table::shared_ptr &table_proto,
 
305
                                bool include_temporary_tables= true);
329
306
  static bool doesTableExist(Session &session,
330
 
                             const drizzled::identifier::Table &identifier,
 
307
                             const drizzled::TableIdentifier &identifier,
331
308
                             bool include_temporary_tables= true);
332
309
 
 
310
  virtual bool doDoesTableExist(Session& session, const drizzled::TableIdentifier &identifier);
 
311
 
333
312
  static plugin::StorageEngine *findByName(const std::string &find_str);
334
313
  static plugin::StorageEngine *findByName(Session& session, const std::string &find_str);
335
314
 
336
315
  static void closeConnection(Session* session);
337
316
  static void dropDatabase(char* path);
338
317
  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
 
 
 
318
  static int dropTable(Session& session,
 
319
                       const drizzled::TableIdentifier &identifier);
 
320
  static int dropTable(Session& session,
 
321
                       StorageEngine &engine,
 
322
                       const drizzled::TableIdentifier &identifier);
351
323
  static void getIdentifiers(Session &session,
352
 
                             const identifier::Schema &schema_identifier,
353
 
                             identifier::Table::vector &set_of_identifiers);
 
324
                             const SchemaIdentifier &schema_identifier,
 
325
                             TableIdentifier::vector &set_of_identifiers);
354
326
 
355
327
  // Check to see if any SE objects to creation.
356
 
  static bool canCreateTable(const drizzled::identifier::Table &identifier);
 
328
  static bool canCreateTable(const drizzled::TableIdentifier &identifier);
 
329
  virtual bool doCanCreateTable(const drizzled::TableIdentifier &identifier)
 
330
  { (void)identifier;  return true; }
357
331
 
358
332
  // @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);
 
333
  static void getIdentifiers(Session &session, SchemaIdentifier::vector &schemas);
 
334
  static bool getSchemaDefinition(const drizzled::TableIdentifier &identifier, message::schema::shared_ptr &proto);
 
335
  static bool getSchemaDefinition(const drizzled::SchemaIdentifier &identifier, message::schema::shared_ptr &proto);
 
336
  static bool doesSchemaExist(const drizzled::SchemaIdentifier &identifier);
 
337
  static const CHARSET_INFO *getSchemaCollation(const drizzled::SchemaIdentifier &identifier);
364
338
  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);
 
339
  static bool dropSchema(const drizzled::SchemaIdentifier &identifier);
368
340
  static bool alterSchema(const drizzled::message::Schema &schema_message);
369
341
 
370
342
  // @note make private/protected
371
 
protected:
372
 
  virtual void doGetSchemaIdentifiers(identifier::Schema::vector&)
 
343
  virtual void doGetSchemaIdentifiers(SchemaIdentifier::vector&)
373
344
  { }
374
345
 
375
 
  virtual drizzled::message::schema::shared_ptr doGetSchemaDefinition(const drizzled::identifier::Schema&)
 
346
  virtual bool doGetSchemaDefinition(const drizzled::SchemaIdentifier&, drizzled::message::schema::shared_ptr&)
376
347
  { 
377
 
    return drizzled::message::schema::shared_ptr(); 
 
348
    return false; 
378
349
  }
379
350
 
380
351
  virtual bool doCreateSchema(const drizzled::message::Schema&)
383
354
  virtual bool doAlterSchema(const drizzled::message::Schema&)
384
355
  { return false; }
385
356
 
386
 
  virtual bool doDropSchema(const drizzled::identifier::Schema&)
 
357
  virtual bool doDropSchema(const drizzled::SchemaIdentifier&)
387
358
  { return false; }
388
359
 
389
 
public:
390
360
  static inline const std::string &resolveName(const StorageEngine *engine)
391
361
  {
392
362
    return engine == NULL ? UNKNOWN_STRING : engine->getName();
393
363
  }
394
364
 
395
 
  static bool createTable(Session &session,
396
 
                          const identifier::Table &identifier,
397
 
                          message::Table& table_message);
 
365
  static int createTable(Session& session,
 
366
                         const drizzled::TableIdentifier &identifier,
 
367
                         message::Table& table_proto);
398
368
 
399
369
  static void removeLostTemporaryTables(Session &session, const char *directory);
400
370
 
401
371
  Cursor *getCursor(Table &share);
402
372
 
403
373
  uint32_t max_record_length() const
404
 
  { return std::min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
 
374
  { return std::min((unsigned int)HA_MAX_REC_LENGTH, max_supported_record_length()); }
405
375
  uint32_t max_keys() const
406
 
  { return std::min(MAX_KEY, max_supported_keys()); }
 
376
  { return std::min((unsigned int)MAX_KEY, max_supported_keys()); }
407
377
  uint32_t max_key_parts() const
408
 
  { return std::min(MAX_REF_PARTS, max_supported_key_parts()); }
 
378
  { return std::min((unsigned int)MAX_REF_PARTS, max_supported_key_parts()); }
409
379
  uint32_t max_key_length() const
410
 
  { return std::min(MAX_KEY_LENGTH, max_supported_key_length()); }
 
380
  { return std::min((unsigned int)MAX_KEY_LENGTH, max_supported_key_length()); }
411
381
  uint32_t max_key_part_length(void) const
412
 
  { return std::min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
 
382
  { return std::min((unsigned int)MAX_KEY_LENGTH, max_supported_key_part_length()); }
413
383
 
414
384
  virtual uint32_t max_supported_record_length(void) const
415
385
  { return HA_MAX_REC_LENGTH; }
419
389
  virtual uint32_t max_supported_key_part_length(void) const { return 255; }
420
390
 
421
391
  /* 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);
 
392
  static int deleteDefinitionFromPath(const drizzled::TableIdentifier &identifier);
 
393
  static int renameDefinitionFromPath(const drizzled::TableIdentifier &dest, const drizzled::TableIdentifier &src);
 
394
  static int writeDefinitionFromPath(const drizzled::TableIdentifier &identifier, message::Table &proto);
426
395
  static bool readTableFile(const std::string &path, message::Table &table_message);
427
396
 
428
397
public:
460
429
  }
461
430
};
462
431
 
463
 
std::ostream& operator<<(std::ostream& output, const StorageEngine &engine);
464
 
 
465
432
} /* namespace plugin */
466
433
} /* namespace drizzled */
467
434