~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table_identifier.cc

  • Committer: Brian Aker
  • Date: 2010-06-15 13:37:26 UTC
  • Revision ID: brian@gaz-20100615133726-160z0ql8gxi8s3rg
This is a rollup set of patches for modifications to TableIdentifier to have
a getKey() which is now used for open_cache and table_share_def cache. This
also includes additional unittests on TableIdentifier, and makes use of some
cleanup, though not perfect, to TableShare for its contructors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
static const char hexchars[]= "0123456789abcdef";
47
47
 
48
48
static bool tablename_to_filename(const char *from, char *to, size_t to_length);
49
 
static size_t build_tmptable_filename(std::string &path);
50
49
 
51
50
/*
52
51
  Translate a cursor name to a table name (WL #1324).
138
137
 
139
138
#endif
140
139
 
141
 
static size_t build_tmptable_filename(std::string &buffer)
 
140
size_t TableIdentifier::build_tmptable_filename(std::string &buffer)
142
141
{
143
142
  size_t tmpdir_length;
144
143
  ostringstream post_tmpdir_str;
156
155
  return buffer.length();
157
156
}
158
157
 
 
158
size_t TableIdentifier::build_tmptable_filename(std::vector<char> &buffer)
 
159
{
 
160
  ostringstream post_tmpdir_str;
 
161
 
 
162
  post_tmpdir_str << drizzle_tmpdir << "/" << TMP_FILE_PREFIX << current_pid;
 
163
  post_tmpdir_str << pthread_self() << "-" << get_counter();
 
164
 
 
165
  buffer.resize(post_tmpdir_str.str().length() + 1);
 
166
  memcpy(&buffer[0], post_tmpdir_str.str().c_str(), post_tmpdir_str.str().size());
 
167
  buffer[post_tmpdir_str.str().size()]= 0;
 
168
 
 
169
  return buffer.size();
 
170
}
 
171
 
 
172
 
159
173
/*
160
174
  Creates path to a cursor: drizzle_data_dir/db/table.ext
161
175
 
331
345
 
332
346
  boost::hash<std::string> hasher;
333
347
  hash_value= hasher(path);
 
348
 
 
349
  key.resize(getKeySize());
 
350
  size_t key_length= TableIdentifier::createKey(&key[0], *this);
 
351
 
 
352
  assert(key_length == getKeySize()); // If this is off, then we have a memory issue.
334
353
}
335
354
 
336
355
 
339
358
  return path;
340
359
}
341
360
 
342
 
bool TableIdentifier::compare(std::string schema_arg, std::string table_arg)
 
361
bool TableIdentifier::compare(std::string schema_arg, std::string table_arg) const
343
362
{
344
363
  std::transform(schema_arg.begin(), schema_arg.end(),
345
364
                 schema_arg.begin(), ::tolower);