~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/storage_engine.h

  • Committer: Brian Aker
  • Date: 2010-10-28 17:12:01 UTC
  • mfrom: (1887.1.3 merge)
  • Revision ID: brian@tangent.org-20101028171201-baj6l1bnntn1s4ad
Merge in POTFILES changes.

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