~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/identifier/schema.cc

  • Committer: Lee Bieber
  • Date: 2010-11-05 20:22:41 UTC
  • mfrom: (1907.1.2 build)
  • Revision ID: kalebral@gmail.com-20101105202241-1fm31t0y0fvdwcd3
Merge Brian - Adding FileSort class, merge in catalog tree
Merge Joe - fix bug 670971: InnoDB does not complete shutdown with transaction log enabled

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include "drizzled/current_session.h"
28
28
#include "drizzled/internal/my_sys.h"
29
29
 
 
30
#include "drizzled/util/tablename_to_filename.h"
30
31
#include "drizzled/util/backtrace.h"
31
32
 
32
33
#include <algorithm>
43
44
extern string drizzle_tmpdir;
44
45
extern pid_t current_pid;
45
46
 
46
 
static const char hexchars[]= "0123456789abcdef";
47
 
 
48
 
static bool tablename_to_filename(const string &from, string &to);
49
 
 
50
47
static size_t build_schema_filename(string &path, const string &db)
51
48
{
52
49
  path.append("");
53
50
  bool conversion_error= false;
54
51
 
55
 
  conversion_error= tablename_to_filename(db, path);
 
52
  conversion_error= util::tablename_to_filename(db, path);
56
53
  if (conversion_error)
57
54
  {
58
55
    errmsg_printf(ERRMSG_LVL_ERROR,
64
61
  return path.length();
65
62
}
66
63
 
67
 
 
68
 
/*
69
 
  Translate a table name to a cursor name (WL #1324).
70
 
 
71
 
  SYNOPSIS
72
 
    tablename_to_filename()
73
 
      from                      The table name
74
 
      to                OUT     The cursor name
75
 
 
76
 
  RETURN
77
 
    true if errors happen. false on success.
78
 
*/
79
 
static bool tablename_to_filename(const string &from, string &to)
80
 
{
81
 
  
82
 
  string::const_iterator iter= from.begin();
83
 
  for (; iter != from.end(); ++iter)
84
 
  {
85
 
    if (isascii(*iter))
86
 
    {
87
 
      if ((isdigit(*iter)) ||
88
 
          (islower(*iter)) ||
89
 
          (*iter == '_') ||
90
 
          (*iter == ' ') ||
91
 
          (*iter == '-'))
92
 
      {
93
 
        to.push_back(*iter);
94
 
        continue;
95
 
      }
96
 
 
97
 
      if (isupper(*iter))
98
 
      {
99
 
        to.push_back(tolower(*iter));
100
 
        continue;
101
 
      }
102
 
    }
103
 
   
104
 
    /* We need to escape this char in a way that can be reversed */
105
 
    to.push_back('@');
106
 
    to.push_back(hexchars[(*iter >> 4) & 15]);
107
 
    to.push_back(hexchars[(*iter) & 15]);
108
 
  }
109
 
 
110
 
  if (internal::check_if_legal_tablename(to.c_str()))
111
 
  {
112
 
    to.append("@@@");
113
 
  }
114
 
  return false;
115
 
}
116
 
 
117
64
SchemaIdentifier::SchemaIdentifier(const std::string &db_arg) :
118
65
  db(db_arg),
119
66
  db_path(""),