47
50
namespace drizzled {
49
54
uint32_t filename_to_tablename(const char *from, char *to, uint32_t to_length);
50
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;
58
65
std::string table_name;
60
66
std::string lower_table_name;
61
67
std::string sql_path;
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)
64
84
TableIdentifier( const std::string &db_arg,
65
85
const std::string &table_name_arg,
66
tmp_table_type tmp_arg= STANDARD_TABLE) :
86
Type tmp_arg= message::Table::STANDARD) :
87
SchemaIdentifier(db_arg),
69
table_name(table_name_arg),
71
lower_table_name(table_name_arg),
74
std::transform(lower_table_name.begin(), lower_table_name.end(),
75
lower_table_name.begin(), ::tolower);
77
std::transform(lower_db.begin(), lower_db.end(),
78
lower_db.begin(), ::tolower);
81
sql_path.append(table_name);
85
This is only used in scavenging lost tables. Once the temp schema engine goes in, this should go away.
87
TableIdentifier( const char *path_arg ) :
93
sql_path.append("temporary");
95
sql_path.append(table_name);
98
TableIdentifier(const char *schema_name_arg, const char *table_name_arg, const char *path_arg ) :
102
table_name(table_name_arg)
104
sql_path.append("temporary");
105
sql_path.append(".");
106
sql_path.append(table_name);
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);
109
108
bool isTmp() const
111
return type == STANDARD_TABLE ? false : true;
110
if (type == message::Table::TEMPORARY || type == message::Table::INTERNAL)
114
const std::string &getSQLPath()
120
const std::string &getSQLPath();
119
122
const std::string &getPath();
121
const std::string &getDBName() const
126
const std::string &getSchemaName() const
131
const std::string getTableName() const
124
void setPath(const std::string &new_path)
129
const std::string &getTableName() const
133
131
return table_name;
140
138
const char *type_str;
142
140
output << "TableIdentifier:(";
143
output << identifier.getDBName();
141
output << identifier.getSchemaName();
145
143
output << identifier.getTableName();
148
146
switch (identifier.type) {
147
case message::Table::STANDARD:
150
148
type_str= "standard";
152
case INTERNAL_TMP_TABLE:
150
case message::Table::INTERNAL:
153
151
type_str= "internal";
153
case message::Table::TEMPORARY:
156
154
type_str= "temporary";
158
case SYSTEM_TMP_TABLE:
156
case message::Table::FUNCTION:
157
type_str= "function";
162
161
output << type_str;
163
output << identifier.path;
165
166
return output; // for multiple << operators.
168
friend bool operator==(const TableIdentifier &left, const TableIdentifier &right)
169
friend bool operator==(TableIdentifier &left, TableIdentifier &right)
170
171
if (left.type == right.type)
172
if (left.db == right.db)
173
if (static_cast<SchemaIdentifier &>(left) == static_cast<SchemaIdentifier &>(right))
174
if (left.table_name == right.table_name)
175
if (left.lower_table_name == right.lower_table_name)