~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/identifier/table.cc

  • Committer: Olaf van der Spek
  • Date: 2011-07-07 13:09:02 UTC
  • mto: This revision was merged to the branch mainline in revision 2385.
  • Revision ID: olafvdspek@gmail.com-20110707130902-lbhjmqfb7kq64s9p
Refactor tablename_to_filename()

Show diffs side-by-side

added added

removed removed

Lines of Context:
179
179
 
180
180
void Table::build_table_filename(std::string &in_path, const std::string &in_db, const std::string &in_table_name, bool is_tmp)
181
181
{
182
 
  if (util::tablename_to_filename(in_db, in_path))
183
 
  {
184
 
    errmsg_printf(error::ERROR, _("Schema name cannot be encoded and fit within filesystem name length restrictions."));
185
 
  }
186
 
 
187
 
  in_path.append(FN_ROOTDIR);
188
 
 
189
 
  if (is_tmp) // It a conversion tmp
190
 
  {
191
 
    in_path.append(in_table_name);
192
 
  }
193
 
  else if (util::tablename_to_filename(in_table_name, in_path))
194
 
  {
195
 
    errmsg_printf(error::ERROR, _("Table name cannot be encoded and fit within filesystem name length restrictions."));
196
 
  }
 
182
  in_path += util::tablename_to_filename(in_db);
 
183
  in_path += FN_LIBCHAR;
 
184
  in_path += is_tmp ? in_table_name : util::tablename_to_filename(in_table_name);
197
185
}
198
186
 
199
187
Table::Table(const drizzled::Table &table) :
209
197
 
210
198
void Table::init()
211
199
{
212
 
  switch (type) {
 
200
  switch (type) 
 
201
  {
213
202
  case message::Table::FUNCTION:
214
203
  case message::Table::STANDARD:
215
 
    assert(path.size() == 0);
 
204
    assert(path.empty());
216
205
    build_table_filename(path, getSchemaName(), table_name, false);
217
206
    break;
218
207
  case message::Table::INTERNAL:
225
214
    break;
226
215
  }
227
216
 
228
 
  switch (type) {
229
 
  case message::Table::FUNCTION:
230
 
  case message::Table::STANDARD:
231
 
  case message::Table::INTERNAL:
232
 
    break;
233
 
  case message::Table::TEMPORARY:
234
 
    {
235
 
      size_t pos= path.find("tmp/#sql");
236
 
      if (pos != std::string::npos) 
237
 
        key_path= path.substr(pos);
238
 
    }
239
 
    break;
 
217
  if (type == message::Table::TEMPORARY)
 
218
  {
 
219
    size_t pos= path.find("tmp/#sql");
 
220
    if (pos != std::string::npos) 
 
221
      key_path= path.substr(pos);
240
222
  }
241
223
 
242
224
  hash_value= util::insensitive_hash()(path);