28
28
#include <drizzled/message/table.pb.h>
29
29
#include "drizzled/plugin/plugin.h"
30
30
#include "drizzled/sql_string.h"
31
#include "drizzled/schema_identifier.h"
32
#include "drizzled/table_identifier.h"
31
#include "drizzled/identifier.h"
33
32
#include "drizzled/cached_directory.h"
34
33
#include "drizzled/plugin/monitored_in_transaction.h"
36
#include "drizzled/hash.h"
35
#include <drizzled/unordered_map.h>
61
60
HTON_BIT_NOT_USER_SELECTABLE,
62
61
HTON_BIT_TEMPORARY_NOT_SUPPORTED, // Having temporary tables not supported
63
62
HTON_BIT_TEMPORARY_ONLY,
64
HTON_BIT_FILE_BASED, // use for check_lowercase_names
65
63
HTON_BIT_DOES_TRANSACTIONS,
66
64
HTON_BIT_STATS_RECORDS_IS_EXACT,
67
65
HTON_BIT_NULL_IN_KEY,
68
66
HTON_BIT_CAN_INDEX_BLOBS,
69
HTON_BIT_PRIMARY_KEY_REQUIRED_FOR_POSITION,
70
67
HTON_BIT_PRIMARY_KEY_IN_READ_INDEX,
71
68
HTON_BIT_PARTIAL_COLUMN_READ,
72
69
HTON_BIT_TABLE_SCAN_ON_INDEX,
93
90
static const std::bitset<HTON_BIT_SIZE> HTON_NOT_USER_SELECTABLE(1 << HTON_BIT_NOT_USER_SELECTABLE);
94
91
static const std::bitset<HTON_BIT_SIZE> HTON_TEMPORARY_NOT_SUPPORTED(1 << HTON_BIT_TEMPORARY_NOT_SUPPORTED);
95
92
static const std::bitset<HTON_BIT_SIZE> HTON_TEMPORARY_ONLY(1 << HTON_BIT_TEMPORARY_ONLY);
96
static const std::bitset<HTON_BIT_SIZE> HTON_FILE_BASED(1 << HTON_BIT_FILE_BASED);
97
93
static const std::bitset<HTON_BIT_SIZE> HTON_HAS_DOES_TRANSACTIONS(1 << HTON_BIT_DOES_TRANSACTIONS);
98
94
static const std::bitset<HTON_BIT_SIZE> HTON_STATS_RECORDS_IS_EXACT(1 << HTON_BIT_STATS_RECORDS_IS_EXACT);
99
95
static const std::bitset<HTON_BIT_SIZE> HTON_NULL_IN_KEY(1 << HTON_BIT_NULL_IN_KEY);
100
96
static const std::bitset<HTON_BIT_SIZE> HTON_CAN_INDEX_BLOBS(1 << HTON_BIT_CAN_INDEX_BLOBS);
101
static const std::bitset<HTON_BIT_SIZE> HTON_PRIMARY_KEY_REQUIRED_FOR_POSITION(1 << HTON_BIT_PRIMARY_KEY_REQUIRED_FOR_POSITION);
102
97
static const std::bitset<HTON_BIT_SIZE> HTON_PRIMARY_KEY_IN_READ_INDEX(1 << HTON_BIT_PRIMARY_KEY_IN_READ_INDEX);
103
98
static const std::bitset<HTON_BIT_SIZE> HTON_PARTIAL_COLUMN_READ(1 << HTON_BIT_PARTIAL_COLUMN_READ);
104
99
static const std::bitset<HTON_BIT_SIZE> HTON_TABLE_SCAN_ON_INDEX(1 << HTON_BIT_TABLE_SCAN_ON_INDEX);
285
280
virtual int doCreateTable(Session &session,
286
281
Table &table_arg,
287
TableIdentifier &identifier,
282
const drizzled::TableIdentifier &identifier,
288
283
message::Table &message)= 0;
290
285
virtual int doRenameTable(Session &session,
291
TableIdentifier &from, TableIdentifier &to)= 0;
286
const drizzled::TableIdentifier &from, const drizzled::TableIdentifier &to)= 0;
295
int renameTable(Session &session, TableIdentifier &from, TableIdentifier &to);
290
int renameTable(Session &session, const drizzled::TableIdentifier &from, const drizzled::TableIdentifier &to);
297
292
// @todo move these to protected
298
293
virtual void doGetTableNames(CachedDirectory &directory,
299
drizzled::SchemaIdentifier &schema_identifier,
294
const drizzled::SchemaIdentifier &schema_identifier,
300
295
TableNameList &set_of_names)= 0;
302
297
virtual void doGetTableIdentifiers(CachedDirectory &directory,
303
drizzled::SchemaIdentifier &schema_identifier,
298
const drizzled::SchemaIdentifier &schema_identifier,
304
299
TableIdentifiers &set_of_identifiers)= 0;
306
301
virtual int doDropTable(Session &session,
307
TableIdentifier &identifier)= 0;
302
const drizzled::TableIdentifier &identifier)= 0;
309
304
/* Class Methods for operating on plugin */
310
305
static bool addPlugin(plugin::StorageEngine *engine);
311
306
static void removePlugin(plugin::StorageEngine *engine);
313
308
static int getTableDefinition(Session& session,
314
TableIdentifier &identifier,
309
const drizzled::TableIdentifier &identifier,
315
310
message::Table &table_proto,
316
311
bool include_temporary_tables= true);
317
312
static bool doesTableExist(Session &session,
318
TableIdentifier &identifier,
313
const drizzled::TableIdentifier &identifier,
319
314
bool include_temporary_tables= true);
321
virtual bool doDoesTableExist(Session& session, TableIdentifier &identifier);
316
virtual bool doDoesTableExist(Session& session, const drizzled::TableIdentifier &identifier);
323
318
static plugin::StorageEngine *findByName(const std::string &find_str);
324
319
static plugin::StorageEngine *findByName(Session& session, const std::string &find_str);
327
322
static void dropDatabase(char* path);
328
323
static bool flushLogs(plugin::StorageEngine *db_type);
329
324
static int dropTable(Session& session,
330
TableIdentifier &identifier);
325
const drizzled::TableIdentifier &identifier);
331
326
static int dropTable(Session& session,
332
327
StorageEngine &engine,
333
TableIdentifier &identifier);
334
static void getTableNames(Session &session, drizzled::SchemaIdentifier& schema_identifier, TableNameList &set_of_names);
335
static void getTableIdentifiers(Session &session, SchemaIdentifier &schema_identifier, TableIdentifiers &set_of_identifiers);
328
const drizzled::TableIdentifier &identifier);
329
static void getIdentifiers(Session &session,
330
const SchemaIdentifier &schema_identifier,
331
TableIdentifiers &set_of_identifiers);
337
333
// Check to see if any SE objects to creation.
338
static bool canCreateTable(drizzled::TableIdentifier &identifier);
339
virtual bool doCanCreateTable(drizzled::TableIdentifier &identifier)
334
static bool canCreateTable(const drizzled::TableIdentifier &identifier);
335
virtual bool doCanCreateTable(const drizzled::TableIdentifier &identifier)
340
336
{ (void)identifier; return true; }
342
338
// @note All schema methods defined here
343
static void getSchemaIdentifiers(Session &session, SchemaIdentifierList &schemas);
344
static bool getSchemaDefinition(TableIdentifier &identifier, message::Schema &proto);
345
static bool getSchemaDefinition(drizzled::SchemaIdentifier &identifier, message::Schema &proto);
346
static bool doesSchemaExist(drizzled::SchemaIdentifier &identifier);
347
static const CHARSET_INFO *getSchemaCollation(drizzled::SchemaIdentifier &identifier);
339
static void getIdentifiers(Session &session, SchemaIdentifiers &schemas);
340
static bool getSchemaDefinition(const drizzled::TableIdentifier &identifier, message::Schema &proto);
341
static bool getSchemaDefinition(const drizzled::SchemaIdentifier &identifier, message::Schema &proto);
342
static bool doesSchemaExist(const drizzled::SchemaIdentifier &identifier);
343
static const CHARSET_INFO *getSchemaCollation(const drizzled::SchemaIdentifier &identifier);
348
344
static bool createSchema(const drizzled::message::Schema &schema_message);
349
static bool dropSchema(drizzled::SchemaIdentifier &identifier);
345
static bool dropSchema(const drizzled::SchemaIdentifier &identifier);
350
346
static bool alterSchema(const drizzled::message::Schema &schema_message);
352
348
// @note make private/protected
353
virtual void doGetSchemaIdentifiers(SchemaIdentifierList&)
349
virtual void doGetSchemaIdentifiers(SchemaIdentifiers&)
356
virtual bool doGetSchemaDefinition(drizzled::SchemaIdentifier&, drizzled::message::Schema&)
352
virtual bool doGetSchemaDefinition(const drizzled::SchemaIdentifier&, drizzled::message::Schema&)
375
371
static int createTable(Session& session,
376
TableIdentifier &identifier,
377
bool update_create_info,
372
const drizzled::TableIdentifier &identifier,
378
373
message::Table& table_proto);
380
375
static void removeLostTemporaryTables(Session &session, const char *directory);
400
395
virtual uint32_t max_supported_key_part_length(void) const { return 255; }
402
397
/* TODO-> Make private */
403
static int deleteDefinitionFromPath(TableIdentifier &identifier);
404
static int renameDefinitionFromPath(TableIdentifier &dest, TableIdentifier &src);
405
static int writeDefinitionFromPath(TableIdentifier &identifier, message::Table &proto);
398
static int deleteDefinitionFromPath(const drizzled::TableIdentifier &identifier);
399
static int renameDefinitionFromPath(const drizzled::TableIdentifier &dest, const drizzled::TableIdentifier &src);
400
static int writeDefinitionFromPath(const drizzled::TableIdentifier &identifier, message::Table &proto);
406
401
static bool readTableFile(const std::string &path, message::Table &table_message);