~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/identifier/table.cc

edit

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include <config.h>
 
21
#include "config.h"
22
22
 
23
23
#include <assert.h>
24
24
#include <boost/lexical_cast.hpp>
25
 
#include <drizzled/identifier.h>
26
 
#include <drizzled/internal/my_sys.h>
 
25
#include "drizzled/identifier.h"
 
26
#include "drizzled/internal/my_sys.h"
27
27
 
28
28
#include <drizzled/error.h>
29
29
#include <drizzled/errmsg_print.h>
31
31
 
32
32
#include <drizzled/table.h>
33
33
 
34
 
#include <drizzled/util/string.h>
35
 
#include <drizzled/util/tablename_to_filename.h>
 
34
#include "drizzled/util/string.h"
 
35
#include "drizzled/util/tablename_to_filename.h"
36
36
 
37
37
#include <algorithm>
38
38
#include <sstream>
217
217
  conversion_error= util::tablename_to_filename(in_db, in_path);
218
218
  if (conversion_error)
219
219
  {
220
 
    errmsg_printf(error::ERROR,
 
220
    errmsg_printf(ERRMSG_LVL_ERROR,
221
221
                  _("Schema name cannot be encoded and fit within filesystem "
222
222
                    "name length restrictions."));
223
223
    return 0;
234
234
    conversion_error= util::tablename_to_filename(in_table_name, in_path);
235
235
    if (conversion_error)
236
236
    {
237
 
      errmsg_printf(error::ERROR,
 
237
      errmsg_printf(ERRMSG_LVL_ERROR,
238
238
                    _("Table name cannot be encoded and fit within filesystem "
239
239
                      "name length restrictions."));
240
240
      return 0;
275
275
    break;
276
276
  }
277
277
 
278
 
  switch (type) {
279
 
  case message::Table::FUNCTION:
280
 
  case message::Table::STANDARD:
281
 
  case message::Table::INTERNAL:
282
 
    break;
283
 
  case message::Table::TEMPORARY:
284
 
    {
285
 
      size_t pos;
286
 
 
287
 
      pos= path.find("tmp/#sql");
288
 
      if (pos != std::string::npos) 
289
 
      {
290
 
        key_path= path.substr(pos);
291
 
      }
292
 
    }
293
 
    break;
294
 
  }
295
 
 
296
278
  util::insensitive_hash hasher;
297
279
  hash_value= hasher(path);
298
280
 
308
290
  return path;
309
291
}
310
292
 
311
 
const std::string &Table::getKeyPath() const
312
 
{
313
 
  if (key_path.empty())
314
 
    return path;
315
 
 
316
 
  return key_path;
317
 
}
318
 
 
319
293
void Table::getSQLPath(std::string &sql_path) const  // @todo this is just used for errors, we should find a way to optimize it
320
294
{
321
295
  switch (type) {
424
398
  return b.getHashValue();
425
399
}
426
400
 
427
 
 
428
 
std::ostream& operator<<(std::ostream& output, Table::const_reference identifier)
429
 
{
430
 
  output << "Table:(";
431
 
  output <<  identifier.getSchemaName();
432
 
  output << ", ";
433
 
  output << identifier.getTableName();
434
 
  output << ", ";
435
 
  output << message::type(identifier.getType());
436
 
  output << ", ";
437
 
  output << identifier.getPath();
438
 
  output << ", ";
439
 
  output << identifier.getHashValue();
440
 
  output << ")";
441
 
 
442
 
  return output;  // for multiple << operators.
443
 
}
444
 
 
445
401
} /* namespace identifier */
446
402
} /* namespace drizzled */