1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2009 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
This is a "work in progress". The concept needs to be replicated throughout
23
the code, but we will start with baby steps for the moment. To not incur
24
cost until we are complete, for the moment it will do no allocation.
26
This is mainly here so that it can be used in the SE interface for
29
This will replace Table_ident.
32
#ifndef DRIZZLED_TABLE_IDENTIFIER_H
33
#define DRIZZLED_TABLE_IDENTIFIER_H
35
#include <drizzled/enum.h>
36
#include "drizzled/definitions.h"
46
uint32_t filename_to_tablename(const char *from, char *to, uint32_t to_length);
47
bool tablename_to_filename(const char *from, char *to, size_t to_length);
48
size_t build_tmptable_filename(char *buff, size_t bufflen);
49
size_t build_table_filename(char *buff, size_t bufflen, const char *db, const char *table_name, bool is_tmp);
60
std::string table_name;
64
TableIdentifier( const char *db_arg,
65
const char *table_name_arg,
66
tmp_table_type tmp_arg= STANDARD_TABLE) :
70
table_name(table_name_arg),
74
sql_path.append(table_name);
79
return type == STANDARD_TABLE ? false : true;
82
const std::string &getSQLPath()
87
const char *getPath();
89
const char *getDBName() const
94
const char *getSchemaName() const
99
const char *getTableName() const
101
return table_name.c_str();
104
friend std::ostream& operator<<(std::ostream& output, const TableIdentifier &identifier)
106
const char *type_str;
108
output << "TableIdentifier:(";
109
output << identifier.getDBName();
111
output << identifier.getTableName();
114
switch (identifier.type) {
116
type_str= "standard";
118
case INTERNAL_TMP_TABLE:
119
type_str= "internal";
122
type_str= "temporary";
124
case SYSTEM_TMP_TABLE:
131
return output; // for multiple << operators.
134
friend bool operator==(const TableIdentifier &left, const TableIdentifier &right)
136
if (left.type == right.type)
138
if (not strcmp(left.db.c_str(), right.db.c_str()))
140
if (not strcmp(left.table_name.c_str(), right.table_name.c_str()))
152
typedef std::set <TableIdentifier> TableIdentifierList;
154
} /* namespace drizzled */
156
#endif /* DRIZZLED_TABLE_IDENTIFIER_H */