~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table_identifier.h

Merged trunk and mysql-protocol-password-udf changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#include "drizzled/definitions.h"
37
37
#include <string.h>
38
38
 
 
39
#include <assert.h>
 
40
 
39
41
#include <ostream>
40
42
#include <set>
 
43
#include <algorithm>
 
44
#include <functional>
41
45
 
42
46
namespace drizzled {
43
47
 
44
48
uint32_t filename_to_tablename(const char *from, char *to, uint32_t to_length);
45
 
bool tablename_to_filename(const char *from, char *to, size_t to_length);
46
 
size_t build_tmptable_filename(char *buff, size_t bufflen);
47
 
size_t build_table_filename(char *buff, size_t bufflen, const char *db, const char *table_name, bool is_tmp);
 
49
size_t build_table_filename(std::string &buff, const char *db, const char *table_name, bool is_tmp);
48
50
 
49
51
 
50
52
class TableIdentifier
51
53
{
52
 
private:
53
 
  bool path_inited;
54
 
 
55
54
  tmp_table_type type;
56
 
  char path[FN_REFLEN];
57
 
  const char *db;
58
 
  const char *table_name;
 
55
  std::string path;
 
56
  std::string db;
 
57
  std::string table_name;
 
58
  std::string lower_db;
 
59
  std::string lower_table_name;
59
60
  std::string sql_path;
60
61
 
61
62
public:
62
 
  TableIdentifier( const char *db_arg,
63
 
                   const char *table_name_arg,
 
63
  TableIdentifier( const std::string &db_arg,
 
64
                   const std::string &table_name_arg,
64
65
                   tmp_table_type tmp_arg= STANDARD_TABLE) :
65
 
    path_inited(false),
66
66
    type(tmp_arg),
67
67
    db(db_arg),
68
68
    table_name(table_name_arg),
 
69
    lower_db(db_arg),
 
70
    lower_table_name(table_name_arg),
 
71
    sql_path(db_arg)
 
72
  { 
 
73
    std::transform(lower_table_name.begin(), lower_table_name.end(),
 
74
                   lower_table_name.begin(), ::tolower);
 
75
 
 
76
    std::transform(lower_db.begin(), lower_db.end(),
 
77
                   lower_db.begin(), ::tolower);
 
78
 
 
79
    sql_path.append(".");
 
80
    sql_path.append(table_name);
 
81
  }
 
82
 
 
83
  /**
 
84
    This is only used in scavenging lost tables. Once the temp schema engine goes in, this should go away.
 
85
  */
 
86
  TableIdentifier( const char *path_arg ) :
 
87
    type(TEMP_TABLE),
 
88
    path(path_arg),
 
89
    db(path_arg),
 
90
    table_name(path_arg),
69
91
    sql_path(db)
70
92
  { 
71
93
    sql_path.append(".");
82
104
    return sql_path;
83
105
  }
84
106
 
85
 
  const char *getPath();
86
 
 
87
 
  const char *getDBName() const
88
 
  {
89
 
    return db;
90
 
  }
91
 
 
92
 
  const char *getSchemaName() const
93
 
  {
94
 
    return db;
95
 
  }
96
 
 
97
 
  const char *getTableName() const
 
107
  const std::string &getPath();
 
108
 
 
109
  const std::string &getDBName() const
 
110
  {
 
111
    return db;
 
112
  }
 
113
 
 
114
  const std::string &getSchemaName() const
 
115
  {
 
116
    return db;
 
117
  }
 
118
 
 
119
  const std::string getTableName() const
98
120
  {
99
121
    return table_name;
100
122
  }
133
155
  {
134
156
    if (left.type == right.type)
135
157
    {
136
 
      if (! strcmp(left.db, right.db))
 
158
      if (left.db == right.db)
137
159
      {
138
 
        if (! strcmp(left.table_name, right.table_name))
 
160
        if (left.table_name == right.table_name)
139
161
        {
140
162
          return true;
141
163
        }