~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/storage_engine.h

  • Committer: Brian Aker
  • Date: 2011-01-02 05:13:03 UTC
  • mfrom: (2044.1.1 trunk-bug-628397)
  • Revision ID: brian@tangent.org-20110102051303-boac41qa2g1myorm
MErge in Andrew's patch for a mysql bug

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include "drizzled/cached_directory.h"
33
33
#include "drizzled/plugin/monitored_in_transaction.h"
34
34
 
35
 
#include <drizzled/error_t.h>
36
 
 
37
35
#include <bitset>
38
36
#include <string>
39
37
#include <vector>
48
46
typedef struct st_hash HASH;
49
47
 
50
48
class TableShare;
 
49
typedef drizzle_lex_string LEX_STRING;
51
50
typedef bool (stat_print_fn)(Session *session, const char *type, uint32_t type_len,
52
51
                             const char *file, uint32_t file_len,
53
52
                             const char *status, uint32_t status_len);
143
142
  typedef uint64_t Table_flags;
144
143
 
145
144
private:
 
145
  const std::bitset<HTON_BIT_SIZE> flags; /* global Cursor flags */
 
146
 
146
147
  static EngineVector &getSchemaEngines();
147
 
  const std::bitset<HTON_BIT_SIZE> flags; /* global Cursor flags */
148
 
 
149
148
 
150
149
  virtual void setTransactionReadWrite(Session& session);
151
150
 
202
201
  pthread_mutex_t proto_cache_mutex;
203
202
 
204
203
public:
 
204
 
205
205
  StorageEngine(const std::string name_arg,
206
206
                const std::bitset<HTON_BIT_SIZE> &flags_arg= HTON_NO_FLAGS);
207
207
 
209
209
 
210
210
protected:
211
211
  virtual int doGetTableDefinition(Session &session,
212
 
                                   const drizzled::identifier::Table &identifier,
 
212
                                   const drizzled::TableIdentifier &identifier,
213
213
                                   message::Table &table_message)
214
214
  {
215
215
    (void)session;
221
221
 
222
222
  /* Old style cursor errors */
223
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);
224
225
  virtual bool get_error_message(int error, String *buf);
225
 
 
226
226
public:
227
227
  virtual void print_error(int error, myf errflag, Table& table);
228
228
 
279
279
protected:
280
280
  virtual int doCreateTable(Session &session,
281
281
                            Table &table_arg,
282
 
                            const drizzled::identifier::Table &identifier,
 
282
                            const drizzled::TableIdentifier &identifier,
283
283
                            message::Table &message)= 0;
284
284
 
285
285
  virtual int doRenameTable(Session &session,
286
 
                            const drizzled::identifier::Table &from, const drizzled::identifier::Table &to)= 0;
 
286
                            const drizzled::TableIdentifier &from, const drizzled::TableIdentifier &to)= 0;
287
287
 
288
288
  virtual int doDropTable(Session &session,
289
 
                          const drizzled::identifier::Table &identifier)= 0;
 
289
                          const drizzled::TableIdentifier &identifier)= 0;
290
290
 
291
291
  virtual void doGetTableIdentifiers(CachedDirectory &directory,
292
 
                                     const drizzled::identifier::Schema &schema_identifier,
293
 
                                     identifier::Table::vector &set_of_identifiers)= 0;
294
 
 
295
 
  virtual bool doDoesTableExist(Session& session, const drizzled::identifier::Table &identifier);
296
 
 
297
 
  virtual bool doCanCreateTable(const drizzled::identifier::Table &identifier)
 
292
                                     const drizzled::SchemaIdentifier &schema_identifier,
 
293
                                     TableIdentifier::vector &set_of_identifiers)= 0;
 
294
 
 
295
  virtual bool doDoesTableExist(Session& session, const drizzled::TableIdentifier &identifier);
 
296
 
 
297
  virtual bool doCanCreateTable(const drizzled::TableIdentifier &identifier)
298
298
  { (void)identifier;  return true; }
299
299
 
300
300
public:
313
313
  friend class StorageEngineDoesTableExist;
314
314
  friend class StorageEngineGetSchemaDefinition;
315
315
  friend class StorageEngineGetTableDefinition;
316
 
  friend class DropTableByIdentifier;
317
316
 
318
 
  int renameTable(Session &session, const drizzled::identifier::Table &from, const drizzled::identifier::Table &to);
 
317
  int renameTable(Session &session, const drizzled::TableIdentifier &from, const drizzled::TableIdentifier &to);
319
318
 
320
319
  /* Class Methods for operating on plugin */
321
320
  static bool addPlugin(plugin::StorageEngine *engine);
322
321
  static void removePlugin(plugin::StorageEngine *engine);
323
322
 
324
323
  static int getTableDefinition(Session& session,
325
 
                                const drizzled::identifier::Table &identifier,
 
324
                                const drizzled::TableIdentifier &identifier,
326
325
                                message::table::shared_ptr &table_proto,
327
326
                                bool include_temporary_tables= true);
328
 
  static message::table::shared_ptr getTableMessage(Session& session,
329
 
                                                    const drizzled::identifier::Table &identifier,
330
 
                                                    drizzled::error_t &error,
331
 
                                                    bool include_temporary_tables= true);
332
327
  static bool doesTableExist(Session &session,
333
 
                             const drizzled::identifier::Table &identifier,
 
328
                             const drizzled::TableIdentifier &identifier,
334
329
                             bool include_temporary_tables= true);
335
330
 
336
331
  static plugin::StorageEngine *findByName(const std::string &find_str);
339
334
  static void closeConnection(Session* session);
340
335
  static void dropDatabase(char* path);
341
336
  static bool flushLogs(plugin::StorageEngine *db_type);
342
 
 
343
 
  static bool dropTable(Session& session,
344
 
                        const drizzled::identifier::Table &identifier);
345
 
  static bool dropTable(Session& session,
346
 
                        const drizzled::identifier::Table &identifier,
347
 
                        drizzled::error_t &error);
348
 
 
349
 
  static bool dropTable(Session& session,
350
 
                        StorageEngine &engine,
351
 
                        identifier::Table::const_reference identifier,
352
 
                        drizzled::error_t &error);
353
 
 
 
337
  static int dropTable(Session& session,
 
338
                       const drizzled::TableIdentifier &identifier);
 
339
  static int dropTable(Session& session,
 
340
                       StorageEngine &engine,
 
341
                       const drizzled::TableIdentifier &identifier);
354
342
  static void getIdentifiers(Session &session,
355
 
                             const identifier::Schema &schema_identifier,
356
 
                             identifier::Table::vector &set_of_identifiers);
 
343
                             const SchemaIdentifier &schema_identifier,
 
344
                             TableIdentifier::vector &set_of_identifiers);
357
345
 
358
346
  // Check to see if any SE objects to creation.
359
 
  static bool canCreateTable(const drizzled::identifier::Table &identifier);
 
347
  static bool canCreateTable(const drizzled::TableIdentifier &identifier);
360
348
 
361
349
  // @note All schema methods defined here
362
 
  static void getIdentifiers(Session &session, identifier::Schema::vector &schemas);
363
 
  static bool getSchemaDefinition(const drizzled::identifier::Table &identifier, message::schema::shared_ptr &proto);
364
 
  static bool getSchemaDefinition(const drizzled::identifier::Schema &identifier, message::schema::shared_ptr &proto);
365
 
  static bool doesSchemaExist(const drizzled::identifier::Schema &identifier);
366
 
  static const CHARSET_INFO *getSchemaCollation(const drizzled::identifier::Schema &identifier);
 
350
  static void getIdentifiers(Session &session, SchemaIdentifier::vector &schemas);
 
351
  static bool getSchemaDefinition(const drizzled::TableIdentifier &identifier, message::schema::shared_ptr &proto);
 
352
  static bool getSchemaDefinition(const drizzled::SchemaIdentifier &identifier, message::schema::shared_ptr &proto);
 
353
  static bool doesSchemaExist(const drizzled::SchemaIdentifier &identifier);
 
354
  static const CHARSET_INFO *getSchemaCollation(const drizzled::SchemaIdentifier &identifier);
367
355
  static bool createSchema(const drizzled::message::Schema &schema_message);
368
 
  static bool dropSchema(drizzled::Session& session, identifier::Schema::const_reference identifier);
 
356
  static bool dropSchema(const drizzled::SchemaIdentifier &identifier);
369
357
  static bool alterSchema(const drizzled::message::Schema &schema_message);
370
358
 
371
359
  // @note make private/protected
372
360
protected:
373
 
  virtual void doGetSchemaIdentifiers(identifier::Schema::vector&)
 
361
  virtual void doGetSchemaIdentifiers(SchemaIdentifier::vector&)
374
362
  { }
375
363
 
376
 
  virtual bool doGetSchemaDefinition(const drizzled::identifier::Schema&, drizzled::message::schema::shared_ptr&)
 
364
  virtual bool doGetSchemaDefinition(const drizzled::SchemaIdentifier&, drizzled::message::schema::shared_ptr&)
377
365
  { 
378
366
    return false; 
379
367
  }
384
372
  virtual bool doAlterSchema(const drizzled::message::Schema&)
385
373
  { return false; }
386
374
 
387
 
  virtual bool doDropSchema(const drizzled::identifier::Schema&)
 
375
  virtual bool doDropSchema(const drizzled::SchemaIdentifier&)
388
376
  { return false; }
389
377
 
390
378
public:
393
381
    return engine == NULL ? UNKNOWN_STRING : engine->getName();
394
382
  }
395
383
 
396
 
  static bool createTable(Session &session,
397
 
                          const identifier::Table &identifier,
398
 
                          message::Table& table_message);
 
384
  static int createTable(Session& session,
 
385
                         const drizzled::TableIdentifier &identifier,
 
386
                         message::Table& table_proto);
399
387
 
400
388
  static void removeLostTemporaryTables(Session &session, const char *directory);
401
389
 
420
408
  virtual uint32_t max_supported_key_part_length(void) const { return 255; }
421
409
 
422
410
  /* TODO-> Make private */
423
 
protected:
424
 
  static int deleteDefinitionFromPath(const drizzled::identifier::Table &identifier);
425
 
  static int renameDefinitionFromPath(const drizzled::identifier::Table &dest, const drizzled::identifier::Table &src);
426
 
  static int writeDefinitionFromPath(const drizzled::identifier::Table &identifier, message::Table &proto);
 
411
  static int deleteDefinitionFromPath(const drizzled::TableIdentifier &identifier);
 
412
  static int renameDefinitionFromPath(const drizzled::TableIdentifier &dest, const drizzled::TableIdentifier &src);
 
413
  static int writeDefinitionFromPath(const drizzled::TableIdentifier &identifier, message::Table &proto);
427
414
  static bool readTableFile(const std::string &path, message::Table &table_message);
428
415
 
429
416
public:
461
448
  }
462
449
};
463
450
 
464
 
std::ostream& operator<<(std::ostream& output, const StorageEngine &engine);
465
 
 
466
451
} /* namespace plugin */
467
452
} /* namespace drizzled */
468
453