30
29
This will replace Table_ident.
33
#ifndef DRIZZLED_IDENTIFIER_TABLE_H
34
#define DRIZZLED_IDENTIFIER_TABLE_H
32
#ifndef DRIZZLED_TABLE_IDENTIFIER_H
33
#define DRIZZLED_TABLE_IDENTIFIER_H
36
35
#include <drizzled/enum.h>
37
36
#include "drizzled/definitions.h"
38
#include "drizzled/message/table.pb.h"
40
37
#include <string.h>
49
#include <boost/functional/hash.hpp>
51
#include "drizzled/visibility.h"
53
41
namespace drizzled {
56
namespace identifier {
58
class DRIZZLED_API Table : public Schema
51
const char *table_name;
61
typedef message::Table::TableType Type;
62
typedef std::vector <Table> vector;
63
typedef const Table& const_reference;
64
typedef Table& reference;
68
std::vector<char> key_buffer;
78
const char *vector() const
80
return &key_buffer[0];
83
std::vector<char> &vectorPtr()
88
void set(size_t resize_arg, const std::string &a, const std::string &b);
90
friend bool operator==(const Key &left, const Key &right)
92
if (left.hash_value == right.hash_value and left.key_buffer.size() == right.key_buffer.size())
54
TableIdentifier( const char *db_arg,
55
const char *table_name_arg,
56
tmp_table_type tmp_arg) :
60
table_name(table_name_arg)
65
return type == NO_TMP_TABLE ? false : true;
68
const char *getPath();
70
const char *getDBName() const
75
const char *getTableName() const
80
friend std::ostream& operator<<(std::ostream& output, const TableIdentifier &identifier)
84
output << "TableIdentifier:(";
85
output << identifier.getDBName();
87
output << identifier.getTableName();
90
switch (identifier.type) {
94
case INTERNAL_TMP_TABLE:
98
type_str= "temporary";
100
case SYSTEM_TMP_TABLE:
107
return output; // for multiple << operators.
110
friend bool operator==(const TableIdentifier &left, const TableIdentifier &right)
112
if (left.type == right.type)
114
if (! strcmp(left.db, right.db))
94
if (memcmp(&left.key_buffer[0], &right.key_buffer[0], left.key_buffer.size()) == 0)
116
if (! strcmp(left.table_name, right.table_name))
101
friend bool operator<(const Key &left, const Key &right)
103
return left.key_buffer < right.key_buffer;
108
return key_buffer.size();
111
size_t getHashValue() const
121
std::string key_path;
122
std::string table_name;
128
size_t getKeySize() const
130
return getSchemaName().size() + getTableName().size() + 2;
135
Table(const drizzled::Table &table);
137
Table(const identifier::Schema &schema,
138
const std::string &table_name_arg,
139
Type tmp_arg= message::Table::STANDARD) :
142
table_name(table_name_arg)
147
Table( const std::string &db_arg,
148
const std::string &table_name_arg,
149
Type tmp_arg= message::Table::STANDARD) :
152
table_name(table_name_arg)
157
Table( const std::string &schema_name_arg,
158
const std::string &table_name_arg,
159
const std::string &path_arg ) :
160
Schema(schema_name_arg),
161
type(message::Table::TEMPORARY),
163
table_name(table_name_arg)
168
using Schema::compare;
172
if (type == message::Table::TEMPORARY || type == message::Table::INTERNAL)
178
static bool isView(message::Table::TableType arg) // Not a SQL view, but a view for I_S
183
case message::Table::STANDARD:
184
case message::Table::TEMPORARY:
185
case message::Table::INTERNAL:
187
case message::Table::FUNCTION:
194
bool isView() const // Not a SQL view, but a view for I_S
204
virtual void getSQLPath(std::string &sql_path) const;
206
virtual const std::string &getPath() const;
207
const std::string &getKeyPath() const;
209
void setPath(const std::string &new_path)
214
const std::string &getTableName() const
219
void copyToTableMessage(message::Table &message) const;
221
friend bool operator<(Table::const_reference left, Table::const_reference right)
223
if (left.getKey() < right.getKey())
231
friend bool operator==(Table::const_reference left, Table::const_reference right)
233
if (left.getHashValue() == right.getHashValue())
235
if (left.getKey() == right.getKey())
242
static uint32_t filename_to_tablename(const char *from, char *to, uint32_t to_length);
243
static size_t build_table_filename(std::string &path, const std::string &db, const std::string &table_name, bool is_tmp);
244
static size_t build_tmptable_filename(std::string &buffer);
245
static size_t build_tmptable_filename(std::vector<char> &buffer);
248
bool isValid() const;
250
size_t getHashValue() const
255
const Key &getKey() const
261
std::ostream& operator<<(std::ostream& output, Table::const_reference identifier);
262
std::size_t hash_value(Table const& b);
263
std::size_t hash_value(Table::Key const& b);
265
} /* namespace identifier */
266
128
} /* namespace drizzled */
268
#endif /* DRIZZLED_IDENTIFIER_TABLE_H */
130
#endif /* DRIZZLED_TABLE_IDENTIFIER_H */