~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table_identifier.h

  • Committer: Brian Aker
  • Date: 2010-03-19 00:16:13 UTC
  • mfrom: (1358.1.5 build)
  • Revision ID: brian@gaz-20100319001613-00rqrgybz9xxyssp
Merge more cleanup from TableIdentifier.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 
41
41
#include <ostream>
42
42
#include <set>
 
43
#include <algorithm>
 
44
#include <functional>
43
45
 
44
46
namespace drizzled {
45
47
 
46
48
uint32_t filename_to_tablename(const char *from, char *to, uint32_t to_length);
47
 
size_t build_tmptable_filename(char *buff, size_t bufflen);
48
 
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);
49
50
 
50
51
 
51
52
class TableIdentifier
54
55
  bool path_inited;
55
56
 
56
57
  tmp_table_type type;
57
 
  char path[FN_REFLEN];
 
58
  std::string path;
58
59
  std::string db;
59
60
  std::string table_name;
 
61
  std::string lower_db;
 
62
  std::string lower_table_name;
60
63
  std::string sql_path;
61
64
 
62
65
public:
63
 
  TableIdentifier( const char *db_arg,
64
 
                   const char *table_name_arg,
 
66
  TableIdentifier( const std::string &db_arg,
 
67
                   const std::string &table_name_arg,
65
68
                   tmp_table_type tmp_arg= STANDARD_TABLE) :
66
69
    path_inited(false),
67
70
    type(tmp_arg),
68
71
    db(db_arg),
69
72
    table_name(table_name_arg),
70
 
    sql_path(db)
 
73
    lower_db(db_arg),
 
74
    lower_table_name(table_name_arg),
 
75
    sql_path(db_arg)
71
76
  { 
 
77
    std::transform(lower_table_name.begin(), lower_table_name.end(),
 
78
                   lower_table_name.begin(), ::tolower);
 
79
 
 
80
    std::transform(lower_db.begin(), lower_db.end(),
 
81
                   lower_db.begin(), ::tolower);
 
82
 
72
83
    sql_path.append(".");
73
84
    sql_path.append(table_name);
74
85
  }
79
90
  TableIdentifier( const char *path_arg ) :
80
91
    path_inited(true),
81
92
    type(TEMP_TABLE),
 
93
    path(path_arg),
82
94
    db(path_arg),
83
95
    table_name(path_arg),
84
96
    sql_path(db)
85
97
  { 
86
98
    sql_path.append(".");
87
99
    sql_path.append(table_name);
88
 
    strncpy(path, path_arg, FN_REFLEN);
89
100
  }
90
101
 
91
102
  bool isTmp() const
149
160
  {
150
161
    if (left.type == right.type)
151
162
    {
152
 
      if (not strcmp(left.db.c_str(), right.db.c_str()))
 
163
      if (left.db == right.db)
153
164
      {
154
 
        if (not strcmp(left.table_name.c_str(), right.table_name.c_str()))
 
165
        if (left.table_name == right.table_name)
155
166
        {
156
167
          return true;
157
168
        }