35
35
#include <drizzled/enum.h>
36
36
#include "drizzled/definitions.h"
37
#include "drizzled/message/table.pb.h"
39
#include "drizzled/schema_identifier.h"
41
37
#include <string.h>
50
41
namespace drizzled {
54
uint32_t filename_to_tablename(const char *from, char *to, uint32_t to_length);
55
size_t build_table_filename(std::string &buff, const char *db, const char *table_name, bool is_tmp);
57
class TableIdentifier : public SchemaIdentifier
60
typedef message::Table::TableType Type;
65
std::string table_name;
66
std::string lower_table_name;
51
const char *table_name;
72
TableIdentifier(const Table &table);
74
TableIdentifier( const SchemaIdentifier &schema,
75
const std::string &table_name_arg,
76
Type tmp_arg= message::Table::STANDARD) :
77
SchemaIdentifier(schema),
79
table_name(table_name_arg)
84
TableIdentifier( const std::string &db_arg,
85
const std::string &table_name_arg,
86
Type tmp_arg= message::Table::STANDARD) :
87
SchemaIdentifier(db_arg),
89
table_name(table_name_arg)
94
TableIdentifier( const std::string &schema_name_arg,
95
const std::string &table_name_arg,
96
const std::string &path_arg ) :
97
SchemaIdentifier(schema_name_arg),
98
type(message::Table::TEMPORARY),
100
table_name(table_name_arg)
105
using SchemaIdentifier::compare;
106
bool compare(std::string schema_arg, std::string table_arg);
54
TableIdentifier( const char *db_arg,
55
const char *table_name_arg,
56
tmp_table_type tmp_arg= NO_TMP_TABLE) :
60
table_name(table_name_arg)
108
63
bool isTmp() const
110
if (type == message::Table::TEMPORARY || type == message::Table::INTERNAL)
120
const std::string &getSQLPath();
122
const std::string &getPath();
124
void setPath(const std::string &new_path)
129
const std::string &getTableName() const
65
return type == NO_TMP_TABLE ? false : true;
68
const char *getPath();
70
const char *getDBName() const
75
const char *getSchemaName() const
80
const char *getTableName() const
131
82
return table_name;
134
void copyToTableMessage(message::Table &message);
136
bool operator<(TableIdentifier &right)
138
int first= getLower().compare(right.getLower());
150
int val= lower_table_name.compare(right.lower_table_name);
162
if (type < right.type)
172
85
friend std::ostream& operator<<(std::ostream& output, const TableIdentifier &identifier)
174
87
const char *type_str;
176
89
output << "TableIdentifier:(";
177
output << identifier.getSchemaName();
90
output << identifier.getDBName();
179
92
output << identifier.getTableName();
182
95
switch (identifier.type) {
183
case message::Table::STANDARD:
184
97
type_str= "standard";
186
case message::Table::INTERNAL:
99
case INTERNAL_TMP_TABLE:
187
100
type_str= "internal";
189
case message::Table::TEMPORARY:
190
103
type_str= "temporary";
192
case message::Table::FUNCTION:
193
type_str= "function";
105
case SYSTEM_TMP_TABLE:
197
109
output << type_str;
199
output << identifier.path;
202
112
return output; // for multiple << operators.
205
friend bool operator==(TableIdentifier &left, TableIdentifier &right)
115
friend bool operator==(const TableIdentifier &left, const TableIdentifier &right)
207
117
if (left.type == right.type)
209
if (static_cast<SchemaIdentifier &>(left) == static_cast<SchemaIdentifier &>(right))
119
if (! strcmp(left.db, right.db))
211
if (left.lower_table_name == right.lower_table_name)
121
if (! strcmp(left.table_name, right.table_name))