~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/identifier/table.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:
29
29
#include "drizzled/table.h"
30
30
 
31
31
#include "drizzled/util/string.h"
 
32
#include "drizzled/util/tablename_to_filename.h"
32
33
 
33
34
#include <algorithm>
34
35
#include <sstream>
46
47
 
47
48
static const char hexchars[]= "0123456789abcdef";
48
49
 
49
 
static bool tablename_to_filename(const string &from, string &to);
50
 
 
51
50
/*
52
51
  Translate a cursor name to a table name (WL #1324).
53
52
 
207
206
{
208
207
  bool conversion_error= false;
209
208
 
210
 
  conversion_error= tablename_to_filename(in_db, in_path);
 
209
  conversion_error= util::tablename_to_filename(in_db, in_path);
211
210
  if (conversion_error)
212
211
  {
213
212
    errmsg_printf(ERRMSG_LVL_ERROR,
224
223
  }
225
224
  else
226
225
  {
227
 
    conversion_error= tablename_to_filename(in_table_name, in_path);
 
226
    conversion_error= util::tablename_to_filename(in_table_name, in_path);
228
227
    if (conversion_error)
229
228
    {
230
229
      errmsg_printf(ERRMSG_LVL_ERROR,
237
236
  return in_path.length();
238
237
}
239
238
 
240
 
 
241
 
/*
242
 
  Translate a table name to a cursor name (WL #1324).
243
 
 
244
 
  SYNOPSIS
245
 
    tablename_to_filename()
246
 
      from                      The table name
247
 
      to                OUT     The cursor name
248
 
      to_length                 The size of the cursor name buffer.
249
 
 
250
 
  RETURN
251
 
    true if errors happen. false on success.
252
 
*/
253
 
static bool tablename_to_filename(const string &from, string &to)
254
 
{
255
 
  
256
 
  string::const_iterator iter= from.begin();
257
 
  for (; iter != from.end(); ++iter)
258
 
  {
259
 
    if (isascii(*iter))
260
 
    {
261
 
      if ((isdigit(*iter)) ||
262
 
          (islower(*iter)) ||
263
 
          (*iter == '_') ||
264
 
          (*iter == ' ') ||
265
 
          (*iter == '-'))
266
 
      {
267
 
        to.push_back(*iter);
268
 
        continue;
269
 
      }
270
 
 
271
 
      if (isupper(*iter))
272
 
      {
273
 
        to.push_back(tolower(*iter));
274
 
        continue;
275
 
      }
276
 
    }
277
 
   
278
 
    /* We need to escape this char in a way that can be reversed */
279
 
    to.push_back('@');
280
 
    to.push_back(hexchars[(*iter >> 4) & 15]);
281
 
    to.push_back(hexchars[(*iter) & 15]);
282
 
  }
283
 
 
284
 
  if (internal::check_if_legal_tablename(to.c_str()))
285
 
  {
286
 
    to.append("@@@");
287
 
  }
288
 
  return false;
289
 
}
290
 
 
291
239
TableIdentifier::TableIdentifier(const drizzled::Table &table) :
292
240
  SchemaIdentifier(table.getShare()->getSchemaName()),
293
241
  type(table.getShare()->getTableType()),